From d15e35371a69d282ab0ca6feee3be6c3aa69c80e Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Sat, 5 Sep 2020 13:57:11 -0400 Subject: [PATCH] WIP. fix all warning, put most messages on stderr --- src/admin.rs | 5 ++--- src/main.rs | 9 +++++---- src/proxy.rs | 7 +++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/admin.rs b/src/admin.rs index 0f7484b..05c4021 100644 --- a/src/admin.rs +++ b/src/admin.rs @@ -50,9 +50,8 @@ pub async fn start_admin (admin_port : u16, let routes = warp::post().and(register); - let server = warp::serve(routes).run(admin_sock); - println!("Admin listening on {}", admin_sock); - server.await; + warp::serve(routes).run(admin_sock).await; + eprintln!("Admin listening on {}", admin_sock); } const HEADER_BUBBLE_SESSION: &'static str = "X-Bubble-Session"; diff --git a/src/main.rs b/src/main.rs index 928bab1..60bc0a2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -//#![deny(warnings)] +#![deny(warnings)] /** * Copyright (c) 2020 Bubble, Inc. All rights reserved. * For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/ @@ -144,7 +144,8 @@ async fn main() { let dns2_ip = args.value_of("dns2").unwrap(); let proxy_port = args.value_of("proxy_port").unwrap().parse::().unwrap(); - start_admin(admin_port, proxy_port, password_hash, session_id).await; - - start_proxy(dns1_ip, dns2_ip, proxy_bind_addr.unwrap().ip(), proxy_port); + let proxy = start_proxy(dns1_ip, dns2_ip, proxy_bind_addr.unwrap().ip(), proxy_port); + let admin = start_admin(admin_port, proxy_port, password_hash, session_id); + proxy.await; + admin.await; } diff --git a/src/proxy.rs b/src/proxy.rs index ce91031..3032ead 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -67,7 +67,7 @@ pub async fn start_proxy (dns1_ip : &str, }); Server::bind(&addr).serve(make_service); - println!("Proxy listening on {}", addr); + eprintln!("Proxy listening on {}", addr); } async fn proxy(client: Client>>, @@ -81,7 +81,7 @@ async fn proxy(client: Client>>, } let host = host.unwrap(); let ip_string = resolve_with_cache(host, &resolver, resolver_cache).await; - println!("req(host {} resolved to: {}): {:?}", host, ip_string, req); + eprintln!("req(host {} resolved to: {}): {:?}", host, ip_string, req); if needs_static_route(&ip_string) { if !create_static_route(&gateway, &ip_string) { @@ -107,7 +107,6 @@ async fn proxy(client: Client>>, tokio::task::spawn(async move { match req.into_body().on_upgrade().await { Ok(upgraded) => { - println!(">>>> CONNECT: tunnelling to addr={:?}", addr); if let Err(e) = tunnel(upgraded, addr).await { eprintln!("server io error: {}", e); }; @@ -157,7 +156,7 @@ async fn tunnel(upgraded: Upgraded, addr: SocketAddr) -> std::io::Result<()> { ); } Err(e) => { - println!("tunnel error: {}", e); + eprintln!("tunnel error: {}", e); } }; Ok(())