enthus1ast / nimSocks

A filtering SOCKS proxy server and client library written in nim.
MIT License
61 stars 5 forks source link

Feature Request: Suppport for Reverse Socks #11

Open jkMason opened 2 years ago

jkMason commented 2 years ago

Any chance on supporting a reverse socks proxy mode similar to Chisel? This would allow for more flexible proxy support in the case of strict egress filtering.

enthus1ast commented 2 years ago

hi @jkMason yes i have considered it (and also build some unpublished demo code). But did not find a good solution yet. Do you know of a standard protocol implementation that does something like this?

I'm not against adding a custom protocol (when its a reasonable amount of work) but would prefer a standard.

I could have a look how Chisel does it, though.

jkMason commented 2 years ago

It looks like there isn't a standard protocol implementation of the reverse portion of a reverse socks proxy (like there is with a standard socks proxy). That being said, I think the easiest way to implement a reverse mode would be to serialize Socks Requests and Socks Responses using something like Protobuf and send this data over a socket.

Hope the following diagram helps illustrate this:

                Standard SOCKS Proxy

+----------+        +----------+        +----------+ 
| SOCKS    |        | SOCKS    |        | Remote   |
| Client   | -----> | Server   | -----> | Resource |
|          |        |          |        |          |
+----------+        +----------+        +----------+ 

                                    Reverse SOCKS Proxy

+----------+        +----------+                         +----------+        +----------+
| SOCKS    |        | SOCKS    |    socket connection    | SOCKS    |        | Remote   |
| Client   | -----> | Server/  | <---------------------  | Server/  | -----> | Resource |
|          |        | Listener |                         | Client   |        |          |
+----------+        +----------+                         +----------+        +----------+