Exemplo n.º 1
0
func defaultConfig(myName string) config.Configuration {
	newCfg := config.New(myID)

	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
}
Exemplo n.º 2
0
func setup(deviceID protocol.DeviceID, dir string) (*config.Wrapper, *bolt.DB, string) {
	configFile, _ := ioutil.TempFile(dir, "config")
	realCfg := config.New(deviceID)
	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",
	}
	cfg.SetFolder(folderCfg)

	return cfg, database, folder
}
Exemplo n.º 3
0
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)
	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
}