erebe / wstunnel

Tunnel all your traffic over Websocket or HTTP2 - Bypass firewalls/DPI - Static binary available
Other
3.22k stars 290 forks source link

error while accepting TLS connection tls handshake eof #174

Closed kanran111 closed 6 months ago

kanran111 commented 6 months ago

Describe the bug I encountered this issue when connecting through the company's proxy on version 7.x. I've tested it on version 7.5 and the issue persists. However, when using client and server versions 6.x, the issue does not occur. I tried setting up a proxy server to test it on version 7.5, and it worked fine. But when running it on the company's proxy, it doesn't work and reports the error as mentioned.

To Reproduce command client v6: wstunnel -u -L "127.0.0.1:9999:127.0.0.1:9382" "wss://PUBLIC:9380" -p "192.168.0.4:8080" command client v7: wstunnel client -L "udp://9999:127.0.0.1:9382" "wss://PUBLIC:9380" -p "http://192.168.0.4:8080"

erebe commented 6 months ago

Hello,

Would you mind starting the client with the env variable RUST_LOG=trace wstunnel client ... and sending me the output (you can send it by email)

Does the server receive some incoming connection, or not at all ?

You can try also to use release https://github.com/erebe/wstunnel/releases/tag/v7.6.0, I tried to be less strict in the http proxy parsing.

1642036 commented 6 months ago

Hello,

Would you mind starting the client with the env variable RUST_LOG=trace wstunnel client ... and sending me the output (you can send it by email)

Does the server receive some incoming connection, or not at all ?

You can try also to use release https://github.com/erebe/wstunnel/releases/tag/v7.6.0, I tried to be less strict in the http proxy parsing.

Yeah, it worked, but network speed still slower than version 6.

erebe commented 6 months ago

Great :)

How do measure/see it is slower ?

P.s: if you use udp to tunnel a vpn traffic, be sure to add ?timeout_sec=0 to your tunnel.

1642036 commented 6 months ago

