瀏覽代碼

cmd/syncthing: Use random folder ID for default folder, limit random charset

This uses the same charset as the Javascript code, excluding confusing
characters like 0, O, I, 1, l etc.

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3064
Jakob Borg 9 年之前
父節點
當前提交
0761d804a4
共有 2 個文件被更改,包括 4 次插入3 次删除
  1. 3 2
      cmd/syncthing/main.go
  2. 1 1
      lib/util/random.go

+ 3 - 2
cmd/syncthing/main.go

@@ -946,8 +946,9 @@ func defaultConfig(myName string) config.Configuration {
 
 	if !noDefaultFolder {
 		l.Infoln("Default folder created and/or linked to new config")
-
-		defaultFolder = config.NewFolderConfiguration("default", locations[locDefFolder])
+		folderID := util.RandomString(5) + "-" + util.RandomString(5)
+		defaultFolder = config.NewFolderConfiguration(folderID, locations[locDefFolder])
+		defaultFolder.Label = "Default Folder (" + folderID + ")"
 		defaultFolder.RescanIntervalS = 60
 		defaultFolder.MinDiskFreePct = 1
 		defaultFolder.Devices = []config.FolderDeviceConfiguration{{DeviceID: myID}}

+ 1 - 1
lib/util/random.go

@@ -15,7 +15,7 @@ import (
 )
 
 // randomCharset contains the characters that can make up a randomString().
-const randomCharset = "01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-"
+const randomCharset = "2345679abcdefghijkmnopqrstuvwxyzACDEFGHJKLMNPQRSTUVWXYZ"
 
 func init() {
 	// The default RNG should be seeded with something good.