default --bind-tunnels to --bind-addr

This commit is contained in:
confor
2025-04-14 17:18:43 -04:00
parent 6a71c9a855
commit 299ad61030
2 changed files with 8 additions and 7 deletions

View File

@@ -49,13 +49,13 @@ enum Command {
#[clap(short, long, env = "BORE_SECRET", hide_env_values = true)] #[clap(short, long, env = "BORE_SECRET", hide_env_values = true)]
secret: Option<String>, secret: Option<String>,
/// IP address where the control server will bind to. Bore clients must reach this. /// IP address to bind to. Bore clients must reach this.
#[clap(long, default_value = "0.0.0.0")] #[clap(long, default_value = "0.0.0.0")]
bind_addr: String, bind_addr: String,
/// IP address where tunnels will listen on. /// IP address where tunnels will listen on. Defaults to --bind-addr.
#[clap(long, default_value = "0.0.0.0")] #[clap(long)]
bind_tunnels: String, bind_tunnels: Option<String>,
}, },
} }
@@ -93,7 +93,7 @@ async fn run(command: Command) -> Result<()> {
.exit(); .exit();
} }
let ipaddr_tunnels = bind_tunnels.parse::<IpAddr>(); let ipaddr_tunnels = bind_tunnels.unwrap_or(bind_addr).parse::<IpAddr>();
if ipaddr_tunnels.is_err() { if ipaddr_tunnels.is_err() {
Args::command() Args::command()
.error(ErrorKind::InvalidValue, "invalid ip address for tunnel connections") .error(ErrorKind::InvalidValue, "invalid ip address for tunnel connections")

View File

@@ -54,7 +54,7 @@ impl Server {
pub async fn listen(self) -> Result<()> { pub async fn listen(self) -> Result<()> {
let this = Arc::new(self); let this = Arc::new(self);
let listener = TcpListener::bind((this.bind_addr, CONTROL_PORT)).await?; let listener = TcpListener::bind((this.bind_addr, CONTROL_PORT)).await?;
info!(addr = ?this.bind_addr, "server listening"); info!(addr = ?this.bind_addr, port = CONTROL_PORT, "server listening");
loop { loop {
let (stream, addr) = listener.accept().await?; let (stream, addr) = listener.accept().await?;
@@ -133,8 +133,9 @@ impl Server {
return Ok(()); return Ok(());
} }
}; };
let host = listener.local_addr()?.ip();
let port = listener.local_addr()?.port(); let port = listener.local_addr()?.port();
info!(?port, "new client"); info!(?host, ?port, "new client");
stream.send(ServerMessage::Hello(port)).await?; stream.send(ServerMessage::Hello(port)).await?;
loop { loop {