2016-03-24 09:09:13 +01:00
|
|
|
// Copyright (C) 2016 The Syncthing Authors.
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
2017-02-09 07:52:18 +01:00
|
|
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
2016-03-24 09:09:13 +01:00
|
|
|
|
2019-03-26 20:53:58 +01:00
|
|
|
package api
|
2016-03-24 09:09:13 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/syncthing/syncthing/lib/config"
|
|
|
|
"github.com/syncthing/syncthing/lib/protocol"
|
2017-02-06 11:27:11 +01:00
|
|
|
"github.com/syncthing/syncthing/lib/util"
|
2016-03-24 09:09:13 +01:00
|
|
|
)
|
|
|
|
|
2016-04-18 22:24:38 +02:00
|
|
|
type mockedConfig struct {
|
|
|
|
gui config.GUIConfiguration
|
|
|
|
}
|
2016-03-24 09:09:13 +01:00
|
|
|
|
|
|
|
func (c *mockedConfig) GUI() config.GUIConfiguration {
|
2016-04-18 22:24:38 +02:00
|
|
|
return c.gui
|
2016-03-24 09:09:13 +01:00
|
|
|
}
|
|
|
|
|
2016-05-04 21:38:12 +02:00
|
|
|
func (c *mockedConfig) ListenAddresses() []string {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-09-11 23:25:24 +02:00
|
|
|
func (c *mockedConfig) LDAP() config.LDAPConfiguration {
|
|
|
|
return config.LDAPConfiguration{}
|
|
|
|
}
|
|
|
|
|
2020-10-22 19:54:35 +02:00
|
|
|
func (c *mockedConfig) SetLDAP(config.LDAPConfiguration) (config.Waiter, error) {
|
|
|
|
return noopWaiter{}, nil
|
|
|
|
}
|
|
|
|
|
2016-11-12 10:34:18 +01:00
|
|
|
func (c *mockedConfig) RawCopy() config.Configuration {
|
2017-02-06 11:27:11 +01:00
|
|
|
cfg := config.Configuration{}
|
2019-02-02 12:16:27 +01:00
|
|
|
util.SetDefaults(&cfg.Options)
|
2017-02-06 11:27:11 +01:00
|
|
|
return cfg
|
2016-03-24 09:09:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *mockedConfig) Options() config.OptionsConfiguration {
|
|
|
|
return config.OptionsConfiguration{}
|
|
|
|
}
|
|
|
|
|
2017-12-07 08:08:24 +01:00
|
|
|
func (c *mockedConfig) Replace(cfg config.Configuration) (config.Waiter, error) {
|
2018-10-05 10:26:25 +02:00
|
|
|
return noopWaiter{}, nil
|
2016-03-24 09:09:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *mockedConfig) Subscribe(cm config.Committer) {}
|
|
|
|
|
2019-02-26 09:09:25 +01:00
|
|
|
func (c *mockedConfig) Unsubscribe(cm config.Committer) {}
|
|
|
|
|
2016-03-24 09:09:13 +01:00
|
|
|
func (c *mockedConfig) Folders() map[string]config.FolderConfiguration {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *mockedConfig) Devices() map[protocol.DeviceID]config.DeviceConfiguration {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-10-22 19:54:35 +02:00
|
|
|
func (c *mockedConfig) DeviceList() []config.DeviceConfiguration {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-12-07 08:08:24 +01:00
|
|
|
func (c *mockedConfig) SetDevice(config.DeviceConfiguration) (config.Waiter, error) {
|
2018-10-05 10:26:25 +02:00
|
|
|
return noopWaiter{}, nil
|
2016-12-21 19:41:25 +01:00
|
|
|
}
|
|
|
|
|
2017-12-07 08:08:24 +01:00
|
|
|
func (c *mockedConfig) SetDevices([]config.DeviceConfiguration) (config.Waiter, error) {
|
2018-10-05 10:26:25 +02:00
|
|
|
return noopWaiter{}, nil
|
2017-03-04 08:54:13 +01:00
|
|
|
}
|
|
|
|
|
2016-03-24 09:09:13 +01:00
|
|
|
func (c *mockedConfig) Save() error {
|
|
|
|
return nil
|
|
|
|
}
|
2016-07-04 22:32:34 +02:00
|
|
|
|
|
|
|
func (c *mockedConfig) RequiresRestart() bool {
|
|
|
|
return false
|
|
|
|
}
|
2018-10-05 10:26:25 +02:00
|
|
|
|
2019-02-26 09:09:25 +01:00
|
|
|
func (c *mockedConfig) AddOrUpdatePendingDevice(device protocol.DeviceID, name, address string) {}
|
|
|
|
|
|
|
|
func (c *mockedConfig) AddOrUpdatePendingFolder(id, label string, device protocol.DeviceID) {}
|
|
|
|
|
2019-05-29 09:56:40 +02:00
|
|
|
func (c *mockedConfig) ConfigPath() string {
|
2019-02-26 09:09:25 +01:00
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2019-05-29 09:56:40 +02:00
|
|
|
func (c *mockedConfig) SetGUI(gui config.GUIConfiguration) (config.Waiter, error) {
|
2019-02-26 09:09:25 +01:00
|
|
|
return noopWaiter{}, nil
|
|
|
|
}
|
|
|
|
|
2019-05-29 09:56:40 +02:00
|
|
|
func (c *mockedConfig) SetOptions(opts config.OptionsConfiguration) (config.Waiter, error) {
|
2019-02-26 09:09:25 +01:00
|
|
|
return noopWaiter{}, nil
|
|
|
|
}
|
|
|
|
|
2019-05-29 09:56:40 +02:00
|
|
|
func (c *mockedConfig) Folder(id string) (config.FolderConfiguration, bool) {
|
2019-02-26 09:09:25 +01:00
|
|
|
return config.FolderConfiguration{}, false
|
|
|
|
}
|
|
|
|
|
2019-05-29 09:56:40 +02:00
|
|
|
func (c *mockedConfig) FolderList() []config.FolderConfiguration {
|
2019-02-26 09:09:25 +01:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-05-29 09:56:40 +02:00
|
|
|
func (c *mockedConfig) SetFolder(fld config.FolderConfiguration) (config.Waiter, error) {
|
2019-02-26 09:09:25 +01:00
|
|
|
return noopWaiter{}, nil
|
|
|
|
}
|
|
|
|
|
2020-05-27 08:05:26 +02:00
|
|
|
func (c *mockedConfig) SetFolders(folders []config.FolderConfiguration) (config.Waiter, error) {
|
|
|
|
return noopWaiter{}, nil
|
|
|
|
}
|
|
|
|
|
2020-10-22 19:54:35 +02:00
|
|
|
func (c *mockedConfig) RemoveFolder(id string) (config.Waiter, error) {
|
|
|
|
return noopWaiter{}, nil
|
|
|
|
}
|
|
|
|
|
2020-11-09 15:33:32 +01:00
|
|
|
func (c *mockedConfig) FolderPasswords(device protocol.DeviceID) map[string]string {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-05-29 09:56:40 +02:00
|
|
|
func (c *mockedConfig) Device(id protocol.DeviceID) (config.DeviceConfiguration, bool) {
|
2019-02-26 09:09:25 +01:00
|
|
|
return config.DeviceConfiguration{}, false
|
|
|
|
}
|
|
|
|
|
2019-05-29 09:56:40 +02:00
|
|
|
func (c *mockedConfig) RemoveDevice(id protocol.DeviceID) (config.Waiter, error) {
|
2019-02-26 09:09:25 +01:00
|
|
|
return noopWaiter{}, nil
|
|
|
|
}
|
|
|
|
|
2019-05-29 09:56:40 +02:00
|
|
|
func (c *mockedConfig) IgnoredDevice(id protocol.DeviceID) bool {
|
2019-02-26 09:09:25 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-05-29 09:56:40 +02:00
|
|
|
func (c *mockedConfig) IgnoredFolder(device protocol.DeviceID, folder string) bool {
|
2019-02-26 09:09:25 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-05-29 09:56:40 +02:00
|
|
|
func (c *mockedConfig) GlobalDiscoveryServers() []string {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *mockedConfig) StunServers() []string {
|
2019-02-26 09:09:25 +01:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-20 14:21:54 +01:00
|
|
|
func (c *mockedConfig) MyID() protocol.DeviceID {
|
|
|
|
return protocol.DeviceID{}
|
|
|
|
}
|
|
|
|
|
2018-10-05 10:26:25 +02:00
|
|
|
type noopWaiter struct{}
|
|
|
|
|
|
|
|
func (noopWaiter) Wait() {}
|