gortc / stun

Fast RFC 5389 STUN implementation in go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

return both ipv4 and ipv6 address

leslie-wang opened this issue · comments

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.

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.

It works. Thanks a lot.

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

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.

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