fix: ip parse panic
This commit is contained in:
parent
f746290d97
commit
b1d812d07b
5 changed files with 29 additions and 9 deletions
|
@ -39,8 +39,8 @@ impl DataManager {
|
|||
|
||||
let res = query_row!(
|
||||
&conn,
|
||||
"SELECT * FROM ipbans WHERE ip LIKE $1",
|
||||
&[&format!("{}%", addr.prefix(None))],
|
||||
"SELECT * FROM ipbans WHERE ip = $1",
|
||||
&[&addr.prefix(None)],
|
||||
|x| { Ok(Self::get_ipban_from_row(x)) }
|
||||
);
|
||||
|
||||
|
|
|
@ -25,7 +25,10 @@ impl From<&str> for RemoteAddr {
|
|||
}
|
||||
} else {
|
||||
// ipv4 (4 bytes; 32 bits)
|
||||
Self(value.parse().unwrap(), AddrProto::IPV4)
|
||||
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