diff options
author | Audrius Butkevicius <audrius.butkevicius@gmail.com> | 2014-09-04 23:01:34 +0100 |
---|---|---|
committer | Audrius Butkevicius <audrius.butkevicius@gmail.com> | 2014-09-04 23:02:10 +0100 |
commit | b445a7c4d3aa086f74292bf7e857bbf5c75c5236 (patch) | |
tree | 978419ba4aa8640d68db9cc9accdb3123529d7fe | |
parent | 33e9a88b56395130873a4052381baa7d90486779 (diff) | |
download | syncthing-b445a7c4d3aa086f74292bf7e857bbf5c75c5236.tar.gz syncthing-b445a7c4d3aa086f74292bf7e857bbf5c75c5236.zip |
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 763e99ff8..61f3d6784 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 { |