config

package
v0.2.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2016 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CurrentVersion = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	Version    int                          `xml:"version,attr" json:"version"`
	MyID       string                       `xml:"-" json:"myID"`
	MountPoint string                       `xml:"mountPoint" json:"mountPoint"`
	Folders    []FolderConfiguration        `xml:"folder" json:"folders"`
	Devices    []config.DeviceConfiguration `xml:"device" json:"devices"`
	Options    OptionsConfiguration         `xml:"options" json:"options"`
	GUI        GUIConfiguration             `xml:"gui" json:"gui"`
	XMLName    xml.Name                     `xml:"configuration" json:"-"`
}

func New

func New(myID protocol.DeviceID, myName string) Configuration

func ReadXML

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

func (*Configuration) WriteXML

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

type FolderConfiguration

type FolderConfiguration struct {
	ID          string                             `xml:"id,attr" json:"id"`
	Devices     []config.FolderDeviceConfiguration `xml:"device" json:"devices"`
	CacheSize   string                             `xml:"cacheSize" json:"cacheSize" default:"512MiB"`
	PinnedFiles []string                           `xml:"pinnedFiles" json:"pinnedFiles"`
}

func (FolderConfiguration) GetCacheSizeBytes

func (f FolderConfiguration) GetCacheSizeBytes() (int32, 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:5833"`
}

type OptionsConfiguration

type OptionsConfiguration struct {
	ListenAddress              []string `xml:"listenAddress" json:"listenAddress" default:"tcp://0.0.0.0:22000"`
	LocalAnnounceEnabled       bool     `xml:"localAnnounceEnabled" json:"localAnnounceEnabled" default:"true"`
	LocalAnnouncePort          int      `xml:"localAnnouncePort" json:"localAnnouncePort" default:"21027"`
	LocalAnnounceMCAddr        string   `xml:"localAnnounceMCAddr" json:"localAnnounceMCAddr"`
	GlobalAnnounceEnabled      bool     `xml:"globalAnnounceEnabled" json:"globalAnnounceEnabled" default:"true"`
	GlobalAnnounceServers      []string `xml:"globalAnnounceServer" json:"globalAnnounceServers" default:"default"`
	RelaysEnabled              bool     `xml:"relaysEnabled" json:"relaysEnabled" default:"true"`
	RelayWithoutGlobalAnnounce bool     `xml:"relayWithoutGlobalAnn" json:"relayWithoutGlobalAnn" default:"false"`
	RelayServers               []string `xml:"relayServer" json:"relayServers" default:"dynamic+https://relays.syncthing.net/endpoint"`
	RelayReconnectIntervalM    int      `xml:"relayReconnectIntervalM" json:"relayReconnectIntervalM" default:"10"`
}

type Wrapper

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

func Wrap(path string, cfg Configuration) *Wrapper

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

func (*Wrapper) AsStCfg

func (w *Wrapper) AsStCfg(myID protocol.DeviceID) *stconfig.Wrapper

func (*Wrapper) ConfigPath

func (w *Wrapper) ConfigPath() string

func (*Wrapper) Devices

func (*Wrapper) Folders

func (w *Wrapper) Folders() map[string]FolderConfiguration

Folders returns a map of folders. Folder structures should not be changed, other than for the purpose of updating via SetFolder().

func (*Wrapper) MyDeviceConfiguration

func (w *Wrapper) MyDeviceConfiguration() stconfig.DeviceConfiguration

func (*Wrapper) Raw

func (w *Wrapper) Raw() Configuration

Raw returns the currently wrapped Configuration object.

func (*Wrapper) Replace

func (w *Wrapper) Replace(to Configuration) error

func (*Wrapper) Save

func (w *Wrapper) Save() error

Save writes the configuration to disk

func (*Wrapper) SetDevice

func (w *Wrapper) SetDevice(devCfg stconfig.DeviceConfiguration)

func (*Wrapper) SetFolder

func (w *Wrapper) SetFolder(fldCfg FolderConfiguration)

Jump to

Keyboard shortcuts

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