From 0761d804a48f0fc6e720392ee32c3446385026c9 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 9 May 2016 09:43:40 +0000 Subject: [PATCH] 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 --- cmd/syncthing/main.go | 5 +++-- lib/util/random.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index a34a3924..af48ada2 100644 --- a/cmd/syncthing/main.go +++ b/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}} diff --git a/lib/util/random.go b/lib/util/random.go index 8b6c485f..21a37fde 100644 --- a/lib/util/random.go +++ b/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.