diff --git a/src/qos_net/src/proxy.rs b/src/qos_net/src/proxy.rs index 59332a56..edba0561 100644 --- a/src/qos_net/src/proxy.rs +++ b/src/qos_net/src/proxy.rs @@ -104,14 +104,22 @@ impl Proxy { Ok(conn) => { let connection_id = conn.id; let remote_ip = conn.ip.clone(); + println!("called new_from_name successfully. Saving connection ID {connection_id}..."); match self.save_connection(conn) { Ok(()) => { + println!("Connection established and saved. Returning ConnectResponse to client"); ProxyMsg::ConnectResponse { connection_id, remote_ip } } - Err(e) => ProxyMsg::ProxyError(e), + Err(e) => { + println!("error saving connection."); + ProxyMsg::ProxyError(e) + } } } - Err(e) => ProxyMsg::ProxyError(e), + Err(e) => { + println!("error calling new_from_name"); + ProxyMsg::ProxyError(e) + } } } @@ -214,12 +222,14 @@ impl server::RequestProcessor for Proxy { dns_port, } => { println!("Proxy connecting to {hostname}:{port}"); - self.connect_by_name( - hostname, + let resp = self.connect_by_name( + hostname.clone(), port, dns_resolvers, dns_port, - ) + ); + println!("Proxy connected to {hostname}:{port}"); + resp } ProxyMsg::ConnectByIpRequest { ip, port } => { println!("Proxy connecting to {ip}:{port}"); diff --git a/src/qos_net/src/proxy_connection.rs b/src/qos_net/src/proxy_connection.rs index 52e85201..3c70a88b 100644 --- a/src/qos_net/src/proxy_connection.rs +++ b/src/qos_net/src/proxy_connection.rs @@ -32,15 +32,20 @@ impl ProxyConnection { dns_resolvers: Vec, dns_port: u16, ) -> Result { + println!("new_from_name invoked"); let ip = resolve_hostname(hostname, dns_resolvers, dns_port)?; + println!("resolved name into an IP"); // Generate a new random u32 to get an ID. We'll use it to name our // socket. This will be our connection ID. let mut rng = rand::thread_rng(); let connection_id: u32 = rng.gen::(); + println!("Random connection ID generated"); let tcp_addr = SocketAddr::new(ip, port); + println!("TCP addr created. Connecting..."); let tcp_stream = TcpStream::connect(tcp_addr)?; + println!("Connected"); Ok(ProxyConnection { id: connection_id, ip: ip.to_string(), @@ -88,6 +93,7 @@ fn resolve_hostname( resolver_addrs: Vec, port: u16, ) -> Result { + println!("resolving hostname..."); let resolver_parsed_addrs = resolver_addrs .iter() .map(|resolver_address| { @@ -107,7 +113,9 @@ fn resolve_hostname( ), ); let resolver = Resolver::new(resolver_config, ResolverOpts::default())?; + println!("resolver ready"); let response = resolver.lookup_ip(hostname.clone())?; + println!("resolver successfully invoked"); response.iter().next().ok_or_else(|| { QosNetError::DNSResolutionError(format!( "Empty response when querying for host {hostname}"