Revert "Fix bugs in #235"

This reverts commit 1aa8a0cb57.
This commit is contained in:
Max Lv
2020-05-07 15:04:39 +08:00
parent 9e9e7a2dfc
commit c58b2a58cb
2 changed files with 11 additions and 16 deletions
+2 -2
View File
@@ -282,8 +282,8 @@ impl AccessControl {
pub fn check_ip_in_proxy_list(&self, ip: &IpAddr) -> bool {
match self.mode {
Mode::BlackList => !self.black_list.check_ip_matched(ip),
Mode::WhiteList => self.white_list.check_ip_matched(ip),
Mode::BlackList => self.black_list.check_ip_matched(ip),
Mode::WhiteList => !self.white_list.check_ip_matched(ip),
}
}
+9 -14
View File
@@ -291,6 +291,9 @@ impl Context {
/// Add a record to the reverse lookup cache
#[cfg(feature = "local-dns-relay")]
pub fn add_to_reverse_lookup_cache(&self, addr: &IpAddr, forward: bool) {
if self.check_ip_in_proxy_list(addr) == forward {
return;
}
let mut reverse_lookup_cache = self.reverse_lookup_cache.lock();
reverse_lookup_cache.insert(addr.clone(), forward);
}
@@ -311,21 +314,13 @@ impl Context {
// Proxy everything by default
None => true,
Some(ref a) => {
// first check the IP list
if a.check_ip_in_proxy_list(ip) {
true
// do the reverse lookup in our local cache
let mut reverse_lookup_cache = self.reverse_lookup_cache.lock();
// if a qname is found
if let Some(forward) = reverse_lookup_cache.get(ip) {
!*forward
} else {
// do the reverse lookup in our local cache
let mut reverse_lookup_cache = self.reverse_lookup_cache.lock();
// if a qname is found
if let Some(forward) = reverse_lookup_cache.get(ip) {
// if qname is resolved by remote,
// we should proxy it as well
*forward
} else {
// by default not proxied
false
}
a.check_ip_in_proxy_list(ip)
}
}
}