Documentation ¶
Overview ¶
Package syncthing provides a client that interacts with the syncthing API.
It provides interfaces for:
- Fetching and updating configuration.
- Adding and removing devices.
- Adding and removing folders.
- Restarting the process.
Index ¶
- func Fetch(path string) error
- func ResetConfig(path string) error
- func UnpackMac(reader io.Reader) (io.Reader, error)
- func UnpackNix(reader io.Reader) (io.Reader, error)
- func UnpackWindows(reader io.Reader) (io.Reader, error)
- type Server
- func (s *Server) Events() (<-chan events.Event, error)
- func (s *Server) Fields() log.Fields
- func (s *Server) GetDevice(id protocol.DeviceID) *config.DeviceConfiguration
- func (s *Server) GetFolder(id string) *config.FolderConfiguration
- func (s *Server) IsAlive() bool
- func (s *Server) Refresh() error
- func (s *Server) RemoveDevice(id protocol.DeviceID)
- func (s *Server) RemoveFolder(id string)
- func (s *Server) Restart() error
- func (s *Server) SetDevice(device *config.DeviceConfiguration) error
- func (s *Server) SetFolder(folder *config.FolderConfiguration) error
- func (s *Server) Stop()
- func (s *Server) String() string
- func (s *Server) Update() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResetConfig ¶
ResetConfig looks at the *local* config and resets it to the preferred default. It does not require a running server as the configuration file is simply overwritten.
Types ¶
type Server ¶
type Server struct { Config *config.Configuration `structs:"-"` ID protocol.DeviceID URL string // contains filtered or unexported fields }
Server represents a syncthing REST server. It is used to fetch and modify configuration as well as restart the syncthing process.
func (*Server) Events ¶
Events returns a stream of events being issued from the syncthing server. It is not filtered and is up to the listener to choose which events they're interested in. Remember to call Server.Stop() to stop listening for events.
func (*Server) GetDevice ¶
func (s *Server) GetDevice(id protocol.DeviceID) *config.DeviceConfiguration
GetDevice takes a device ID, looks in the current configuration and returns that device.
func (*Server) GetFolder ¶
func (s *Server) GetFolder(id string) *config.FolderConfiguration
GetFolder takes the folder id (not the path) and returns it from the current configuration.
func (*Server) IsAlive ¶
IsAlive checks the `system/status` endpoint to see where the syncthing process is alive.
func (*Server) Refresh ¶
Refresh pulls the latest configuration from the configured server and updates Server.Config with that value.
func (*Server) RemoveDevice ¶
RemoveDevice takes a device id and removes it from the local configuration. Server.Update() will then save this.
func (*Server) RemoveFolder ¶
RemoveFolder takes a folder id (not the path) and removes it from the local configuration. Server.Update() will then save this.
func (*Server) Restart ¶
Restart rolls the remote server. Because of how syncthing runs, this just happens in the background with only minimal interruption.
func (*Server) SetDevice ¶
func (s *Server) SetDevice(device *config.DeviceConfiguration) error
SetDevice takes a complete device and adds it to the local configuration. Server.Update() will then save this. Note that if the device already exists it is simply overwritten.
func (*Server) SetFolder ¶
func (s *Server) SetFolder(folder *config.FolderConfiguration) error
SetFolder takes a fully configured folder and adds it to the local configuration. Server.Update() will then save this. Note that if the folder already exists, it is simply overwritten.