Compare commits
2 commits
main
...
to-canonic
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
555902adec | ||
|
|
ec34fc9e99 |
1 changed files with 4 additions and 2 deletions
|
|
@ -187,10 +187,12 @@ impl<T: Clone> FederationConfig<T> {
|
||||||
// Resolve domain and see if it points to private IP
|
// Resolve domain and see if it points to private IP
|
||||||
// TODO: Use is_global() once stabilized
|
// TODO: Use is_global() once stabilized
|
||||||
// https://doc.rust-lang.org/std/net/enum.IpAddr.html#method.is_global
|
// https://doc.rust-lang.org/std/net/enum.IpAddr.html#method.is_global
|
||||||
let mut ips = lookup_host((domain.to_owned(), 80)).await?;
|
let mut ips = lookup_host((domain.to_owned(), 80))
|
||||||
|
.await?
|
||||||
|
.map(|s| s.ip().to_canonical());
|
||||||
let allow_local = std::env::var("DANGER_FEDERATION_ALLOW_LOCAL_IP").is_ok();
|
let allow_local = std::env::var("DANGER_FEDERATION_ALLOW_LOCAL_IP").is_ok();
|
||||||
let invalid_ip = !allow_local
|
let invalid_ip = !allow_local
|
||||||
&& ips.any(|addr| match addr.ip() {
|
&& ips.any(|ip| match ip {
|
||||||
IpAddr::V4(addr) => {
|
IpAddr::V4(addr) => {
|
||||||
addr.is_private()
|
addr.is_private()
|
||||||
|| addr.is_link_local()
|
|| addr.is_link_local()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue