mirror of
https://github.com/eycorsican/leaf.git
synced 2026-12-05 08:01:26 +00:00
Turn off domain sniffing
This commit is contained in:
1 parent
4aa7ecbc6d
commit
cd009cc7f2
2 files changed
+37
-31
No files matched your search
+33
-31
@@ -80,41 +80,43 @@ impl Dispatcher {
|
||||
where
|
||||
T: 'static + AsyncRead + AsyncWrite + Unpin + Send + Sync,
|
||||
{
|
||||
let mut lhs: Box<dyn ProxyStream> =
|
||||
if !sess.destination.is_domain() && sess.destination.port() == 443 {
|
||||
let mut lhs = sniff::SniffingStream::new(lhs);
|
||||
match lhs.sniff().await {
|
||||
Ok(res) => {
|
||||
if let Some(domain) = res {
|
||||
debug!(
|
||||
"sniffed domain {} for tcp link {} <-> {}",
|
||||
&domain, &sess.source, &sess.destination,
|
||||
);
|
||||
sess.destination =
|
||||
match SocksAddr::try_from((&domain, sess.destination.port())) {
|
||||
Ok(a) => a,
|
||||
Err(e) => {
|
||||
warn!(
|
||||
"convert sniffed domain {} to destination failed: {}",
|
||||
&domain, e,
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
let mut lhs: Box<dyn ProxyStream> = if *option::DOMAIN_SNIFFING
|
||||
&& !sess.destination.is_domain()
|
||||
&& sess.destination.port() == 443
|
||||
{
|
||||
let mut lhs = sniff::SniffingStream::new(lhs);
|
||||
match lhs.sniff().await {
|
||||
Ok(res) => {
|
||||
if let Some(domain) = res {
|
||||
debug!(
|
||||
"sniff tcp uplink {} -> {} failed: {}",
|
||||
&sess.source, &sess.destination, e,
|
||||
"sniffed domain {} for tcp link {} <-> {}",
|
||||
&domain, &sess.source, &sess.destination,
|
||||
);
|
||||
return;
|
||||
sess.destination =
|
||||
match SocksAddr::try_from((&domain, sess.destination.port())) {
|
||||
Ok(a) => a,
|
||||
Err(e) => {
|
||||
warn!(
|
||||
"convert sniffed domain {} to destination failed: {}",
|
||||
&domain, e,
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Box::new(lhs)
|
||||
} else {
|
||||
Box::new(lhs)
|
||||
};
|
||||
Err(e) => {
|
||||
debug!(
|
||||
"sniff tcp uplink {} -> {} failed: {}",
|
||||
&sess.source, &sess.destination, e,
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Box::new(lhs)
|
||||
} else {
|
||||
Box::new(lhs)
|
||||
};
|
||||
|
||||
let outbound = {
|
||||
let router = self.router.read().await;
|
||||
|
||||
@@ -97,6 +97,10 @@ lazy_static! {
|
||||
get_env_var_or("LOG_NO_COLOR", false)
|
||||
};
|
||||
|
||||
pub static ref DOMAIN_SNIFFING: bool = {
|
||||
get_env_var_or("DOMAIN_SNIFFING", false)
|
||||
};
|
||||
|
||||
/// Uplink timeout after downlink EOF.
|
||||
pub static ref TCP_UPLINK_TIMEOUT: u64 = {
|
||||
get_env_var_or("TCP_UPLINK_TIMEOUT", 10)
|
||||
|
||||
Reference in new issue
Block a user