fix: ipv4 parse panic

This commit is contained in:
trisua 2025-05-22 00:29:00 -04:00
parent b1d812d07b
commit 3224ce3305

View file

@ -25,10 +25,19 @@ impl From<&str> for RemoteAddr {
} }
} else { } else {
// ipv4 (4 bytes; 32 bits) // ipv4 (4 bytes; 32 bits)
Self( if !value.contains(":1000") {
value.parse().unwrap_or("0.0.0.0:1000".parse().unwrap()), Self(
AddrProto::IPV4, 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,
)
}
} }
} }
} }