change
This commit is contained in:
parent
a087c489a0
commit
2d0845431d
1 changed files with 10 additions and 10 deletions
|
|
@ -183,7 +183,7 @@ impl<T: Clone> FederationConfig<T> {
|
|||
}
|
||||
|
||||
let allow_local = std::env::var("DANGER_FEDERATION_ALLOW_LOCAL_IP").is_ok();
|
||||
if !allow_local && self.is_valid_ip(&url).await.is_err() {
|
||||
if !allow_local && validate_ip(&url).await.is_err() {
|
||||
return Err(Error::DomainResolveError(domain.to_string()));
|
||||
}
|
||||
}
|
||||
|
|
@ -222,15 +222,6 @@ impl<T: Clone> FederationConfig<T> {
|
|||
pub fn domain(&self) -> &str {
|
||||
&self.domain
|
||||
}
|
||||
|
||||
/// Resolve domain of the url and throw error if it points to local/private IP.
|
||||
pub async fn is_valid_ip(&self, url: &Url) -> Result<(), Error> {
|
||||
if self.debug {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
validate_ip(url).await
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone> FederationConfigBuilder<T> {
|
||||
|
|
@ -387,6 +378,15 @@ impl<T: Clone> Data<T> {
|
|||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Resolve domain of the url and throw error if it points to local/private IP.
|
||||
pub async fn is_valid_ip(&self, url: &Url) -> Result<(), Error> {
|
||||
if self.config.debug {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
validate_ip(url).await
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone> Deref for Data<T> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue