mirror of
https://github.com/threefoldtech/mycelium.git
synced 2026-10-23 14:02:21 +00:00
Add slightly more logging when connecting socks proxy
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
1 parent
c4f96b8e58
commit
490b37ae59
2 files changed
+8
-8
No files matched your search
+1
-1
@@ -2,7 +2,7 @@ use std::future::Future;
|
||||
use std::net::{IpAddr, Ipv6Addr, SocketAddr};
|
||||
use std::path::PathBuf;
|
||||
#[cfg(feature = "message")]
|
||||
use std::{future::Future, time::Duration};
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::cdn::Cdn;
|
||||
use crate::proxy::{ConnectionError, Proxy};
|
||||
|
||||
@@ -301,6 +301,12 @@ where
|
||||
.chosen_remote
|
||||
.lock()
|
||||
.expect("Can lock chosen remote; qed");
|
||||
if target.is_none() {
|
||||
warn!("Can't start proxy if target is none, this should not happen");
|
||||
return;
|
||||
}
|
||||
let target = target.unwrap();
|
||||
info!(%target, "Starting Socks5 proxy forwarding");
|
||||
// First cancel the old token, then set a new token
|
||||
let mut old_token = self.proxy_token.lock().expect("Can lock proxy token; qed");
|
||||
old_token.cancel();
|
||||
@@ -321,17 +327,11 @@ where
|
||||
Err(err) => {
|
||||
error!(%err, "Proxy listener accept error");
|
||||
return Err(err)
|
||||
}
|
||||
}
|
||||
Ok((mut stream, source)) => {
|
||||
trace!(%source, "Got new proxy stream");
|
||||
let proxy_token = proxy_token.clone();
|
||||
let target = target;
|
||||
if target.is_none() {
|
||||
warn!("Refusing to proxy Socks5 stream as we have no remote set - this should not happen");
|
||||
break
|
||||
}
|
||||
// Unwrap is safe since we checked the none variant above
|
||||
let target = target.unwrap();
|
||||
tokio::spawn(async move {
|
||||
let mut con = TcpStream::connect(target).await?;
|
||||
select! {
|
||||
|
||||
Reference in new issue
Block a user