lib/connections: Un-deprecate relaysEnabled (fixes #3074)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3098
This commit is contained in:
@@ -29,9 +29,9 @@ const (
|
||||
|
||||
var (
|
||||
// DefaultListenAddresses should be substituted when the configuration
|
||||
// contains <listenAddress>default</listenAddress>. This is
|
||||
// done by the "consumer" of the configuration, as we don't want these
|
||||
// saved to the config.
|
||||
// contains <listenAddress>default</listenAddress>. This is done by the
|
||||
// "consumer" of the configuration as we don't want these saved to the
|
||||
// config.
|
||||
DefaultListenAddresses = []string{
|
||||
"tcp://0.0.0.0:22000",
|
||||
"dynamic+https://relays.syncthing.net/endpoint",
|
||||
@@ -258,27 +258,53 @@ func convertV13V14(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
|
||||
if cfg.Options.DeprecatedRelaysEnabled {
|
||||
cfg.Options.ListenAddresses = append(cfg.Options.ListenAddresses, cfg.Options.DeprecatedRelayServers...)
|
||||
// Replace our two fairly long addresses with 'default' if both exist.
|
||||
var newAddresses []string
|
||||
for _, addr := range cfg.Options.ListenAddresses {
|
||||
if addr != "tcp://0.0.0.0:22000" && addr != "dynamic+https://relays.syncthing.net/endpoint" {
|
||||
newAddresses = append(newAddresses, addr)
|
||||
}
|
||||
}
|
||||
|
||||
if len(newAddresses)+2 == len(cfg.Options.ListenAddresses) {
|
||||
cfg.Options.ListenAddresses = append([]string{"default"}, newAddresses...)
|
||||
// Migrate UPnP -> NAT options
|
||||
cfg.Options.NATEnabled = cfg.Options.DeprecatedUPnPEnabled
|
||||
cfg.Options.DeprecatedUPnPEnabled = false
|
||||
cfg.Options.NATLeaseM = cfg.Options.DeprecatedUPnPLeaseM
|
||||
cfg.Options.DeprecatedUPnPLeaseM = 0
|
||||
cfg.Options.NATRenewalM = cfg.Options.DeprecatedUPnPRenewalM
|
||||
cfg.Options.DeprecatedUPnPRenewalM = 0
|
||||
cfg.Options.NATTimeoutS = cfg.Options.DeprecatedUPnPTimeoutS
|
||||
cfg.Options.DeprecatedUPnPTimeoutS = 0
|
||||
|
||||
// Replace the default listen address "tcp://0.0.0.0:22000" with the
|
||||
// string "default", but only if we also have the default relay pool
|
||||
// among the relay servers as this is implied by the new "default"
|
||||
// entry.
|
||||
hasDefault := false
|
||||
for _, raddr := range cfg.Options.DeprecatedRelayServers {
|
||||
if raddr == "dynamic+https://relays.syncthing.net/endpoint" {
|
||||
for i, addr := range cfg.Options.ListenAddresses {
|
||||
if addr == "tcp://0.0.0.0:22000" {
|
||||
cfg.Options.ListenAddresses[i] = "default"
|
||||
hasDefault = true
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
cfg.Options.DeprecatedRelaysEnabled = false
|
||||
|
||||
// Copy relay addresses into listen addresses.
|
||||
for _, addr := range cfg.Options.DeprecatedRelayServers {
|
||||
if hasDefault && addr == "dynamic+https://relays.syncthing.net/endpoint" {
|
||||
// Skip the default relay address if we already have the
|
||||
// "default" entry in the list.
|
||||
continue
|
||||
}
|
||||
if addr == "" {
|
||||
continue
|
||||
}
|
||||
cfg.Options.ListenAddresses = append(cfg.Options.ListenAddresses, addr)
|
||||
}
|
||||
|
||||
cfg.Options.DeprecatedRelayServers = nil
|
||||
|
||||
// For consistency
|
||||
sort.Strings(cfg.Options.ListenAddresses)
|
||||
|
||||
var newAddrs []string
|
||||
for _, addr := range cfg.Options.GlobalAnnServers {
|
||||
if addr != "default" {
|
||||
|
||||
Reference in New Issue
Block a user