mirror of
https://git.asonix.dog/asonix/relay.git
synced 2024-11-22 09:31:07 +00:00
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
|
||||
PORT=8079
|
||||
RESTRICTED_MODE=true
|
||||
|
|
|
@ -169,20 +169,24 @@ impl Inner {
|
|||
|
||||
fn is_allowed(&self, domain: &str) -> bool {
|
||||
let prefix = domain_prefix(domain);
|
||||
let reverse_domain = domain_key(domain);
|
||||
|
||||
if self.restricted_mode {
|
||||
self.allowed_domains
|
||||
.scan_prefix(prefix)
|
||||
.keys()
|
||||
.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 {
|
||||
!self
|
||||
.blocked_domains
|
||||
.scan_prefix(prefix)
|
||||
.keys()
|
||||
.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