Merge pull request #631 from AudriusButkevicius/upnp

Check if we had successfully acquired a UPnP mapping before (fixes #627)
This commit is contained in:
Jakob Borg 2014-09-05 09:09:23 +02:00
commit 33a26bc0cf

View File

@ -663,13 +663,16 @@ func renewUPnP(port int) {
} }
// Just renew the same port that we already have // Just renew the same port that we already have
if externalPort != 0 {
err = igd.AddPortMapping(upnp.TCP, externalPort, port, "syncthing", cfg.Options.UPnPLease*60) err = igd.AddPortMapping(upnp.TCP, externalPort, port, "syncthing", cfg.Options.UPnPLease*60)
if err == nil { if err == nil {
l.Infoln("Renewed UPnP port mapping - external port", externalPort) l.Infoln("Renewed UPnP port mapping - external port", externalPort)
continue 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. // Retry the same port sequence from the beginning.
r := setupExternalPort(igd, port) r := setupExternalPort(igd, port)
if r != 0 { if r != 0 {