swarm_proxy

Crates.ioswarm_proxy
lib.rsswarm_proxy
version0.1.0
sourcesrc
created_at2023-11-13 19:41:13.700827
updated_at2023-11-13 19:41:13.700827
descriptionA proxy for forwarding a bunch of ports really quickly
homepagehttps://github.com/jkcoxson/swarm_proxy
repositoryhttps://github.com/jkcoxson/swarm_proxy
max_upload_size
id1033956
size38,077
Jackson Coxson (jkcoxson)

documentation

https://docs.rs/swarm_proxy

README

Swarm Proxy

A proxy that forwards a lot of ports really fast and is also pretty quick too

Motivation

I had a server behind a double NAT, and masquerading all the ports would have been a lot of effort. I'm lazy, so I wrote a proxy to work around a solvable problem :)

Usage

Command line

swarm_proxy <config.json> | <target> udp [<udp_port|udp_range>] tcp [<tcp_port|tcp_range>]

Example

Forwards ports 69-79 udp and 80 and 443 to 8443 tcp to 10.7.0.2

swarm_proxy 10.7.0.2 udp 69-79:69-79 tcp 80 443:8443

Design

TCP

Super simple, connection goes in, new connection made and packets are exchanged.

UDP

Not as simple. UDP is stateless, but server needs to know which port to forward to on the way back. When a packet is sent, a new port is bound in the proxy server only for sending back to that one client. Clients are bound for about five minutes, then the port is released. Tokio channels go brrrr.

Speed

Pretty quick, I'm not about to talk trash about my own proxy. I ran a few benchmarks with iperf, the speed in and out of the proxy was negligable. Open a PR if you have better benchmarks, or don't.

Commit count: 8

cargo fmt