config

package
v1.29.4-rc.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: MPL-2.0 Imports: 40 Imported by: 32

Documentation

Overview

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

Index

Constants

View Source
const (
	OldestHandledVersion = 10
	CurrentVersion       = 37
	MaxRescanIntervalS   = 365 * 24 * 60 * 60
)
View Source
const (
	DefaultMarkerName   = ".stfolder"
	EncryptionTokenName = "syncthing-encryption_password_token" //nolint: gosec

)

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{
		netutil.AddressURL("tcp", net.JoinHostPort("0.0.0.0", strconv.Itoa(DefaultTCPPort))),
		"dynamic+https://relays.syncthing.net/endpoint",
		netutil.AddressURL("quic", net.JoinHostPort("0.0.0.0", strconv.Itoa(DefaultQUICPort))),
	}
	// DefaultDiscoveryServersV4 should be substituted when the configuration
	// contains <globalAnnounceServer>default-v4</globalAnnounceServer>.
	DefaultDiscoveryServersV4 = []string{
		"https://discovery-lookup.syncthing.net/v2/?noannounce",
		"https://discovery-announce-v4.syncthing.net/v2/?nolookup",
	}
	// DefaultDiscoveryServersV6 should be substituted when the configuration
	// contains <globalAnnounceServer>default-v6</globalAnnounceServer>.
	DefaultDiscoveryServersV6 = []string{
		"https://discovery-lookup.syncthing.net/v2/?noannounce",
		"https://discovery-announce-v6.syncthing.net/v2/?nolookup",
	}
	// 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.hitv.com:3478",
		"stun.ideasip.com:3478",
		"stun.internetcalls.com:3478",
		"stun.miwifi.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(minFree Size, usage fs.Usage) error

CheckFreeSpace checks that the free space does not fall below the minimum required free space.

Types

type AuthMode added in v0.14.51

type AuthMode int32
const (
	AuthModeStatic AuthMode = 0
	AuthModeLDAP   AuthMode = 1
)

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 int32
const (
	BlockPullOrderStandard BlockPullOrder = 0
	BlockPullOrderRandom   BlockPullOrder = 1
	BlockPullOrderInOrder  BlockPullOrder = 2
)

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 {
	CommitConfiguration(from, to Configuration) (handled bool)
	String() string
}

The Committer and Verifier interfaces are 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 that implements it, with copies of 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.

A Committer must take care not to hold any locks while changing the configuration (e.g. calling Wrapper.SetFolder), that are also acquired in any methods of the Committer interface.

type Compression added in v1.29.0

type Compression int32
const (
	CompressionMetadata Compression = 0
	CompressionNever    Compression = 1
	CompressionAlways   Compression = 2
)

func (Compression) MarshalText added in v1.29.0

func (c Compression) MarshalText() ([]byte, error)

func (Compression) ToProtocol added in v1.29.0

func (c Compression) ToProtocol() protocol.Compression

func (*Compression) UnmarshalText added in v1.29.0

func (c *Compression) UnmarshalText(bs []byte) error

type Configuration

type Configuration struct {
	Version                  int                   `json:"version" xml:"version,attr"`
	Folders                  []FolderConfiguration `json:"folders" xml:"folder"`
	Devices                  []DeviceConfiguration `json:"devices" xml:"device"`
	GUI                      GUIConfiguration      `json:"gui" xml:"gui"`
	LDAP                     LDAPConfiguration     `json:"ldap" xml:"ldap"`
	Options                  OptionsConfiguration  `json:"options" xml:"options"`
	IgnoredDevices           []ObservedDevice      `json:"remoteIgnoredDevices" xml:"remoteIgnoredDevice"`
	DeprecatedPendingDevices []ObservedDevice      `json:"-" xml:"pendingDevice,omitempty"` // Deprecated: Do not use.
	Defaults                 Defaults              `json:"defaults" xml:"defaults"`
}

func New

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, int, error)

func (Configuration) Copy

func (cfg Configuration) Copy() Configuration

