feat: pending add allowed list

This commit is contained in:
2020-09-07 00:45:13 +08:00
parent a9ba9ea94e
commit 96b3ca62ea
2 changed files with 5 additions and 3 deletions

View File

@@ -28,11 +28,12 @@ fn main() {
.help("The address on which to listen for incoming requests"))
.arg(Arg::with_name("debug").short("d").long("debug").takes_value(true)
.help("Enable debug mode"))
.arg(Arg::with_name("allowed_list").short("A").long("allowed-list").takes_value(true).multiple(true).help("Allowed IP list, e.g. 127.0.0.1, 120.0.0.0/8"))
.get_matches();
let local_port: i32 = matches.value_of("local_port").unwrap().parse().unwrap();
let remote_port: i32 = matches.value_of("remote_port").unwrap().parse().unwrap();
let remote_host = matches.value_of("h").unwrap();
let remote_host = matches.value_of("host").unwrap();
let bind_addr = match matches.value_of("bind") {
Some(addr) => addr.to_owned(),
None => "127.0.0.1".to_owned(),
@@ -65,6 +66,7 @@ fn forward(bind_addr: &str, local_port: i32, remote_host: &str, remote_port: i32
let mut buf = [0; 64 * 1024];
loop {
let (num_bytes, src_addr) = local.recv_from(&mut buf).expect("Didn't receive data");
// TODO check src_addr ...
//we create a new thread for each unique client
let mut remove_existing = false;