Go 中的 P2P 网络库。致力于设备🌍之间的直接通信,帖子地址: https://www.v2ex.com/t/1025195
Go to file
2024-08-10 17:39:44 +08:00
cmd pgcli/vpn: fix flag disco-port-scan-duration not working 2024-08-03 22:16:03 +08:00
connmux connmux: sync FIN state detect and data write 2024-08-09 21:12:19 +08:00
disco disco: shuffle stun servers 2024-08-04 19:55:17 +08:00
fileshare fileshare: set read header deadline 2024-08-03 19:47:23 +08:00
lru disco: detect network changed 2024-03-29 23:03:14 +08:00
net p2p: improve SetReadDeadline 2024-08-03 19:55:03 +08:00
netlink netlink: move func AddRoute/DelRoute 2024-07-20 09:37:53 +08:00
p2p p2p: refactor func runNetworkChangeDetectLoop 2024-08-10 17:39:44 +08:00
peermap peermap: default peer metadata 2024-08-03 19:08:59 +08:00
rdt deadline: close conn should return io.EOF 2024-08-07 21:00:18 +08:00
secure p2p: add SharedKey func 2024-04-29 21:24:32 +08:00
upnp disco: add UPnP support 2024-01-27 16:53:24 +08:00
vpn disco: drop ErrUseOfClosedConnection 2024-08-03 11:48:16 +08:00
.gitignore peermap: add map exporter api 2024-03-27 21:46:15 +08:00
Dockerfile chore: pgserve -> pgmap 2024-03-28 21:07:45 +08:00
go.mod vpn: implement link.RouteSubscribe for windows 2024-07-07 15:34:14 +08:00
go.sum vpn: implement link.RouteSubscribe for windows 2024-07-07 15:34:14 +08:00
LICENSE add license 2024-01-19 07:30:49 +08:00
Makefile chore: add mips arch 2024-06-06 20:11:57 +08:00
README_zh_CN.md readme: add nodes time sync notes 2024-07-05 19:59:46 +08:00
README.md readme: add nodes time sync notes 2024-07-05 19:59:46 +08:00

PeerGuard

Another p2p network library in Go. Committed to direct communication between devices.
[简体中文]

Features

  • Elegantly simple architecture (pgcli & pgmap & OpenID Connect)
  • NAT traversal with high success rate (STUN & UPnP & PortScan)
  • Full support for IPv4/IPv6 dual stack
  • Easy-to-use library (net.PacketConn)
  • Transport layer security (curve25519 & chacha20poly1305 for end-to-end encryption)
  • RDT protocol for reliable data transfer
  • Cross-platform compatibility (linux/windows/macOS/iOS/android)

Get Started

Note

Time synchronization between nodes is crucial; the difference should not exceed 5 seconds

p2p vpn

# node1
sudo pgcli vpn -s wss://synf.in/pg --ipv4 100.64.0.1/24 --ipv6 fd00::1/64
# node2
sudo pgcli vpn -s wss://synf.in/pg --ipv4 100.64.0.2/24 --ipv6 fd00::2/64

p2p file sharing

# share
$ PG_SERVER=wss://synf.in/pg pgcli share ~/my-show.pptx
ShareURL: pg://DJX2csRurJ3DvKeh63JebVHFDqVhnFjckdVhToAAiPYf/0/my-show.pptx
# download
$ PG_SERVER=wss://synf.in/pg pgcli download pg://DJX2csRurJ3DvKeh63JebVHFDqVhnFjckdVhToAAiPYf/0/my-show.pptx

Advanced

deploy the peermap server

1. run the pgmap daemon

$ pgmap -l 127.0.0.1:9987 --secret-key 5172554832d76672d1959a5ac63c5ab9 \
    --stun stun.miwifi.com:3478 --stun stunserver.stunprotocol.org:3478

2. wrap pgmap as an https server

$ caddy reverse-proxy --from https://synf.in/pg --to 127.0.0.1:9987

uses pre-shared secret file instead of OIDC auth

first

$ export PG_SECRET_KEY=5172554832d76672d1959a5ac63c5ab9
$ export PG_SERVER=wss://synf.in/pg
$ pgcli admin secret --network "<email>" --duration 24h > psns.json

then

sudo pgcli vpn -s wss://synf.in/pg -4 100.64.0.1/24 -f psns.json

License

GNU General Public License v3.0

Contributing

Contributions welcome! Have an improvement? Submit a pull request.

Note

I also maintain a closed-source version, and contributions to the open-source project may be included in the closed-source version.