Add to_canonical() for ip check
This commit is contained in:
parent
b5dd86ab07
commit
ec34fc9e99
1 changed files with 14 additions and 14 deletions
|
|
@ -186,10 +186,10 @@ impl<T: Clone> FederationConfig<T> {
|
|||
// Resolve domain and see if it points to private IP
|
||||
// TODO: Use is_global() once stabilized
|
||||
// https://doc.rust-lang.org/std/net/enum.IpAddr.html#method.is_global
|
||||
let invalid_ip =
|
||||
lookup_host((domain.to_owned(), 80))
|
||||
let mut ips = lookup_host((domain.to_owned(), 80))
|
||||
.await?
|
||||
.any(|addr| match addr.ip() {
|
||||
.map(|s| s.ip().to_canonical());
|
||||
let invalid_ip = ips.any(|ip| match ip {
|
||||
IpAddr::V4(addr) => {
|
||||
addr.is_private()
|
||||
|| addr.is_link_local()
|
||||
|
|
|
|||
Loading…
Reference in a new issue