A simple port forward and tun2socks tools build on libp2p with holepunch support.
NAME:
p2p-tun - port forward and tun2socks through libp2p
USAGE:
p2p-tun [global options] command [command options] [arguments...]
COMMANDS:
client start client node
server start server node
genkey generate a private key
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--private-key value private key generated by genkey cmd [$PRIVATE_KEY]
--listen-port value p2p listen port (default: 0)
--secret value authenticate user [$SECRET]
--debug log debug (default: false)
--help, -h show help (default: false)
$ p2p-tun genkey
CAISIOsUwgZfa2zQ8SDX5ZVK8QH3ypx5GL8F3KLCgvIr01LD
forward remote target:port to local port.
server
$ export PRIVATE_KEY=CAISIOsUwgZfa2zQ8SDX5ZVK8QH3ypx5GL8F3KLCgvIr01LD
$ export SECRET=abcd
$ p2p-tun server port --forward-addr 192.168.1.1:80
client
$ export SECRET=abcd
$ export SERVER_ID=16Uiu2HAm19Fic7qSLVVmFVe5RDzrdKrii7fcVUU7wYHXEtRTjXrw
$ p2p-tun client port --local-address :8888
$ curl localhost:8888
tunnel tcp/udp to remote built-in socks5 server
udp only support request/response mod, such as DNS.
server
$ export PRIVATE_KEY=CAISIOsUwgZfa2zQ8SDX5ZVK8QH3ypx5GL8F3KLCgvIr01LD
$ export SECRET=abcd
$ p2p-tun server socks
client
$ sudo ip tuntap add mode tun tun0
$ sudo ip link set dev tun0 up
$ sudo ip route add 192.168.1.0/24 dev tun0
$ export SECRET=abcd
$ export SERVER_ID=16Uiu2HAm19Fic7qSLVVmFVe5RDzrdKrii7fcVUU7wYHXEtRTjXrw
$ p2p-tun client tun --tun-name tun0
$ curl 192.168.1.1:80
$ dig www.github.com @192.168.1.1