diff --git a/lib/config/config.go b/lib/config/config.go index dd04c15e2..6116f164f 100644 --- a/lib/config/config.go +++ b/lib/config/config.go @@ -14,6 +14,7 @@ import ( "io/ioutil" "net/url" "os" + "path" "sort" "strings" @@ -23,7 +24,7 @@ import ( const ( OldestHandledVersion = 10 - CurrentVersion = 14 + CurrentVersion = 15 MaxRescanIntervalS = 365 * 24 * 60 * 60 ) @@ -201,6 +202,9 @@ func (cfg *Configuration) prepare(myID protocol.DeviceID) { if cfg.Version == 13 { convertV13V14(cfg) } + if cfg.Version == 14 { + convertV14V15(cfg) + } // Build a list of available devices existingDevices := make(map[protocol.DeviceID]bool) @@ -254,6 +258,21 @@ func (cfg *Configuration) prepare(myID protocol.DeviceID) { } } +func convertV14V15(cfg *Configuration) { + // Undo v0.13.0 broken migration + + for i, addr := range cfg.Options.GlobalAnnServers { + switch addr { + case "default-v4v2/": + cfg.Options.GlobalAnnServers[i] = "default-v4" + case "default-v6v2/": + cfg.Options.GlobalAnnServers[i] = "default-v6" + } + } + + cfg.Version = 15 +} + func convertV13V14(cfg *Configuration) { // Not using the ignore cache is the new default. Disable it on existing // configurations. @@ -307,12 +326,13 @@ func convertV13V14(cfg *Configuration) { var newAddrs []string for _, addr := range cfg.Options.GlobalAnnServers { - if addr != "default" { - uri, err := url.Parse(addr) - if err != nil { - panic(err) - } - uri.Path += "v2/" + uri, err := url.Parse(addr) + if err != nil { + // That's odd. Skip the broken address. + continue + } + if uri.Scheme == "https" { + uri.Path = path.Join(uri.Path, "v2") + "/" addr = uri.String() } diff --git a/lib/config/config_test.go b/lib/config/config_test.go index 38c175b55..f2288ee37 100644 --- a/lib/config/config_test.go +++ b/lib/config/config_test.go @@ -365,12 +365,12 @@ func TestIssue1750(t *testing.T) { t.Errorf("%q != %q", cfg.Options().ListenAddresses[1], "tcp://:23001") } - if cfg.Options().GlobalAnnServers[0] != "udp4://syncthing.nym.se:22026/v2/" { - t.Errorf("%q != %q", cfg.Options().GlobalAnnServers[0], "udp4://syncthing.nym.se:22026/v2/") + if cfg.Options().GlobalAnnServers[0] != "udp4://syncthing.nym.se:22026" { + t.Errorf("%q != %q", cfg.Options().GlobalAnnServers[0], "udp4://syncthing.nym.se:22026") } - if cfg.Options().GlobalAnnServers[1] != "udp4://syncthing.nym.se:22027/v2/" { - t.Errorf("%q != %q", cfg.Options().GlobalAnnServers[1], "udp4://syncthing.nym.se:22027/v2/") + if cfg.Options().GlobalAnnServers[1] != "udp4://syncthing.nym.se:22027" { + t.Errorf("%q != %q", cfg.Options().GlobalAnnServers[1], "udp4://syncthing.nym.se:22027") } } diff --git a/lib/config/testdata/v15.xml b/lib/config/testdata/v15.xml new file mode 100644 index 000000000..a102f2be9 --- /dev/null +++ b/lib/config/testdata/v15.xml @@ -0,0 +1,14 @@ + + + + + 1 + -1 + + +
tcp://a
+
+ +
tcp://b
+
+