Add unit suffix to UPnP settings
This commit is contained in:
@@ -739,7 +739,7 @@ func setupUPnP() {
|
|||||||
} else {
|
} else {
|
||||||
l.Infof("Created UPnP port mapping for external port %d on UPnP device %s.", externalPort, igd.FriendlyIdentifier())
|
l.Infof("Created UPnP port mapping for external port %d on UPnP device %s.", externalPort, igd.FriendlyIdentifier())
|
||||||
|
|
||||||
if opts.UPnPRenewal > 0 {
|
if opts.UPnPRenewalM > 0 {
|
||||||
go renewUPnP(port)
|
go renewUPnP(port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -757,7 +757,7 @@ func setupExternalPort(igd *upnp.IGD, port int) int {
|
|||||||
|
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
r := 1024 + predictableRandom.Intn(65535-1024)
|
r := 1024 + predictableRandom.Intn(65535-1024)
|
||||||
err := igd.AddPortMapping(upnp.TCP, r, port, fmt.Sprintf("syncthing-%d", r), cfg.Options().UPnPLease*60)
|
err := igd.AddPortMapping(upnp.TCP, r, port, fmt.Sprintf("syncthing-%d", r), cfg.Options().UPnPLeaseM*60)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
@@ -768,7 +768,7 @@ func setupExternalPort(igd *upnp.IGD, port int) int {
|
|||||||
func renewUPnP(port int) {
|
func renewUPnP(port int) {
|
||||||
for {
|
for {
|
||||||
opts := cfg.Options()
|
opts := cfg.Options()
|
||||||
time.Sleep(time.Duration(opts.UPnPRenewal) * time.Minute)
|
time.Sleep(time.Duration(opts.UPnPRenewalM) * time.Minute)
|
||||||
// Some values might have changed while we were sleeping
|
// Some values might have changed while we were sleeping
|
||||||
opts = cfg.Options()
|
opts = cfg.Options()
|
||||||
|
|
||||||
@@ -792,7 +792,7 @@ 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 {
|
if externalPort != 0 {
|
||||||
err := igd.AddPortMapping(upnp.TCP, externalPort, port, "syncthing", opts.UPnPLease*60)
|
err := igd.AddPortMapping(upnp.TCP, externalPort, port, "syncthing", opts.UPnPLeaseM*60)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Warnf("Error renewing UPnP port mapping for external port %d on device %s: %s", externalPort, igd.FriendlyIdentifier(), err.Error())
|
l.Warnf("Error renewing UPnP port mapping for external port %d on device %s: %s", externalPort, igd.FriendlyIdentifier(), err.Error())
|
||||||
} else if debugNet {
|
} else if debugNet {
|
||||||
|
|||||||
@@ -227,8 +227,8 @@ type OptionsConfiguration struct {
|
|||||||
ReconnectIntervalS int `xml:"reconnectionIntervalS" json:"reconnectionIntervalS" default:"60"`
|
ReconnectIntervalS int `xml:"reconnectionIntervalS" json:"reconnectionIntervalS" default:"60"`
|
||||||
StartBrowser bool `xml:"startBrowser" json:"startBrowser" default:"true"`
|
StartBrowser bool `xml:"startBrowser" json:"startBrowser" default:"true"`
|
||||||
UPnPEnabled bool `xml:"upnpEnabled" json:"upnpEnabled" default:"true"`
|
UPnPEnabled bool `xml:"upnpEnabled" json:"upnpEnabled" default:"true"`
|
||||||
UPnPLease int `xml:"upnpLeaseMinutes" json:"upnpLeaseMinutes" default:"0"`
|
UPnPLeaseM int `xml:"upnpLeaseMinutes" json:"upnpLeaseMinutes" default:"0"`
|
||||||
UPnPRenewal int `xml:"upnpRenewalMinutes" json:"upnpRenewalMinutes" default:"30"`
|
UPnPRenewalM int `xml:"upnpRenewalMinutes" json:"upnpRenewalMinutes" default:"30"`
|
||||||
UPnPTimeoutS int `xml:"upnpTimeoutSeconds" json:"upnpTimeoutSeconds" default:"3"`
|
UPnPTimeoutS int `xml:"upnpTimeoutSeconds" json:"upnpTimeoutSeconds" default:"3"`
|
||||||
URAccepted int `xml:"urAccepted" json:"urAccepted"` // Accepted usage reporting version; 0 for off (undecided), -1 for off (permanently)
|
URAccepted int `xml:"urAccepted" json:"urAccepted"` // Accepted usage reporting version; 0 for off (undecided), -1 for off (permanently)
|
||||||
URUniqueID string `xml:"urUniqueID" json:"urUniqueId"` // Unique ID for reporting purposes, regenerated when UR is turned on.
|
URUniqueID string `xml:"urUniqueID" json:"urUniqueId"` // Unique ID for reporting purposes, regenerated when UR is turned on.
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ func TestDefaultValues(t *testing.T) {
|
|||||||
ReconnectIntervalS: 60,
|
ReconnectIntervalS: 60,
|
||||||
StartBrowser: true,
|
StartBrowser: true,
|
||||||
UPnPEnabled: true,
|
UPnPEnabled: true,
|
||||||
UPnPLease: 0,
|
UPnPLeaseM: 0,
|
||||||
UPnPRenewal: 30,
|
UPnPRenewalM: 30,
|
||||||
UPnPTimeoutS: 3,
|
UPnPTimeoutS: 3,
|
||||||
RestartOnWakeup: true,
|
RestartOnWakeup: true,
|
||||||
AutoUpgradeIntervalH: 12,
|
AutoUpgradeIntervalH: 12,
|
||||||
@@ -148,8 +148,8 @@ func TestOverriddenValues(t *testing.T) {
|
|||||||
ReconnectIntervalS: 6000,
|
ReconnectIntervalS: 6000,
|
||||||
StartBrowser: false,
|
StartBrowser: false,
|
||||||
UPnPEnabled: false,
|
UPnPEnabled: false,
|
||||||
UPnPLease: 60,
|
UPnPLeaseM: 60,
|
||||||
UPnPRenewal: 15,
|
UPnPRenewalM: 15,
|
||||||
UPnPTimeoutS: 15,
|
UPnPTimeoutS: 15,
|
||||||
RestartOnWakeup: false,
|
RestartOnWakeup: false,
|
||||||
AutoUpgradeIntervalH: 24,
|
AutoUpgradeIntervalH: 24,
|
||||||
|
|||||||
Reference in New Issue
Block a user