fix: ipv4 parse panic
This commit is contained in:
parent
b1d812d07b
commit
3224ce3305
1 changed files with 13 additions and 4 deletions
|
@ -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,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue