Browse Source

WIP. fix all warning, put most messages on stderr

master
Jonathan Cobb 4 years ago
parent
commit
d15e35371a
3 changed files with 10 additions and 11 deletions
  1. +2
    -3
      src/admin.rs
  2. +5
    -4
      src/main.rs
  3. +3
    -4
      src/proxy.rs

+ 2
- 3
src/admin.rs View File

@@ -50,9 +50,8 @@ pub async fn start_admin (admin_port : u16,


let routes = warp::post().and(register); 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"; const HEADER_BUBBLE_SESSION: &'static str = "X-Bubble-Session";


+ 5
- 4
src/main.rs View File

@@ -1,4 +1,4 @@
//#![deny(warnings)]
#![deny(warnings)]
/** /**
* Copyright (c) 2020 Bubble, Inc. All rights reserved. * Copyright (c) 2020 Bubble, Inc. All rights reserved.
* For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/ * 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 dns2_ip = args.value_of("dns2").unwrap();
let proxy_port = args.value_of("proxy_port").unwrap().parse::<u16>().unwrap(); let proxy_port = args.value_of("proxy_port").unwrap().parse::<u16>().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;
} }

+ 3
- 4
src/proxy.rs View File

@@ -67,7 +67,7 @@ pub async fn start_proxy (dns1_ip : &str,
}); });


Server::bind(&addr).serve(make_service); Server::bind(&addr).serve(make_service);
println!("Proxy listening on {}", addr);
eprintln!("Proxy listening on {}", addr);
} }


async fn proxy(client: Client<HttpsConnector<HttpConnector<CacheResolver>>>, async fn proxy(client: Client<HttpsConnector<HttpConnector<CacheResolver>>>,
@@ -81,7 +81,7 @@ async fn proxy(client: Client<HttpsConnector<HttpConnector<CacheResolver>>>,
} }
let host = host.unwrap(); let host = host.unwrap();
let ip_string = resolve_with_cache(host, &resolver, resolver_cache).await; 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 needs_static_route(&ip_string) {
if !create_static_route(&gateway, &ip_string) { if !create_static_route(&gateway, &ip_string) {
@@ -107,7 +107,6 @@ async fn proxy(client: Client<HttpsConnector<HttpConnector<CacheResolver>>>,
tokio::task::spawn(async move { tokio::task::spawn(async move {
match req.into_body().on_upgrade().await { match req.into_body().on_upgrade().await {
Ok(upgraded) => { Ok(upgraded) => {
println!(">>>> CONNECT: tunnelling to addr={:?}", addr);
if let Err(e) = tunnel(upgraded, addr).await { if let Err(e) = tunnel(upgraded, addr).await {
eprintln!("server io error: {}", e); eprintln!("server io error: {}", e);
}; };
@@ -157,7 +156,7 @@ async fn tunnel(upgraded: Upgraded, addr: SocketAddr) -> std::io::Result<()> {
); );
} }
Err(e) => { Err(e) => {
println!("tunnel error: {}", e);
eprintln!("tunnel error: {}", e);
} }
}; };
Ok(()) Ok(())


Loading…
Cancel
Save