feat: pending add allowed list
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -232,9 +232,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust_util"
|
name = "rust_util"
|
||||||
version = "0.6.5"
|
version = "0.6.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c152cad8a04f2de2840155adcc473dac011ffbe8ff33f8dfcfab489afa92d134"
|
checksum = "47a20a379d025a6f0da1bc84d6284137eea58c493484bf6912144a864f53c3de"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
|
|||||||
@@ -28,11 +28,12 @@ fn main() {
|
|||||||
.help("The address on which to listen for incoming requests"))
|
.help("The address on which to listen for incoming requests"))
|
||||||
.arg(Arg::with_name("debug").short("d").long("debug").takes_value(true)
|
.arg(Arg::with_name("debug").short("d").long("debug").takes_value(true)
|
||||||
.help("Enable debug mode"))
|
.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();
|
.get_matches();
|
||||||
|
|
||||||
let local_port: i32 = matches.value_of("local_port").unwrap().parse().unwrap();
|
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_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") {
|
let bind_addr = match matches.value_of("bind") {
|
||||||
Some(addr) => addr.to_owned(),
|
Some(addr) => addr.to_owned(),
|
||||||
None => "127.0.0.1".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];
|
let mut buf = [0; 64 * 1024];
|
||||||
loop {
|
loop {
|
||||||
let (num_bytes, src_addr) = local.recv_from(&mut buf).expect("Didn't receive data");
|
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
|
//we create a new thread for each unique client
|
||||||
let mut remove_existing = false;
|
let mut remove_existing = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user