mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-11-15 00:15:11 +00:00
Code formatting
This commit is contained in:
+16
-14
@@ -10,10 +10,7 @@ use std::{
|
||||
};
|
||||
|
||||
#[cfg(feature = "local-dns-relay")]
|
||||
use std::{
|
||||
net::IpAddr,
|
||||
time::Duration,
|
||||
};
|
||||
use std::{net::IpAddr, time::Duration};
|
||||
|
||||
use bloomfilter::Bloom;
|
||||
#[cfg(feature = "local-dns-relay")]
|
||||
@@ -186,8 +183,9 @@ impl Context {
|
||||
fn new(config: Config, server_state: SharedServerState) -> Context {
|
||||
let nonce_ppbloom = Mutex::new(PingPongBloom::new(config.config_type));
|
||||
#[cfg(feature = "local-dns-relay")]
|
||||
let reverse_lookup_cache = Mutex::new(LruCache::<IpAddr, bool>::with_expiry_duration(
|
||||
Duration::from_secs(3 * 24 * 60 * 60)));
|
||||
let reverse_lookup_cache = Mutex::new(LruCache::<IpAddr, bool>::with_expiry_duration(Duration::from_secs(
|
||||
3 * 24 * 60 * 60,
|
||||
)));
|
||||
|
||||
Context {
|
||||
config,
|
||||
@@ -298,14 +296,18 @@ impl Context {
|
||||
let is_exception = self.check_ip_in_proxy_list(addr) != forward;
|
||||
let mut reverse_lookup_cache = self.reverse_lookup_cache.lock();
|
||||
match reverse_lookup_cache.get_mut(addr) {
|
||||
Some(value) => if is_exception {
|
||||
*value = forward;
|
||||
} else {
|
||||
// we do not need to remember the entry if it is already matched correctly
|
||||
reverse_lookup_cache.remove(addr);
|
||||
Some(value) => {
|
||||
if is_exception {
|
||||
*value = forward;
|
||||
} else {
|
||||
// we do not need to remember the entry if it is already matched correctly
|
||||
reverse_lookup_cache.remove(addr);
|
||||
}
|
||||
}
|
||||
None => if is_exception {
|
||||
reverse_lookup_cache.insert(addr.clone(), forward);
|
||||
None => {
|
||||
if is_exception {
|
||||
reverse_lookup_cache.insert(addr.clone(), forward);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -351,7 +353,7 @@ impl Context {
|
||||
let mut reverse_lookup_cache = self.reverse_lookup_cache.lock();
|
||||
// if a qname is found
|
||||
if let Some(forward) = reverse_lookup_cache.get(&saddr.ip()) {
|
||||
return !*forward
|
||||
return !*forward;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,9 @@ async fn acl_lookup(
|
||||
Some(false) => None,
|
||||
_ => {
|
||||
let timeout = Some(Duration::new(3, 0));
|
||||
try_timeout(proxy_lookup(context.clone(), svr_cfg, remote, qname, qtype), timeout).await.ok()
|
||||
try_timeout(proxy_lookup(context.clone(), svr_cfg, remote, qname, qtype), timeout)
|
||||
.await
|
||||
.ok()
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -151,7 +153,8 @@ async fn acl_lookup(
|
||||
let timeout = Some(Duration::new(3, 0));
|
||||
try_timeout(local_lookup(qname, qtype, local), timeout).await.ok()
|
||||
}
|
||||
}.unwrap_or_else(Message::new);
|
||||
}
|
||||
.unwrap_or_else(Message::new);
|
||||
|
||||
match qname_in_proxy_list {
|
||||
Some(true) => {
|
||||
@@ -179,7 +182,7 @@ async fn acl_lookup(
|
||||
};
|
||||
if !forward {
|
||||
debug!("pick local response (ip): {:?}", local_response);
|
||||
return Ok((local_response, false))
|
||||
return Ok((local_response, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user