Help us shape the future of Go! Take the 2026 Go Developer Survey

clientdl

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 15 Imported by: 0

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

View Source
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

View Source
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.

View Source
var ErrUnavailable = errors.New("client download unavailable")

ErrUnavailable is returned when no release (or no such asset) is known.

View Source
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.

View Source
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. A shift that leaves "--" or makes the name longer than maxFileName is skipped, and every shift is tried before ErrFileName is returned: the result is never a cut name or one that does not read back as the settings it carries.

The relay is deliberately left out of the name. hbbs hands every client the relay to use when it answers a connection attempt, so a client that has none of its own works the same — while carrying it costs around 48 characters of a budget that decides whether the installer can be offered at all. The relay is still shown on the Install client and share pages, and is part of the config string for a manual import; only the file name goes without it.

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.

func (*Release) Asset

func (r *Release) Asset(id string) (Asset, bool)

Asset returns the asset of a platform.

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

func New(dir, version, userAgent string) *Service

New returns a Service for the official repository. dir keeps installer copies; version pins a release ("" = latest).

func (*Service) Open

func (s *Service) Open(ctx context.Context, id string) (*os.File, Asset, error)

Open returns a verified local copy of a release asset, downloading it on first use (size and, when GitHub publishes one, SHA-256 checked). Copies of other versions are removed after a new version is stored.

func (*Service) Release

func (s *Service) Release(ctx context.Context) Result

Release returns the cached lookup, refreshing it first when it is stale. Concurrent callers wait for one in-flight request; a cancelled caller does not abort the shared refresh.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL