Documentation
¶
Index ¶
- Constants
- func CopyFile(from, to string) error
- func FileExists(name string) bool
- func GetBinaryName() string
- func GetDir(path string) string
- func GetDownloadURL(os, arch, version string) (string, error)
- func IsSubPathFolder(path string, paths []string) (bool, error)
- func NewAPIClient() *http.Client
- func Stop(pid int, force bool) error
- type Folder
- type Ignores
- type Syncthing
- func (s *Syncthing) APICall(ctx context.Context, url, method string, code int, params map[string]string, ...) ([]byte, error)
- func (s *Syncthing) GetLocalConfigXML() ([]byte, error)
- func (s *Syncthing) GetRemoteConfigXML() ([]byte, error)
- func (s *Syncthing) Run(ctx context.Context) error
- func (s *Syncthing) UpdateConfig() error
- type SyncthingInstaller
Constants ¶
View Source
const ( SyncSecretName = "nocalhost-syncthing-secret" RemoteHome = "/var/syncthing/config" Bind = "127.0.0.1" Nocalhost = "nocalhost" LogFile = "syncthing.log" IgnoredFIle = ".nhignore" // Use to access syncthing API DefaultAPIKey = "nocalhost" // DefaultRemoteDeviceID remote syncthing ID DefaultRemoteDeviceID = "MDPJNTF-OSPJC65-LZNCQGD-3AWRUW6-BYJULSS-GOCA2TU-5DWWBNC-TKM4VQ5" // DefaultFileWatcherDelay how much to wait before starting a sync after a file change DefaultFileWatcherDelay = 5 // may result bug due to syncthing config changing DefaultFolderName = "nh-1" // 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 EnableParseFromGitIgnore = "#enableParseFromGitIgnore" DisableParseFromGitIgnore = "#disableParseFromGitIgnore" )
Variables ¶
This section is empty.
Functions ¶
func FileExists ¶
func GetBinaryName ¶
func GetBinaryName() string
func GetDownloadURL ¶
func IsSubPathFolder ¶
IsSubPathFolder checks if a sync folder is a subpath of another sync folder
func NewAPIClient ¶
NewAPIClient returns a new syncthing api client configured to call the syncthing api
Types ¶
type Folder ¶
type Folder struct {
Name string `yaml:"name"`
LocalPath string `yaml:"localPath"`
RemotePath string `yaml:"remotePath"`
Retries int `yaml:"-"`
SentStIgnore bool `yaml:"-"`
}
Folder represents a sync folder
type Ignores ¶
type Ignores struct {
Ignore []string `json:"ignore"`
}
Ignores represents the .stignore file
type Syncthing ¶
type Syncthing struct {
APIKey string `yaml:"apikey"`
GUIPassword string `yaml:"password"`
GUIPasswordHash string `yaml:"-"`
BinPath string `yaml:"-"`
Client *http.Client `yaml:"-"`
Folders []*Folder `yaml:"folders"`
FileWatcherDelay int `yaml:"-"`
ForceSendOnly bool `yaml:"-"`
GUIAddress string `yaml:"local"`
LocalHome string `yaml:"-"`
RemoteHome string `yaml:"-"`
LogPath string `yaml:"-"`
ListenAddress string `yaml:"-"`
RemoteAddress string `yaml:"-"`
RemoteDeviceID string `yaml:"-"`
RemoteGUIAddress string `yaml:"remote"`
RemoteGUIPort int `yaml:"-"`
RemotePort int `yaml:"-"`
LocalGUIPort int `yaml:"-"`
LocalPort int `yaml:"-"`
Type string `yaml:"-"`
IgnoreDelete bool `yaml:"-"`
PortForwardBackGroundPid int `yaml:"-"`
SyncthingBackGroundPid int `yaml:"-"`
RescanInterval string `yaml:"-"`
// resolve ignore/sync from pattern
SyncedPattern []string `yaml:"-"`
IgnoredPattern []string `yaml:"-"`
// resolve ignore/sync from gitignore
EnableParseFromGitIgnore bool `yaml:"-"`
// contains filtered or unexported fields
}
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) GetLocalConfigXML ¶
func (*Syncthing) GetRemoteConfigXML ¶
func (*Syncthing) UpdateConfig ¶
UpdateConfig updates the syncthing config file
type SyncthingInstaller ¶
func NewInstaller ¶
func NewInstaller(binPath string, version string, commitId string) *SyncthingInstaller
func (*SyncthingInstaller) InstallIfNeeded ¶
func (s *SyncthingInstaller) InstallIfNeeded() (bool, error)
the return val bool is only for test case, it shows that whether download again
Click to show internal directories.
Click to hide internal directories.