Documentation ¶
Index ¶
- Constants
- func GetDownloadURL(os, arch, version string) (string, error)
- func GetFolderName(folder *Folder) string
- func GetLogFile(namespace, name string) string
- func GetMinimumVersion() *semver.Version
- func Install(p getter.ProgressTracker) error
- func IsInstalled() bool
- func NewAPIClient() *http.Client
- func RemoveFolder(dev *model.Dev) error
- func ShouldUpgrade() bool
- type Completion
- type Connection
- type Connections
- type DataFolderErrorEvent
- type DataFolderSummaryEvent
- type DataStateChangedEvent
- type DownloadProgressData
- type Folder
- type FolderError
- type FolderErrorEvent
- type FolderSummaryEvent
- type ItemEvent
- type StateChangedEvent
- type Status
- type Syncthing
- func (s *Syncthing) APICall(ctx context.Context, url, method string, code int, params map[string]string, ...) ([]byte, error)
- func (s *Syncthing) GetCompletion(ctx context.Context, local bool, device string) (*Completion, error)
- func (s *Syncthing) GetFolderErrors(ctx context.Context, local bool) error
- func (s *Syncthing) GetInSynchronizationFile(ctx context.Context) string
- func (s *Syncthing) GetPullErrors(ctx context.Context, local bool) (int64, error)
- func (s *Syncthing) GetSyncthingStatus(ctx context.Context, folder *Folder, local bool) (string, error)
- func (s *Syncthing) GetSystemErrors(ctx context.Context, local bool) (*SystemErrors, error)
- func (s *Syncthing) HardTerminate() error
- func (s *Syncthing) IdentifyReadinessIssue(fs afero.Fs) error
- func (s *Syncthing) IsAllOverwritten() bool
- func (s *Syncthing) IsHealthy(ctx context.Context, local bool, max int) error
- func (s *Syncthing) IsLocalRunningOutOfSpace(ctx context.Context) bool
- func (s *Syncthing) Monitor(ctx context.Context, disconnect chan error)
- func (s *Syncthing) MonitorStatus(ctx context.Context, disconnect chan error)
- func (s *Syncthing) Overwrite(ctx context.Context) error
- func (s *Syncthing) Ping(ctx context.Context, local bool) bool
- func (s *Syncthing) RegexMatchesLogs(fs afero.Fs, regx *regexp.Regexp) bool
- func (s *Syncthing) Restart(ctx context.Context) error
- func (s *Syncthing) Run() error
- func (s *Syncthing) SaveConfig(dev *model.Dev) error
- func (s *Syncthing) SoftTerminate() error
- func (s *Syncthing) UpdateConfig() error
- func (s *Syncthing) WaitForCompletion(ctx context.Context, reporter chan float64) error
- func (s *Syncthing) WaitForConnected(ctx context.Context) error
- func (s *Syncthing) WaitForPing(ctx context.Context, local bool, fs afero.Fs) error
- func (s *Syncthing) WaitForScanning(ctx context.Context, local bool) error
- type SystemError
- type SystemErrors
Constants ¶
const ( APIKeyHeader = "X-Api-Key" APIKeyHeaderValue = "cnd" )
const ( // DefaultRemoteDeviceID remote syncthing device ID DefaultRemoteDeviceID = "ATOPHFJ-VPVLDFY-QVZDCF2-OQQ7IOW-OG4DIXF-OA7RWU3-ZYA4S22-SI4XVAU" // LocalDeviceID local syncthing device ID LocalDeviceID = "ABKAVQF-RUO4CYO-FSC2VIP-VRX4QDA-TQQRN2J-MRDXJUC-FXNWP6N-S6ZSAAR" // DefaultFileWatcherDelay how much to wait before starting a sync after a file change DefaultFileWatcherDelay = 5 // ClusterPort is the port used by syncthing in the cluster ClusterPort = 22000 // GUIPort is the port used by syncthing in the cluster for the http endpoint GUIPort = 8384 )
Variables ¶
This section is empty.
Functions ¶
func GetDownloadURL ¶
GetDownloadURL returns the url of the syncthing package for the OS and ARCH
func GetFolderName ¶
func GetLogFile ¶
GetLogFile returns the path to the syncthing log file
func GetMinimumVersion ¶
func GetMinimumVersion() *semver.Version
func NewAPIClient ¶
NewAPIClient returns a new syncthing api client configured to call the syncthing api
func RemoveFolder ¶
RemoveFolder deletes all the files created by the syncthing instance
func ShouldUpgrade ¶
func ShouldUpgrade() bool
ShouldUpgrade returns true if syncthing should be upgraded
Types ¶
type Completion ¶
type Completion struct { Completion float64 `json:"completion"` GlobalBytes int64 `json:"globalBytes"` NeedBytes int64 `json:"needBytes"` GlobalItems int64 `json:"globalItems"` NeedItems int64 `json:"needItems"` NeedDeletes int64 `json:"needDeletes"` }
Completion represents the completion of a syncthing folder.
type Connection ¶
type Connection struct {
Connected bool `json:"connected"`
}
Connection represents syncthing connection.
type Connections ¶
type Connections struct {
Connections map[string]Connection `json:"connections"`
}
Connections represents syncthing connections.
type DataFolderErrorEvent ¶
type DataFolderErrorEvent struct {
Errors []FolderError `json:"errors"`
}
DataFolderErrorEvent represents data folder errors in syncthing.
type DataFolderSummaryEvent ¶
type DataFolderSummaryEvent struct {
Summary Status `json:"summary"`
}
DataFolderSummaryEvent represents data folder summary in syncthing.
type DataStateChangedEvent ¶
type DataStateChangedEvent struct {
State string `json:"to"`
}
DataStateChangedEvent represents data state changed in syncthing.
type DownloadProgressData ¶
type DownloadProgressData struct {
BytesTotal int64 `json:"bytesTotal"`
}
DownloadProgressData represents an the information about a DownloadProgress event
type Folder ¶
type Folder struct { Name string `yaml:"name"` LocalPath string `yaml:"localPath"` RemotePath string `yaml:"remotePath"` Overwritten bool `yaml:"-"` }
Folder represents a sync folder
type FolderError ¶
FolderError represents a folder error in syncthing.
type FolderErrorEvent ¶
type FolderErrorEvent struct { Type string `json:"type"` Data DataFolderErrorEvent `json:"data"` }
FolderErrorEvent represents folder errors in syncthing.
type FolderSummaryEvent ¶
type FolderSummaryEvent struct { Type string `json:"type"` Data DataFolderSummaryEvent `json:"data"` }
FolderSummaryEvent represents folder summary in syncthing.
type ItemEvent ¶
type ItemEvent struct { Time time.Time `json:"time"` Data map[string]map[string]DownloadProgressData `json:"data"` Id int `json:"id"` GlobalId int `json:"globalID"` }
ItemEvent represents an item event of any type in syncthing.
type StateChangedEvent ¶
type StateChangedEvent struct { Type string `json:"type"` Data DataStateChangedEvent `json:"data"` }
StateChangedEvent represents state changed in syncthing.
type Syncthing ¶
type Syncthing struct { Client *http.Client `yaml:"-"` Type string `yaml:"-"` APIKey string `yaml:"apikey"` RemoteDeviceID string `yaml:"-"` RemoteGUIAddress string `yaml:"remote"` GUIPassword string `yaml:"password"` GUIPasswordHash string `yaml:"-"` GUIAddress string `yaml:"local"` Home string `yaml:"-"` LogPath string `yaml:"-"` ListenAddress string `yaml:"-"` RemoteAddress string `yaml:"-"` RescanInterval string `yaml:"-"` Compression string `yaml:"-"` Folders []*Folder `yaml:"folders"` FileWatcherDelay int `yaml:"-"` RemoteGUIPort int `yaml:"-"` RemotePort int `yaml:"-"` LocalGUIPort int `yaml:"-"` LocalPort int `yaml:"-"` ForceSendOnly bool `yaml:"-"` ResetDatabase bool `yaml:"-"` IgnoreDelete bool `yaml:"-"` Verbose bool `yaml:"-"` // contains filtered or unexported fields }
Syncthing represents the local syncthing process.
func (*Syncthing) APICall ¶
func (s *Syncthing) APICall(ctx context.Context, url, method string, code int, params map[string]string, local bool, body []byte, readBody bool, maxRetries int) ([]byte, error)
APICall calls the syncthing API and returns the parsed json or an error
func (*Syncthing) GetCompletion ¶
func (s *Syncthing) GetCompletion(ctx context.Context, local bool, device string) (*Completion, error)
GetCompletion returns the syncthing completion
func (*Syncthing) GetFolderErrors ¶
GetFolderErrors returns the last folder errors
func (*Syncthing) GetInSynchronizationFile ¶
GetInSynchronizationFile the files syncthing
func (*Syncthing) GetPullErrors ¶
GetPullErrors returns the syncthing current pull errors
func (*Syncthing) GetSyncthingStatus ¶
func (s *Syncthing) GetSyncthingStatus(ctx context.Context, folder *Folder, local bool) (string, error)
GetSyncthingStatus returns the syncthing status
func (*Syncthing) GetSystemErrors ¶
GetSystemErrors returns the system errors identified by syncthing
func (*Syncthing) HardTerminate ¶
HardTerminate halts the background process, waits for 1s and kills the process if it is still running
func (*Syncthing) IdentifyReadinessIssue ¶
IdentifyReadinessIssue attempts to identify the issue that is preventing syncthing from being ready
func (*Syncthing) IsAllOverwritten ¶
IsAllOverwritten checks if all overwrite operations has been completed
func (*Syncthing) IsLocalRunningOutOfSpace ¶
func (*Syncthing) Monitor ¶
Monitor will send a message to disconnected if remote syncthing is disconnected for more than 10 seconds.
func (*Syncthing) MonitorStatus ¶
MonitorStatus will send a message to disconnected if there is a synchronization error
func (*Syncthing) RegexMatchesLogs ¶
RegexMatchesLogs checks if a regex matches in the syncthing logs
func (*Syncthing) SaveConfig ¶
SaveConfig saves the syncthing object in the dev home folder
func (*Syncthing) SoftTerminate ¶
SoftTerminate halts the background process
func (*Syncthing) UpdateConfig ¶
UpdateConfig updates the syncthing config file
func (*Syncthing) WaitForCompletion ¶
WaitForCompletion waits for the remote to be totally synched
func (*Syncthing) WaitForConnected ¶
WaitForConnected waits for local and remote syncthing to be connected
func (*Syncthing) WaitForPing ¶
WaitForPing waits for syncthing to be ready
type SystemError ¶
type SystemError struct {
Message string `json:"message"`
}
SystemError represents a system error in syncthing.
type SystemErrors ¶
type SystemErrors struct {
Errors []SystemError `json:"errors"`
}
SystemErrors represents a list of system errors