Documentation
¶
Index ¶
- Constants
- func CheckStrongPassword(pw string) error
- func Errorf(code, msg string) error
- type App
- func (a *App) AllowCtrlAltDel(ctx context.Context) error
- func (a *App) CheckUpdate(ctx context.Context)
- func (a *App) CloseConsole(target string)
- func (a *App) ConsoleURL(target string) (string, error)
- func (a *App) Decide(n int, allow, control, files, remember bool) error
- func (a *App) DiagnosticsReport(ui UIInfo) string
- func (a *App) Dir() string
- func (a *App) DisableUnattended(ctx context.Context) error
- func (a *App) Disconnect(id int) error
- func (a *App) EditDevice(identity, name string, control, files bool) error
- func (a *App) EnableUnattended(ctx context.Context, password string) error
- func (a *App) ExportDiagnostics(ctx context.Context, ui UIInfo, withService bool) (string, error)
- func (a *App) FinishSetup(mode, addr, lang string) error
- func (a *App) Forget(target string) error
- func (a *App) ForgetDevice(identity string) error
- func (a *App) InstallFFmpeg() error
- func (a *App) InstallUpdate(done func()) error
- func (a *App) LAN(ctx context.Context) ([]LANPeer, error)
- func (a *App) Peers(ctx context.Context, refresh bool) ([]Peer, string)
- func (a *App) Regenerate() error
- func (a *App) SavedPassword(target string, forget bool) (string, error)
- func (a *App) ServiceDisconnect(ctx context.Context, id int) error
- func (a *App) ServiceLog(ctx context.Context) ([]string, error)
- func (a *App) ServicePassword(ctx context.Context, password string) error
- func (a *App) ServiceSessions(ctx context.Context) ([]hostd.ControlSession, error)
- func (a *App) SetAlias(target, alias string) error
- func (a *App) SetAutoInstall(on bool) error
- func (a *App) SetHooks(h Hooks)
- func (a *App) SetIncoming(on bool) error
- func (a *App) SetLang(lang string) error
- func (a *App) SetOpenTabs(n int)
- func (a *App) SetOwnPassword(password string) error
- func (a *App) SetServer(mode, addr string) error
- func (a *App) SetSessionAccess(id int, control, files bool) error
- func (a *App) SetTheme(theme string) error
- func (a *App) SetUpdateAuto(on bool) error
- func (a *App) SetWake(target, mac string) error
- func (a *App) Settings() Settings
- func (a *App) SkipUpdate(version string) error
- func (a *App) Start() error
- func (a *App) State() State
- func (a *App) Stop()
- func (a *App) Subscribe() (<-chan struct{}, func())
- func (a *App) UnattendedReveal(ctx context.Context) (string, error)
- func (a *App) UnattendedState() UnattendedState
- func (a *App) UpdateLink(target, lang string) (string, error)
- func (a *App) UpdateSeen() error
- func (a *App) UpdateService(ctx context.Context) error
- func (a *App) Wake(ctx context.Context, target string) error
- type AutostartState
- type Config
- type Hooks
- type Incoming
- type LANPeer
- type PageState
- type Peer
- type Request
- type SeenDevice
- type Server
- type ServerState
- type Session
- type Settings
- type State
- type TrustedDevice
- type UI
- type UIInfo
- type UnattendedState
- type UpdateState
Constants ¶
const ( PhaseOff = "off" // incoming connections are switched off PhaseStarting = "starting" // host running, not registered yet PhaseReady = "ready" // reachable: ID (or address) and password known PhaseError = "error" // the host could not start PhaseElsewhere = "elsewhere" // another RemoHop host serves this computer (the service, a terminal) PhaseNoServer = "no_server" // ready, but without a rendezvous server: reachable by address only )
Phases of "This computer".
const AskTimeout = 60 * time.Second
AskTimeout is how long a connection request waits for an answer.
const ( // NoUpdateCheckEnv switches the check off for managed installations, // whatever the setting says. NoUpdateCheckEnv = "REMOHOP_NO_UPDATE_CHECK" )
Checking for a newer release: once shortly after start, then once a day while the app runs. Only the version file is read; the app tells the user and offers "Upgrade now" (or the download page, or the package manager's command). With "Install updates automatically" on, a copy that can upgrade itself also downloads and verifies a newer release at once and puts it in place when nobody uses the app, or when it quits (autoupdate.go).
const OfficialServer = signal.OfficialAddr
OfficialServer is the public rendezvous server the first-run wizard offers. Nothing uses it unless the user picks it.
const TelegramURL = "https://t.me/remohop"
TelegramURL is the project's Telegram channel (the website's support page and footer link to it too).
const WaitLockEnv = "REMOHOP_UPGRADE_RESTART"
WaitLockEnv tells a starting app to wait for the running one to quit (an upgrade restarting it) rather than show that one's window.
Variables ¶
This section is empty.
Functions ¶
func CheckStrongPassword ¶
CheckStrongPassword is the rule for an unattended password: it guards a computer nobody watches, so more than the host's minimum.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the desktop app's state and logic: this computer's host, the connection requests, the gateway behind the console, the address book. The UI server (server.go) shows and drives it.
func (*App) AllowCtrlAltDel ¶
AllowCtrlAltDel asks an administrator (Windows) to let the unattended service send Ctrl+Alt+Del, for a service set up before the app did it when turning unattended access on: the administrator step "sas".
func (*App) CheckUpdate ¶
CheckUpdate reads the version file now. The outcome is in the state; a newer release is downloaded at once when the app installs updates automatically.
func (*App) CloseConsole ¶
CloseConsole ends the sessions to target (its tab was closed).
func (*App) ConsoleURL ¶
ConsoleURL is the address of the console (the web client's page in the in-process gateway), connecting to target if it is not empty.
func (*App) Decide ¶
Decide answers request n. For a login, control and files are what the device may do (unknown devices are offered view only), and remember trusts it for the next time. For an access request, allow grants what it asked for.
func (*App) DiagnosticsReport ¶
DiagnosticsReport builds the report's text.
func (*App) DisableUnattended ¶
DisableUnattended removes the service (and on macOS and Linux the fixed password, so the app's own temporary password is the only one again).
func (*App) Disconnect ¶
Disconnect ends session id; id 0 ends them all.
func (*App) EditDevice ¶
EditDevice changes a remembered device: the name it is listed under and the access it gets when it connects next (a session already open keeps what it has; its switches in Connected now change that).
func (*App) EnableUnattended ¶
EnableUnattended installs the service with password.
func (*App) ExportDiagnostics ¶
ExportDiagnostics writes the report to the user's Downloads folder (or the temporary directory) and shows it in the file manager. It returns the file's path. withService adds the end of the unattended-access service's log (ServiceLog); a report is written even when that cannot be read, and says why it is not there.
func (*App) FinishSetup ¶
FinishSetup ends the first-run wizard: the server choice ("" skips it) and the language ("" follows the system).
func (*App) ForgetDevice ¶
ForgetDevice stops trusting a remembered device.
func (*App) InstallFFmpeg ¶
InstallFFmpeg downloads and installs the ffmpeg that screen sharing needs, in the background; State.FFmpeg follows it. Sessions that start after it has finished can share the screen.
func (*App) InstallUpdate ¶
InstallUpdate upgrades this copy to the latest release: downloads its archive, checks it against the release's signed SHA256SUMS (and on macOS the app's code signature), swaps the program, starts the new one and calls done, which quits this one. A release already downloaded by the automatic update is put in place at once; one being downloaded is put in place when it is ready. It refuses while anyone is connected to this computer. Progress and failure are in the state.
func (*App) LAN ¶
LAN lists the computers on the local network, this one left out. One look at a time: callers that come while it runs get its result.
func (*App) Peers ¶
Peers lists the address book. Presence comes from the rendezvous server and is asked for at most every 30 seconds unless refresh is set.
func (*App) Regenerate ¶
Regenerate replaces the temporary password.
func (*App) SavedPassword ¶
SavedPassword is the password saved for target (the console saves one when the user asks it to remember a host that does not pair), for the page to show; with forget it is removed instead.
func (*App) ServiceDisconnect ¶
ServiceDisconnect ends a session of the service (0: all of them), elevated on Windows.
func (*App) ServiceLog ¶
ServiceLog returns the last lines of the unattended-access service's log, redacted. On Windows the log (service.log in %ProgramData%\RemoHop) is readable by administrators only, so an administrator step reads it (one UAC prompt). On macOS and Linux the service is the user's own, and its log is read here (`remohop service logs --user`).
func (*App) ServicePassword ¶
ServicePassword changes the unattended password, elevated on Windows.
func (*App) ServiceSessions ¶
ServiceSessions lists the sessions of the unattended-access service. On Windows the service's state is the administrators' only, so this asks for an administrator (UAC) and also refreshes the service's ID.
func (*App) SetAutoInstall ¶
SetAutoInstall switches "Install updates automatically" on or off. On downloads a newer release already known at once; off removes one downloaded and waiting.
func (*App) SetIncoming ¶
SetIncoming switches incoming connections on or off. Off ends every incoming session.
func (*App) SetOpenTabs ¶
SetOpenTabs records how many computers are open in the page's tabs.
func (*App) SetOwnPassword ¶
SetOwnPassword makes password the one for incoming connections, kept across starts, instead of a new temporary one at every start; "" goes back to temporary passwords. Every connection still asks. The rule is hostd.CheckOwnPassword.
func (*App) SetServer ¶
SetServer picks the rendezvous server: "official", "custom" with addr, or "none" (connect by address only).
func (*App) SetSessionAccess ¶
SetSessionAccess changes what connected session id may do.
func (*App) SetUpdateAuto ¶
SetUpdateAuto switches the daily check on or off.
func (*App) SetWake ¶
SetWake saves (or with mac "" removes) the Wake-on-LAN address of a saved host.
func (*App) SkipUpdate ¶
SkipUpdate stops showing the notice for version (the next one shows again). An empty version shows it again.
func (*App) Start ¶
Start starts the gateway behind the console and, if incoming connections are on, this computer's host.
func (*App) Stop ¶
func (a *App) Stop()
Stop ends every incoming session, takes the host offline and closes the gateway (and with it the connections to other computers).
func (*App) Subscribe ¶
func (a *App) Subscribe() (<-chan struct{}, func())
Subscribe returns a channel that receives whenever the state may have changed, and a function that ends the subscription.
func (*App) UnattendedReveal ¶
UnattendedReveal returns the unattended-access password, which the user asked to see. On Windows it is in the service's settings, which only administrators can read, so this asks for one (UAC) and also refreshes the service's ID; on macOS and Linux it is in the user's own settings.
func (*App) UnattendedState ¶
func (a *App) UnattendedState() UnattendedState
UnattendedState reports unattended access (the service is asked at most every few seconds).
func (*App) UpdateLink ¶
UpdateLink is the page to open for target: "download" (the website's download page in lang) or "notes" (the latest release's page).
func (*App) UpdateSeen ¶
UpdateSeen: the page told the user "Updated to ...".
func (*App) UpdateService ¶
UpdateService brings the unattended-access service to this program's version. Windows: the administrator step "update" (one UAC prompt); macOS and Linux: a restart of the user's service.
type AutostartState ¶
AutostartState is "start RemoHop when I sign in".
type Config ¶
type Config struct {
// Dir is the remohop config directory; empty means the default.
Dir string
// Signal overrides the configured rendezvous server (--signal).
Signal string
Logger *slog.Logger
// AskTimeout defaults to the package's AskTimeout.
AskTimeout time.Duration
// UIOrigin is the origin of the app's own page, which shows the
// console of each host in a frame (web.Config.FrameAncestor).
UIOrigin string
// Seams for tests.
Host func(*hostd.Config)
Gateway func(*web.Config)
NoSignal bool
Now func() time.Time
// LANBrowse replaces the look at the local network (dial.DiscoverLAN).
LANBrowse func(ctx context.Context, dir string) ([]dial.LANHost, error)
// The update check (update.go): the version file's address (empty:
// update.URL), the HTTP client, the first check's delay and the
// interval. NoUpdateCheck leaves the check out altogether.
UpdateURL string
UpdateClient *http.Client
UpdateDelay time.Duration
UpdateEvery time.Duration
NoUpdateCheck bool
// One-click upgrades: the release download address (update.Fetcher
// Base), the trusted keys and what restarts the program; the defaults
// are GitHub, update.Keys and restartInto.
UpdateBase string
UpdateKeys []ed25519.PublicKey
UpdateRestart func(update.Plan) error
UpdatePlan *update.Plan // what an upgrade replaces (tests); default: this program
// Installing updates automatically (autoupdate.go): how long nothing
// must go on before a downloaded release goes in place (default a
// minute; negative: at once) and how often the app looks (a minute).
UpdateIdle time.Duration
UpdateIdlePoll time.Duration
// FFmpeg finds and installs the ffmpeg screen sharing needs; nil
// means the real one.
FFmpeg *ffmpeg.Installer
}
Config configures an App.
type Hooks ¶
type Hooks struct {
// Request: a connection request arrived (bring the window up).
Request func(r Request)
// Sessions: who is connected changed (the "being controlled" banner
// and the tray). names is empty when nobody is.
Sessions func(names []string)
// Lang: the user picked a language.
Lang func(lang string)
}
Hooks are how the window shell learns what needs the user's attention. They run on the App's goroutines and must not block.
type Incoming ¶
type Incoming struct {
On bool `json:"on"`
Phase string `json:"phase"`
ErrorCode string `json:"error_code,omitempty"`
Error string `json:"error,omitempty"`
ID string `json:"id,omitempty"`
OtherID string `json:"other_id,omitempty"`
Password string `json:"password,omitempty"`
// PasswordMode: "temporary" (new at every start, "New" replaces it)
// or "fixed" (the user's own, SetOwnPassword).
PasswordMode string `json:"password_mode"`
Online bool `json:"online"`
Transport string `json:"transport,omitempty"`
Addresses []string `json:"addresses,omitempty"`
Waited int `json:"waited,omitempty"`
Device string `json:"device,omitempty"`
Requests []Request `json:"requests"`
Sessions []Session `json:"sessions"`
}
Incoming is "This computer".
type LANPeer ¶
type LANPeer struct {
Name string `json:"name"`
Addr string `json:"addr"`
ID string `json:"id,omitempty"`
Fingerprint string `json:"fingerprint"`
// Saved is how the address book has it (an alias, an ID or an
// address), if it has it with this key; Paired, if a pairing is saved.
Saved string `json:"saved,omitempty"`
Paired bool `json:"paired,omitempty"`
// Conflict is the saved computer (an ID or address) it claims to be
// although its key is not the one saved for it.
Conflict string `json:"conflict,omitempty"`
}
LANPeer is a computer that answered discovery on the local network (internal/lan). What it says about itself is a hint: connecting to Addr checks its key like any connection.
type PageState ¶
type PageState struct {
State
UI UIInfo `json:"ui"`
Autostart AutostartState `json:"autostart"`
Unattended UnattendedState `json:"unattended"`
// Smoke is the screen the smoke test wants shown (see smoke.go).
Smoke string `json:"smoke,omitempty"`
}
PageState is State plus what the page needs about its surroundings.
type Peer ¶
type Peer struct {
Target string `json:"target"`
Alias string `json:"alias,omitempty"`
Name string `json:"name,omitempty"`
Platform string `json:"platform,omitempty"`
Account bool `json:"account,omitempty"`
Login string `json:"login"`
Presence string `json:"presence"`
LastSeen *time.Time `json:"last_seen,omitempty"`
// Wake: a Wake-on-LAN address is saved for it.
Wake bool `json:"wake,omitempty"`
}
Peer is an address-book entry: a host this computer connected to or paired with, or a device of its account.
type Request ¶
type Request struct {
N int `json:"n"`
Name string `json:"name,omitempty"`
Device string `json:"device,omitempty"`
Identity string `json:"identity"`
From string `json:"from,omitempty"`
Auth string `json:"auth"`
Left int `json:"left"`
// FirstSeen: this device never asked before.
FirstSeen bool `json:"first_seen"`
// Access is set for a connected session that asks for more ("input",
// "file"); Session is its ID.
Access []string `json:"access,omitempty"`
Session int `json:"session,omitempty"`
// Action is set when a session on a grant asks to run a command or
// change a file (hostd.Approval.Action), on one line with control
// characters escaped; Grant is the grant's name.
Action string `json:"action,omitempty"`
Grant string `json:"grant,omitempty"`
}
Request is a connection request as the page shows it.
type SeenDevice ¶
type SeenDevice struct {
Identity string `json:"identity"`
First time.Time `json:"first"`
Last time.Time `json:"last"`
}
SeenDevice is a device that asked to connect before.
type Server ¶
Server is the app's UI server: the page, its API and its event stream.
func (*Server) Origin ¶
Origin is the page's origin (http://127.0.0.1:PORT).
type ServerState ¶
type ServerState struct {
Mode string `json:"mode"` // official, custom, none
Addr string `json:"addr,omitempty"`
// Chosen: the user made this choice (here, in quick support or with
// `remohop config`); otherwise none is only the absence of one.
Chosen bool `json:"chosen"`
}
ServerState is the rendezvous server choice.
type Session ¶
type Session struct {
ID int `json:"id"`
Label string `json:"label"`
Device string `json:"device,omitempty"`
Identity string `json:"identity"`
From string `json:"from,omitempty"`
Path string `json:"path"`
Seconds int `json:"seconds"`
Control bool `json:"control"`
Files bool `json:"files"`
Trusted bool `json:"trusted"`
}
Session is a connected device.
type Settings ¶
type Settings struct {
// Setup is true once the first-run wizard is done (or skipped).
Setup bool `json:"setup"`
// Lang is "zh", "en" or "" (follow the system).
Lang string `json:"lang,omitempty"`
// Theme is "light", "dark" or "" (follow the system).
Theme string `json:"theme,omitempty"`
// Incoming: others may connect to this computer while the app runs
// (every connection still asks). Off until the user turns it on.
Incoming bool `json:"incoming"`
// Trusted are the devices the user chose to remember: their next
// logins are let in with the access chosen then, without a question,
// while incoming connections are on.
Trusted []TrustedDevice `json:"trusted,omitempty"`
// ServiceID is the Windows unattended-access service's ID, as the
// elevated steps last found it (its state is administrators' only).
ServiceID string `json:"service_id,omitempty"`
// ServiceFFmpeg is the ffmpeg that service uses for screen sharing,
// as the elevated steps last found it; empty when none was found or
// nobody looked yet.
ServiceFFmpeg string `json:"service_ffmpeg,omitempty"`
// Seen are the devices that asked before, so a request can say
// whether this one is new. Oldest first; bounded.
Seen []SeenDevice `json:"seen,omitempty"`
// UpdateCheck: the app looks once a day for a newer release. Unset
// means on.
UpdateCheck *bool `json:"update_check,omitempty"`
// SkipVersion is a release the user chose not to be told about again.
SkipVersion string `json:"skip_version,omitempty"`
// AutoInstall: a newer release that a check finds is downloaded and
// verified at once and put in place when nobody uses the app (or at
// quit). Off unless the user turns it on.
AutoInstall bool `json:"auto_install,omitempty"`
// UpdatedTo is the release the app last put in place of itself, until
// that version has started and told the user ("Updated to ...").
UpdatedTo string `json:"updated_to,omitempty"`
// UpdatedAt is when it did: a background service started before then
// (macOS, Linux) still runs the old program.
UpdatedAt time.Time `json:"updated_at,omitzero"`
// OwnPassword is the password the user chose for incoming connections
// instead of a new temporary one at every start (as typed; every
// connection still asks). Not the command line's host-password, which
// the app's host ignores, and not unattended access's.
OwnPassword string `json:"own_password,omitempty"`
}
Settings are the app's choices, kept across runs.
type State ¶
type State struct {
Version string `json:"version"`
Setup bool `json:"setup"`
Lang string `json:"lang"`
Theme string `json:"theme"`
Server ServerState `json:"server"`
Incoming Incoming `json:"incoming"`
Trusted []TrustedDevice `json:"trusted"`
Timeout int `json:"ask_timeout"`
Update UpdateState `json:"update"`
// FFmpeg: whether screen sharing lacks ffmpeg, and its one-click
// install (InstallFFmpeg).
FFmpeg ffmpeg.UIState `json:"ffmpeg"`
}
State is everything the page shows.
type TrustedDevice ¶
type TrustedDevice struct {
Identity string `json:"identity"`
Name string `json:"name,omitempty"`
Control bool `json:"control"`
Files bool `json:"files"`
Added time.Time `json:"added"`
}
TrustedDevice is a remembered device.
type UI ¶
type UI interface {
// Show brings the main window up.
Show()
// Hide puts it away (into the tray).
Hide()
// PopOut shows url (a host's console) in a window of its own.
PopOut(url, title string) error
// Quit ends the app.
Quit()
// Info describes the shell.
Info() UIInfo
}
UI is what the page may ask of the window around it.
type UIInfo ¶
type UIInfo struct {
// Native: a native window (WebView2, WKWebView, WebKitGTK); otherwise
// a browser window.
Native bool `json:"native"`
Engine string `json:"engine,omitempty"`
// Tray: closing the window keeps the app in the tray.
Tray bool `json:"tray"`
Platform string `json:"platform"`
}
UIInfo describes the window shell to the page.
type UnattendedState ¶
type UnattendedState struct {
Available bool `json:"available"`
Installed bool `json:"installed"`
Running bool `json:"running"`
Admin bool `json:"needs_admin"`
ID string `json:"id,omitempty"`
Busy bool `json:"busy,omitempty"`
Error string `json:"error,omitempty"`
// StatusError is why the service's status could not be read (shown in
// the diagnostic report only).
StatusError string `json:"status_error,omitempty"`
// Outdated is the older version the Windows service still runs after
// the app was upgraded: its copy of the program in Program Files is
// replaced only by an administrator (UpdateService).
Outdated string `json:"outdated,omitempty"`
// CtrlAltDel: the Windows policy lets the service send Ctrl+Alt+Del
// (AllowCtrlAltDel asks an administrator to allow it).
CtrlAltDel bool `json:"ctrl_alt_del,omitempty"`
}
UnattendedState is shown under "This computer".
type UpdateState ¶
type UpdateState struct {
// Auto: the app checks by itself (the setting).
Auto bool `json:"auto"`
// Managed: switched off by REMOHOP_NO_UPDATE_CHECK.
Managed bool `json:"managed"`
Checking bool `json:"checking"`
Checked int64 `json:"checked,omitempty"` // Unix milliseconds of the last answer
Current string `json:"current"`
Latest string `json:"latest,omitempty"`
// Available: Latest is newer than this copy.
Available bool `json:"available"`
// Skipped: the user chose to skip Latest.
Skipped bool `json:"skipped"`
Error string `json:"error,omitempty"`
Method update.Method `json:"method"`
// CanInstall: "Upgrade now" can replace this copy (a download from
// the website, in a place the user can write, with trusted update
// keys in this build).
CanInstall bool `json:"can_install"`
// Stage is the upgrade under way: verifying, downloading (Percent),
// installing, restarting; InstallError the last one's failure.
Stage string `json:"stage,omitempty"`
Percent int `json:"percent"`
InstallError string `json:"install_error,omitempty"`
// AutoInstall: "Install updates automatically" is on (the setting).
AutoInstall bool `json:"auto_install"`
// AutoBlock says why this copy cannot install updates by itself,
// whatever the setting: "managed" (REMOHOP_NO_UPDATE_CHECK),
// "package" (a package manager installed it: Method says which),
// "readonly" (the user cannot write where it is), "unsupported"
// (quick support, an unknown system) or "keys" (no update keys in
// this build). Empty: it can.
AutoBlock string `json:"auto_block,omitempty"`
// Ready is the release downloaded, verified and waiting to be put in
// place; Waiting says what it waits for (an activity of
// activity.why), empty when nothing holds it.
Ready string `json:"ready,omitempty"`
Waiting string `json:"waiting,omitempty"`
// AutoError is why the last automatic download failed (it is tried
// again at the next check).
AutoError string `json:"auto_error,omitempty"`
// Updated: this copy is the release the app just put in place of the
// old one, and the user has not been told yet.
Updated string `json:"updated,omitempty"`
}
UpdateState is the update check as the page shows it.