Documentation
¶
Overview ¶
Package config implements reading and writing of the syncthing configuration file.
Index ¶
- Constants
- func ChangeRequiresRestart(from, to Configuration) bool
- type ConfigWrapper
- func (w *ConfigWrapper) Devices() map[protocol.DeviceID]DeviceConfiguration
- func (w *ConfigWrapper) Folders() map[string]FolderConfiguration
- func (w *ConfigWrapper) GUI() GUIConfiguration
- func (w *ConfigWrapper) InvalidateFolder(id string, err string)
- func (w *ConfigWrapper) Options() OptionsConfiguration
- func (w *ConfigWrapper) Raw() Configuration
- func (w *ConfigWrapper) Replace(cfg Configuration)
- func (w *ConfigWrapper) Save() error
- func (w *ConfigWrapper) Serve()
- func (w *ConfigWrapper) SetDevice(dev DeviceConfiguration)
- func (w *ConfigWrapper) SetFolder(fld FolderConfiguration)
- func (w *ConfigWrapper) SetGUI(gui GUIConfiguration)
- func (w *ConfigWrapper) SetOptions(opts OptionsConfiguration)
- func (w *ConfigWrapper) Stop()
- func (w *ConfigWrapper) Subscribe(h Handler)
- type Configuration
- type DeviceConfiguration
- type DeviceConfigurationList
- type FolderConfiguration
- type FolderDeviceConfiguration
- type FolderDeviceConfigurationList
- type GUIConfiguration
- type Handler
- type HandlerFunc
- type InternalParam
- type InternalVersioningConfiguration
- type OptionsConfiguration
- type VersioningConfiguration
Constants ¶
const CurrentVersion = 6
Variables ¶
This section is empty.
Functions ¶
func ChangeRequiresRestart ¶
func ChangeRequiresRestart(from, to Configuration) bool
ChangeRequiresRestart returns true if updating the configuration requires a complete restart.
Types ¶
type ConfigWrapper ¶ added in v0.10.0
type ConfigWrapper struct {
// contains filtered or unexported fields
}
func Load ¶
func Load(path string, myID protocol.DeviceID) (*ConfigWrapper, error)
Load loads an existing file on disk and returns a new configuration wrapper.
func Wrap ¶ added in v0.10.0
func Wrap(path string, cfg Configuration) *ConfigWrapper
Wrap wraps an existing Configuration structure and ties it to a file on disk.
func (*ConfigWrapper) Devices ¶ added in v0.10.0
func (w *ConfigWrapper) Devices() map[protocol.DeviceID]DeviceConfiguration
Devices returns a map of devices. Device structures should not be changed, other than for the purpose of updating via SetDevice().
func (*ConfigWrapper) Folders ¶ added in v0.10.0
func (w *ConfigWrapper) Folders() map[string]FolderConfiguration
Devices returns a map of folders. Folder structures should not be changed, other than for the purpose of updating via SetFolder().
func (*ConfigWrapper) GUI ¶ added in v0.10.0
func (w *ConfigWrapper) GUI() GUIConfiguration
GUI returns the current GUI configuration object.
func (*ConfigWrapper) InvalidateFolder ¶ added in v0.10.0
func (w *ConfigWrapper) InvalidateFolder(id string, err string)
InvalidateFolder sets the invalid marker on the given folder.
func (*ConfigWrapper) Options ¶ added in v0.10.0
func (w *ConfigWrapper) Options() OptionsConfiguration
Options returns the current options configuration object.
func (*ConfigWrapper) Raw ¶ added in v0.10.0
func (w *ConfigWrapper) Raw() Configuration
Raw returns the currently wrapped Configuration object.
func (*ConfigWrapper) Replace ¶ added in v0.10.0
func (w *ConfigWrapper) Replace(cfg Configuration)
Replace swaps the current configuration object for the given one.
func (*ConfigWrapper) Save ¶ added in v0.10.0
func (w *ConfigWrapper) Save() error
Save writes the configuration to disk, and generates a ConfigSaved event.
func (*ConfigWrapper) Serve ¶ added in v0.10.0
func (w *ConfigWrapper) Serve()
Serve handles configuration replace events and calls any interested handlers. It is started automatically by Wrap() and Load() and should not be run manually.
func (*ConfigWrapper) SetDevice ¶ added in v0.10.0
func (w *ConfigWrapper) SetDevice(dev DeviceConfiguration)
SetDevice adds a new device to the configuration, or overwrites an existing device with the same ID.
func (*ConfigWrapper) SetFolder ¶ added in v0.10.0
func (w *ConfigWrapper) SetFolder(fld FolderConfiguration)
SetFolder adds a new folder to the configuration, or overwrites an existing folder with the same ID.
func (*ConfigWrapper) SetGUI ¶ added in v0.10.0
func (w *ConfigWrapper) SetGUI(gui GUIConfiguration)
SetGUI replaces the current GUI configuration object.
func (*ConfigWrapper) SetOptions ¶ added in v0.10.0
func (w *ConfigWrapper) SetOptions(opts OptionsConfiguration)
SetOptions replaces the current options configuration object.
func (*ConfigWrapper) Stop ¶ added in v0.10.0
func (w *ConfigWrapper) Stop()
Stop stops the Serve() loop. Set and Replace operations will panic after a Stop.
func (*ConfigWrapper) Subscribe ¶ added in v0.10.0
func (w *ConfigWrapper) Subscribe(h Handler)
Subscribe registers the given handler to be called on any future configuration changes.
type Configuration ¶
type Configuration struct {
Version int `xml:"version,attr"`
Folders []FolderConfiguration `xml:"folder"`
Devices []DeviceConfiguration `xml:"device"`
GUI GUIConfiguration `xml:"gui"`
Options OptionsConfiguration `xml:"options"`
XMLName xml.Name `xml:"configuration" json:"-"`
OriginalVersion int `xml:"-" json:"-"` // The version we read from disk, before any conversion
Deprecated_Repositories []FolderConfiguration `xml:"repository" json:"-"`
Deprecated_Nodes []DeviceConfiguration `xml:"node" json:"-"`
}
func New ¶
func New(myID protocol.DeviceID) Configuration
type DeviceConfiguration ¶ added in v0.10.0
type DeviceConfigurationList ¶ added in v0.10.0
type DeviceConfigurationList []DeviceConfiguration
func (DeviceConfigurationList) Len ¶ added in v0.10.0
func (l DeviceConfigurationList) Len() int
func (DeviceConfigurationList) Less ¶ added in v0.10.0
func (l DeviceConfigurationList) Less(a, b int) bool
func (DeviceConfigurationList) Swap ¶ added in v0.10.0
func (l DeviceConfigurationList) Swap(a, b int)
type FolderConfiguration ¶ added in v0.10.0
type FolderConfiguration struct {
ID string `xml:"id,attr"`
Path string `xml:"path,attr"`
Devices []FolderDeviceConfiguration `xml:"device"`
ReadOnly bool `xml:"ro,attr"`
RescanIntervalS int `xml:"rescanIntervalS,attr" default:"60"`
IgnorePerms bool `xml:"ignorePerms,attr"`
Versioning VersioningConfiguration `xml:"versioning"`
LenientMtimes bool `xml:"lenientMtimes"`
Copiers int `xml:"copiers" default:"1"` // This defines how many files are handled concurrently.
Pullers int `xml:"pullers" default:"16"` // Defines how many blocks are fetched at the same time, possibly between separate copier routines.
Finishers int `xml:"finishers" default:"1"` // Most of the time, should be equal to the number of copiers. These are CPU bound due to hashing.
Invalid string `xml:"-"` // Set at runtime when there is an error, not saved
Deprecated_Directory string `xml:"directory,omitempty,attr" json:"-"`
Deprecated_Nodes []FolderDeviceConfiguration `xml:"node" json:"-"`
// contains filtered or unexported fields
}
func (*FolderConfiguration) CreateMarker ¶ added in v0.10.2
func (f *FolderConfiguration) CreateMarker() error
func (*FolderConfiguration) DeviceIDs ¶ added in v0.10.0
func (r *FolderConfiguration) DeviceIDs() []protocol.DeviceID
func (*FolderConfiguration) HasMarker ¶ added in v0.10.2
func (f *FolderConfiguration) HasMarker() bool
type FolderDeviceConfiguration ¶ added in v0.10.0
type FolderDeviceConfigurationList ¶ added in v0.10.0
type FolderDeviceConfigurationList []FolderDeviceConfiguration
func (FolderDeviceConfigurationList) Len ¶ added in v0.10.0
func (l FolderDeviceConfigurationList) Len() int
func (FolderDeviceConfigurationList) Less ¶ added in v0.10.0
func (l FolderDeviceConfigurationList) Less(a, b int) bool
func (FolderDeviceConfigurationList) Swap ¶ added in v0.10.0
func (l FolderDeviceConfigurationList) Swap(a, b int)
type GUIConfiguration ¶
type Handler ¶ added in v0.10.0
type Handler interface {
Changed(Configuration) error
}
type HandlerFunc ¶ added in v0.10.0
type HandlerFunc func(Configuration) error
func (HandlerFunc) Changed ¶ added in v0.10.0
func (fn HandlerFunc) Changed(cfg Configuration) error
type InternalParam ¶
type InternalVersioningConfiguration ¶
type InternalVersioningConfiguration struct {
Type string `xml:"type,attr,omitempty"`
Params []InternalParam `xml:"param"`
}
type OptionsConfiguration ¶
type OptionsConfiguration struct {
ListenAddress []string `xml:"listenAddress" default:"0.0.0.0:22000"`
GlobalAnnServers []string `xml:"globalAnnounceServer" default:"announce.syncthing.net:22026"`
GlobalAnnEnabled bool `xml:"globalAnnounceEnabled" default:"true"`
LocalAnnEnabled bool `xml:"localAnnounceEnabled" default:"true"`
LocalAnnPort int `xml:"localAnnouncePort" default:"21025"`
LocalAnnMCAddr string `xml:"localAnnounceMCAddr" default:"[ff32::5222]:21026"`
MaxSendKbps int `xml:"maxSendKbps"`
MaxRecvKbps int `xml:"maxRecvKbps"`
ReconnectIntervalS int `xml:"reconnectionIntervalS" default:"60"`
StartBrowser bool `xml:"startBrowser" default:"true"`
UPnPEnabled bool `xml:"upnpEnabled" default:"true"`
UPnPLease int `xml:"upnpLeaseMinutes" default:"0"`
UPnPRenewal int `xml:"upnpRenewalMinutes" default:"30"`
URAccepted int `xml:"urAccepted"` // Accepted usage reporting version; 0 for off (undecided), -1 for off (permanently)
URUniqueID string `xml:"urUniqueID"` // Unique ID for reporting purposes, regenerated when UR is turned on.
RestartOnWakeup bool `xml:"restartOnWakeup" default:"true"`
AutoUpgradeIntervalH int `xml:"autoUpgradeIntervalH" default:"12"` // 0 for off
KeepTemporariesH int `xml:"keepTemporariesH" default:"24"` // 0 for off
CacheIgnoredFiles bool `xml:"cacheIgnoredFiles" default:"true"`
ProgressUpdateIntervalS int `xml:"progressUpdateIntervalS" default:"5"`
Deprecated_RescanIntervalS int `xml:"rescanIntervalS,omitempty" json:"-"`
Deprecated_UREnabled bool `xml:"urEnabled,omitempty" json:"-"`
Deprecated_URDeclined bool `xml:"urDeclined,omitempty" json:"-"`
Deprecated_ReadOnly bool `xml:"readOnly,omitempty" json:"-"`
Deprecated_GUIEnabled bool `xml:"guiEnabled,omitempty" json:"-"`
Deprecated_GUIAddress string `xml:"guiAddress,omitempty" json:"-"`
}
type VersioningConfiguration ¶
func (*VersioningConfiguration) MarshalXML ¶
func (c *VersioningConfiguration) MarshalXML(e *xml.Encoder, start xml.StartElement) error
func (*VersioningConfiguration) UnmarshalXML ¶
func (c *VersioningConfiguration) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error