indutny / node-nat-upnp

NAT port mapping via UPnP
147 stars 59 forks source link

Is sourcing 1900 required? #11

Closed coolaj86 closed 9 years ago

coolaj86 commented 9 years ago

In your code you source port 1900 explicitly for the SSDP search for the gateway. Part of what I'm trying to determine empirically with https://github.com/indutny/node-nat-upnp/issues/10 is whether that's arbitrary or if 1900 MUST be used as the source port for SSDP to work.

Sending to port 1900 as a requirement makes sense, but I thought UDP responses go back to the port number in the message received by the router.

indutny commented 9 years ago

I think routers are sending announcements to multicast 1900 port. So yeah, it MUST be used.

coolaj86 commented 9 years ago

So they don't respond to the M-SEARCH, but rather broadcast?

So, to your knowledge, there's no method for having two applications listening for SSDP messages on the same machine?

indutny commented 9 years ago

@coolaj86 I'm afraid I don't know this details anymore :) I was working on this thing quite long time ago, sorry!

coolaj86 commented 9 years ago

Hey, I dove into this a bit and found that the responses to multicast requests go to whichever port the request came from, as I had initially thought.

See

I'll put in a pull request to make this dynamic.

I've tested this on 3 different routers with 3 different firmwares. I'm pretty confident about it.

indutny commented 9 years ago

Nice!