diff options
author | Jakob Borg <jakob@nym.se> | 2014-09-05 09:09:23 +0200 |
---|---|---|
committer | Jakob Borg <jakob@nym.se> | 2014-09-05 09:09:23 +0200 |
commit | 33a26bc0cf539f203d486a1fc63405ed083a25af (patch) | |
tree | 845c7ae90247040af1781fcdd5cd59d1ddc12a46 | |
parent | e6892d0c3ea3e123ba227477e6efccc353bd9395 (diff) | |
parent | b445a7c4d3aa086f74292bf7e857bbf5c75c5236 (diff) |
Merge pull request #631 from AudriusButkevicius/upnp
Check if we had successfully acquired a UPnP mapping before (fixes #627)
-rw-r--r-- | cmd/syncthing/main.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 763e99ff8c..61f3d67841 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -663,13 +663,16 @@ func renewUPnP(port int) { } // Just renew the same port that we already have - err = igd.AddPortMapping(upnp.TCP, externalPort, port, "syncthing", cfg.Options.UPnPLease*60) - if err == nil { - l.Infoln("Renewed UPnP port mapping - external port", externalPort) - continue + if externalPort != 0 { + err = igd.AddPortMapping(upnp.TCP, externalPort, port, "syncthing", cfg.Options.UPnPLease*60) + if err == nil { + l.Infoln("Renewed UPnP port mapping - external port", externalPort) + continue + } } - // Something strange has happened. Perhaps the gateway has changed? + // Something strange has happened. We didn't have an external port before? + // Or perhaps the gateway has changed? // Retry the same port sequence from the beginning. r := setupExternalPort(igd, port) if r != 0 { |