rc

package
v0.11.12 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2015 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package rc provides remote control of a Syncthing process via the REST API.

Index

Constants

View Source
const APIKey = "592A47BC-A7DF-4C2F-89E0-A80B3E5094EE"

We set the API key via the STGUIAPIKEY variable when we launch the binary, to ensure that we have API access regardless of authentication settings.

Variables

This section is empty.

Functions

func AwaitSync

func AwaitSync(folder string, ps ...*Process)

func InSync

func InSync(folder string, ps ...*Process) bool

Types

type Event

type Event struct {
	ID   int
	Time time.Time
	Type string
	Data interface{}
}

type Model

type Model struct {
	GlobalBytes   int
	GlobalDeleted int
	GlobalFiles   int
	InSyncBytes   int
	InSyncFiles   int
	Invalid       string
	LocalBytes    int
	LocalDeleted  int
	LocalFiles    int
	NeedBytes     int
	NeedFiles     int
	State         string
	StateChanged  time.Time
	Version       int
}

type Process

type Process struct {
	// contains filtered or unexported fields
}

func NewProcess

func NewProcess(addr string) *Process

NewProcess returns a new Process talking to Syncthing at the specified address. Example: NewProcess("127.0.0.1:8082")

func (*Process) AwaitStartup

func (p *Process) AwaitStartup()

AwaitStartup waits for the Syncthing process to start and perform initial scans of all folders.

func (*Process) Events

func (p *Process) Events(since int) ([]Event, error)

func (*Process) Get

func (p *Process) Get(path string) ([]byte, error)

Get performs an HTTP GET and returns the bytes and/or an error. Any non-200 return code is returned as an error.

func (*Process) LogTo

func (p *Process) LogTo(filename string) error

LogTo creates the specified log file and ensures that stdout and stderr from the Start()ed process is redirected there. Must be called before Start().

func (*Process) Model

func (p *Process) Model(folder string) (Model, error)

func (*Process) Post

func (p *Process) Post(path string, data io.Reader) ([]byte, error)

Post performs an HTTP POST and returns the bytes and/or an error. Any non-200 return code is returned as an error.

func (*Process) Rescan

func (p *Process) Rescan(folder string) error

func (*Process) RescanDelay

func (p *Process) RescanDelay(folder string, delaySeconds int) error

func (*Process) Start

func (p *Process) Start(bin string, args ...string) error

Start runs the specified Syncthing binary with the given arguments. Syncthing should be configured to provide an API on the address given to NewProcess. Event processing is started.

func (*Process) Stop

func (p *Process) Stop() (*os.ProcessState, error)

Stop stops the running Syncthing process. If the process was logging to a local file (set by LogTo), the log file will be opened and checked for panics and data races. The presence of either will be signalled in the form of a returned error.

Jump to

Keyboard shortcuts

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