Skip to content

Commit

Permalink
net/portmapper: ignore IGD SSDP responses from !defaultgw
Browse files Browse the repository at this point in the history
Now that we multicast the SSDP query, we can get IGD offers from
devices other than the current device's default gateway. We don't want
to accidentally bind ourselves to those.

Updates #3197

Signed-off-by: David Anderson <danderson@tailscale.com>
(cherry picked from commit 060ba86)
  • Loading branch information
danderson authored and bradfitz committed Oct 29, 2021
1 parent d117f77 commit 6f332b4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion net/portmapper/portmapper.go
Expand Up @@ -752,10 +752,14 @@ func (c *Client) Probe(ctx context.Context) (res ProbeResult, err error) {
}
return res, err
}
ip, ok := netaddr.FromStdIP(addr.(*net.UDPAddr).IP)
if !ok {
continue
}
port := uint16(addr.(*net.UDPAddr).Port)
switch port {
case c.upnpPort():
if mem.Contains(mem.B(buf[:n]), mem.S(":InternetGatewayDevice:")) {
if ip == gw && mem.Contains(mem.B(buf[:n]), mem.S(":InternetGatewayDevice:")) {
meta, err := parseUPnPDiscoResponse(buf[:n])
if err != nil {
c.logf("unrecognized UPnP discovery response; ignoring")
Expand Down

0 comments on commit 6f332b4

Please sign in to comment.