lib/connections: Un-deprecate relaysEnabled (fixes #3074)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3098
This commit is contained in:
@@ -12,7 +12,9 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -40,6 +42,7 @@ func TestDefaultValues(t *testing.T) {
|
||||
MaxSendKbps: 0,
|
||||
MaxRecvKbps: 0,
|
||||
ReconnectIntervalS: 60,
|
||||
RelaysEnabled: true,
|
||||
RelayReconnectIntervalM: 10,
|
||||
StartBrowser: true,
|
||||
NATEnabled: true,
|
||||
@@ -169,6 +172,7 @@ func TestOverriddenValues(t *testing.T) {
|
||||
MaxSendKbps: 1234,
|
||||
MaxRecvKbps: 2341,
|
||||
ReconnectIntervalS: 6000,
|
||||
RelaysEnabled: false,
|
||||
RelayReconnectIntervalM: 20,
|
||||
StartBrowser: false,
|
||||
NATEnabled: false,
|
||||
@@ -616,3 +620,61 @@ func TestRemoveDuplicateDevicesFolders(t *testing.T) {
|
||||
t.Errorf("Incorrect number of folder devices, %d != 2", l)
|
||||
}
|
||||
}
|
||||
|
||||
func TestV14ListenAddressesMigration(t *testing.T) {
|
||||
tcs := [][3][]string{
|
||||
|
||||
// Default listen plus default relays is now "default"
|
||||
{
|
||||
{"tcp://0.0.0.0:22000"},
|
||||
{"dynamic+https://relays.syncthing.net/endpoint"},
|
||||
{"default"},
|
||||
},
|
||||
// Default listen address without any relay addresses gets converted
|
||||
// to just the listen address. It's easier this way, and frankly the
|
||||
// user has gone to some trouble to get the empty string in the
|
||||
// config to start with...
|
||||
{
|
||||
{"tcp://0.0.0.0:22000"}, // old listen addrs
|
||||
{""}, // old relay addrs
|
||||
{"tcp://0.0.0.0:22000"}, // new listen addrs
|
||||
},
|
||||
// Default listen plus non-default relays gets copied verbatim
|
||||
{
|
||||
{"tcp://0.0.0.0:22000"},
|
||||
{"dynamic+https://other.example.com"},
|
||||
{"tcp://0.0.0.0:22000", "dynamic+https://other.example.com"},
|
||||
},
|
||||
// Non-default listen plus default relays gets copied verbatim
|
||||
{
|
||||
{"tcp://1.2.3.4:22000"},
|
||||
{"dynamic+https://relays.syncthing.net/endpoint"},
|
||||
{"tcp://1.2.3.4:22000", "dynamic+https://relays.syncthing.net/endpoint"},
|
||||
},
|
||||
// Default stuff gets sucked into "default", the rest gets copied
|
||||
{
|
||||
{"tcp://0.0.0.0:22000", "tcp://1.2.3.4:22000"},
|
||||
{"dynamic+https://relays.syncthing.net/endpoint", "relay://other.example.com"},
|
||||
{"default", "tcp://1.2.3.4:22000", "relay://other.example.com"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tcs {
|
||||
cfg := Configuration{
|
||||
Version: 13,
|
||||
Options: OptionsConfiguration{
|
||||
ListenAddresses: tc[0],
|
||||
DeprecatedRelayServers: tc[1],
|
||||
},
|
||||
}
|
||||
convertV13V14(&cfg)
|
||||
if cfg.Version != 14 {
|
||||
t.Error("Configuration was not converted")
|
||||
}
|
||||
|
||||
sort.Strings(tc[2])
|
||||
if !reflect.DeepEqual(cfg.Options.ListenAddresses, tc[2]) {
|
||||
t.Errorf("Migration error; actual %#v != expected %#v", cfg.Options.ListenAddresses, tc[2])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user