Skip to content

Commit

Permalink
more changes to fwd
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwample committed Mar 23, 2024
1 parent 5c5d1f7 commit 286bed6
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions crates/obfs4/src/bin/fwd/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct Args {
log_level: String,

/// Disable the address scrubber on logging
#[arg(long, default_value_t = false)]
#[arg(long, action)]
unsafe_logging: bool,
}

Expand All @@ -89,12 +89,7 @@ enum Mode {
/// initialize the logging receiver(s) for things to be logged into using the
/// tracing / tracing_subscriber libraries
// TODO: GeoIP. Json for file log writer.
fn init_logging_recvr(should_scrub: bool, level_str: &str) -> Result<()> {
if should_scrub {
safelog::enforce_safe_logging();
} else {
safelog::disable_safe_logging();
}
fn init_logging_recvr(unsafe_logging: bool, level_str: &str) -> Result<safelog::Guard> {

let log_lvl = LevelFilter::from_str(level_str)?;

Expand All @@ -107,16 +102,22 @@ fn init_logging_recvr(should_scrub: bool, level_str: &str) -> Result<()> {
.init();
warn!("log level set to {level_str}");

Ok(())
if unsafe_logging {
info!("⚠️ ⚠️ enabling unsafe logging ⚠️ ⚠️ ");
safelog::disable_safe_logging().context("failed to get safelog Guard")
} else {
safelog::enforce_safe_logging().context("failed to get safelog Guard")
}
}

/// Main function, ties everything together and parses arguments etc.
#[tokio::main]
async fn main() -> Result<()> {
let args = Args::parse();

println!("unsafe_logging: {}",args.unsafe_logging);
// launch tracing subscriber with filter level
init_logging_recvr(!args.unsafe_logging, &args.log_level)?;
let _guard = init_logging_recvr(args.unsafe_logging, &args.log_level)?;

let dst_addr = SocketAddr::from_str(&args.dst)?;

Expand Down Expand Up @@ -256,7 +257,7 @@ where
}
Ok(c) => c,
};
tokio::spawn(client_handle_connection(conn, builder.clone(), remote_addr.clone(), client_addr));
tokio::spawn(client_handle_connection(conn, builder.clone(), remote_addr, client_addr));
// tokio::spawn(client_handle_connection( conn, builder.build(), proxy_uri.clone(), client_addr));
}
}
Expand Down

0 comments on commit 286bed6

Please sign in to comment.