Documentation
¶
Overview ¶
Package config implements reading and writing of the syncthing configuration file.
Index ¶
- Constants
- func ChangeRequiresRestart(from, to Configuration) bool
- 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
- type Wrapper
- func (w *Wrapper) Devices() map[protocol.DeviceID]DeviceConfiguration
- func (w *Wrapper) Folders() map[string]FolderConfiguration
- func (w *Wrapper) GUI() GUIConfiguration
- func (w *Wrapper) IgnoredDevice(id protocol.DeviceID) bool
- func (w *Wrapper) InvalidateFolder(id string, err string)
- func (w *Wrapper) Options() OptionsConfiguration
- func (w *Wrapper) Raw() Configuration
- func (w *Wrapper) Replace(cfg Configuration)
- func (w *Wrapper) Save() error
- func (w *Wrapper) Serve()
- func (w *Wrapper) SetDevice(dev DeviceConfiguration)
- func (w *Wrapper) SetFolder(fld FolderConfiguration)
- func (w *Wrapper) SetGUI(gui GUIConfiguration)
- func (w *Wrapper) SetOptions(opts OptionsConfiguration)
- func (w *Wrapper) Stop()
- func (w *Wrapper) Subscribe(h Handler)
Constants ¶
const CurrentVersion = 9
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 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"`
IgnoredDevices []protocol.DeviceID `xml:"ignoredDevice"`
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 DeviceConfiguration struct {
DeviceID protocol.DeviceID `xml:"id,attr"`
Name string `xml:"name,attr,omitempty"`
Addresses []string `xml:"address,omitempty"`
Compression protocol.Compression `xml:"compression,attr"`
CertName string `xml:"certName,attr,omitempty"`
Introducer bool `xml:"introducer,attr"`
}
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.
Hashers int `xml:"hashers" default:"0"` // Less than one sets the value to the number of cores. 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 (f *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:"udp4://announce.syncthing.net:22026, udp6://announce-v6.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"`
SymlinksEnabled bool `xml:"symlinksEnabled" default:"true"`
LimitBandwidthInLan bool `xml:"limitBandwidthInLan" default:"false"`
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
type Wrapper ¶ added in v0.10.12
type Wrapper struct {
// contains filtered or unexported fields
}
func Wrap ¶ added in v0.10.0
func Wrap(path string, cfg Configuration) *Wrapper
Wrap wraps an existing Configuration structure and ties it to a file on disk.
func (*Wrapper) Devices ¶ added in v0.10.12
func (w *Wrapper) 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 (*Wrapper) Folders ¶ added in v0.10.12
func (w *Wrapper) 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 (*Wrapper) GUI ¶ added in v0.10.12
func (w *Wrapper) GUI() GUIConfiguration
GUI returns the current GUI configuration object.
func (*Wrapper) IgnoredDevice ¶ added in v0.10.15
Returns whether or not connection attempts from the given device should be silently ignored.
func (*Wrapper) InvalidateFolder ¶ added in v0.10.12
InvalidateFolder sets the invalid marker on the given folder.
func (*Wrapper) Options ¶ added in v0.10.12
func (w *Wrapper) Options() OptionsConfiguration
Options returns the current options configuration object.
func (*Wrapper) Raw ¶ added in v0.10.12
func (w *Wrapper) Raw() Configuration
Raw returns the currently wrapped Configuration object.
func (*Wrapper) Replace ¶ added in v0.10.12
func (w *Wrapper) Replace(cfg Configuration)
Replace swaps the current configuration object for the given one.
func (*Wrapper) Save ¶ added in v0.10.12
Save writes the configuration to disk, and generates a ConfigSaved event.
func (*Wrapper) Serve ¶ added in v0.10.12
func (w *Wrapper) 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 (*Wrapper) SetDevice ¶ added in v0.10.12
func (w *Wrapper) SetDevice(dev DeviceConfiguration)
SetDevice adds a new device to the configuration, or overwrites an existing device with the same ID.
func (*Wrapper) SetFolder ¶ added in v0.10.12
func (w *Wrapper) SetFolder(fld FolderConfiguration)
SetFolder adds a new folder to the configuration, or overwrites an existing folder with the same ID.
func (*Wrapper) SetGUI ¶ added in v0.10.12
func (w *Wrapper) SetGUI(gui GUIConfiguration)
SetGUI replaces the current GUI configuration object.
func (*Wrapper) SetOptions ¶ added in v0.10.12
func (w *Wrapper) SetOptions(opts OptionsConfiguration)
SetOptions replaces the current options configuration object.