forked from mirrors/relay
Fix rdnn block checks
This commit is contained in:
parent
c3d5de600d
commit
2619a93643
2 changed files with 7 additions and 2 deletions
1
.env
1
.env
|
@ -1,2 +1,3 @@
|
||||||
HOSTNAME=localhost:8079
|
HOSTNAME=localhost:8079
|
||||||
PORT=8079
|
PORT=8079
|
||||||
|
RESTRICTED_MODE=true
|
||||||
|
|
|
@ -169,20 +169,24 @@ impl Inner {
|
||||||
|
|
||||||
fn is_allowed(&self, domain: &str) -> bool {
|
fn is_allowed(&self, domain: &str) -> bool {
|
||||||
let prefix = domain_prefix(domain);
|
let prefix = domain_prefix(domain);
|
||||||
|
let reverse_domain = domain_key(domain);
|
||||||
|
|
||||||
if self.restricted_mode {
|
if self.restricted_mode {
|
||||||
self.allowed_domains
|
self.allowed_domains
|
||||||
.scan_prefix(prefix)
|
.scan_prefix(prefix)
|
||||||
.keys()
|
.keys()
|
||||||
.filter_map(|res| res.ok())
|
.filter_map(|res| res.ok())
|
||||||
.any(|rdnn| domain.starts_with(String::from_utf8_lossy(&rdnn).as_ref()))
|
.any(|rdnn| {
|
||||||
|
let rdnn_string = String::from_utf8_lossy(&rdnn);
|
||||||
|
reverse_domain.starts_with(rdnn_string.as_ref())
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
!self
|
!self
|
||||||
.blocked_domains
|
.blocked_domains
|
||||||
.scan_prefix(prefix)
|
.scan_prefix(prefix)
|
||||||
.keys()
|
.keys()
|
||||||
.filter_map(|res| res.ok())
|
.filter_map(|res| res.ok())
|
||||||
.any(|rdnn| domain.starts_with(String::from_utf8_lossy(&rdnn).as_ref()))
|
.any(|rdnn| reverse_domain.starts_with(String::from_utf8_lossy(&rdnn).as_ref()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue