Documentation ¶
Overview ¶
Package rc provides remote control of a Syncthing process via the REST API.
Index ¶
- Constants
- func AwaitSync(folder string, ps ...*Process)
- func InSync(folder string, ps ...*Process) bool
- type Event
- type Model
- type Process
- func (p *Process) AwaitStartup()
- func (p *Process) Events(since int) ([]Event, error)
- func (p *Process) Get(path string) ([]byte, error)
- func (p *Process) LogTo(filename string) error
- func (p *Process) Model(folder string) (Model, error)
- func (p *Process) Post(path string, data io.Reader) ([]byte, error)
- func (p *Process) Rescan(folder string) error
- func (p *Process) RescanDelay(folder string, delaySeconds int) error
- func (p *Process) Start(bin string, args ...string) error
- func (p *Process) Stop() (*os.ProcessState, error)
Constants ¶
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 ¶
Types ¶
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
func NewProcess ¶
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) Get ¶
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 ¶
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) Post ¶
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) Start ¶
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.