Just some minor cleanup

This commit is contained in:
Mahmoud Al-Qudsi 2017-08-14 00:34:41 -05:00
parent 49aee2300b
commit 0e99ab0eb6
1 changed files with 3 additions and 3 deletions

View File

@ -92,7 +92,6 @@ fn forward(bind_ip: &str, local_port: i32, remote_host: &str, remote_port: i32)
.expect(&format!("Unable to bind to {}", &bind_addr));
println!("Listening on {}", listener.local_addr().unwrap());
let handle2 = handle.clone();
//we have either been provided an IP address or a host name
//instead of trying to check its format, just trying creating a SocketAddr from it
let parse_result = format!("{}:{}", remote_host, remote_port).parse::<std::net::SocketAddr>();
@ -100,7 +99,7 @@ fn forward(bind_ip: &str, local_port: i32, remote_host: &str, remote_port: i32)
.or_else(|_| {
//it's a hostname; we're going to need to resolve it
//create an async dns resolver
let resolver = DnsResolver::system_config(&handle2).unwrap();
let resolver = DnsResolver::system_config(&handle).unwrap();
resolver.resolve(&format!("{}:{}", remote_host, remote_port))
.map(move |resolved| {
@ -109,13 +108,14 @@ fn forward(bind_ip: &str, local_port: i32, remote_host: &str, remote_port: i32)
})
.map_err(|err| println!("{:?}", err))
})
.and_then(move |remote_addr| {
.and_then(|remote_addr| {
println!("Resolved {}:{} to {}",
remote_host,
remote_port,
remote_addr);
let remote_addr = remote_addr.clone();
let handle = handle.clone();
listener.incoming()
.for_each(move |(client, client_addr)| {
println!("New connection from {}", client_addr);