lib/nat: Add a nat package and service to track mappings on multiple IGDs

This commit is contained in:
Audrius Butkevicius
2016-04-10 19:36:38 +00:00
committed by Jakob Borg
parent f3ac421266
commit 19b4f3bfb4
20 changed files with 661 additions and 236 deletions

View File

@@ -242,6 +242,10 @@ func convertV12V13(cfg *Configuration) {
// Not using the ignore cache is the new default. Disable it on existing
// configurations.
cfg.Options.CacheIgnoredFiles = false
cfg.Options.NATEnabled = cfg.Options.DeprecatedUPnPEnabled
cfg.Options.NATLeaseM = cfg.Options.DeprecatedUPnPLeaseM
cfg.Options.NATRenewalM = cfg.Options.DeprecatedUPnPRenewalM
cfg.Options.NATTimeoutS = cfg.Options.DeprecatedUPnPTimeoutS
cfg.Version = 13
}

View File

@@ -44,10 +44,10 @@ func TestDefaultValues(t *testing.T) {
RelaysEnabled: true,
RelayReconnectIntervalM: 10,
StartBrowser: true,
UPnPEnabled: true,
UPnPLeaseM: 60,
UPnPRenewalM: 30,
UPnPTimeoutS: 10,
NATEnabled: true,
NATLeaseM: 60,
NATRenewalM: 30,
NATTimeoutS: 10,
RestartOnWakeup: true,
AutoUpgradeIntervalH: 12,
KeepTemporariesH: 24,
@@ -174,10 +174,10 @@ func TestOverriddenValues(t *testing.T) {
RelaysEnabled: false,
RelayReconnectIntervalM: 20,
StartBrowser: false,
UPnPEnabled: false,
UPnPLeaseM: 90,
UPnPRenewalM: 15,
UPnPTimeoutS: 15,
NATEnabled: false,
NATLeaseM: 90,
NATRenewalM: 15,
NATTimeoutS: 15,
RestartOnWakeup: false,
AutoUpgradeIntervalH: 24,
KeepTemporariesH: 48,

View File

@@ -20,10 +20,10 @@ type OptionsConfiguration struct {
RelaysEnabled bool `xml:"relaysEnabled" json:"relaysEnabled" default:"true"`
RelayReconnectIntervalM int `xml:"relayReconnectIntervalM" json:"relayReconnectIntervalM" default:"10"`
StartBrowser bool `xml:"startBrowser" json:"startBrowser" default:"true"`
UPnPEnabled bool `xml:"upnpEnabled" json:"upnpEnabled" default:"true"`
UPnPLeaseM int `xml:"upnpLeaseMinutes" json:"upnpLeaseMinutes" default:"60"`
UPnPRenewalM int `xml:"upnpRenewalMinutes" json:"upnpRenewalMinutes" default:"30"`
UPnPTimeoutS int `xml:"upnpTimeoutSeconds" json:"upnpTimeoutSeconds" default:"10"`
NATEnabled bool `xml:"natEnabled" json:"natEnabled" default:"true"`
NATLeaseM int `xml:"natLeaseMinutes" json:"natLeaseMinutes" default:"60"`
NATRenewalM int `xml:"natRenewalMinutes" json:"natRenewalMinutes" default:"30"`
NATTimeoutS int `xml:"natTimeoutSeconds" json:"natTimeoutSeconds" default:"10"`
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.
URURL string `xml:"urURL" json:"urURL" default:"https://data.syncthing.net/newdata"`
@@ -40,6 +40,11 @@ type OptionsConfiguration struct {
ReleasesURL string `xml:"releasesURL" json:"releasesURL" default:"https://api.github.com/repos/syncthing/syncthing/releases?per_page=30"`
AlwaysLocalNets []string `xml:"alwaysLocalNet" json:"alwaysLocalNets"`
OverwriteNames bool `xml:"overwriteNames" json:"overwriteNames" default:"false"`
DeprecatedUPnPEnabled bool `xml:"upnpEnabled"`
DeprecatedUPnPLeaseM int `xml:"upnpLeaseMinutes"`
DeprecatedUPnPRenewalM int `xml:"upnpRenewalMinutes"`
DeprecatedUPnPTimeoutS int `xml:"upnpTimeoutSeconds"`
}
func (orig OptionsConfiguration) Copy() OptionsConfiguration {

View File

@@ -17,10 +17,10 @@
<relayReconnectIntervalM>20</relayReconnectIntervalM>
<relayWithoutGlobalAnn>true</relayWithoutGlobalAnn>
<startBrowser>false</startBrowser>
<upnpEnabled>false</upnpEnabled>
<upnpLeaseMinutes>90</upnpLeaseMinutes>
<upnpRenewalMinutes>15</upnpRenewalMinutes>
<upnpTimeoutSeconds>15</upnpTimeoutSeconds>
<natEnabled>false</natEnabled>
<natLeaseMinutes>90</natLeaseMinutes>
<natRenewalMinutes>15</natRenewalMinutes>
<natTimeoutSeconds>15</natTimeoutSeconds>
<restartOnWakeup>false</restartOnWakeup>
<autoUpgradeIntervalH>24</autoUpgradeIntervalH>
<keepTemporariesH>48</keepTemporariesH>