Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : adds announce-addr #212

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading