Skip to content

Instantly share code, notes, and snippets.

@james4k
Last active December 22, 2015 15:38
Show Gist options
  • Save james4k/6493344 to your computer and use it in GitHub Desktop.
Save james4k/6493344 to your computer and use it in GitHub Desktop.
P2P NAT-holepunching Hub
Each peer is addressable by a public key in the network, essentially by DHT, but
in such a way that keeps the device's IP pseudo-anonymous, where an
ipaddr-publickey pair only suggests knowledge of the peer. This has a name, but
I cannot recall or seem to search the right keywords for it.
I don't fully understand NAT holepunching, so this may not be adequate. As I
understand it, and to put it simply, a mutually known middleman out on the
internet is used to relay your public address to another peer. But, your
discussion about STUN, ICE and such makes me think it may not be that simple.
So, to establish a connection to another peer there are two steps. First you
send out a request to the network for your publicip:publicport address from
your locally bound address, which contains a special one-use public key. A peer
of the network can reply directly to you with your publicip:publicport
encrypted with your one-use public key. Second, you send a connection request
'towards' your target peer from your addressable public key, encrypting your
publicip:publicport with the target peer's public key. Then.. the target peer
can reply directly to you.
This seems like pretty specialized behavior, and gaurantees little anonymity
(none to the peer you make your publicip request to, and to your target peer),
but you also get minimum latency once you establish a connection. I'm not sure
if there are similar existing p2p protocols. If latency is not too much of an
issue, you could always use I2P or Tor and get more anonymity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment