Musixal / Backhaul

Lightning-fast reverse tunneling solution for NAT traversal, optimized for handling massive concurrent connections with tcp, tcpmux, ws, wsmux, wss and wssmux support.
https://gozar_xray.t.me
GNU Affero General Public License v3.0
158 stars 26 forks source link

[FeatureRequest] Bind to a specific IP address on both server and client #7

Closed ariadarkkkis closed 1 week ago

ariadarkkkis commented 1 week ago

I have a suggestion for Ports section of Server config:

ports = [ # Local to remote port mapping in this format LocalPort=RemotePort (mandatory).
    "4000=5201",
    "4001=5201",
]

In this example, port 4000 of the server will be set to LISTENING state and forward all the traffic from this port to 5201 of the client. Then on the client, you can use forwarder to send traffic coming to 5201 to any port or address on the client like the following:

forwarder = [ # Forward incoming connection to another address. optional.
   "4000=IP:PORT",
   "4001=127.0.0.1:9090",
]

My suggestion is to have bind address inPorts config. Like the following:

ports = [ # Local to remote port mapping in this format LocalPort=RemotePort (mandatory).
    "127.0.0.1:4000=5201",
    "127.0.0.2:4001=5201",
]

This is useful for server with multiple IP addresses and also useful if there is a custom load balancer running on the server side.

Better way to do this is just like FRP. Have the ports configuration on the client side, so the client choose what ports to open on server and then forward them to a port on the local network of the clinet as follow:

ports = [ # Local to remote port mapping in this format LocalPort=RemotePort (mandatory).
    "1.2.3.4:4000=127.0.0.1:5200",
    "0.0.0.0:4001=127.0.0.2:5201",
]

This way, the client opens a port on 1.2.3.4 IP address of the server and opens 4000 port and then forward the traffic to 127.0.0.1 of the client local network on port 5200.

This way, the whole port configuration and forwarding will be done on client side without need any modification on server side.

Musixal commented 1 week ago

Thanks for your comments. Regarding the first part, it can be done and will be added soon, along with Port Range settings. However, I disagree with the second part, as determining the destination IP on the server side increases packet header size and conflicts with the general backhaul policy. Backhaul is designed to manage a very high number of connections with minimal packet header size.