Karan Gauswami
2 years ago
No known key found for this signature in database
GPG Key ID: C88FAE6243A24FD3
2 changed files with
17 additions and
19 deletions
-
README.md
-
src/main.rs
|
|
@ -32,15 +32,15 @@ This will create proxy server on 8080 and use localhost:1080 as a Socks5 Proxy |
|
|
|
There are a few options for using `sthp`. |
|
|
|
|
|
|
|
```text |
|
|
|
USAGE: |
|
|
|
sthp [OPTIONS] |
|
|
|
|
|
|
|
OPTIONS: |
|
|
|
-h, --help Print help information |
|
|
|
--listen-ip <LISTEN_IP> [default: 0.0.0.0] |
|
|
|
-p, --port <PORT> port where Http proxy should listen [default: 8080] |
|
|
|
-P, --password <PASSWORD> Socks5 password |
|
|
|
-s, --socks-address <SOCKS_ADDRESS> Socks5 proxy address [default: 127.0.0.1:1080] |
|
|
|
-u, --username <USERNAME> Socks5 username |
|
|
|
-V, --version Print version information |
|
|
|
Usage: sthp [OPTIONS] |
|
|
|
|
|
|
|
Options: |
|
|
|
-p, --port <PORT> port where Http proxy should listen [default: 8080] |
|
|
|
--listen-ip <LISTEN_IP> [default: 0.0.0.0] |
|
|
|
-u, --username <USERNAME> Socks5 username |
|
|
|
-P, --password <PASSWORD> Socks5 password |
|
|
|
-s, --socks-address <SOCKS_ADDRESS> Socks5 proxy address [default: 127.0.0.1:1080] |
|
|
|
--allowed-domains <ALLOWED_DOMAINS> Comma-separated list of allowed domains |
|
|
|
-h, --help Print help information |
|
|
|
-V, --version Print version information |
|
|
|
``` |
|
|
|
|
|
@ -55,10 +55,9 @@ async fn main() -> Result<()> { |
|
|
|
let socks_address = args.socks_address; |
|
|
|
let port = args.port; |
|
|
|
|
|
|
|
let auth = match args.auth { |
|
|
|
Some(auth) => Some(Auth::new(auth.username, auth.password)), |
|
|
|
None => None, |
|
|
|
}; |
|
|
|
let auth = args |
|
|
|
.auth |
|
|
|
.map(|auth| Auth::new(auth.username, auth.password)); |
|
|
|
let auth = &*Box::leak(Box::new(auth)); |
|
|
|
|
|
|
|
let addr = SocketAddr::from((args.listen_ip, port)); |
|
|
@ -72,10 +71,9 @@ async fn main() -> Result<()> { |
|
|
|
}; |
|
|
|
let client: Client<SocksConnector<HttpConnector>> = hyper::Client::builder().build(connector); |
|
|
|
let client = &*Box::leak(Box::new(client)); |
|
|
|
let allowed_domains = match args.allowed_domains { |
|
|
|
Some(domains) => Some(domains.split(',').map(|d| d.trim().to_owned()).collect()), |
|
|
|
None => None, |
|
|
|
}; |
|
|
|
let allowed_domains = args |
|
|
|
.allowed_domains |
|
|
|
.map(|domains| domains.split(',').map(|d| d.trim().to_owned()).collect()); |
|
|
|
let allowed_domains = &*Box::leak(Box::new(allowed_domains)); |
|
|
|
let make_service = make_service_fn(move |_| async move { |
|
|
|
Ok::<_, Infallible>(service_fn(move |req| { |
|
|
|