2023-10-28T14:06:44.872861Z INFO tunnel:tunnel{peer="CLIENT_IP:55069"}: wstunnel::tunnel::server: Doing TLS handshake 2023-10-28T14:06:44.913559Z INFO tunnel:tunnel{peer="CLIENT_IP:55069" id="018b769b-f06c-7cbc-bd7b-4efd40056056" remote="127.0.0.1:43822"}: wstunnel::tunnel::server: connected to Udp { timeout: None } Ipv4(127.0.0.1) 43822 2023-10-28T14:07:11.654521Z ERROR tunnel:tunnel{peer="CLIENT_IP:54904" id="018b769a-41fe-721b-84e4-012ca169ca42" remote="127.0.0.1:43822"}: wstunnel::tunnel::io: error while reading from websocket rx unexpected end of file 2023-10-28T14:07:11.654581Z INFO tunnel:tunnel{peer="CLIENT_IP:54904" id="018b769a-41fe-721b-84e4-012ca169ca42" remote="127.0.0.1:43822"}: wstunnel::tunnel::io: Closing local rx <== websocket rx tunnel 2023-10-28T14:07:11.654728Z INFO tunnel:tunnel{peer="CLIENT_IP:54904" id="018b769a-41fe-721b-84e4-012ca169ca42" remote="127.0.0.1:43822"}: wstunnel::tunnel::io: Closing local tx ==> websocket tx tunnel 2023-10-28T14:07:11.662441Z ERROR tunnel:tunnel{peer="CLIENT_IP:55025" id="018b769b-475d-7166-b5cc-88ba80673e94" remote="127.0.0.1:43822"}: wstunnel::tunnel::io: error while reading from websocket rx unexpected end of file 2023-10-28T14:07:11.662463Z INFO tunnel:tunnel{peer="CLIENT_IP:55025" id="018b769b-475d-7166-b5cc-88ba80673e94" remote="127.0.0.1:43822"}: wstunnel::tunnel::io: Closing local rx <== websocket rx tunnel 2023-10-28T14:07:11.662533Z INFO tunnel:tunnel{peer="CLIENT_IP:55025" id="018b769b-475d-7166-b5cc-88ba80673e94" remote="127.0.0.1:43822"}: wstunnel::tunnel::io: Closing local tx ==> websocket tx tunnel 2023-10-28T14:07:11.666579Z ERROR tunnel:tunnel{peer="CLIENT_IP:55035" id="018b769b-6020-751e-b3db-e8985066ada8" remote="127.0.0.1:43822"}: wstunnel::tunnel::io: error while reading from websocket rx unexpected end of file 2023-10-28T14:07:11.666597Z INFO tunnel:tunnel{peer="CLIENT_IP:55035" id="018b769b-6020-751e-b3db-e8985066ada8" remote="127.0.0.1:43822"}: wstunnel::tunnel::io: Closing local rx <== websocket rx tunnel 2023-10-28T14:07:11.666696Z INFO tunnel:tunnel{peer="CLIENT_IP:55035" id="018b769b-6020-751e-b3db-e8985066ada8" remote="127.0.0.1:43822"}: wstunnel::tunnel::io: Closing local tx ==> websocket tx tunnel 2023-10-28T14:07:11.671812Z ERROR tunnel:tunnel{peer="CLIENT_IP:55069" id="018b769b-f06c-7cbc-bd7b-4efd40056056" remote="127.0.0.1:43822"}: wstunnel::tunnel::io: error while reading from websocket rx unexpected end of file 2023-10-28T14:07:11.671831Z INFO tunnel:tunnel{peer="CLIENT_IP:55069" id="018b769b-f06c-7cbc-bd7b-4efd40056056" remote="127.0.0.1:43822"}: wstunnel::tunnel::io: Closing local rx <== websocket rx tunnel 2023-10-28T14:07:11.671903Z INFO tunnel:tunnel{peer="CLIENT_IP:55069" id="018b769b-f06c-7cbc-bd7b-4efd40056056" remote="127.0.0.1:43822"}: wstunnel::tunnel::io: Closing local tx ==> websocket tx tunnel 2023-10-28T14:07:23.696533Z INFO tunnel: wstunnel::tunnel::server: Accepting connection 2023-10-28T14:07:23.696601Z INFO tunnel:tunnel{peer="CLIENT_IP:55101"}: wstunnel::tunnel::server: Doing TLS handshake 2023-10-28T14:07:23.736694Z INFO tunnel:tunnel{peer="CLIENT_IP:55101" id="018b769c-880e-77fb-82aa-8101121435e3" remote="127.0.0.1:43822"}: wstunnel::tunnel::server: connected to Udp { timeout: None } Ipv4(127.0.0.1) 43822 2023-10-28T14:07:26.970467Z ERROR tunnel:tunnel{peer="CLIENT_IP:55101" id="018b769c-880e-77fb-82aa-8101121435e3" remote="127.0.0.1:43822"}: wstunnel::tunnel::io: error while reading from websocket rx unexpected end of file 2023-10-28T14:07:26.970519Z INFO tunnel:tunnel{peer="CLIENT_IP:55101" id="018b769c-880e-77fb-82aa-8101121435e3" remote="127.0.0.1:43822"}: wstunnel::tunnel::io: Closing local rx <== websocket rx tunnel 2023-10-28T14:07:26.970649Z INFO tunnel:tunnel{peer="CLIENT_IP:55101" id="018b769c-880e-77fb-82aa-8101121435e3" remote="127.0.0.1:43822"}: wstunnel::tunnel::io: Closing local tx ==> websocket tx tunnel

@erebe These are logs from my server. I conducted a test by downloading a 1MB file. On version 6, the speed was 100kbps (due to the company's restrictions), while on version 7.6, it was 0.1kbps. And in the logs, it keeps repeating continuously with client connected -> proxy connected -> handshake with the host

erebe commented 6 months ago

Can you try the new release https://github.com/erebe/wstunnel/releases/tag/v7.7.2 and let me know ?

Wireguard requires respecting its udp framing, which wstunnel was not doing before.

kanran111 commented 6 months ago

Can you try the new release https://github.com/erebe/wstunnel/releases/tag/v7.7.2 and let me know ?

Wireguard requires respecting its udp framing, which wstunnel was not doing before.

You was right; I'm using WireGuard. With the latest version 7.7.2, everything is working smoothly. That amazing! some coffee as a token of my appreciation.

erebe commented 6 months ago

Thank you :)

You may want to use release https://github.com/erebe/wstunnel/releases/tag/v7.8.0 to get the full speed :)