From afd953a968ae9eddc18cc9ee2d1d5bdd86651d33 Mon Sep 17 00:00:00 2001 From: "Alexander V. Nikolaev" Date: Wed, 20 Nov 2024 15:57:51 +0200 Subject: [PATCH] Multiple TCP listeners Signed-off-by: Alexander V. Nikolaev --- src/bin/givc-admin.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/bin/givc-admin.rs b/src/bin/givc-admin.rs index caf578b..f5dc321 100644 --- a/src/bin/givc-admin.rs +++ b/src/bin/givc-admin.rs @@ -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>, + #[arg(long, help = "Additionally listen UNIX socket (path)")] - unix: Option, + listen_unix: Option>, #[arg(long, help = "Additionally listen Vsock socket (cid:port format)")] vsock: Option, @@ -83,9 +86,17 @@ async fn main() -> std::result::Result<(), Box> { 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 {