From 3224ce33058cb2888c28584f6b024033900773ed Mon Sep 17 00:00:00 2001 From: trisua Date: Thu, 22 May 2025 00:29:00 -0400 Subject: [PATCH] fix: ipv4 parse panic --- crates/core/src/model/addr.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/core/src/model/addr.rs b/crates/core/src/model/addr.rs index af6abe9..42e6721 100644 --- a/crates/core/src/model/addr.rs +++ b/crates/core/src/model/addr.rs @@ -25,10 +25,19 @@ impl From<&str> for RemoteAddr { } } else { // ipv4 (4 bytes; 32 bits) - Self( - value.parse().unwrap_or("0.0.0.0:1000".parse().unwrap()), - AddrProto::IPV4, - ) + if !value.contains(":1000") { + Self( + format!("{value}:1000") + .parse() + .unwrap_or("0.0.0.0:1000".parse().unwrap()), + AddrProto::IPV4, + ) + } else { + Self( + value.parse().unwrap_or("0.0.0.0:1000".parse().unwrap()), + AddrProto::IPV4, + ) + } } } }