func defaultConfig(myName string) config.Configuration { newCfg := config.New(myID, myName) port, err := getFreePort("0.0.0.0", 22000) if err != nil { l.Fatalln("get free port (BEP):", err) } newCfg.Options.ListenAddress = []string{fmt.Sprintf("tcp://0.0.0.0:%d", port)} return newCfg }
func setup(t *testing.T, cacheSize string) (*config.Wrapper, *bolt.DB, config.FolderConfiguration) { dir, _ := ioutil.TempDir("", "stf-mt") configFile, _ := ioutil.TempFile(dir, "config") deviceID, _ := protocol.DeviceIDFromString("FFR6LPZ-7K4PTTV-UXQSMUU-CPQ5YWH-OEDFIIQ-JUG777G-2YQXXR5-YD6AWQR") realCfg := config.New(deviceID, "local") cfg := config.Wrap(configFile.Name(), realCfg) databasePath := path.Join(path.Dir(cfg.ConfigPath()), "boltdb") database, _ := bolt.Open(databasePath, 0600, nil) folderCfg := config.FolderConfiguration{ ID: folder, CacheSize: cacheSize, } cfg.SetFolder(folderCfg) return cfg, database, folderCfg }
func setup(deviceID protocol.DeviceID, dir string, peers ...protocol.DeviceID) (*config.Wrapper, *bolt.DB, string) { configFile, _ := ioutil.TempFile(dir, "config") realCfg := config.New(deviceID, deviceID.String()[:5]) cfg := config.Wrap(configFile.Name(), realCfg) databasePath := path.Join(path.Dir(cfg.ConfigPath()), "boltdb") database, _ := bolt.Open(databasePath, 0600, nil) folder := "syncthingfusetest" folderCfg := config.FolderConfiguration{ ID: folder, CacheSize: "1MiB", Devices: make([]stconfig.FolderDeviceConfiguration, len(peers)), } for i, peer := range peers { folderCfg.Devices[i] = stconfig.FolderDeviceConfiguration{DeviceID: peer} } cfg.SetFolder(folderCfg) return cfg, database, folder }