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 {
// 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,
)
}
}
}
}