fix: ipv4 parse panic
This commit is contained in:
parent
b1d812d07b
commit
3224ce3305
1 changed files with 13 additions and 4 deletions
|
@ -25,12 +25,21 @@ impl From<&str> for RemoteAddr {
|
|||
}
|
||||
} else {
|
||||
// ipv4 (4 bytes; 32 bits)
|
||||
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,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RemoteAddr {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue