gortc / stun

Fast RFC 5389 STUN implementation in go
BSD 3-Clause "New" or "Revised" License
494 stars 53 forks source link

return both ipv4 and ipv6 address #62

Closed leslie-wang closed 5 years ago

leslie-wang commented 5 years ago

When I try stun-client example, it can successfully output my ipv6 address, and seems like bind was also successful. Can you please show me how I can get my ipv4 address as well? I tried client.Start method, handler can only receive one ipv6 event. I don't see any other related options. I'm using default google stun server address.

ernado commented 5 years ago

Hi, seems like the problem is in

c, err := stun.Dial("udp", addr)

If you change it to "udp4", server and client will talk using IPv4.

c, err := stun.Dial("udp4", addr)

Please try it, let's see if it works.

leslie-wang commented 5 years ago

It works. Thanks a lot.

It may benefit other people as well if you can add the description in README.

leslie-wang commented 5 years ago

Interesting. It can display ipv4 address, but seems like hole is not punch, and I can not connect the port from another server, which are at another home.

ernado commented 5 years ago

It depends on your NAT type. If it is symmetric, the outgoing ports for two destination addresses will be different.