From b5483db940ff9b530af65847f1ace168bc126173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=AF=92=E5=BD=A4?= <70561268+cxw620@users.noreply.github.com> Date: Thu, 2 May 2024 09:52:28 +0800 Subject: [PATCH] fix: auto detect ip if not given ip and if_name (#39) --- src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 09b18a1..6e38d9e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -115,10 +115,16 @@ fn config_login(matches: Matches) { Some(u) => u, None => format!("http://{}", env!("AUTH_SERVER_IP")), }); - for user in config_i { + for mut user in config_i { println!("login user: {:#?}", user); + let mut detect_ip = false; + if user.ip.is_none() && user.if_name.is_none() { + println!("miss both ip and if_name, will auto detect ip"); + user.ip = Some(String::new()); + detect_ip = true + } let mut client = SrunClient::new_from_user(&server, user) - .set_detect_ip(config.detect_ip) + .set_detect_ip(detect_ip || config.detect_ip) .set_strict_bind(config.strict_bind) .set_double_stack(config.double_stack); if let Some(n) = config.n {