-
Notifications
You must be signed in to change notification settings - Fork 47
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
Examples? #6
Comments
@isaachess Yes, It should work exactly you described, but currently stun.Discover uses net.Dial instead of Listen (so, the socket is associated with a STUN-server's address) and hole-punching does not work. I'll fix it, thanks. |
I just spent the better part of a day tearing my hair out over this, so I wanted to make sure that I documented exactly what's happening here, in the hopes that someone else won't have to. Although @pixelbender fixed the issue with the fact that I guess that's what @pixelbender meant by the |
@isaachess That PR (#8) should allow you to use this library for hole-punching. The For what it's worth, you'll do something like this for both clients (although you still need an external service to help them exchange addresses): conn, externalAddr, err := stun.Discover(STUNServer)
if err != nil {
return nil, errors.Wrap(err, "failed to set up public UDP socket")
}
peerExternalAddr := &net.UDPAddr{
IP: net.ParseIP("<peer addr>"),
Port: 1234,
}
conn.WriteTo([]byte("hello"), peerExternalAddr) |
Could you please point me to the example on how to setup a TCP connection between 2 nodes both behind NAT? |
I'm struggling to use this effectively and am wondering if you could provide some examples.
The actually communication with the STUN server works fine: it returns the public addr observed by the STUN server.
But USING this information isn't working for me, and it has me wondering if I'm just misunderstanding how the package works (thus the request for examples).
For example, when calling
stun.Discover
it returns a conn and addr. I'm attempting, after performing the discover, to receive UDP packets sent to addr. So I'm trying to read from the return conn (while sending UDP messages toaddr
from another machine), but nothing ever comes through.The purpose of STUN in my understanding is to hole-punch so peers can send UDP traffic to the public
addr
, which is then forwarded to the correct host. Can I see an example of how this package gets that done?The text was updated successfully, but these errors were encountered: