config

package
v0.11.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2015 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package config implements reading and writing of the syncthing configuration file.

Index

Constants

View Source
const (
	OldestHandledVersion = 5
	CurrentVersion       = 10
)

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" json:"version"`
	Folders        []FolderConfiguration `xml:"folder" json:"folders"`
	Devices        []DeviceConfiguration `xml:"device" json:"devices"`
	GUI            GUIConfiguration      `xml:"gui" json:"gui"`
	Options        OptionsConfiguration  `xml:"options" json:"options"`
	IgnoredDevices []protocol.DeviceID   `xml:"ignoredDevice" json:"ignoredDevices"`
	XMLName        xml.Name              `xml:"configuration" json:"-"`

	OriginalVersion int `xml:"-" json:"-"` // The version we read from disk, before any conversion
}

func New

func ReadXML added in v0.10.0

func ReadXML(r io.Reader, myID protocol.DeviceID) (Configuration, error)

func (Configuration) Copy added in v0.11.0

func (orig Configuration) Copy() Configuration

func (*Configuration) WriteXML added in v0.10.0

func (cfg *Configuration) WriteXML(w io.Writer) error

type DeviceConfiguration added in v0.10.0

type DeviceConfiguration struct {
	DeviceID    protocol.DeviceID    `xml:"id,attr" json:"deviceID"`
	Name        string               `xml:"name,attr,omitempty" json:"name"`
	Addresses   []string             `xml:"address,omitempty" json:"addresses"`
	Compression protocol.Compression `xml:"compression,attr" json:"compression"`
	CertName    string               `xml:"certName,attr,omitempty" json:"certName"`
	Introducer  bool                 `xml:"introducer,attr" json:"introducer"`
}

func (DeviceConfiguration) Copy added in v0.11.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" json:"id"`
	RawPath         string                      `xml:"path,attr" json:"path"`
	Devices         []FolderDeviceConfiguration `xml:"device" json:"devices"`
	ReadOnly        bool                        `xml:"ro,attr" json:"readOnly"`
	RescanIntervalS int                         `xml:"rescanIntervalS,attr" json:"rescanIntervalS"`
	IgnorePerms     bool                        `xml:"ignorePerms,attr" json:"ignorePerms"`
	AutoNormalize   bool                        `xml:"autoNormalize,attr" json:"autoNormalize"`
	Versioning      VersioningConfiguration     `xml:"versioning" json:"versioning"`
	LenientMtimes   bool                        `xml:"lenientMtimes" json:"lenientMTimes"`
	Copiers         int                         `xml:"copiers" json:"copiers"` // This defines how many files are handled concurrently.
	Pullers         int                         `xml:"pullers" json:"pullers"` // Defines how many blocks are fetched at the same time, possibly between separate copier routines.
	Hashers         int                         `xml:"hashers" json:"hashers"` // Less than one sets the value to the number of cores. These are CPU bound due to hashing.

	Invalid string `xml:"-" json:"invalid"` // Set at runtime when there is an error, not saved
	// contains filtered or unexported fields
}

func (FolderConfiguration) Copy added in v0.11.0

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

func (FolderConfiguration) Path added in v0.10.0

func (f FolderConfiguration) Path() string

type FolderDeviceConfiguration added in v0.10.0

type FolderDeviceConfiguration struct {
	DeviceID protocol.DeviceID `xml:"id,attr" json:"deviceID"`
}

type FolderDeviceConfigurationList added in v0.10.0

type FolderDeviceConfigurationList []FolderDeviceConfiguration

func (FolderDeviceConfigurationList) Len added in v0.10.0

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 GUIConfiguration struct {
	Enabled  bool   `xml:"enabled,attr" json:"enabled" default:"true"`
	Address  string `xml:"address" json:"address" default:"127.0.0.1:8384"`
	User     string `xml:"user,omitempty" json:"user"`
	Password string `xml:"password,omitempty" json:"password"`
	UseTLS   bool   `xml:"tls,attr" json:"useTLS"`
	APIKey   string `xml:"apikey,omitempty" json:"apiKey"`
}

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 InternalParam struct {
	Key string `xml:"key,attr"`
	Val string `xml:"val,attr"`
}

type InternalVersioningConfiguration

type InternalVersioningConfiguration struct {
	Type   string          `xml:"type,attr,omitempty"`
	Params []InternalParam `xml:"param"`
}

type OptionsConfiguration

type OptionsConfiguration struct {
	ListenAddress           []string `xml:"listenAddress" json:"listenAddress" default:"0.0.0.0:22000"`
	GlobalAnnServers        []string `` /* 169-byte string literal not displayed */
	GlobalAnnEnabled        bool     `xml:"globalAnnounceEnabled" json:"globalAnnounceEnabled" default:"true"`
	LocalAnnEnabled         bool     `xml:"localAnnounceEnabled" json:"localAnnounceEnabled" default:"true"`
	LocalAnnPort            int      `xml:"localAnnouncePort" json:"localAnnouncePort" default:"21025"`
	LocalAnnMCAddr          string   `xml:"localAnnounceMCAddr" json:"localAnnounceMCAddr" default:"[ff32::5222]:21026"`
	MaxSendKbps             int      `xml:"maxSendKbps" json:"maxSendKbps"`
	MaxRecvKbps             int      `xml:"maxRecvKbps" json:"maxRecvKbps"`
	ReconnectIntervalS      int      `xml:"reconnectionIntervalS" json:"reconnectionIntervalS" default:"60"`
	StartBrowser            bool     `xml:"startBrowser" json:"startBrowser" default:"true"`
	UPnPEnabled             bool     `xml:"upnpEnabled" json:"upnpEnabled" default:"true"`
	UPnPLeaseM              int      `xml:"upnpLeaseMinutes" json:"upnpLeaseMinutes" default:"0"`
	UPnPRenewalM            int      `xml:"upnpRenewalMinutes" json:"upnpRenewalMinutes" default:"30"`
	UPnPTimeoutS            int      `xml:"upnpTimeoutSeconds" json:"upnpTimeoutSeconds" default:"3"`
	URAccepted              int      `xml:"urAccepted" json:"urAccepted"` // Accepted usage reporting version; 0 for off (undecided), -1 for off (permanently)
	URUniqueID              string   `xml:"urUniqueID" json:"urUniqueId"` // Unique ID for reporting purposes, regenerated when UR is turned on.
	RestartOnWakeup         bool     `xml:"restartOnWakeup" json:"restartOnWakeup" default:"true"`
	AutoUpgradeIntervalH    int      `xml:"autoUpgradeIntervalH" json:"autoUpgradeIntervalH" default:"12"` // 0 for off
	KeepTemporariesH        int      `xml:"keepTemporariesH" json:"keepTemporariesH" default:"24"`         // 0 for off
	CacheIgnoredFiles       bool     `xml:"cacheIgnoredFiles" json:"cacheIgnoredFiles" default:"true"`
	ProgressUpdateIntervalS int      `xml:"progressUpdateIntervalS" json:"progressUpdateIntervalS" default:"5"`
	SymlinksEnabled         bool     `xml:"symlinksEnabled" json:"symlinksEnabled" default:"true"`
	LimitBandwidthInLan     bool     `xml:"limitBandwidthInLan" json:"limitBandwidthInLan" default:"false"`
}

func (OptionsConfiguration) Copy added in v0.11.0

type VersioningConfiguration

type VersioningConfiguration struct {
	Type   string            `xml:"type,attr" json:"type"`
	Params map[string]string `json:"params"`
}

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 Load

func Load(path string, myID protocol.DeviceID) (*Wrapper, 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) *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

func (w *Wrapper) IgnoredDevice(id protocol.DeviceID) bool

Returns whether or not connection attempts from the given device should be silently ignored.

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

func (w *Wrapper) Save() error

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.

func (*Wrapper) Stop added in v0.10.12

func (w *Wrapper) Stop()

Stop stops the Serve() loop. Set and Replace operations will panic after a Stop.

func (*Wrapper) Subscribe added in v0.10.12

func (w *Wrapper) Subscribe(h Handler)

Subscribe registers the given handler to be called on any future configuration changes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL