go-stun icon indicating copy to clipboard operation
go-stun copied to clipboard

Doesn't work with some servers

Open AlexKMDev opened this issue 9 years ago • 20 comments

For example google ones:

stun.l.google.com:19302 stun1.l.google.com:19302 stun2.l.google.com:19302 stun3.l.google.com:19302 stun4.l.google.com:19302

Test1 fails with "No changed address." error. Any idea what could be wrong?

AlexKMDev avatar May 19 '16 17:05 AlexKMDev

I'm still getting the error "Server error: no changed address." using the google servers.

EDIT: Google servers seem to have changed their port. But when using Port 19305 the returned *Host is nil.

chrikoch avatar Aug 20 '16 19:08 chrikoch

@chrikoch Can you please provide a reproduce step?

xiang90 avatar Aug 20 '16 19:08 xiang90

@xiang90

My Code:

func minimalExample() { stunClient := stun.NewClient() stunClient.SetServerHost("stun1.l.google.com", 19305) _, host, err := stunClient.Discover()

if err != nil {
    log.Println(err)
    return
}

if host == nil {
    log.Println("no host")
    return
}

}

Output is: 2016/08/20 22:33:27 no host

chrikoch avatar Aug 20 '16 20:08 chrikoch

I think there is a bug in the Google servers. In test2, we send a request to the server with flag of changing IP and port. But the received packet is from the original IP and port (not changed).

Let me know if you think it is not Google servers' bug and have any hints to me. Thanks.

ccding avatar Aug 21 '16 03:08 ccding

Sorry I messed up this bug with another one. Please ignore the above comment. See below:

In the test1 response from Google servers, it doesn't provide a changedAddr attribute, which is required by RFC3489. I think this is a bug in Google servers. I think the previous fix is incorrect.

ccding avatar Aug 21 '16 03:08 ccding

@ccding @xiang90 I tried to debug this a bit more. Now I think 19302 seems to be the correct port for googles stun servers. Requests to 19305 don't give any response in wireshark: 19305 So it's even stranger the lib doesn't return an error but a nil host.

Requests to 19302 do get a response from google: 19302 Output of my testing code is in that case: 2016/08/21 20:39:26 Server error: no changed address.

chrikoch avatar Aug 21 '16 18:08 chrikoch

What I meant was that, the response doesn't include a CHANGED-ADDRESS field, which is required by RFC (see https://tools.ietf.org/html/rfc3489#section-11.2.3)

ccding avatar Aug 21 '16 18:08 ccding

Actually I was looking for a stun library working with in-the-wild-servers, even if they don't respect the RFC ;-)

chrikoch avatar Aug 21 '16 18:08 chrikoch

If a server doesn't follow RFC, how can I understand its response given the fact that the server itself doesn't provide any documentation? I'd suggest you to use this server stun.ekiga.net:3478

ccding avatar Aug 21 '16 18:08 ccding

The reason RFC requires this filed is that we need this CHANGED-ADDRESS field to perform the next step test. If it doesn't exist, I cannot perform the next step. Therefore I have to report an error.

ccding avatar Aug 21 '16 19:08 ccding

@ccding @chrikoch I think we want to accept the patch if it makes go-stun more adoptive to the wild. However, the patch itself needs to be well documented and isolated to make it clear that it exists for the purpose of one wild deployed service.

@chrikoch Do you want to help on this? Thank you!

xiang90 avatar Aug 21 '16 19:08 xiang90

It cannot be more adoptive to the wild.

  1. There is another bug in google servers: in test2, when I request to change IP and port, the server doesn't change it. If I don't report error in CHANGED-ADDRESS, the error of not changing IP and port will be reported later.

  2. If the NAT is not sym. UPD firewall or open Internet, by RFC, I have to perform another test: send packet to the CHANGED-ADDRESS specified in test1. Given the CHANGED-ADDRESS is not specified in test1, I don't know where to send the packet. The CHANGED-ADDRESS error will be reported anyway.

ccding avatar Aug 21 '16 20:08 ccding

I don't think there is a bug in the google servers. Obviously they're using STUN from RFC 5389, which obsoletes RFC 3489 (which seems to be implemented in go-stun). The CHANGED-ADDRESS was removed from STUN:

"[...] CHANGED-ADDRESS, that have been removed from this specification"

See: https://tools.ietf.org/html/rfc5389#section-12

chrikoch avatar Aug 23 '16 18:08 chrikoch

in RFC5780, CHANGED-ADDRESS has been replaced by OTHER-ADDRESS

InsZVA avatar Jan 26 '17 15:01 InsZVA

see #20

ccding avatar Feb 11 '17 06:02 ccding

Perhaps this is the wrong issue, but when I run the tool behind a mobile network I always hit the Server error: response IP/port errors. I've tried many servers, and ones that work behind normal home networks.

@ccding do you know where in the spec the fact that it returns from a diff ip/port that it invalidates the algo?

yonderblue avatar Feb 26 '19 02:02 yonderblue

https://tools.ietf.org/html/rfc3489#section-11.2.3

ccding avatar Feb 27 '19 18:02 ccding