erebe / wstunnel

Tunnel all your traffic over Websocket or HTTP2 - Bypass firewalls/DPI - Static binary available
BSD 3-Clause "New" or "Revised" License
4.34k stars 372 forks source link

Forward Traffic to Another HTTP Proxy #324

Closed CorrM closed 3 months ago

CorrM commented 3 months ago

Describe the goal

I am trying to use wstunnel to forward traffic from my local machine to an external HTTP proxy that requires a username and password for authentication. My goal is to have my local machine connect to a VPS via wstunnel, and then have wstunnel on the VPS forward the traffic to the external HTTP proxy.

Maybe something like that but for server:

-p, --http-proxy <USER:PASS@HOST:PORT>
          If set, will use this http proxy to connect to the server [env: HTTP_PROXY=]
      --http-proxy-login <LOGIN>
          If set, will use this login to connect to the http proxy. Override the one from --http-proxy [env: WSTUNNEL_HTTP_PROXY_LOGIN=]
      --http-proxy-password <PASSWORD>
          If set, will use this password to connect to the http proxy. Override the one from --http-proxy [env: WSTUNNEL_HTTP_PROXY_PASSWORD=]

Describe what does not work

wstunnel doesn't respect http_proxy env variable

Describe your wstunnel setup

Client:

wstunnel client -L socks5://127.0.0.1:8888 --connection-min-idle 5 wss://<VPS_IP>:8080

Server:

#!/bin/bash

export http_proxy=http://<USER>:<PASS>@<PROXY_IP>:<PROXY_PORT>
export https_proxy=http://<USER>:<PASS>@<PROXY_IP>:<PROXY_PORT>

wstunnel server wss://[::]:8080

Desktop

github-actions[bot] commented 3 months ago

Hello @CorrM :wave:

This issue is being automatically closed because it does not follow the issue template.

CorrM commented 3 months ago

@erebe

erebe commented 3 months ago

Indeed, At the moment, the server does not handle using another http proxy as relay. I keep the feature open and will see when I have time to implement it.

For now, I am working of adding the client to starting a http proxy localy to forward traffic.

CorrM commented 3 months ago

For now, I am working of adding the client to starting a http proxy localy to forward traffic.

Thats what client -p do right?

erebe commented 3 months ago

More a new local and remote listener that is an http proxy

  -L, --local-to-remote <{tcp,udp,socks5,stdio,unix}://[BIND:]PORT:HOST:PORT>
          Listen on local and forwards traffic from remote. Can be specified multiple times
          examples:
          'tcp://1212:google.com:443'      =>       listen locally on tcp on port 1212 and forward to google.com on port 443
          'tcp://2:n.lan:4?proxy_protocol' =>       listen locally on tcp on port 2 and forward to n.lan on port 4
                                                    Send a proxy protocol header v2 when establishing connection to n.lan

          'udp://1212:1.1.1.1:53'          =>       listen locally on udp on port 1212 and forward to cloudflare dns 1.1.1.1 on port 53
          'udp://1212:1.1.1.1:53?timeout_sec=10'    timeout_sec on udp force close the tunnel after 10sec. Set it to 0 to disable the timeout [default: 30]

          'socks5://[::1]:1212'            =>       listen locally with socks5 on port 1212 and forward dynamically requested tunnel
          'socks5://[::1]:1212?login=admin&password=admin' => listen locally with socks5 on port 1212 and only accept connection with login=admin and password=admin

          'http://[::1]:1212'              =>       start a http proxy on port 1212 and forward dynamically requested tunnel
          'http://[::1]:1212?login=admin&password=admin' => start a http proxy on port 1212 and only accept connection with login=admin and password=admin

the last line in the quote

CorrM commented 3 months ago

i will try read the code and if i though that i can contribute will send RP.

btw, nice work on the project <3.

if there a way we can talk, discord?

erebe commented 3 months ago

Sure, I am going for a run now, but I usually connected on rust programming language or tokio rust discord under the same username

CorrM commented 3 months ago

Sure, I am going for a run now, but I usually connected on rust programming language or tokio rust discord under the same username

i cant add you in discord, my dicord are corrm add me