ClarkQAQ / wgsd

Wireguard peer discover helper (Wireguard 对等发现助手)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question on Clarity?

lonnietc opened this issue · comments

Hello,

While researching for components that might be used in a new P2P project that I am ramping up now, I came across your "wgsd" approach which sounds like it might be what I need for a system that effectively connects to peers (with one or both possibly behind NAT's) and then hands off the connection to the peers so that they can communicate.

Your Principle says:

You run a service on each node, and the central node no longer handles data exchange; instead, it is used for device discovery.
 The main function of each service is to obtain the peer addresses of devices corresponding to local public keys from specified addresses. 
It also serves other devices, providing them with the peer addresses of all locally connected devices. 
This concept is somewhat akin to a simplified version of a DHT (Distributed Hash Table network structure) (although it is far from the same level of complexity).

I am a bit confused on exactly how 2 peers can be connected if they are both behind different firewalls without any port forwarding happening on the peers. If Peer-A and Peer-B are both on different networks (i.e. LAN's that could be located in 2 different places across the world) then aren't they blocked off from each other for "direct" connections but could only communicate if they go through a public IP node.

Can you please clarify this as I may be missing something here?
Thanks and have a great day

Hello,
In the example, I mentioned that she needs three nodes to function properly, and the A node is essential, specifically requiring it to have public accessibility. Thus, the role of the A node is akin to that of a STUN server in a P2P network (Wikipedia), helping the nodes determine their NAT information.

Meanwhile, the role of wgsd is simply to aid B and C in exchanging their respective NAT (Wikipedia) information.

Device Name Public Address (Address+Port) Peer Address
A 10.0.114.1:19198 10.0.6.1
B NAT: 10.0.114.2:11451 10.0.6.2
C NAT: 10.0.114.2:11452 10.0.6.3