Skip to content
/ p2p-tun Public

A simple port forward tools build on libp2p with holepunch support.

Notifications You must be signed in to change notification settings

optman/p2p-tun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

p2p-tun

A simple port forward and tun2socks tools build on libp2p with holepunch support.

Usage

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)

generate new private key

$ p2p-tun genkey
CAISIOsUwgZfa2zQ8SDX5ZVK8QH3ypx5GL8F3KLCgvIr01LD

port forward

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

tun2socks

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

About

A simple port forward tools build on libp2p with holepunch support.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages