Documentation
¶
Overview ¶
Package clientdl offers the official RustDesk clients set up for this server. It looks up a RustDesk release on GitHub (cached like updatecheck: 6 h, failures retried after 30 min while the last good answer is kept) and keeps verified copies of the Windows installers, which the panel serves under a file name that carries the server settings.
Index ¶
Constants ¶
const ( DefaultAPI = "https://api.github.com" DefaultWeb = "https://github.com" DefaultRepo = "rustdesk/rustdesk" DefaultTTL = 6 * time.Hour DefaultRetry = 30 * time.Minute // MaxAssetSize bounds a downloaded installer. MaxAssetSize = 300 << 20 )
Defaults of a Service.
Variables ¶
var ErrFileName = errors.New("server settings do not fit into a Windows file name")
ErrFileName is returned when the settings cannot be put into a file name.
ErrUnavailable is returned when no release (or no such asset) is known.
var Platforms = []struct{ ID, Pattern string }{
{"windows-x64", `rustdesk-%s-x86_64\.exe`},
{"windows-x64-msi", `rustdesk-%s-x86_64\.msi`},
{"windows-arm64", `rustdesk-%s-aarch64\.exe`},
{"windows-arm64-msi", `rustdesk-%s-aarch64\.msi`},
{"macos-arm64", `rustdesk-%s-aarch64\.dmg`},
{"macos-x64", `rustdesk-%s-x86_64\.dmg`},
{"linux-deb-x64", `rustdesk-%s-x86_64\.deb`},
{"linux-deb-arm64", `rustdesk-%s-aarch64\.deb`},
{"linux-rpm-x64", `rustdesk-%s(-0)?\.x86_64\.rpm`},
{"linux-rpm-arm64", `rustdesk-%s(-0)?\.aarch64\.rpm`},
{"linux-appimage-x64", `rustdesk-%s-x86_64\.AppImage`},
{"linux-appimage-arm64", `rustdesk-%s-aarch64\.AppImage`},
{"android-universal", `rustdesk-%s-universal-signed\.apk`},
{"android-arm64", `rustdesk-%s-aarch64-signed\.apk`},
{"android-armv7", `rustdesk-%s-armv7-signed\.apk`},
{"android-x64", `rustdesk-%s-x86_64-signed\.apk`},
}
Platforms are the assets offered, by ID, with their file name patterns (%s: the version). Official release names since RustDesk 1.2.
var VersionRe = regexp.MustCompile(`^\d{1,3}\.\d{1,3}\.\d{1,3}$`)
VersionRe matches the RustDesk release tags this package accepts ("1.4.2").
Functions ¶
func WindowsFileName ¶
func WindowsFileName(s ServerSettings) (string, error)
WindowsFileName returns the name under which the official Windows client applies s on its own when started (and keeps them when it installs): "rustdesk-licensed-<config string>.exe", the config string being RustDesk's reversed URL-safe base64 of the settings JSON. RustDesk splits the name at "--", which the encoding of non-ASCII JSON (an IDN host name) can contain; such encodings are avoided by shifting the base64 alignment with leading JSON whitespace, which RustDesk's parser skips.
Types ¶
type Asset ¶
type Asset struct {
// ID names the platform, e.g. "windows-x64" (see Platforms).
ID string `json:"id"`
Name string `json:"name"`
Size int64 `json:"size"`
// URL is GitHub's download URL of the asset.
URL string `json:"url"`
// SHA256 is GitHub's digest of the asset (hex); "" when GitHub has none.
SHA256 string `json:"sha256,omitempty"`
}
Asset is one downloadable client of a release.
type Release ¶
type Release struct {
Version string
URL string
PublishedAt time.Time
Assets []Asset // in Platforms order
}
Release is a RustDesk release with the assets of known platforms.
type Result ¶
type Result struct {
// Release is nil until a lookup succeeded.
Release *Release
CheckedAt time.Time
// Err is the last attempt's error ("" when it succeeded).
Err string
}
Result is the cached state of the release lookup.
type ServerSettings ¶
type ServerSettings struct {
Host string `json:"host,omitempty"`
Relay string `json:"relay,omitempty"`
Key string `json:"key,omitempty"`
API string `json:"api,omitempty"`
}
ServerSettings are what a RustDesk client needs to use this server.
func ParseWindowsFileName ¶
func ParseWindowsFileName(name string) (ServerSettings, bool)
ParseWindowsFileName reads settings back from a file name the way the RustDesk client does (src/custom_server.rs, get_custom_server_from_string, "licensed" form, unsigned config). It exists to check WindowsFileName.
type Service ¶
type Service struct {
API string // GitHub API base URL
Web string // GitHub base URL: assets must come from <Web>/<Repo>/releases/download/
Repo string // owner/name
Version string // pinned release tag; "" = the latest release
UserAgent string
Client *http.Client // API requests
Download *http.Client // asset downloads
// Dir keeps downloaded installers (<Dir>/<version>/<asset name>).
Dir string
TTL time.Duration
Retry time.Duration
Now func() time.Time
// contains filtered or unexported fields
}
Service looks up releases and keeps verified installer copies. The zero value is not usable; use New.
func New ¶
New returns a Service for the official repository. dir keeps installer copies; version pins a release ("" = latest).