func (*Configuration) Device added in v1.14.0

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) Folder added in v1.14.0

func (cfg *Configuration) Folder(id string) (FolderConfiguration, int, bool)

func (*Configuration) FolderMap added in v1.14.0

func (cfg *Configuration) FolderMap() map[string]FolderConfiguration

FolderMap returns a map of folder ID to folder configuration for the given configuration.

func (Configuration) FolderPasswords added in v1.12.0

func (cfg Configuration) FolderPasswords(device protocol.DeviceID) map[string]string

FolderPasswords returns the folder passwords set for this device, for folders that have an encryption password set.

func (*Configuration) ProbeFreePorts added in v1.19.0

func (cfg *Configuration) ProbeFreePorts() error

func (*Configuration) SetDevice added in v1.14.0

func (cfg *Configuration) SetDevice(device DeviceConfiguration)

func (*Configuration) SetDevices added in v1.14.0

func (cfg *Configuration) SetDevices(devices []DeviceConfiguration)

func (*Configuration) SetFolder added in v1.14.0

func (cfg *Configuration) SetFolder(folder FolderConfiguration)

func (*Configuration) SetFolders added in v1.14.0

func (cfg *Configuration) SetFolders(folders []FolderConfiguration)

func (*Configuration) WriteXML

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

type CopyRangeMethod added in v1.29.0

type CopyRangeMethod int32
const (
	CopyRangeMethodStandard         CopyRangeMethod = 0
	CopyRangeMethodIoctl            CopyRangeMethod = 1
	CopyRangeMethodCopyFileRange    CopyRangeMethod = 2
	CopyRangeMethodSendFile         CopyRangeMethod = 3
	CopyRangeMethodDuplicateExtents CopyRangeMethod = 4
	CopyRangeMethodAllWithFallback  CopyRangeMethod = 5
)

func (CopyRangeMethod) MarshalText added in v1.29.0

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

func (*CopyRangeMethod) ParseDefault added in v1.29.0

func (o *CopyRangeMethod) ParseDefault(str string) error

func (CopyRangeMethod) String added in v1.29.0

func (o CopyRangeMethod) String() string

func (CopyRangeMethod) ToFS added in v1.29.0

func (*CopyRangeMethod) UnmarshalText added in v1.29.0

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

type Defaults added in v1.14.0

type Defaults struct {
	Folder  FolderConfiguration `json:"folder" xml:"folder"`
	Device  DeviceConfiguration `json:"device" xml:"device"`
	Ignores Ignores             `json:"ignores" xml:"ignores"`
}

type DeviceConfiguration

type DeviceConfiguration struct {
	DeviceID                 protocol.DeviceID `json:"deviceID" xml:"id,attr" nodefault:"true"`
	Name                     string            `json:"name" xml:"name,attr,omitempty"`
	Addresses                []string          `json:"addresses" xml:"address,omitempty"`
	Compression              Compression       `json:"compression" xml:"compression,attr"`
	CertName                 string            `json:"certName" xml:"certName,attr,omitempty"`
	Introducer               bool              `json:"introducer" xml:"introducer,attr"`
	SkipIntroductionRemovals bool              `json:"skipIntroductionRemovals" xml:"skipIntroductionRemovals,attr"`
	IntroducedBy             protocol.DeviceID `json:"introducedBy" xml:"introducedBy,attr" nodefault:"true"`
	Paused                   bool              `json:"paused" xml:"paused"`
	AllowedNetworks          []string          `json:"allowedNetworks" xml:"allowedNetwork,omitempty"`
	AutoAcceptFolders        bool              `json:"autoAcceptFolders" xml:"autoAcceptFolders"`
	MaxSendKbps              int               `json:"maxSendKbps" xml:"maxSendKbps"`
	MaxRecvKbps              int               `json:"maxRecvKbps" xml:"maxRecvKbps"`
	IgnoredFolders           []ObservedFolder  `json:"ignoredFolders" xml:"ignoredFolder"`
	DeprecatedPendingFolders []ObservedFolder  `json:"-" xml:"pendingFolder,omitempty"` // Deprecated: Do not use.
	MaxRequestKiB            int               `json:"maxRequestKiB" xml:"maxRequestKiB"`
	Untrusted                bool              `json:"untrusted" xml:"untrusted"`
	RemoteGUIPort            int               `json:"remoteGUIPort" xml:"remoteGUIPort"`
	RawNumConnections        int               `json:"numConnections" xml:"numConnections"`
}

func (DeviceConfiguration) Copy

func (*DeviceConfiguration) Description added in v1.20.3

func (cfg *DeviceConfiguration) Description() string

func (*DeviceConfiguration) IgnoredFolder added in v0.14.51

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

func (*DeviceConfiguration) NumConnections added in v1.25.0

func (cfg *DeviceConfiguration) NumConnections() int

type FilesystemType added in v1.29.0

type FilesystemType int32
const (
	FilesystemTypeBasic FilesystemType = 0
	FilesystemTypeFake  FilesystemType = 1
)

func (FilesystemType) MarshalText added in v1.29.0

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

func (FilesystemType) String added in v1.29.0

func (t FilesystemType) String() string

func (FilesystemType) ToFS added in v1.29.0

func (t FilesystemType) ToFS() fs.FilesystemType

func (*FilesystemType) UnmarshalText added in v1.29.0

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

type FolderConfiguration

type FolderConfiguration struct {
	ID                      string                      `json:"id" xml:"id,attr" nodefault:"true"`
	Label                   string                      `json:"label" xml:"label,attr" restart:"false"`
	FilesystemType          FilesystemType              `json:"filesystemType" xml:"filesystemType"`
	Path                    string                      `json:"path" xml:"path,attr" default:"~"`
	Type                    FolderType                  `json:"type" xml:"type,attr"`
	Devices                 []FolderDeviceConfiguration `json:"devices" xml:"device"`
	RescanIntervalS         int                         `json:"rescanIntervalS" xml:"rescanIntervalS,attr" default:"3600"`
	FSWatcherEnabled        bool                        `json:"fsWatcherEnabled" xml:"fsWatcherEnabled,attr" default:"true"`
	FSWatcherDelayS         float64                     `json:"fsWatcherDelayS" xml:"fsWatcherDelayS,attr" default:"10"`
	FSWatcherTimeoutS       float64                     `json:"fsWatcherTimeoutS" xml:"fsWatcherTimeoutS,attr"`
	IgnorePerms             bool                        `json:"ignorePerms" xml:"ignorePerms,attr"`
	AutoNormalize           bool                        `json:"autoNormalize" xml:"autoNormalize,attr" default:"true"`
	MinDiskFree             Size                        `json:"minDiskFree" xml:"minDiskFree" default:"1 %"`
	Versioning              VersioningConfiguration     `json:"versioning" xml:"versioning"`
	Copiers                 int                         `json:"copiers" xml:"copiers"`
	PullerMaxPendingKiB     int                         `json:"pullerMaxPendingKiB" xml:"pullerMaxPendingKiB"`
	Hashers                 int                         `json:"hashers" xml:"hashers"`
	Order                   PullOrder                   `json:"order" xml:"order"`
	IgnoreDelete            bool                        `json:"ignoreDelete" xml:"ignoreDelete"`
	ScanProgressIntervalS   int                         `json:"scanProgressIntervalS" xml:"scanProgressIntervalS"`
	PullerPauseS            int                         `json:"pullerPauseS" xml:"pullerPauseS"`
	MaxConflicts            int                         `json:"maxConflicts" xml:"maxConflicts" default:"10"`
	DisableSparseFiles      bool                        `json:"disableSparseFiles" xml:"disableSparseFiles"`
	DisableTempIndexes      bool                        `json:"disableTempIndexes" xml:"disableTempIndexes"`
	Paused                  bool                        `json:"paused" xml:"paused"`
	WeakHashThresholdPct    int                         `json:"weakHashThresholdPct" xml:"weakHashThresholdPct"`
	MarkerName              string                      `json:"markerName" xml:"markerName"`
	CopyOwnershipFromParent bool                        `json:"copyOwnershipFromParent" xml:"copyOwnershipFromParent"`
	RawModTimeWindowS       int                         `json:"modTimeWindowS" xml:"modTimeWindowS"`
	MaxConcurrentWrites     int                         `json:"maxConcurrentWrites" xml:"maxConcurrentWrites" default:"2"`
	DisableFsync            bool                        `json:"disableFsync" xml:"disableFsync"`
	BlockPullOrder          BlockPullOrder              `json:"blockPullOrder" xml:"blockPullOrder"`
	CopyRangeMethod         CopyRangeMethod             `json:"copyRangeMethod" xml:"copyRangeMethod" default:"standard"`
	CaseSensitiveFS         bool                        `json:"caseSensitiveFS" xml:"caseSensitiveFS"`
	JunctionsAsDirs         bool                        `json:"junctionsAsDirs" xml:"junctionsAsDirs"`
	SyncOwnership           bool                        `json:"syncOwnership" xml:"syncOwnership"`
	SendOwnership           bool                        `json:"sendOwnership" xml:"sendOwnership"`
	SyncXattrs              bool                        `json:"syncXattrs" xml:"syncXattrs"`
	SendXattrs              bool                        `json:"sendXattrs" xml:"sendXattrs"`
	XattrFilter             XattrFilter                 `json:"xattrFilter" xml:"xattrFilter"`
	// Legacy deprecated
	DeprecatedReadOnly       bool    `json:"-" xml:"ro,attr,omitempty"`        // Deprecated: Do not use.
	DeprecatedMinDiskFreePct float64 `json:"-" xml:"minDiskFreePct,omitempty"` // Deprecated: Do not use.
	DeprecatedPullers        int     `json:"-" xml:"pullers,omitempty"`        // Deprecated: Do not use.
	DeprecatedScanOwnership  bool    `json:"-" xml:"scanOwnership,omitempty"`  // Deprecated: Do not use.
}

func (*FolderConfiguration) CheckAvailableSpace added in v0.14.51

func (f *FolderConfiguration) CheckAvailableSpace(req uint64) 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) Device added in v1.12.0

func (*FolderConfiguration) DeviceIDs

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

func (FolderConfiguration) Filesystem added in v0.14.37

func (f FolderConfiguration) Filesystem(fset *db.FileSet) fs.Filesystem

Filesystem creates a filesystem for the path and options of this folder. The fset parameter may be nil, in which case no mtime handling on top of the filesystem is provided.

func (FolderConfiguration) ModTimeWindow added in v1.2.2

func (f FolderConfiguration) ModTimeWindow() time.Duration

func (*FolderConfiguration) RemoveMarker added in v1.27.8

func (f *FolderConfiguration) RemoveMarker() error

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 `json:"deviceID" xml:"id,attr"`
	IntroducedBy       protocol.DeviceID `json:"introducedBy" xml:"introducedBy,attr"`
	EncryptionPassword string            `json:"encryptionPassword" xml:"encryptionPassword"`
}

type FolderType added in v0.13.0

type FolderType int32
const (
	FolderTypeSendReceive      FolderType = 0
	FolderTypeSendOnly         FolderType = 1
	FolderTypeReceiveOnly      FolderType = 2
	FolderTypeReceiveEncrypted FolderType = 3
)

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     `json:"enabled" xml:"enabled,attr" default:"true"`
	RawAddress                string   `json:"address" xml:"address" default:"127.0.0.1:8384"`
	RawUnixSocketPermissions  string   `json:"unixSocketPermissions" xml:"unixSocketPermissions,omitempty"`
	User                      string   `json:"user" xml:"user,omitempty"`
	Password                  string   `json:"password" xml:"password,omitempty"`
	AuthMode                  AuthMode `json:"authMode" xml:"authMode,omitempty"`
	RawUseTLS                 bool     `json:"useTLS" xml:"tls,attr"`
	APIKey                    string   `json:"apiKey" xml:"apikey,omitempty"`
	InsecureAdminAccess       bool     `json:"insecureAdminAccess" xml:"insecureAdminAccess,omitempty"`
	Theme                     string   `json:"theme" xml:"theme" default:"default"`
	Debugging                 bool     `json:"debugging" xml:"debugging,attr"`
	InsecureSkipHostCheck     bool     `json:"insecureSkipHostcheck" xml:"insecureSkipHostcheck,omitempty"`
	InsecureAllowFrameLoading bool     `json:"insecureAllowFrameLoading" xml:"insecureAllowFrameLoading,omitempty"`
	SendBasicAuthPrompt       bool     `json:"sendBasicAuthPrompt" xml:"sendBasicAuthPrompt,attr"`
}

func (GUIConfiguration) Address

func (c GUIConfiguration) Address() string

func (GUIConfiguration) CompareHashedPassword added in v1.18.5

func (c GUIConfiguration) CompareHashedPassword(password string) error

CompareHashedPassword returns nil when the given plaintext password matches the stored hash.

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 (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) SetPassword added in v1.25.0

func (c *GUIConfiguration) SetPassword(password string) error

SetPassword takes a bcrypt hash or a plaintext password and stores it. Plaintext passwords are hashed. Returns an error if the password is not valid.

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 Ignores added in v1.19.0

type Ignores struct {
	Lines []string `json:"lines" xml:"line"`
}

func (Ignores) Copy added in v1.19.0

func (i Ignores) Copy() Ignores

type LDAPConfiguration added in v0.14.51

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

func (LDAPConfiguration) Copy added in v0.14.51

type LDAPTransport added in v0.14.51

type LDAPTransport int32
const (
	LDAPTransportPlain    LDAPTransport = 0
	LDAPTransportTLS      LDAPTransport = 2
	LDAPTransportStartTLS LDAPTransport = 3
)

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 ModifyFunction added in v1.14.0

type ModifyFunction func(*Configuration)

ModifyFunction gets a pointer to a copy of the currently active configuration for modification.

type ObservedDevice added in v0.14.51

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

type ObservedFolder added in v0.14.51

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

type OptionsConfiguration

type OptionsConfiguration struct {
	RawListenAddresses          []string `json:"listenAddresses" xml:"listenAddress" default:"default"`
	RawGlobalAnnServers         []string `json:"globalAnnounceServers" xml:"globalAnnounceServer" default:"default"`
	GlobalAnnEnabled            bool     `json:"globalAnnounceEnabled" xml:"globalAnnounceEnabled" default:"true"`
	LocalAnnEnabled             bool     `json:"localAnnounceEnabled" xml:"localAnnounceEnabled" default:"true"`
	LocalAnnPort                int      `json:"localAnnouncePort" xml:"localAnnouncePort" default:"21027"`
	LocalAnnMCAddr              string   `json:"localAnnounceMCAddr" xml:"localAnnounceMCAddr" default:"[ff12::8384]:21027"`
	MaxSendKbps                 int      `json:"maxSendKbps" xml:"maxSendKbps"`
	MaxRecvKbps                 int      `json:"maxRecvKbps" xml:"maxRecvKbps"`
	ReconnectIntervalS          int      `json:"reconnectionIntervalS" xml:"reconnectionIntervalS" default:"60"`
	RelaysEnabled               bool     `json:"relaysEnabled" xml:"relaysEnabled" default:"true"`
	RelayReconnectIntervalM     int      `json:"relayReconnectIntervalM" xml:"relayReconnectIntervalM" default:"10"`
	StartBrowser                bool     `json:"startBrowser" xml:"startBrowser" default:"true"`
	NATEnabled                  bool     `json:"natEnabled" xml:"natEnabled" default:"true"`
	NATLeaseM                   int      `json:"natLeaseMinutes" xml:"natLeaseMinutes" default:"60"`
	NATRenewalM                 int      `json:"natRenewalMinutes" xml:"natRenewalMinutes" default:"30"`
	NATTimeoutS                 int      `json:"natTimeoutSeconds" xml:"natTimeoutSeconds" default:"10"`
	URAccepted                  int      `json:"urAccepted" xml:"urAccepted"`
	URSeen                      int      `json:"urSeen" xml:"urSeen"`
	URUniqueID                  string   `json:"urUniqueId" xml:"urUniqueID"`
	URURL                       string   `json:"urURL" xml:"urURL" default:"https://data.syncthing.net/newdata"`
	URPostInsecurely            bool     `json:"urPostInsecurely" xml:"urPostInsecurely" default:"false"`
	URInitialDelayS             int      `json:"urInitialDelayS" xml:"urInitialDelayS" default:"1800"`
	AutoUpgradeIntervalH        int      `json:"autoUpgradeIntervalH" xml:"autoUpgradeIntervalH" default:"12"`
	UpgradeToPreReleases        bool     `json:"upgradeToPreReleases" xml:"upgradeToPreReleases"`
	KeepTemporariesH            int      `json:"keepTemporariesH" xml:"keepTemporariesH" default:"24"`
	CacheIgnoredFiles           bool     `json:"cacheIgnoredFiles" xml:"cacheIgnoredFiles" default:"false"`
	ProgressUpdateIntervalS     int      `json:"progressUpdateIntervalS" xml:"progressUpdateIntervalS" default:"5"`
	LimitBandwidthInLan         bool     `json:"limitBandwidthInLan" xml:"limitBandwidthInLan" default:"false"`
	MinHomeDiskFree             Size     `json:"minHomeDiskFree" xml:"minHomeDiskFree" default:"1 %"`
	ReleasesURL                 string   `json:"releasesURL" xml:"releasesURL" default:"https://upgrades.syncthing.net/meta.json"`
	AlwaysLocalNets             []string `json:"alwaysLocalNets" xml:"alwaysLocalNet"`
	OverwriteRemoteDevNames     bool     `json:"overwriteRemoteDeviceNamesOnConnect" xml:"overwriteRemoteDeviceNamesOnConnect" default:"false"`
	TempIndexMinBlocks          int      `json:"tempIndexMinBlocks" xml:"tempIndexMinBlocks" default:"10"`
	UnackedNotificationIDs      []string `json:"unackedNotificationIDs" xml:"unackedNotificationID"`
	TrafficClass                int      `json:"trafficClass" xml:"trafficClass"`
	DeprecatedDefaultFolderPath string   `json:"-" xml:"defaultFolderPath,omitempty"` // Deprecated: Do not use.
	SetLowPriority              bool     `json:"setLowPriority" xml:"setLowPriority" default:"true"`
	RawMaxFolderConcurrency     int      `json:"maxFolderConcurrency" xml:"maxFolderConcurrency"`
	CRURL                       string   `json:"crURL" xml:"crashReportingURL" default:"https://crash.syncthing.net/newcrash"`
	CREnabled                   bool     `json:"crashReportingEnabled" xml:"crashReportingEnabled" default:"true"`
	StunKeepaliveStartS         int      `json:"stunKeepaliveStartS" xml:"stunKeepaliveStartS" default:"180"`
	StunKeepaliveMinS           int      `json:"stunKeepaliveMinS" xml:"stunKeepaliveMinS" default:"20"`
	RawStunServers              []string `json:"stunServers" xml:"stunServer" default:"default"`
	DatabaseTuning              Tuning   `json:"databaseTuning" xml:"databaseTuning" restart:"true"`
	RawMaxCIRequestKiB          int      `json:"maxConcurrentIncomingRequestKiB" xml:"maxConcurrentIncomingRequestKiB"`
	AnnounceLANAddresses        bool     `json:"announceLANAddresses" xml:"announceLANAddresses" default:"true"`
	SendFullIndexOnUpgrade      bool     `json:"sendFullIndexOnUpgrade" xml:"sendFullIndexOnUpgrade"`
	FeatureFlags                []string `json:"featureFlags" xml:"featureFlag"`
	// The number of connections at which we stop trying to connect to more
	// devices, zero meaning no limit. Does not affect incoming connections.
	ConnectionLimitEnough int `json:"connectionLimitEnough" xml:"connectionLimitEnough"`
	// The maximum number of connections which we will allow in total, zero
	// meaning no limit. Affects incoming connections and prevents
	// attempting outgoing connections.
	ConnectionLimitMax int `json:"connectionLimitMax" xml:"connectionLimitMax"`
	// When set, this allows TLS 1.2 on sync connections, where we otherwise
	// default to TLS 1.3+ only.
	InsecureAllowOldTLSVersions        bool `json:"insecureAllowOldTLSVersions" xml:"insecureAllowOldTLSVersions"`
	ConnectionPriorityTCPLAN           int  `json:"connectionPriorityTcpLan" xml:"connectionPriorityTcpLan" default:"10"`
	ConnectionPriorityQUICLAN          int  `json:"connectionPriorityQuicLan" xml:"connectionPriorityQuicLan" default:"20"`
	ConnectionPriorityTCPWAN           int  `json:"connectionPriorityTcpWan" xml:"connectionPriorityTcpWan" default:"30"`
	ConnectionPriorityQUICWAN          int  `json:"connectionPriorityQuicWan" xml:"connectionPriorityQuicWan" default:"40"`
	ConnectionPriorityRelay            int  `json:"connectionPriorityRelay" xml:"connectionPriorityRelay" default:"50"`
	ConnectionPriorityUpgradeThreshold int  `json:"connectionPriorityUpgradeThreshold" xml:"connectionPriorityUpgradeThreshold" default:"0"`
	// Legacy deprecated
	DeprecatedUPnPEnabled        bool     `json:"-" xml:"upnpEnabled,omitempty"`        // Deprecated: Do not use.
	DeprecatedUPnPLeaseM         int      `json:"-" xml:"upnpLeaseMinutes,omitempty"`   // Deprecated: Do not use.
	DeprecatedUPnPRenewalM       int      `json:"-" xml:"upnpRenewalMinutes,omitempty"` // Deprecated: Do not use.
	DeprecatedUPnPTimeoutS       int      `json:"-" xml:"upnpTimeoutSeconds,omitempty"` // Deprecated: Do not use.
	DeprecatedRelayServers       []string `json:"-" xml:"relayServer,omitempty"`        // Deprecated: Do not use.
	DeprecatedMinHomeDiskFreePct float64  `json:"-" xml:"minHomeDiskFreePct,omitempty"` // Deprecated: Do not use.
	DeprecatedMaxConcurrentScans int      `json:"-" xml:"maxConcurrentScans,omitempty"` // Deprecated: Do not use.
}

func (OptionsConfiguration) AutoUpgradeEnabled added in v1.9.0

func (opts OptionsConfiguration) AutoUpgradeEnabled() bool

func (OptionsConfiguration) Copy

func (OptionsConfiguration) FeatureFlag added in v1.12.0

func (opts OptionsConfiguration) FeatureFlag(name string) bool

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) LowestConnectionLimit added in v1.13.0

func (opts OptionsConfiguration) LowestConnectionLimit() int

LowestConnectionLimit is the lower of ConnectionLimitEnough or ConnectionLimitMax, or whichever of them is actually set if only one of them is set. It's the point where we should stop dialing.

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) StunServers added in v0.14.25

func (opts OptionsConfiguration) StunServers() []string

type PullOrder

type PullOrder int32
const (
	PullOrderRandom        PullOrder = 0
	PullOrderAlphabetic    PullOrder = 1
	PullOrderSmallestFirst PullOrder = 2
	PullOrderLargestFirst  PullOrder = 3
	PullOrderOldestFirst   PullOrder = 4
	PullOrderNewestFirst   PullOrder = 5
)

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 int32
const (
	TuningAuto  Tuning = 0
	TuningSmall Tuning = 1
	TuningLarge Tuning = 2
)

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 Verifier added in v1.18.5

type Verifier interface {
	VerifyConfiguration(from, to Configuration) error
}

