Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: what's a "peer" object, what does "holepunch" do #20

Open
cinnamon-bun opened this issue Feb 2, 2021 · 1 comment
Open

Comments

@cinnamon-bun
Copy link

Hello, some friendly feedback about improving the docs for this module <3

What's the scope of this module?

It gives you the ip addresses of peers and holepunches to them? Meaning you get a stream to each peer?

What's a peer object?

Docs say

// emitted when a peer is found
lookup.on('peer', console.log)

...but what's in a peer object? What can it do?

I think this is the answer?
https://github.com/hyperswarm/discovery/blob/master/index.js#L389

        topic.emit('peer', { port: a.data.port, host, local: true, referrer: null, topic: topic.key })

So a peer is mostly a port and hostname, not a stream.

What does holepunch do?

Docs just say:

d.holepunch(peer, cb)
UDP holepunch to another peer.

What actually happens? What does the callback get?

Looking in the code, it just calls dht.holepunch. The docs for hyperswarm/dht just say

node.holepunch(peer, [callback])

UDP holepunch to another peer.

peer should be a { host, port, referrer: { host, port } }, where referrer should be the host and port of the DHT node who told you about this peer.

Ok, so that's probably the peer object we were talking about earlier. But what does this do, and what's provided to the callback?

The word holepunch does not occur in any of the code in hyperswarm/dht so I can't find what it's actually doing.

@sallespro
Copy link

hi, there's a perfect explanation for you in this video about Hole Punching. https://youtu.be/1qzDiAg4VGk?t=674

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants