config

package
v1.8.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: MPL-2.0 Imports: 28 Imported by: 29

Documentation

Overview

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

Index

Constants

View Source
const (
	OldestHandledVersion = 10
	CurrentVersion       = 31
	MaxRescanIntervalS   = 365 * 24 * 60 * 60
)
View Source
const DefaultMarkerName = ".stfolder"

Variables

View Source
var (
	// DefaultTCPPort defines default TCP port used if the URI does not specify one, for example tcp://0.0.0.0
	DefaultTCPPort = 22000
	// DefaultQUICPort defines default QUIC port used if the URI does not specify one, for example quic://0.0.0.0
	DefaultQUICPort = 22000
	// DefaultListenAddresses should be substituted when the configuration
	// contains <listenAddress>default</listenAddress>. This is done by the
	// "consumer" of the configuration as we don't want these saved to the
	// config.
	DefaultListenAddresses = []string{
		util.Address("tcp", net.JoinHostPort("0.0.0.0", strconv.Itoa(DefaultTCPPort))),
		"dynamic+https://relays.syncthing.net/endpoint",
		util.Address("quic", net.JoinHostPort("0.0.0.0", strconv.Itoa(DefaultQUICPort))),
	}
	DefaultGUIPort = 8384
	// DefaultDiscoveryServersV4 should be substituted when the configuration
	// contains <globalAnnounceServer>default-v4</globalAnnounceServer>.
	DefaultDiscoveryServersV4 = []string{
		"https://discovery.syncthing.net/v2/?noannounce&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW",
		"https://discovery-v4.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW",
	}
	// DefaultDiscoveryServersV6 should be substituted when the configuration
	// contains <globalAnnounceServer>default-v6</globalAnnounceServer>.
	DefaultDiscoveryServersV6 = []string{
		"https://discovery.syncthing.net/v2/?noannounce&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW",
		"https://discovery-v6.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW",
	}
	// DefaultDiscoveryServers should be substituted when the configuration
	// contains <globalAnnounceServer>default</globalAnnounceServer>.
	DefaultDiscoveryServers = append(DefaultDiscoveryServersV4, DefaultDiscoveryServersV6...)
	// DefaultTheme is the default and fallback theme for the web UI.
	DefaultTheme = "default"

	// DefaultPrimaryStunServers are servers provided by us (to avoid causing the public servers burden)
	DefaultPrimaryStunServers = []string{
		"stun.syncthing.net:3478",
	}
	DefaultSecondaryStunServers = []string{
		"stun.callwithus.com:3478",
		"stun.counterpath.com:3478",
		"stun.counterpath.net:3478",
		"stun.ekiga.net:3478",
		"stun.ideasip.com:3478",
		"stun.internetcalls.com:3478",
		"stun.schlund.de:3478",
		"stun.sipgate.net:10000",
		"stun.sipgate.net:3478",
		"stun.voip.aebc.com:3478",
		"stun.voiparound.com:3478",
		"stun.voipbuster.com:3478",
		"stun.voipstunt.com:3478",
		"stun.xten.com:3478",
	}
)
View Source
var (
	ErrPathNotDirectory = errors.New("folder path not a directory")
	ErrPathMissing      = errors.New("folder path missing")
	ErrMarkerMissing    = errors.New("folder marker missing (this indicates potential data loss, search docs/forum to get information about how to proceed)")
)

Functions

func CheckFreeSpace added in v1.1.0

func CheckFreeSpace(req Size, usage fs.Usage) error

Types

type AuthMode added in v0.14.51

type AuthMode int
const (
	AuthModeStatic AuthMode = iota // default is static
	AuthModeLDAP
)

func (AuthMode) MarshalText added in v0.14.51

func (t AuthMode) MarshalText() ([]byte, error)

func (AuthMode) String added in v0.14.51

func (t AuthMode) String() string

func (*AuthMode) UnmarshalText added in v0.14.51

func (t *AuthMode) UnmarshalText(bs []byte) error

type BlockPullOrder added in v1.6.0

type BlockPullOrder int
const (
	BlockPullOrderStandard BlockPullOrder = iota // default is standard
	BlockPullOrderRandom
	BlockPullOrderInOrder
)

func (BlockPullOrder) MarshalText added in v1.6.0

func (o BlockPullOrder) MarshalText() ([]byte, error)

func (BlockPullOrder) String added in v1.6.0

func (o BlockPullOrder) String() string

func (*BlockPullOrder) UnmarshalText added in v1.6.0

func (o *BlockPullOrder) UnmarshalText(bs []byte) error

type Committer

type Committer interface {
	VerifyConfiguration(from, to Configuration) error
	CommitConfiguration(from, to Configuration) (handled bool)
	String() string
}

The Committer interface is implemented by objects that need to know about or have a say in configuration changes.

When the configuration is about to be changed, VerifyConfiguration() is called for each subscribing object, with the old and new configuration. A nil error is returned if the new configuration is acceptable (i.e. does not contain any errors that would prevent it from being a valid config). Otherwise an error describing the problem is returned.

If any subscriber returns an error from VerifyConfiguration(), the configuration change is not committed and an error is returned to whoever tried to commit the broken config.

If all verification calls returns nil, CommitConfiguration() is called for each subscribing object. The callee returns true if the new configuration has been successfully applied, otherwise false. Any Commit() call returning false will result in a "restart needed" response to the API/user. Note that the new configuration will still have been applied by those who were capable of doing so.

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"`
	LDAP           LDAPConfiguration     `xml:"ldap" json:"ldap"`
	Options        OptionsConfiguration  `xml:"options" json:"options"`
	IgnoredDevices []ObservedDevice      `xml:"remoteIgnoredDevice" json:"remoteIgnoredDevices"`
	PendingDevices []ObservedDevice      `xml:"pendingDevice" json:"pendingDevices"`
	XMLName        xml.Name              `xml:"configuration" json:"-"`

	MyID            protocol.DeviceID `xml:"-" json:"-"` // Provided by the instantiator.
	OriginalVersion int               `xml:"-" json:"-"` // The version we read from disk, before any conversion
}

func New

func NewWithFreePorts added in v1.1.0

func NewWithFreePorts(myID protocol.DeviceID) (Configuration, error)

func ReadJSON added in v0.12.0

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

func ReadXML

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

func (Configuration) Copy

func (cfg Configuration) Copy() Configuration

func (*Configuration) DeviceMap added in v0.14.47

func (cfg *Configuration) DeviceMap() map[protocol.DeviceID]DeviceConfiguration

DeviceMap returns a map of device ID to device configuration for the given configuration.

func (*Configuration) WriteXML

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

type DeviceConfiguration

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" default:"dynamic"`
	Compression              protocol.Compression `xml:"compression,attr" json:"compression"`
	CertName                 string               `xml:"certName,attr,omitempty" json:"certName"`
	Introducer               bool                 `xml:"introducer,attr" json:"introducer"`
	SkipIntroductionRemovals bool                 `xml:"skipIntroductionRemovals,attr" json:"skipIntroductionRemovals"`
	IntroducedBy             protocol.DeviceID    `xml:"introducedBy,attr" json:"introducedBy"`
	Paused                   bool                 `xml:"paused" json:"paused"`
	AllowedNetworks          []string             `xml:"allowedNetwork,omitempty" json:"allowedNetworks"`
	AutoAcceptFolders        bool                 `xml:"autoAcceptFolders" json:"autoAcceptFolders"`
	MaxSendKbps              int                  `xml:"maxSendKbps" json:"maxSendKbps"`
	MaxRecvKbps              int                  `xml:"maxRecvKbps" json:"maxRecvKbps"`
	IgnoredFolders           []ObservedFolder     `xml:"ignoredFolder" json:"ignoredFolders"`
	PendingFolders           []ObservedFolder     `xml:"pendingFolder" json:"pendingFolders"`
	MaxRequestKiB            int                  `xml:"maxRequestKiB" json:"maxRequestKiB"`
}

func NewDeviceConfiguration added in v0.12.2

func NewDeviceConfiguration(id protocol.DeviceID, name string) DeviceConfiguration

func (DeviceConfiguration) Copy

func (*DeviceConfiguration) IgnoredFolder added in v0.14.51

func (cfg *DeviceConfiguration) IgnoredFolder(folder string) bool

type FolderConfiguration

type FolderConfiguration struct {
	ID                      string                      `xml:"id,attr" json:"id"`
	Label                   string                      `xml:"label,attr" json:"label" restart:"false"`
	FilesystemType          fs.FilesystemType           `xml:"filesystemType" json:"filesystemType"`
	Path                    string                      `xml:"path,attr" json:"path"`
	Type                    FolderType                  `xml:"type,attr" json:"type"`
	Devices                 []FolderDeviceConfiguration `xml:"device" json:"devices"`
	RescanIntervalS         int                         `xml:"rescanIntervalS,attr" json:"rescanIntervalS" default:"3600"`
	FSWatcherEnabled        bool                        `xml:"fsWatcherEnabled,attr" json:"fsWatcherEnabled" default:"true"`
	FSWatcherDelayS         int                         `xml:"fsWatcherDelayS,attr" json:"fsWatcherDelayS" default:"10"`
	IgnorePerms             bool                        `xml:"ignorePerms,attr" json:"ignorePerms"`
	AutoNormalize           bool                        `xml:"autoNormalize,attr" json:"autoNormalize" default:"true"`
	MinDiskFree             Size                        `xml:"minDiskFree" json:"minDiskFree" default:"1%"`
	Versioning              VersioningConfiguration     `xml:"versioning" json:"versioning"`
	Copiers                 int                         `xml:"copiers" json:"copiers"` // This defines how many files are handled concurrently.
	PullerMaxPendingKiB     int                         `xml:"pullerMaxPendingKiB" json:"pullerMaxPendingKiB"`
	Hashers                 int                         `xml:"hashers" json:"hashers"` // Less than one sets the value to the number of cores. These are CPU bound due to hashing.
	Order                   PullOrder                   `xml:"order" json:"order"`
	IgnoreDelete            bool                        `xml:"ignoreDelete" json:"ignoreDelete"`
	ScanProgressIntervalS   int                         `xml:"scanProgressIntervalS" json:"scanProgressIntervalS"` // Set to a negative value to disable. Value of 0 will get replaced with value of 2 (default value)
	PullerPauseS            int                         `xml:"pullerPauseS" json:"pullerPauseS"`
	MaxConflicts            int                         `xml:"maxConflicts" json:"maxConflicts" default:"-1"`
	DisableSparseFiles      bool                        `xml:"disableSparseFiles" json:"disableSparseFiles"`
	DisableTempIndexes      bool                        `xml:"disableTempIndexes" json:"disableTempIndexes"`
	Paused                  bool                        `xml:"paused" json:"paused"`
	WeakHashThresholdPct    int                         `xml:"weakHashThresholdPct" json:"weakHashThresholdPct"` // Use weak hash if more than X percent of the file has changed. Set to -1 to always use weak hash.
	MarkerName              string                      `xml:"markerName" json:"markerName"`
	CopyOwnershipFromParent bool                        `xml:"copyOwnershipFromParent" json:"copyOwnershipFromParent"`
	RawModTimeWindowS       int                         `xml:"modTimeWindowS" json:"modTimeWindowS"`
	MaxConcurrentWrites     int                         `xml:"maxConcurrentWrites" json:"maxConcurrentWrites" default:"2"`
	DisableFsync            bool                        `xml:"disableFsync" json:"disableFsync"`
	BlockPullOrder          BlockPullOrder              `xml:"blockPullOrder" json:"blockPullOrder"`
	CopyRangeMethod         fs.CopyRangeMethod          `xml:"copyRangeMethod" json:"copyRangeMethod" default:"standard"`

	DeprecatedReadOnly       bool    `xml:"ro,attr,omitempty" json:"-"`
	DeprecatedMinDiskFreePct float64 `xml:"minDiskFreePct,omitempty" json:"-"`
	DeprecatedPullers        int     `xml:"pullers,omitempty" json:"-"`
	// contains filtered or unexported fields
}

func NewFolderConfiguration added in v0.12.2

func NewFolderConfiguration(myID protocol.DeviceID, id, label string, fsType fs.FilesystemType, path string) FolderConfiguration

func (*FolderConfiguration) CheckAvailableSpace added in v0.14.51

func (f *FolderConfiguration) CheckAvailableSpace(req int64) error

func (*FolderConfiguration) CheckPath added in v0.14.40

func (f *FolderConfiguration) CheckPath() error

CheckPath returns nil if the folder root exists and contains the marker file

func (FolderConfiguration) Copy

func (*FolderConfiguration) CreateMarker

func (f *FolderConfiguration) CreateMarker() error

func (*FolderConfiguration) CreateRoot added in v0.14.28

func (f *FolderConfiguration) CreateRoot() (err error)

func (FolderConfiguration) Description added in v0.14.12

func (f FolderConfiguration) Description() string

func (*FolderConfiguration) DeviceIDs

func (f *FolderConfiguration) DeviceIDs() []protocol.DeviceID

func (FolderConfiguration) Filesystem added in v0.14.37

func (f FolderConfiguration) Filesystem() fs.Filesystem

func (FolderConfiguration) ModTimeWindow added in v1.2.2

func (f FolderConfiguration) ModTimeWindow() time.Duration

func (FolderConfiguration) RequiresRestartOnly added in v0.14.42

func (f FolderConfiguration) RequiresRestartOnly() FolderConfiguration

RequiresRestartOnly returns a copy with only the attributes that require restart on change.

func (*FolderConfiguration) SharedWith added in v0.14.49

func (f *FolderConfiguration) SharedWith(device protocol.DeviceID) bool

type FolderDeviceConfiguration

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

type FolderType added in v0.13.0

type FolderType int
const (
	FolderTypeSendReceive FolderType = iota // default is sendreceive
	FolderTypeSendOnly
	FolderTypeReceiveOnly
)

func (FolderType) MarshalText added in v0.13.0

func (t FolderType) MarshalText() ([]byte, error)

func (FolderType) String added in v0.13.0

func (t FolderType) String() string

func (*FolderType) UnmarshalText added in v0.13.0

func (t *FolderType) UnmarshalText(bs []byte) error

type GUIConfiguration

type GUIConfiguration struct {
	Enabled                   bool     `xml:"enabled,attr" json:"enabled" default:"true"`
	RawAddress                string   `xml:"address" json:"address" default:"127.0.0.1:8384"`
	RawUnixSocketPermissions  string   `xml:"unixSocketPermissions,omitempty" json:"unixSocketPermissions"`
	User                      string   `xml:"user,omitempty" json:"user"`
	Password                  string   `xml:"password,omitempty" json:"password"`
	AuthMode                  AuthMode `xml:"authMode,omitempty" json:"authMode"`
	RawUseTLS                 bool     `xml:"tls,attr" json:"useTLS"`
	APIKey                    string   `xml:"apikey,omitempty" json:"apiKey"`
	InsecureAdminAccess       bool     `xml:"insecureAdminAccess,omitempty" json:"insecureAdminAccess"`
	Theme                     string   `xml:"theme" json:"theme" default:"default"`
	Debugging                 bool     `xml:"debugging,attr" json:"debugging"`
	InsecureSkipHostCheck     bool     `xml:"insecureSkipHostcheck,omitempty" json:"insecureSkipHostcheck"`
	InsecureAllowFrameLoading bool     `xml:"insecureAllowFrameLoading,omitempty" json:"insecureAllowFrameLoading"`
}

func (GUIConfiguration) Address

func (c GUIConfiguration) Address() string

func (GUIConfiguration) Copy added in v0.14.50

func (GUIConfiguration) IsAuthEnabled added in v0.14.51

func (c GUIConfiguration) IsAuthEnabled() bool

func (GUIConfiguration) IsOverridden added in v0.14.52

func (c GUIConfiguration) IsOverridden() bool

func (GUIConfiguration) IsValidAPIKey added in v0.12.18

func (c GUIConfiguration) IsValidAPIKey(apiKey string) bool

IsValidAPIKey returns true when the given API key is valid, including both the value in config and any overrides

func (GUIConfiguration) Network added in v0.14.52

func (c GUIConfiguration) Network() string

func (GUIConfiguration) URL added in v0.12.0

func (c GUIConfiguration) URL() string

func (GUIConfiguration) UnixSocketPermissions added in v1.4.1

func (c GUIConfiguration) UnixSocketPermissions() os.FileMode

func (GUIConfiguration) UseTLS

func (c GUIConfiguration) UseTLS() bool

type LDAPConfiguration added in v0.14.51

type LDAPConfiguration struct {
	Address            string        `xml:"address,omitempty" json:"address"`
	BindDN             string        `xml:"bindDN,omitempty" json:"bindDN"`
	Transport          LDAPTransport `xml:"transport,omitempty" json:"transport"`
	InsecureSkipVerify bool          `xml:"insecureSkipVerify,omitempty" json:"insecureSkipVerify" default:"false"`
	SearchBaseDN       string        `xml:"searchBaseDN,omitempty" json:"searchBaseDN"`
	SearchFilter       string        `xml:"searchFilter,omitempty" json:"searchFilter"`
}

func (LDAPConfiguration) Copy added in v0.14.51

type LDAPTransport added in v0.14.51

type LDAPTransport int
const (
	LDAPTransportPlain LDAPTransport = iota // default is plain
	LDAPTransportTLS
	LDAPTransportStartTLS
)

func (LDAPTransport) MarshalText added in v0.14.51

func (t LDAPTransport) MarshalText() ([]byte, error)

func (LDAPTransport) String added in v0.14.51

func (t LDAPTransport) String() string

func (*LDAPTransport) UnmarshalText added in v0.14.51

func (t *LDAPTransport) UnmarshalText(bs []byte) error

type ObservedDevice added in v0.14.51

type ObservedDevice struct {
	Time    time.Time         `xml:"time,attr" json:"time"`
	ID      protocol.DeviceID `xml:"id,attr" json:"deviceID"`
	Name    string            `xml:"name,attr" json:"name"`
	Address string            `xml:"address,attr" json:"address"`
}

type ObservedFolder added in v0.14.51

type ObservedFolder struct {
	Time  time.Time `xml:"time,attr" json:"time"`
	ID    string    `xml:"id,attr" json:"id"`
	Label string    `xml:"label,attr" json:"label"`
}

type OptionsConfiguration

type OptionsConfiguration struct {
	RawListenAddresses      []string `xml:"listenAddress" json:"listenAddresses" default:"default"`
	RawGlobalAnnServers     []string `xml:"globalAnnounceServer" json:"globalAnnounceServers" default:"default" restart:"true"`
	GlobalAnnEnabled        bool     `xml:"globalAnnounceEnabled" json:"globalAnnounceEnabled" default:"true" restart:"true"`
	LocalAnnEnabled         bool     `xml:"localAnnounceEnabled" json:"localAnnounceEnabled" default:"true" restart:"true"`
	LocalAnnPort            int      `xml:"localAnnouncePort" json:"localAnnouncePort" default:"21027" restart:"true"`
	LocalAnnMCAddr          string   `xml:"localAnnounceMCAddr" json:"localAnnounceMCAddr" default:"[ff12::8384]:21027" restart:"true"`
	MaxSendKbps             int      `xml:"maxSendKbps" json:"maxSendKbps"`
	MaxRecvKbps             int      `xml:"maxRecvKbps" json:"maxRecvKbps"`
	ReconnectIntervalS      int      `xml:"reconnectionIntervalS" json:"reconnectionIntervalS" default:"60"`
	RelaysEnabled           bool     `xml:"relaysEnabled" json:"relaysEnabled" default:"true"`
	RelayReconnectIntervalM int      `xml:"relayReconnectIntervalM" json:"relayReconnectIntervalM" default:"10"`
	StartBrowser            bool     `xml:"startBrowser" json:"startBrowser" default:"true"`
	NATEnabled              bool     `xml:"natEnabled" json:"natEnabled" default:"true"`
	NATLeaseM               int      `xml:"natLeaseMinutes" json:"natLeaseMinutes" default:"60"`
	NATRenewalM             int      `xml:"natRenewalMinutes" json:"natRenewalMinutes" default:"30"`
	NATTimeoutS             int      `xml:"natTimeoutSeconds" json:"natTimeoutSeconds" default:"10"`
	URAccepted              int      `xml:"urAccepted" json:"urAccepted"`                                    // Accepted usage reporting version; 0 for off (undecided), -1 for off (permanently)
	URSeen                  int      `xml:"urSeen" json:"urSeen"`                                            // Report which the user has been prompted for.
	URUniqueID              string   `xml:"urUniqueID" json:"urUniqueId"`                                    // Unique ID for reporting purposes, regenerated when UR is turned on.
	URURL                   string   `xml:"urURL" json:"urURL" default:"https://data.syncthing.net/newdata"` // usage reporting URL
	URPostInsecurely        bool     `xml:"urPostInsecurely" json:"urPostInsecurely" default:"false"`        // For testing
	URInitialDelayS         int      `xml:"urInitialDelayS" json:"urInitialDelayS" default:"1800"`
	RestartOnWakeup         bool     `xml:"restartOnWakeup" json:"restartOnWakeup" default:"true" restart:"true"`
	AutoUpgradeIntervalH    int      `xml:"autoUpgradeIntervalH" json:"autoUpgradeIntervalH" default:"12" restart:"true"` // 0 for off
	UpgradeToPreReleases    bool     `xml:"upgradeToPreReleases" json:"upgradeToPreReleases" restart:"true"`              // when auto upgrades are enabled
	KeepTemporariesH        int      `xml:"keepTemporariesH" json:"keepTemporariesH" default:"24"`                        // 0 for off
	CacheIgnoredFiles       bool     `xml:"cacheIgnoredFiles" json:"cacheIgnoredFiles" default:"false" restart:"true"`
	ProgressUpdateIntervalS int      `xml:"progressUpdateIntervalS" json:"progressUpdateIntervalS" default:"5"`
	LimitBandwidthInLan     bool     `xml:"limitBandwidthInLan" json:"limitBandwidthInLan" default:"false"`
	MinHomeDiskFree         Size     `xml:"minHomeDiskFree" json:"minHomeDiskFree" default:"1 %"`
	ReleasesURL             string   `xml:"releasesURL" json:"releasesURL" default:"https://upgrades.syncthing.net/meta.json" restart:"true"`
	AlwaysLocalNets         []string `xml:"alwaysLocalNet" json:"alwaysLocalNets"`
	OverwriteRemoteDevNames bool     `xml:"overwriteRemoteDeviceNamesOnConnect" json:"overwriteRemoteDeviceNamesOnConnect" default:"false"`
	TempIndexMinBlocks      int      `xml:"tempIndexMinBlocks" json:"tempIndexMinBlocks" default:"10"`
	UnackedNotificationIDs  []string `xml:"unackedNotificationID" json:"unackedNotificationIDs"`
	TrafficClass            int      `xml:"trafficClass" json:"trafficClass"`
	DefaultFolderPath       string   `xml:"defaultFolderPath" json:"defaultFolderPath" default:"~"`
	SetLowPriority          bool     `xml:"setLowPriority" json:"setLowPriority" default:"true"`
	RawMaxFolderConcurrency int      `xml:"maxFolderConcurrency" json:"maxFolderConcurrency"`
	CRURL                   string   `xml:"crashReportingURL" json:"crURL" default:"https://crash.syncthing.net/newcrash"` // crash reporting URL
	CREnabled               bool     `xml:"crashReportingEnabled" json:"crashReportingEnabled" default:"true" restart:"true"`
	StunKeepaliveStartS     int      `xml:"stunKeepaliveStartS" json:"stunKeepaliveStartS" default:"180"` // 0 for off
	StunKeepaliveMinS       int      `xml:"stunKeepaliveMinS" json:"stunKeepaliveMinS" default:"20"`      // 0 for off
	RawStunServers          []string `xml:"stunServer" json:"stunServers" default:"default"`
	DatabaseTuning          Tuning   `xml:"databaseTuning" json:"databaseTuning" restart:"true"`
	RawMaxCIRequestKiB      int      `xml:"maxConcurrentIncomingRequestKiB" json:"maxConcurrentIncomingRequestKiB"`

	DeprecatedUPnPEnabled        bool     `xml:"upnpEnabled,omitempty" json:"-"`
	DeprecatedUPnPLeaseM         int      `xml:"upnpLeaseMinutes,omitempty" json:"-"`
	DeprecatedUPnPRenewalM       int      `xml:"upnpRenewalMinutes,omitempty" json:"-"`
	DeprecatedUPnPTimeoutS       int      `xml:"upnpTimeoutSeconds,omitempty" json:"-"`
	DeprecatedRelayServers       []string `xml:"relayServer,omitempty" json:"-"`
	DeprecatedMinHomeDiskFreePct float64  `xml:"minHomeDiskFreePct,omitempty" json:"-"`
	DeprecatedMaxConcurrentScans int      `xml:"maxConcurrentScans,omitempty" json:"-"`
}

func (OptionsConfiguration) Copy

func (OptionsConfiguration) GlobalDiscoveryServers added in v1.3.3

func (opts OptionsConfiguration) GlobalDiscoveryServers() []string

func (OptionsConfiguration) IsStunDisabled added in v1.2.0

func (opts OptionsConfiguration) IsStunDisabled() bool

func (OptionsConfiguration) ListenAddresses added in v0.13.0

func (opts OptionsConfiguration) ListenAddresses() []string

func (OptionsConfiguration) MaxConcurrentIncomingRequestKiB added in v1.4.0

func (opts OptionsConfiguration) MaxConcurrentIncomingRequestKiB() int

func (OptionsConfiguration) MaxFolderConcurrency added in v1.4.0

func (opts OptionsConfiguration) MaxFolderConcurrency() int

func (OptionsConfiguration) RequiresRestartOnly added in v0.14.42

func (opts OptionsConfiguration) RequiresRestartOnly() OptionsConfiguration

RequiresRestartOnly returns a copy with only the attributes that require restart on change.

func (OptionsConfiguration) ShouldAutoUpgrade added in v1.6.1

func (opts OptionsConfiguration) ShouldAutoUpgrade() bool

func (OptionsConfiguration) StunServers added in v0.14.25

func (opts OptionsConfiguration) StunServers() []string

type PullOrder

type PullOrder int
const (
	OrderRandom PullOrder = iota // default is random
	OrderAlphabetic
	OrderSmallestFirst
	OrderLargestFirst
	OrderOldestFirst
	OrderNewestFirst
)

func (PullOrder) MarshalText

func (o PullOrder) MarshalText() ([]byte, error)

func (PullOrder) String

func (o PullOrder) String() string

func (*PullOrder) UnmarshalText

func (o *PullOrder) UnmarshalText(bs []byte) error

type Size added in v0.14.28

type Size struct {
	Value float64 `json:"value" xml:",chardata"`
	Unit  string  `json:"unit" xml:"unit,attr"`
}

func ParseSize added in v0.14.28

func ParseSize(s string) (Size, error)

func (Size) BaseValue added in v0.14.28

func (s Size) BaseValue() float64

func (*Size) ParseDefault added in v0.14.28

func (s *Size) ParseDefault(str string) error

func (Size) Percentage added in v0.14.28

func (s Size) Percentage() bool

func (Size) String added in v0.14.28

func (s Size) String() string

type Tuning added in v1.3.0

type Tuning int
const (
	// N.b. these constants must match those in lib/db.Tuning!
	TuningAuto Tuning = iota // default is auto
	TuningSmall
	TuningLarge
)

func (Tuning) MarshalText added in v1.3.0

func (t Tuning) MarshalText() ([]byte, error)

func (Tuning) String added in v1.3.0

func (t Tuning) String() string

func (*Tuning) UnmarshalText added in v1.3.0

func (t *Tuning) UnmarshalText(bs []byte) error

type VersioningConfiguration

type VersioningConfiguration struct {
	Type             string            `json:"type"`
	Params           map[string]string `json:"params"`
	CleanupIntervalS int               `json:"cleanupIntervalS" default:"3600"`
}

VersioningConfiguration is used in the code and for JSON serialization

func (VersioningConfiguration) Copy added in v0.12.0

func (*VersioningConfiguration) MarshalXML

func (c *VersioningConfiguration) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*VersioningConfiguration) UnmarshalJSON added in v1.8.0

func (c *VersioningConfiguration) UnmarshalJSON(data []byte) error

func (*VersioningConfiguration) UnmarshalXML

func (c *VersioningConfiguration) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Waiter added in v0.14.42

type Waiter interface {
	Wait()
}

Waiter allows to wait for the given config operation to complete.

type Wrapper

type Wrapper interface {
	MyName() string
	ConfigPath() string

	RawCopy() Configuration
	Replace(cfg Configuration) (Waiter, error)
	RequiresRestart() bool
	Save() error

	GUI() GUIConfiguration
	SetGUI(gui GUIConfiguration) (Waiter, error)
	LDAP() LDAPConfiguration

	Options() OptionsConfiguration
	SetOptions(opts OptionsConfiguration) (Waiter, error)

	Folder(id string) (FolderConfiguration, bool)
	Folders() map[string]FolderConfiguration
	FolderList() []FolderConfiguration
	SetFolder(fld FolderConfiguration) (Waiter, error)
	SetFolders(folders []FolderConfiguration) (Waiter, error)

	Device(id protocol.DeviceID) (DeviceConfiguration, bool)
	Devices() map[protocol.DeviceID]DeviceConfiguration
	RemoveDevice(id protocol.DeviceID) (Waiter, error)
	SetDevice(DeviceConfiguration) (Waiter, error)
	SetDevices([]DeviceConfiguration) (Waiter, error)

	AddOrUpdatePendingDevice(device protocol.DeviceID, name, address string)
	AddOrUpdatePendingFolder(id, label string, device protocol.DeviceID)
	IgnoredDevice(id protocol.DeviceID) bool
	IgnoredFolder(device protocol.DeviceID, folder string) bool

	Subscribe(c Committer)
	Unsubscribe(c Committer)
}

A Wrapper around a Configuration that manages loads, saves and published notifications of changes to registered Handlers

func Load

func Load(path string, myID protocol.DeviceID, evLogger events.Logger) (Wrapper, error)

Load loads an existing file on disk and returns a new configuration wrapper.

func Wrap

func Wrap(path string, cfg Configuration, evLogger events.Logger) Wrapper

Wrap wraps an existing Configuration structure and ties it to a file on disk.

Jump to

Keyboard shortcuts

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