Skip to content

Commit

Permalink
Multiple TCP listeners
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander V. Nikolaev <[email protected]>
  • Loading branch information
avnik committed Nov 20, 2024
1 parent 995738c commit afd953a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/bin/givc-admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ struct Cli {
#[arg(long, env = "PORT", default_missing_value = "9000", value_parser = clap::value_parser!(u16).range(1..))]
port: u16,

#[arg(long, help = "Additionally listen TCP socket (addr:port)")]
listen_tcp: Option<Vec<SocketAddr>>,

#[arg(long, help = "Additionally listen UNIX socket (path)")]
unix: Option<String>,
listen_unix: Option<Vec<String>>,

#[arg(long, help = "Additionally listen Vsock socket (cid:port format)")]
vsock: Option<String>,
Expand Down Expand Up @@ -83,9 +86,17 @@ async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {

let mut addrs = vec![tcp_addr];

if let Some(unix_sock) = cli.unix {
let unix_sock_addr = tokio_listener::ListenerAddress::Path(unix_sock.into());
addrs.push(unix_sock_addr)
if let Some(tcp_addrs) = cli.listen_tcp {
for each in tcp_addrs {
addrs.push(tokio_listener::ListenerAddress::Tcp(each))
}
}

if let Some(unix_socks) = cli.listen_unix {
for unix_sock in unix_socks {
let unix_sock_addr = tokio_listener::ListenerAddress::Path(unix_sock.into());
addrs.push(unix_sock_addr)
}
}

if let Some(vsock) = cli.vsock {
Expand Down

0 comments on commit afd953a

Please sign in to comment.