Flag to start network requester in open proxy mode (#418)
This commit is contained in:
committed by
GitHub
parent
566eb87b83
commit
d6a191a9b1
@@ -19,10 +19,11 @@ use websocket_requests::{requests::ClientRequest, responses::ServerResponse};
|
||||
pub struct ServiceProvider {
|
||||
listening_address: String,
|
||||
outbound_request_filter: OutboundRequestFilter,
|
||||
open_proxy: bool,
|
||||
}
|
||||
|
||||
impl ServiceProvider {
|
||||
pub fn new(listening_address: String) -> ServiceProvider {
|
||||
pub fn new(listening_address: String, open_proxy: bool) -> ServiceProvider {
|
||||
let allowed_hosts = HostsStore::new(
|
||||
HostsStore::default_base_dir(),
|
||||
PathBuf::from("allowed.list"),
|
||||
@@ -36,6 +37,7 @@ impl ServiceProvider {
|
||||
ServiceProvider {
|
||||
listening_address,
|
||||
outbound_request_filter,
|
||||
open_proxy,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +130,7 @@ impl ServiceProvider {
|
||||
message,
|
||||
return_address,
|
||||
} => {
|
||||
if !self.outbound_request_filter.check(&remote_addr) {
|
||||
if !self.open_proxy && !self.outbound_request_filter.check(&remote_addr) {
|
||||
log::info!("Domain {:?} failed filter check", remote_addr);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,36 @@
|
||||
use clap::{App, Arg, ArgMatches};
|
||||
|
||||
mod allowed_hosts;
|
||||
mod connection;
|
||||
mod core;
|
||||
mod websocket;
|
||||
|
||||
const OPEN_PROXY_ARG: &str = "open-proxy";
|
||||
|
||||
fn parse_args<'a>() -> ArgMatches<'a> {
|
||||
App::new("Nym Network Requester")
|
||||
.author("Nymtech")
|
||||
.arg(
|
||||
Arg::with_name(OPEN_PROXY_ARG)
|
||||
.help("specifies whether this network requester should run in 'open-proxy' mode")
|
||||
.long(OPEN_PROXY_ARG)
|
||||
.short("o"),
|
||||
)
|
||||
.get_matches()
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
setup_logging();
|
||||
let matches = parse_args();
|
||||
let open_proxy = matches.is_present(OPEN_PROXY_ARG);
|
||||
if open_proxy {
|
||||
println!("\n\nYOU HAVE STARTED IN 'OPEN PROXY' MODE. ANYONE WITH YOUR CLIENT ADDRESS CAN MAKE REQUESTS FROM YOUR MACHINE. PLEASE QUIT IF YOU DON'T UNDERSTAND WHAT YOU'RE DOING.\n\n");
|
||||
}
|
||||
|
||||
let uri = "ws://localhost:1977";
|
||||
println!("Starting socks5 service provider:");
|
||||
let mut server = core::ServiceProvider::new(uri.into());
|
||||
let mut server = core::ServiceProvider::new(uri.into(), open_proxy);
|
||||
server.run().await;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user