Przeglądaj źródła

standardize error logs

master
Jonathan Cobb 4 lat temu
rodzic
commit
6fa4f04a0c
3 zmienionych plików z 14 dodań i 14 usunięć
  1. +6
    -6
      src/admin.rs
  2. +4
    -4
      src/main.rs
  3. +4
    -4
      src/proxy.rs

+ 6
- 6
src/admin.rs Wyświetl plik

@@ -52,7 +52,7 @@ pub async fn start_admin (admin_port : u16,
let routes = warp::post().and(register);

let admin_server = warp::serve(routes).run(admin_sock);
eprintln!("Admin listening on {}", admin_sock);
eprintln!("start_admin: INFO: Admin listening on {}", admin_sock);
admin_server.await;
}

@@ -64,7 +64,7 @@ async fn handle_register(registration : AdminRegistration,
hashed_password : String) -> Result<impl warp::Reply, warp::Rejection> {
let pass_result = is_correct_password(registration.password, hashed_password);
if pass_result.is_err() {
eprintln!("handle_register: error verifying password: {:?}", pass_result.err());
eprintln!("handle_register: ERROR: error verifying password: {:?}", pass_result.err());
Ok(warp::reply::with_status(
"error verifying password",
http::StatusCode::UNAUTHORIZED,
@@ -93,7 +93,7 @@ async fn handle_register(registration : AdminRegistration,
// PUT it and see if it worked
let client = reqwest::Client::new();
let url = format!("https://{}/api/me/flexRouters", registration.bubble);
println!("handle_register: registering ourself with {}, sending: {:?}", url, bubble_registration);
println!("handle_register: INFO registering ourself with {}, sending: {:?}", url, bubble_registration);
match client.put(url.as_str())
.header(HEADER_BUBBLE_SESSION, registration.session)
.json(&bubble_registration)
@@ -101,14 +101,14 @@ async fn handle_register(registration : AdminRegistration,
Ok(response) => {
match response.status() {
ReqwestStatusCode::OK => {
eprintln!("successfully registered with bubble");
eprintln!("handle_register: INFO successfully registered with bubble");
Ok(warp::reply::with_status(
"successfully registered with bubble",
http::StatusCode::OK,
))
},
_ => {
eprintln!("error registering with bubble: {:?}", response.status());
eprintln!("handle_register: ERROR: error registering with bubble: {:?}", response.status());
Ok(warp::reply::with_status(
"error registering with bubble",
http::StatusCode::PRECONDITION_FAILED,
@@ -117,7 +117,7 @@ async fn handle_register(registration : AdminRegistration,
}
},
Err(error) => {
eprintln!("error registering with bubble: {:?}", error);
eprintln!("handle_register: ERROR: error registering with bubble: {:?}", error);
Ok(warp::reply::with_status(
"error registering with bubble",
http::StatusCode::PRECONDITION_FAILED,


+ 4
- 4
src/main.rs Wyświetl plik

@@ -84,7 +84,7 @@ async fn main() {

let password_file_opt = args.value_of("password_file");
if password_file_opt.is_none() {
eprintln!("\nERROR: password-file argument is required\n");
eprintln!("\nmain: ERROR: password-file argument is required\n");
exit(2);
}
let password_file = password_file_opt.unwrap();
@@ -94,13 +94,13 @@ async fn main() {

let proxy_ip_opt = args.value_of("proxy_ip");
if proxy_ip_opt.is_none() {
eprintln!("\nERROR: proxy-ip argument is required\n");
eprintln!("\nmain: ERROR: proxy-ip argument is required\n");
exit(2);
}

let proxy_ip = proxy_ip_opt.unwrap();
if !is_private_ip(proxy_ip.to_string()) {
eprintln!("\nERROR: proxy IP must be a private IP address: {}\n", proxy_ip);
eprintln!("\nmain: ERROR: proxy IP must be a private IP address: {}\n", proxy_ip);
exit(2);
}
let mut proxy_bind_addr = None;
@@ -115,7 +115,7 @@ async fn main() {
}
}
if proxy_bind_addr.is_none() {
eprintln!("\nERROR: Could not find IP for binding: {}\n", proxy_ip);
eprintln!("\nmain: ERROR: Could not find IP for binding: {}\n", proxy_ip);
exit(2);
}



+ 4
- 4
src/proxy.rs Wyświetl plik

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

let server = Server::bind(&addr).serve(make_service);
eprintln!("Proxy listening on {}", addr);
eprintln!("start_proxy: INFO Proxy listening on {}", addr);
let result = server.await;
eprintln!("Proxy await result: {:?}", result);
eprintln!("start_proxy: INFO Proxy await result: {:?}", result);
}

async fn proxy(client: Client<HttpsConnector<HttpConnector<CacheResolver>>>,
@@ -90,7 +90,7 @@ async fn proxy(client: Client<HttpsConnector<HttpConnector<CacheResolver>>>,
}
let host = host.unwrap();
let ip_string = resolve_with_cache(host, &resolver, resolver_cache).await;
eprintln!("proxy: req(host {} resolved to: {}): {:?}", host, ip_string, req);
eprintln!("proxy: INFO req(host {} resolved to: {}): {:?}", host, ip_string, req);

if needs_static_route(&ip_string) {
if !create_static_route(&gateway, &ip_string) {
@@ -160,7 +160,7 @@ async fn tunnel(upgraded: Upgraded, addr: SocketAddr) -> std::io::Result<()> {
// Print message when done
match amounts {
Ok((from_client, from_server)) => {
println!("client wrote {} bytes and received {} bytes", from_client, from_server);
eprintln!("proxy: DEBUG: client wrote {} bytes and received {} bytes", from_client, from_server);
}
Err(e) => {
eprintln!("proxy: ERROR: tunnel error: {}", e);


Ładowanie…
Anuluj
Zapisz