rename flags to bind_addr and bind_tunnels

This commit is contained in:
confor
2025-04-14 16:46:31 -04:00
parent 53dad89514
commit dd954c98e2
2 changed files with 17 additions and 17 deletions

View File

@@ -49,13 +49,13 @@ enum Command {
#[clap(short, long, env = "BORE_SECRET", hide_env_values = true)]
secret: Option<String>,
/// 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::<IpAddr>();
let ipaddr_control = bind_addr.parse::<IpAddr>();
if ipaddr_control.is_err() {
Args::command()
.error(ErrorKind::InvalidValue, "invalid ip address for control server")
.exit();
}
let ipaddr_tunnels = tunnels_addr.parse::<IpAddr>();
let ipaddr_tunnels = bind_tunnels.parse::<IpAddr>();
if ipaddr_tunnels.is_err() {
Args::command()
.error(ErrorKind::InvalidValue, "invalid ip address for tunnel connections")

View File

@@ -25,11 +25,11 @@ pub struct Server {
/// Concurrent map of IDs to incoming connections.
conns: Arc<DashMap<Uuid, TcpStream>>,
/// 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<u16>,
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<TcpListener, &'static str> {
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",