A pure Python implementation mimicking SSH Port Forwarding, includes only local/remote forwarding, featured by non-blocking socket, event IO and TCP/UDP forwarding tunnel.
I developed this project due to the unstable newtork connection between my laptop and cloud dev host. The remote forwarding of port 22 bridged by UDP tunnel saved me.
Basicly, port forwarding is a port mapping technique that you could "pull" a remote port down to your local host or "push" a local port to remote. There are many use cases, such as intranet penetration.
Remote Port Forwarding:
Local Port Forwarding:
$ pip install portflyOn server side, you need to setup portfly to listen, even for udp tunnel due to the initial TCP connection:
$ python -m portfly -s server_listen_ip:portOn client side, you control all the details:
# remote forwarding by tcp is the default
$ python -m portfly -c [-x] [--log {INFO|DEBUG} <settings>
# local forwarding by tcp:
$ python -m portfly -c -L <settings>
# local forwarding by udp:
$ python -m portfly -c -L -u <udpport> <settings>
# remote forwarding by udp:
$ python -m portfly -u <udpport> <settings>The <settings> part is just like ssh, which is:
mapping_port:target_ip:target_port+server_ip:target_port
The extra + can leave the whole parameters unquoted.
Each client process can map only one port to/from server. But server can be connected by many clients simultaneously.
Enjoy...XD