A Verifier can determine if a new configuration is acceptable. See the description for Committer, above.

type VersioningConfiguration

type VersioningConfiguration struct {
	Type             string            `json:"type" xml:"type,attr"`
	Params           map[string]string `json:"params" xml:"parameter" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
	CleanupIntervalS int               `json:"cleanupIntervalS" xml:"cleanupIntervalS" default:"3600"`
	FSPath           string            `json:"fsPath" xml:"fsPath"`
	FSType           FilesystemType    `json:"fsType" xml:"fsType"`
}

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) Reset added in v1.10.0

func (c *VersioningConfiguration) Reset()

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 {
	ConfigPath() string
	MyID() protocol.DeviceID

	RawCopy() Configuration
	RequiresRestart() bool
	Save() error

	Modify(ModifyFunction) (Waiter, error)
	RemoveFolder(id string) (Waiter, error)
	RemoveDevice(id protocol.DeviceID) (Waiter, error)

	GUI() GUIConfiguration
	LDAP() LDAPConfiguration
	Options() OptionsConfiguration
	DefaultIgnores() Ignores

	Folder(id string) (FolderConfiguration, bool)
	Folders() map[string]FolderConfiguration
	FolderList() []FolderConfiguration
	FolderPasswords(device protocol.DeviceID) map[string]string
	DefaultFolder() FolderConfiguration

	Device(id protocol.DeviceID) (DeviceConfiguration, bool)
	Devices() map[protocol.DeviceID]DeviceConfiguration
	DeviceList() []DeviceConfiguration
	DefaultDevice() DeviceConfiguration

	IgnoredDevices() []ObservedDevice
	IgnoredDevice(id protocol.DeviceID) bool
	IgnoredFolder(device protocol.DeviceID, folder string) bool

	Subscribe(c Committer) Configuration
	Unsubscribe(c Committer)

	suture.Service
}

Wrapper handles a Configuration, i.e. it provides methods to access, change and save the config, and notifies registered subscribers (Committer) of changes.

Modify allows changing the currently active configuration through the given ModifyFunction. It can be called concurrently: All calls will be queued and called in order.

func Load

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

Load loads an existing file on disk and returns a new configuration wrapper. The returned Wrapper is a suture.Service, thus needs to be started (added to a supervisor).

func Wrap

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

Wrap wraps an existing Configuration structure and ties it to a file on disk. The returned Wrapper is a suture.Service, thus needs to be started (added to a supervisor).

type XattrFilter added in v1.22.0

type XattrFilter struct {
	Entries            []XattrFilterEntry `json:"entries" xml:"entry"`
	MaxSingleEntrySize int                `json:"maxSingleEntrySize" xml:"maxSingleEntrySize" default:"1024"`
	MaxTotalSize       int                `json:"maxTotalSize" xml:"maxTotalSize" default:"4096"`
}

Extended attribute filter. This is a list of patterns to match (glob style), each with an action (permit or deny). First match is used. If the filter is empty, all strings are permitted. If the filter is non-empty, the default action becomes deny. To counter this, you can use the "*" pattern to match all strings at the end of the filter. There are also limits on the size of accepted attributes.

func (XattrFilter) GetMaxSingleEntrySize added in v1.22.0

func (f XattrFilter) GetMaxSingleEntrySize() int

func (XattrFilter) GetMaxTotalSize added in v1.22.0

func (f XattrFilter) GetMaxTotalSize() int

func (XattrFilter) Permit added in v1.22.0

func (f XattrFilter) Permit(s string) bool

type XattrFilterEntry added in v1.22.0

type XattrFilterEntry struct {
	Match  string `json:"match" xml:"match,attr"`
	Permit bool   `json:"permit" xml:"permit,attr"`
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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