rapiz1 / rathole

A lightweight and high-performance reverse proxy for NAT traversal, written in Rust. An alternative to frp and ngrok.
Apache License 2.0
8.82k stars 441 forks source link

ReadMe & UDP #273

Closed mrbluecoat closed 11 months ago

mrbluecoat commented 11 months ago

I noticed you had an old code merge that introduced UDP support but your README says type = "tcp" # Optional. Possible values: ["tcp", "tls", "noise"]. Default: "tcp"

Does rathole support UDP (for example, exposing a WireGuard or IKEv2 server behind NAT to the internet)?

fernvenue commented 11 months ago

You should read the README completely. The type you mentioned is the transport type under transport category. Currently, rathole supports the three types mentioned in the README:

...
[client.transport] # The whole block is optional. Specify which transport to use
type = "tcp" # Optional. Possible values: ["tcp", "tls", "noise"]. Default: "tcp"
...

However, for each service, you need to specify the type, as stated in the README. Currently, rathole supports any type of TCP and UDP:

...
[client.services.service1] # A service that needs forwarding. The name `service1` can change arbitrarily, as long as identical to the name in the server's configuration
type = "tcp" # Optional. The protocol that needs forwarding. Possible values: ["tcp", "udp"]. Default: "tcp"
...
mrbluecoat commented 11 months ago

Oh, sorry. Isn't UDP a transport? Better question: which transport type should I use with WireGuard?

fernvenue commented 11 months ago

Short answer: tcp, because WireGuard already has encryption, you don't need additional one, so tls and noise is not for you. By the way, tcp is the default option for transport, so you can just skip this whole block. Let me give you an example:

[server]
bind_addr = "0.0.0.0:2333"
[server.services.wireguard]
type = "udp"
bind_addr = "0.0.0.0:9573"

[client]
remote_addr = "myserver.com:2333"
[client.services.wireguard]
type = "udp"
local_addr = "127.0.0.1:9573"

Is that clear? In this way, your WireGuard can be access on the server's 9573 port.

mrbluecoat commented 11 months ago

Awesome, thanks!

adminy commented 3 months ago

How come UDP is so much slower than TCP? Isn't it supposed to be faster? Is this some kind of mistake?