Documentation
¶
Overview ¶
Package updatechecker finds newer gitsss releases and verifies downloaded packages.
Index ¶
- Constants
- func GetNeedUpdate(ctx context.Context) bool
- func GetRemoteVersion(ctx context.Context) string
- func GitSSSUpdateChecker(ctx context.Context, httpEndpoint string) error
- func MirrorText(mirrors []string) string
- func ParseMirrors(text string) ([]string, error)
- func SaveReport(ctx context.Context, report Report) error
- func SaveSettings(settings Settings) error
- func UpdateRemoteVersion(ctx context.Context, version string) (err error)
- type Asset
- type CheckerState
- type DownloadResult
- type Options
- type Probe
- type Report
- type ReportState
- type Settings
Constants ¶
const ( // DefaultGitHubRepo is the release source checked by the CLI and admin UI. DefaultGitHubRepo = "neko233-com/gitsss" // DefaultMirror is a public prefix proxy that stays reachable from many // networks in mainland China when api.github.com does not. Replace it // with an internal mirror when one exists. DefaultMirror = "https://ghfast.top" )
Variables ¶
This section is empty.
Functions ¶
func GetNeedUpdate ¶
GetNeedUpdate returns true whether a newer version of gitsss is available.
func GetRemoteVersion ¶
GetRemoteVersion returns the current remote version (or currently installed version if fail to fetch from DB)
func GitSSSUpdateChecker ¶
GitSSSUpdateChecker records the version from an explicitly configured manifest endpoint. An empty endpoint performs no network request, including when the cron task is enabled.
func MirrorText ¶ added in v1.2.0
MirrorText renders mirrors one per line for the admin form.
func ParseMirrors ¶ added in v1.2.0
ParseMirrors splits a comma, semicolon, or newline separated mirror list.
func SaveReport ¶ added in v1.2.0
SaveReport stores the latest check for the admin page.
func SaveSettings ¶ added in v1.2.0
SaveSettings writes mirror settings back to app.ini and the live config. HTTP_ENDPOINT is preserved.
Types ¶
type Asset ¶ added in v1.2.0
type Asset struct {
Name string `json:"name"`
URL string `json:"url"`
Size int64 `json:"size"`
SHA256 string `json:"sha256,omitempty"`
}
Asset is one file attached to a gitsss release.
type CheckerState ¶
type CheckerState struct {
LatestVersion string
}
CheckerState stores the remote version from the JSON endpoint
func (*CheckerState) Name ¶
func (r *CheckerState) Name() string
Name returns the name of the state item for update checker
type DownloadResult ¶ added in v1.2.0
type DownloadResult struct {
Report Report `json:"report"`
Asset string `json:"asset"`
Output string `json:"output"`
SHA256 string `json:"sha256"`
Bytes int64 `json:"bytes"`
Verified bool `json:"verified"`
Source string `json:"source"`
}
DownloadResult is the machine-readable result of a verified package download.
type Options ¶ added in v1.2.0
type Options struct {
HTTPEndpoint string
CheckGitHub bool
GitHubRepo string
Mirrors []string
ProbeTimeout time.Duration
DownloadTimeout time.Duration
CurrentVersion string
}
Options selects where a check looks for the latest gitsss release. An empty mirror list uses DefaultMirror when GitHub checking is enabled. Direct api.github.com is always probed alongside those mirrors.
func OptionsFromConfig ¶ added in v1.2.0
func OptionsFromConfig() Options
OptionsFromConfig reads the update checker section from the loaded config. CHECK_GITHUB stays false when the key is absent, so startup does not contact GitHub.
type Probe ¶ added in v1.2.0
type Probe struct {
Name string `json:"name"`
Kind string `json:"kind"`
URL string `json:"url"`
Mirror string `json:"mirror,omitempty"`
OK bool `json:"ok"`
LatencyMS int64 `json:"latency_ms"`
StatusCode int `json:"status_code,omitempty"`
Error string `json:"error,omitempty"`
Selected bool `json:"selected"`
}
Probe is one availability and latency sample.
type Report ¶ added in v1.2.0
type Report struct {
OK bool `json:"ok"`
Error string `json:"error,omitempty"`
CurrentVersion string `json:"current_version,omitempty"`
LatestVersion string `json:"latest_version,omitempty"`
NeedUpdate bool `json:"need_update"`
HTMLURL string `json:"html_url,omitempty"`
ManifestSource string `json:"manifest_source,omitempty"`
ManifestKind string `json:"manifest_kind,omitempty"`
ManifestTrusted bool `json:"manifest_trusted"`
SelectedMirror string `json:"selected_mirror,omitempty"`
Note string `json:"note,omitempty"`
DownloadOrder []string `json:"download_order,omitempty"`
Assets []Asset `json:"assets,omitempty"`
Probes []Probe `json:"probes"`
CheckedAt string `json:"checked_at"`
}
Report is the machine-readable result of an update check.
type ReportState ¶ added in v1.2.0
type ReportState struct {
Report Report `json:"report"`
}
ReportState stores the last check in the application state table.
func (*ReportState) Name ¶ added in v1.2.0
func (r *ReportState) Name() string
Name returns the app-state key for the last update report.