Skip to content

Commit

Permalink
feat : adds announce-addr
Browse files Browse the repository at this point in the history
This commits adds the ability to announce the IP address where the
lampo node can listen for inbound connections.
  • Loading branch information
Harshit933 authored and vincenzopalazzo committed Apr 19, 2024
1 parent e39f65f commit 6ae24fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lampo-common/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct LampoConf {
pub log_file: Option<String>,
pub log_level: String,
pub alias: Option<String>,
pub announce_addr: Option<String>,
}

impl LampoConf {
Expand Down Expand Up @@ -50,6 +51,7 @@ impl LampoConf {
log_level: "info".to_string(),
log_file: None,
alias: None,
announce_addr: None,
}
}

Expand Down Expand Up @@ -216,6 +218,7 @@ impl TryFrom<String> for LampoConf {
};
let log_file = conf.get_conf("log-file").unwrap_or_else(|_| None);
let alias = conf.get_conf("alias").unwrap_or(None);
let announce_addr = conf.get_conf("announce-addr").unwrap_or_else(|_| None);

Ok(Self {
inner: Some(conf),
Expand All @@ -232,6 +235,7 @@ impl TryFrom<String> for LampoConf {
log_file,
log_level: level,
alias,
announce_addr,
})
}
}
Expand Down
9 changes: 7 additions & 2 deletions lampod/src/ln/peer_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,15 @@ impl LampoPeerManager {
.clone()
.ok_or(error::anyhow!("channel manager is None"))?;
let alias = self.conf.alias.clone().unwrap_or_default();
let addr = self
.conf
.announce_addr
.clone()
.unwrap_or_else(|| "127.0.0.1".to_string());
std::thread::spawn(move || {
let result = async_run!(async move {
let bind_addr = format!("0.0.0.0:{}", listen_port);
log::info!(target: "lampo", "Litening for in-bound connection on {bind_addr}");
let bind_addr = format!("{addr}:{listen_port}");
log::info!(target: "lampo", "Listening for in-bound connection on {bind_addr}");
let listener = match tokio::net::TcpListener::bind(bind_addr.clone()).await {
Ok(listener) => listener,
Err(e) => {
Expand Down

0 comments on commit 6ae24fa

Please sign in to comment.