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

MOAR DOCS #1

Open
lilyannehall opened this issue Dec 24, 2015 · 11 comments
Open

MOAR DOCS #1

lilyannehall opened this issue Dec 24, 2015 · 11 comments

Comments

@lilyannehall
Copy link

Hey! Nice work! I'd love to incorporate TURN as a transport middleware for [kad](github.com/gordon writescode/kad). Any ideas when you might have some documentation to help?

For now I'll use the source!

@nicojanssens
Copy link
Owner

Thx!

Sure, will add a README file later on this week.

@Globik
Copy link

Globik commented Mar 26, 2016

And how to use this stuff?

@nicojanssens
Copy link
Owner

@Globik The easiest way to get started is by checking out the example scripts -- you can find them in the examples dir. Both scripts setup relay connections between two sockets, and use these connections to exchange messages. One script exchanges these messages via STUN data packets, while the other example binds a TURN channel first to transmit data messages.

To test these example scripts, run
node channel_data.js --addr=TURN_ADDR --port=TURN_PORT --user=TURN_USER --pwd=TURN_PWD or node channel_bind.js --addr=TURN_HOST --port=TURN_PORT --user=TURN_USER --pwd=TURN_PWD

If you're not running a TURN server yourself, you can create an account on the Numb STUN/TURN server and use these credentials when launching my example scripts.

@lilyannehall
Copy link
Author

@Globik also, feel free to use turn.counterpointhackers.org - no credentials required

@ghost
Copy link

ghost commented Apr 22, 2016

@nicojanssens , you said that one script exchanges via STUN and another via TURN, which one is STUN and which is TURN ??

sendToChannel == STUN
sendToRelay == TURN

???

@ghost
Copy link

ghost commented Apr 22, 2016

And where do we need mappedAddress ??

@nicojanssens
Copy link
Owner

@iMihael That was a typo. Both scripts establish TURN connections. (The TURN protocol uses STUN packets, that's probably where my lapsus originates from).

  • examples/channel_bind.js exchanges data over a negotiated TURN channel -- use sendToChannel() to transmit data over such a channel
  • examples/channel_data.js uses TURN data packets to relay packets between two endpoints -- you need to use sendToRelay to send these TURN data packets

@nicojanssens
Copy link
Owner

@iMihael The mappedAddress is not required to establish a bidirectional connection between two clients. It specifies a client's mapped public address -- which is the address of the NAT box a client is located behind.

@ghost
Copy link

ghost commented Apr 22, 2016

If it possible to use (establish) stun connection between two peers, will your lib use this variant to decrease turn server load ??

@nicojanssens
Copy link
Owner

@iMihael you mean a direct connection between two nodes located behind a NAT box? Nope, this lib does relaying only. It does not iterate over various connectivity strategies like WebRTC does using ICE -- first trying to connect two peers using their private addresses, then using their server reflexive address and finally establishing a relay connection if all other options failed.

It's on my todo list (I implemented a udp hole punching lib for that purpose, see https://github.com/nicojanssens/udp-hole-puncher-js) but I didn't find the time yet to complete this.

Btw, you may want to have a look at the kad-traverse module of @gordonwritescode. Gordon implemented a strategy like the one I explained above, such that TURN connections are only used if all other connection attempts have failed. GH repo: https://github.com/kadtools/kad-traverse

@ghost
Copy link

ghost commented Apr 22, 2016

Thank you for answer!

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

3 participants