syncthing

package
v0.0.0-...-9a6de97 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fetch

func Fetch(path string) error

Fetch pulls down the latest syncthing binary to the provided path.

func ResetConfig

func ResetConfig(path string) error

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.

func UnpackMac

func UnpackMac(reader io.Reader) (io.Reader, error)

UnpackWindows unpacks the zip archive and returns a reader containing the binary

func UnpackNix

func UnpackNix(reader io.Reader) (io.Reader, error)

UnpackNix upacks the tarball and returns a reader containing the binary

func UnpackWindows

func UnpackWindows(reader io.Reader) (io.Reader, error)

UnpackWindows unpacks the zip archive and returns a reader containing the binary

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 NewServer

func NewServer(host string, apikey string) (*Server, error)

NewServer constructs a Server with the provided host and apikey.

func (*Server) Events

func (s *Server) Events() (<-chan events.Event, error)

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) Fields

func (s *Server) Fields() log.Fields

Fields returns a set of structured fields for logging.

func (*Server) GetDevice

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

func (s *Server) IsAlive() bool

IsAlive checks the `system/status` endpoint to see where the syncthing process is alive.

func (*Server) Refresh

func (s *Server) Refresh() error

Refresh pulls the latest configuration from the configured server and updates Server.Config with that value.

func (*Server) RemoveDevice

func (s *Server) RemoveDevice(id protocol.DeviceID)

RemoveDevice takes a device id and removes it from the local configuration. Server.Update() will then save this.

func (*Server) RemoveFolder

func (s *Server) RemoveFolder(id string)

RemoveFolder takes a folder id (not the path) and removes it from the local configuration. Server.Update() will then save this.

func (*Server) Restart

func (s *Server) Restart() error

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.

func (*Server) Stop

func (s *Server) Stop()

Stop is used to clean up everything that this server is doing in the background.

func (*Server) String

func (s *Server) String() string

func (*Server) Update

func (s *Server) Update() error

Update takes the current config, sets the server's config to that.

Jump to

Keyboard shortcuts

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