mirror of
https://github.com/ekzhang/bore.git
synced 2025-12-15 19:37:47 +01:00
default --bind-tunnels to --bind-addr
This commit is contained in:
10
src/main.rs
10
src/main.rs
@@ -49,13 +49,13 @@ enum Command {
|
||||
#[clap(short, long, env = "BORE_SECRET", hide_env_values = true)]
|
||||
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")]
|
||||
bind_addr: String,
|
||||
|
||||
/// IP address where tunnels will listen on.
|
||||
#[clap(long, default_value = "0.0.0.0")]
|
||||
bind_tunnels: String,
|
||||
/// IP address where tunnels will listen on. Defaults to --bind-addr.
|
||||
#[clap(long)]
|
||||
bind_tunnels: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ async fn run(command: Command) -> Result<()> {
|
||||
.exit();
|
||||
}
|
||||
|
||||
let ipaddr_tunnels = bind_tunnels.parse::<IpAddr>();
|
||||
let ipaddr_tunnels = bind_tunnels.unwrap_or(bind_addr).parse::<IpAddr>();
|
||||
if ipaddr_tunnels.is_err() {
|
||||
Args::command()
|
||||
.error(ErrorKind::InvalidValue, "invalid ip address for tunnel connections")
|
||||
|
||||
@@ -54,7 +54,7 @@ impl Server {
|
||||
pub async fn listen(self) -> Result<()> {
|
||||
let this = Arc::new(self);
|
||||
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 {
|
||||
let (stream, addr) = listener.accept().await?;
|
||||
@@ -133,8 +133,9 @@ impl Server {
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
let host = listener.local_addr()?.ip();
|
||||
let port = listener.local_addr()?.port();
|
||||
info!(?port, "new client");
|
||||
info!(?host, ?port, "new client");
|
||||
stream.send(ServerMessage::Hello(port)).await?;
|
||||
|
||||
loop {
|
||||
|
||||
Reference in New Issue
Block a user