|
|
@@ -26,6 +26,7 @@ import (
|
|
|
"reflect"
|
|
|
"sort"
|
|
|
"strconv"
|
|
|
+ "strings"
|
|
|
|
|
|
"github.com/calmh/logger"
|
|
|
"github.com/syncthing/protocol"
|
|
|
@@ -35,7 +36,7 @@ import (
|
|
|
|
|
|
var l = logger.DefaultLogger
|
|
|
|
|
|
-const CurrentVersion = 7
|
|
|
+const CurrentVersion = 8
|
|
|
|
|
|
type Configuration struct {
|
|
|
Version int `xml:"version,attr"`
|
|
|
@@ -162,7 +163,7 @@ type FolderDeviceConfiguration struct {
|
|
|
|
|
|
type OptionsConfiguration struct {
|
|
|
ListenAddress []string `xml:"listenAddress" default:"0.0.0.0:22000"`
|
|
|
- GlobalAnnServers []string `xml:"globalAnnounceServer" default:"udp4://announce.syncthing.net:22026"`
|
|
|
+ GlobalAnnServers []string `xml:"globalAnnounceServer" default:"udp4://announce.syncthing.net:22026, udp6://announce-v6.syncthing.net:22026"`
|
|
|
GlobalAnnEnabled bool `xml:"globalAnnounceEnabled" default:"true"`
|
|
|
LocalAnnEnabled bool `xml:"localAnnounceEnabled" default:"true"`
|
|
|
LocalAnnPort int `xml:"localAnnouncePort" default:"21025"`
|
|
|
@@ -296,35 +297,28 @@ func (cfg *Configuration) prepare(myID protocol.DeviceID) {
|
|
|
cfg.Options.Deprecated_URDeclined = false
|
|
|
cfg.Options.Deprecated_UREnabled = false
|
|
|
|
|
|
- // Upgrade to v1 configuration if appropriate
|
|
|
+ // Upgrade configuration versions as appropriate
|
|
|
if cfg.Version == 1 {
|
|
|
convertV1V2(cfg)
|
|
|
}
|
|
|
-
|
|
|
- // Upgrade to v3 configuration if appropriate
|
|
|
if cfg.Version == 2 {
|
|
|
convertV2V3(cfg)
|
|
|
}
|
|
|
-
|
|
|
- // Upgrade to v4 configuration if appropriate
|
|
|
if cfg.Version == 3 {
|
|
|
convertV3V4(cfg)
|
|
|
}
|
|
|
-
|
|
|
- // Upgrade to v5 configuration if appropriate
|
|
|
if cfg.Version == 4 {
|
|
|
convertV4V5(cfg)
|
|
|
}
|
|
|
-
|
|
|
- // Upgrade to v6 configuration if appropriate
|
|
|
if cfg.Version == 5 {
|
|
|
convertV5V6(cfg)
|
|
|
}
|
|
|
-
|
|
|
- // Upgrade to v7 configuration if appropriate
|
|
|
if cfg.Version == 6 {
|
|
|
convertV6V7(cfg)
|
|
|
}
|
|
|
+ if cfg.Version == 7 {
|
|
|
+ convertV7V8(cfg)
|
|
|
+ }
|
|
|
|
|
|
// Hash old cleartext passwords
|
|
|
if len(cfg.GUI.Password) > 0 && cfg.GUI.Password[0] != '$' {
|
|
|
@@ -416,6 +410,15 @@ func ChangeRequiresRestart(from, to Configuration) bool {
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
+func convertV7V8(cfg *Configuration) {
|
|
|
+ // Add IPv6 announce server
|
|
|
+ if len(cfg.Options.GlobalAnnServers) == 1 && cfg.Options.GlobalAnnServers[0] == "udp4://announce.syncthing.net:22026" {
|
|
|
+ cfg.Options.GlobalAnnServers = append(cfg.Options.GlobalAnnServers, "udp6://announce-v6.syncthing.net:22026")
|
|
|
+ }
|
|
|
+
|
|
|
+ cfg.Version = 8
|
|
|
+}
|
|
|
+
|
|
|
func convertV6V7(cfg *Configuration) {
|
|
|
// Migrate announce server addresses to the new URL based format
|
|
|
for i := range cfg.Options.GlobalAnnServers {
|
|
|
@@ -594,8 +597,16 @@ func fillNilSlices(data interface{}) error {
|
|
|
switch f.Interface().(type) {
|
|
|
case []string:
|
|
|
if f.IsNil() {
|
|
|
- rv := reflect.MakeSlice(reflect.TypeOf([]string{}), 1, 1)
|
|
|
- rv.Index(0).SetString(v)
|
|
|
+ // Treat the default as a comma separated slice
|
|
|
+ vs := strings.Split(v, ",")
|
|
|
+ for i := range vs {
|
|
|
+ vs[i] = strings.TrimSpace(vs[i])
|
|
|
+ }
|
|
|
+
|
|
|
+ rv := reflect.MakeSlice(reflect.TypeOf([]string{}), len(vs), len(vs))
|
|
|
+ for i, v := range vs {
|
|
|
+ rv.Index(i).SetString(v)
|
|
|
+ }
|
|
|
f.Set(rv)
|
|
|
}
|
|
|
}
|