OpenHausIO / connector

Connector between backend & local network
MIT License
1 stars 2 forks source link

Add SCOKS5 support? #58

Open mStirner opened 3 months ago

mStirner commented 3 months ago

Instead of this websocket open/close stuff, implmenet in the backend a socks5 server, and forward this to client where the needed actions are done?

But for every connection, there needs to be a tunnel to forward connect requests (like tcp connections). So is sockes impelmentation #54 with extra steps?

Doing so sets the requirement that a system wide proxy for the backend can be set, that no specific (http) agents need to be set and a simple http request to a internal LAN ip works out of the box: e.g.:

const http = require("http");
http.request("http://192.168.21.52")

The http request made in the backend is forwarded to the LAN that the connector runs in.

1) HTTP Client request 2) OS init socks5 session, tcp socket create to socks5 server (backend) 3) socks5 server froward request to connector 4) connector creates websocket connection to backend, which is used as underlaying network socket 5) socks5 server (backend) tells client "ok, send data" 6) HTTP Client request sends over sockets->websocket->connector->LAN target

With the flow above, even listener (forwareder) can be create from within the backend without any special configration on the lan/connector side. (0x02 = bindet einen Port¹)

To forward all traffic/sockets create in the backend/node.js process:

image https://unix.stackexchange.com/q/71481

The sockets5 protocol seems pretty simple. Some demo/reference implementations:

Now the final question: What benefit do we gain from this?