diff --git a/src/main.rs b/src/main.rs index 873cde5..6207d6d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,13 +49,13 @@ enum Command { #[clap(short, long, env = "BORE_SECRET", hide_env_values = true)] secret: Option, - /// IP address for the control server. Bore clients must reach this address. + /// IP address where the control server will bind to. Bore clients must reach this. #[clap(long, default_value = "0.0.0.0")] - control_addr: String, + bind_addr: String, /// IP address where tunnels will listen on. #[clap(long, default_value = "0.0.0.0")] - tunnels_addr: String, + bind_tunnels: String, }, } @@ -76,8 +76,8 @@ async fn run(command: Command) -> Result<()> { min_port, max_port, secret, - control_addr, - tunnels_addr, + bind_addr, + bind_tunnels, } => { let port_range = min_port..=max_port; if port_range.is_empty() { @@ -86,14 +86,14 @@ async fn run(command: Command) -> Result<()> { .exit(); } - let ipaddr_control = control_addr.parse::(); + let ipaddr_control = bind_addr.parse::(); if ipaddr_control.is_err() { Args::command() .error(ErrorKind::InvalidValue, "invalid ip address for control server") .exit(); } - let ipaddr_tunnels = tunnels_addr.parse::(); + let ipaddr_tunnels = bind_tunnels.parse::(); if ipaddr_tunnels.is_err() { Args::command() .error(ErrorKind::InvalidValue, "invalid ip address for tunnel connections") diff --git a/src/server.rs b/src/server.rs index cbce41f..45bb75e 100644 --- a/src/server.rs +++ b/src/server.rs @@ -25,11 +25,11 @@ pub struct Server { /// Concurrent map of IDs to incoming connections. conns: Arc>, - /// IP address for the control server. Bore clients must reach this address. - control_addr: IpAddr, + /// IP address where the control server will bind to. Bore clients must reach this. + bind_addr: IpAddr, /// IP address where tunnels will listen on. - tunnels_addr: IpAddr, + bind_tunnels: IpAddr, } impl Server { @@ -37,24 +37,24 @@ impl Server { pub fn new( port_range: RangeInclusive, secret: Option<&str>, - control_addr: IpAddr, - tunnels_addr: IpAddr, + bind_addr: IpAddr, + bind_tunnels: IpAddr, ) -> Self { assert!(!port_range.is_empty(), "must provide at least one port"); Server { port_range, conns: Arc::new(DashMap::new()), auth: secret.map(Authenticator::new), - control_addr, - tunnels_addr, + bind_addr, + bind_tunnels, } } /// Start the server, listening for new connections. pub async fn listen(self) -> Result<()> { let this = Arc::new(self); - let listener = TcpListener::bind((this.control_addr, CONTROL_PORT)).await?; - info!(?this.control_addr, "server listening"); + let listener = TcpListener::bind((this.bind_addr, CONTROL_PORT)).await?; + info!(addr = ?this.bind_addr, "server listening"); loop { let (stream, addr) = listener.accept().await?; @@ -75,7 +75,7 @@ impl Server { async fn create_listener(&self, port: u16) -> Result { let try_bind = |port: u16| async move { - TcpListener::bind((self.tunnels_addr, port)) + TcpListener::bind((self.bind_tunnels, port)) .await .map_err(|err| match err.kind() { io::ErrorKind::AddrInUse => "port already in use",