This document specifies the HTTP surface of the server for other devices
(mygo/pair, run by the application when its settings say so): the contract that the Docker
gateway (mygo/gateway) and the phone app (mygo/phone) program against. The server serves
the API only. The web interface is a single page that the gateway serves (see
the web interface). The implementation is mygo/pair/pair.go (Server),
host.go (Host), web.go and webapi.go.
- A pairing link is a one-time URL
/auth/connect/<token>. Tokens work once and expire after 5 minutes. Opening one pairs the browser: the server answers204 No ContentwithSet-Cookie: vfox-plus-session=<session>(Secure,HttpOnly,SameSite=Lax) and no redirect, since it serves no page to go on to (see the web interface). The application makes the links: Pair a phone in its settings, for the devices of the network, which copy the link to the gateway or scan its code. - A session cookie authenticates every route except
/auth/connect/*. The sessions of the server for other devices expire after 24 hours. Expired sessions answer 401 and must pair again. - State-changing routes additionally refuse the cross-origin requests of
browsers, with the cross-origin protection of
net/http: a request whoseSec-Fetch-Siteis notsame-origin(ornone), or, without that header, whoseOriginnames another host than the one asked, answers 403. Requests with neither header (like curl) are allowed through with the session cookie. - The remote server is the one server of the builds that are released (the end-to-end
build also starts a loopback server for the tools), and it shares the application state with
nothing else (see the architecture). It listens on
0.0.0.0on the port of the settingwebPort(8369 by default), over HTTPS only, whilewebRemoteis on. Turning the setting off closes the server and every connection it holds; the sessions end with it. Pairing does not survive a restart of the application. - The web interface can read and change how other devices connect and whether the
application stays up without its window, and can quit the application (
/api/web,/api/quit).
| Method and path | Auth | Meaning |
|---|---|---|
GET /auth/connect/<token> |
token | Consume the token, set the session cookie, answer 204 No Content. Invalid, reused or expired tokens answer 403. |
GET /api/token |
session | Mint another one-time pairing link for a second browser: {url} rendered with the caller's host. |
The pairing code of the settings is the pairing link of the remote server, with an
address of the computer on a network in it (Host.RemoteLink), as a QR code
(mygo/pair.QRMatrix; the page of the web interface gets it as an SVG from
POST /api/web/pairing), so that the phone app reads it from a photo or a picture instead of typing.
Other devices are off by default: the settings ask for a confirmation before they
open the computer to the network.
The server serves no page: the web interface is a single embedded page, with no
external requests and all assets inlined, and the gateway serves it at GET /app
(see the gateway). It follows the design system
(seed colour, shapes, motion) with inlined SVG icons, and calls the routes of this
document. This server answers 404 for /, /app and /manifest.webmanifest.
The web app manifest of the page is the gateway's too: GET /manifest.webmanifest on
the gateway (no session) serves application/manifest+json, Cache-Control: no-cache:
name and short_name vfox+, id and start_url /app, scope /, display
standalone, the colours of the page, and one icon, the favicon as an SVG data URI of
the size any. Chromium browsers offer to install the web interface as an application
with it. It needs no session because it names only the application and its start page,
and because a browser may process a manifest without the page that links it (the
specification mentions installing from a sync service), and so without the session cookie.
GET /api/inventory (session) answers the installed SDKs, the
registry and the vfox configuration in one fetch. Each section carries its
own loading and error state, like the desktop interface:
{
"vfox": {"availability": "available|missing|broken", "version": "1.1.0", "error": ""},
"installed": {"loading": false, "value": [{"Name": "nodejs", "Versions": ["24.11.1"], "Current": "24.11.1", "HasCurrent": true}]},
"registry": {"loading": false, "value": [{"Name": "nodejs", "Homepage": "https://…", "Official": true}]},
"config": {"loading": false, "value": [{"Key": "proxy.enable", "Value": "false"}]},
"complete": true
}Field names follow the Go models (core.InstalledSdk, core.AvailablePlugin,
core.ConfigEntry); complete reports whether all three sections finished
within the load timeout (2 minutes).
| Method and path | Meaning |
|---|---|
GET /api/sdks/<name>/info |
Plugin metadata (core.PluginInfo): {Name, Version, Homepage, InstallPath, Description}. Unknown plugins answer 404; vfox failures answer 502. |
GET /api/sdks/<name>/versions[?search=<value>] |
Installable versions (core.AvailableVersion[]): {Version, Note, HasNote, Additions: [{Name, Version}], Installed}. Without search the plugin lists the choice that the user made (what PUT .../search kept; the default of the plugin when none was made). search is the value of a choice of the plugin's profile (for java the short name of a distribution, or all) and becomes the argument of vfox search for this request only; an unknown value, and any value for a plugin without such a choice, answer 400. For a plugin with a profile each version also has parts (the name taken apart: {version, source: {value, name: {en, zh}}, flavors}) and facets ({<facet id>: [values]}, left out when empty), so that the page needs no rules of its own. Searches may take seconds; timeouts answer 504. |
GET /api/sdks/<name>/profile |
The profile of the plugin, see below. Plugins without one answer 404. |
PUT /api/sdks/<name>/search |
Choose what the plugin lists: {value}, the value of a choice of its profile; the default of the plugin is a choice too, and an empty value means it. The application keeps the choice in the settings, so that it is what the plugin lists from now on, in every interface and after a restart. Answers {value}, the choice now. An unknown value and a body without a value answer 400, a plugin whose search takes no argument (and one without a profile) 404. |
GET /api/sdks/<name>/aliases |
Version aliases (vfox.VersionAlias[]): {sdk, alias, target, display}. Timeouts answer 504. |
GET /api/doctor[?sdk=<name>[&version=<version>]] |
Health (vfox.DoctorReport): {ok, findings: [{id, severity, sdk, version, message, hints, fix, ignored}]}. Timeouts answer 504. |
PUT /api/sdks/<name>/variables |
Set one environment variable that the profile lists: {key, value}, an empty value takes it away. A variable the plugin does not read, a value it does not take and a body without a key answer 400 with the reason, a plugin without a profile 404. The value joins the extra environment of the settings. |
GET /api/sdks/<name>/profile answers what the application knows about the plugin
(mygo/core/profile, see the architecture). Every
text comes in both languages, {"en": …, "zh": …} (zh is left out where it would repeat
en), so that the page chooses by its own language setting:
{
"plugin": "java", "naming": "java",
"search": {"label": {"en": "Distribution", "zh": "发行版"}, "default": "open", "current": "tem",
"choices": [{"value": "tem", "name": {"en": "Temurin"}, "maker": {"en": "Eclipse Adoptium"}, "aliases": ["temurin"], "popular": true}]},
"shorthands": [{"name": "21-tem", "meaning": {"en": "The newest Temurin 21", "zh": "最新的 Temurin 21"}}],
"variables": [{"key": "VFOX_JAVA_GITHUB_MIRROR", "label": {"en": "GitHub mirror"}, "help": {"en": "…"},
"kind": "url", "presets": [{"value": "https://gh-proxy.org/", "name": {"en": "gh-proxy"}}], "example": "https://gh-proxy.org/", "value": ""}],
"legacyFiles": [".sdkmanrc"], "legacyStrategy": false,
"facets": [{"id": "support", "label": {"en": "Support"}, "values": ["LTS"]}],
"guide": {"en": "…"}, "tips": [{"en": "…"}], "docs": [{"title": {"en": "Versions and names"}, "url": {"en": "https://…"}}],
"installed": {"21.0.12.1+1-tem": {"version": "21.0.12.1+1", "source": {"value": "tem", "name": {"en": "Temurin"}}, "flavors": []}}
}variables[].value is what vfox runs with now, and installed takes the names of the
installed versions apart. search.current is the value of the choice that the plugin lists.
naming is java, flutter or plain.
A plugin that was added under an alias (vfox add --alias coffee java) is named by the
alias in every path of /api/sdks/<name>/…, and has the profile of the plugin it was made
from: the server asks vfox info which plugin it is. The choice of its search is kept under
the alias.
Task life cycle:
---
config:
theme: base
themeVariables:
fontFamily: "system-ui, -apple-system, 'Segoe UI', 'Noto Sans', 'Noto Sans CJK SC', 'PingFang SC', 'Microsoft YaHei', sans-serif"
lineColor: "#7C79A8"
primaryColor: "#FFE9D0"
primaryBorderColor: "#F28C1B"
primaryTextColor: "#3B2200"
clusterBkg: "#F4F2FF"
clusterBorder: "#B9B3F5"
titleColor: "#1E1470"
edgeLabelBackground: "#FFFFFF"
flowchart:
curve: basis
wrappingWidth: 320
subGraphTitleMargin:
top: 10
bottom: 8
---
stateDiagram-v2
accTitle: Task life cycle
accDescr: A task is queued, runs, and ends as succeeded, failed or cancelled; a queued task can also be cancelled.
direction LR
[*] --> queued: POST /api/tasks
queued --> running: its turn
queued --> cancelled: cancel
running --> succeeded: exit code 0
running --> failed: cannot start, or<br/>exit code ≠ 0
running --> cancelled: cancel, the<br/>process is killed
succeeded --> [*]
failed --> [*]
cancelled --> [*]
classDef wait fill:#E4E0FF,stroke:#5A4BE8,color:#1E1470,stroke-width:1.5px
classDef busy fill:#FFE9D0,stroke:#F28C1B,color:#3B2200,stroke-width:1.5px
classDef good fill:#D9F2EA,stroke:#13836B,color:#06332A,stroke-width:1.5px
classDef bad fill:#FFDAD6,stroke:#BA1A1A,color:#410002,stroke-width:1.5px
classDef stop fill:#ECEBF3,stroke:#8E8BA8,color:#2B2840,stroke-width:1.5px
class queued wait
class running busy
class succeeded good
class failed bad
class cancelled stop
One state-changing command runs at a time; the rest queue. The queue is
per process, and every task additionally holds a cross-process file lock
(tasks.lock next to the settings) while its vfox process runs, so the
applications of two users on one vfox data directory still serialize mutations.
| Method and path | Meaning |
|---|---|
GET /api/tasks |
List tasks, newest first, with the newest 50 log lines each. |
POST /api/tasks |
Start a task: {operation, sdk?, version?, scope?, source?, alias?, path?, force?, yes?, use?, reinstall?}. Answers 201 with the task. |
GET /api/tasks/<id> |
One task with the newest 500 log lines. |
GET /api/tasks/<id>/log |
The retained full log of a failed task as plain text (404 when none was kept). |
POST /api/tasks/<id>/cancel |
Cancel a queued or running task. |
POST /api/tasks/<id>/retry |
Run a finished task again. |
DELETE /api/tasks/finished |
Forget finished tasks: {cleared: true}. |
A task carries hasFullLog when its complete output was kept on disk. The
queue spills every running task to per-task files under the OS user cache
(vfox-plus/tasks), capped per file and pruned to the newest 20; only
failed tasks keep theirs, successful and cancelled ones delete theirs, and a
forgotten finished task deletes its file with it. A task looks like this:
{"id": 3, "operation": "install", "sdk": "nodejs", "version": "24.11.1",
"commandLine": "vfox install --yes nodejs@24.11.1", "status": "running",
"progress": 0.42, "createdAt": "…", "startedAt": "…",
"log": ["…"], "droppedLines": 0}A task of aliasSet or aliasUnset also has alias, the alias that it names, which the
title of the task says.
Operations: install (sdk + version, optional use to switch after installing and reinstall for a fresh copy), uninstall (sdk + version), use
(sdk + version, only the global scope — browsers cannot name a directory
on the machine that runs vfox), unuse (sdk), add (remote URL source +
optional alias; local paths are rejected), remove (sdk), update (sdk,
or empty for --all), link (sdk + version + path, optional force),
linkDetect (sdk, optional yes), aliasSet (sdk + alias + version),
aliasUnset (sdk + alias), doctorAdopt (optional sdk + version). Unknown operations and missing fields answer 400.
POST /api/plugins (session, same-origin) adds a plugin from a JSON body
{source, alias?} (remote URLs only) or from a multipart/form-data upload
(file plus optional alias, at most 33 MiB). Uploads are written to a
private directory with mode 0600 and deleted by the task finalizer. Answers
201 with the task.
| Method and path | Meaning |
|---|---|
GET /api/settings |
The editable GUI settings: {vfoxExecutable, extraEnvironment, language, updateMirror}. The mirror prefixes GitHub downloads of releases and plugin profiles, e.g. https://gh-proxy.org/. |
PUT /api/settings |
Update them (language is system, english or simplifiedChinese). Unknown languages answer 400. |
GET /api/web |
How other devices connect, and whether the application stays up without its window: {remote, port, lightweight, listening, addresses[], publicAddress, tunnel, fingerprint, selfSigned, error}. remote, port and lightweight are the settings webRemote, webPort and lightweight; the rest says what the remote server made of them: whether it is listening, the addresses of the computer on its networks (IPv4 first), the publicAddress at which something else publishes the server (the setting webPublicAddress, or the address of the Cloudflare quick tunnel while the application publishes it through one, in which case tunnel is true; empty when there is none), the SHA-256 fingerprint of its certificate and whether the application made it (selfSigned), and error when other devices are allowed and cannot connect (the port is taken, the certificate does not load). |
PUT /api/web |
Change any of {remote, port, lightweight} (same-origin). A port outside 1024 to 65535 answers 400. The answer is the new GET /api/web, which may still show the servers as they were: they follow the settings at once, and the page learns of it by the web event. |
POST /api/web/pairing |
Make a pairing link for a device on the network (same-origin): the body may name the host, one of the addresses or the publicAddress, and answers {url, svg}, the link and its QR code as an SVG. 409 when other devices cannot connect or the address is none of the computer's. |
POST /api/quit |
Quit the application (same-origin): answers 202 {quitting: true} and quits shortly after. Cancels the tasks that run. |
PUT /api/config |
Set one vfox key: {key, value}. vfox failures answer 502 with its message. |
DELETE /api/config?key=<key> |
Reset one vfox key to its default. |
GET /api/events (session) is a server-sent-events stream. Messages are
event: <kind> with an empty JSON payload; the client refetches what
changed. Kinds: hello (after connecting), task, inventory, vfox, web (the connections of other devices changed). A
: ping heartbeat comment every 25 seconds keeps proxies from closing idle
connections.
The remote server always speaks HTTPS, and NewServer refuses to listen beyond loopback
without a certificate. Without webCertificate and webKey in the settings, the
application generates a self-signed pair next to the settings the first time
that other devices are allowed (mygo/pair/tlscert.go) and the settings show its SHA-256
fingerprint. Clients — the browser and the phone app — must show that fingerprint for
comparison before trusting the certificate. Bringing your own certificate avoids the warning.
The session cookie is always Secure: loopback origins are trustworthy, so
browsers send it back over plain HTTP there, which only the end-to-end build serves, for the tools.
mygo/phone is a native client of this API, for Android. It has no page and no web view: its
screens are mygo's own, and it reads and changes the computer through the routes of this document.
It keeps one computer.
- Pairing. The person gives the phone the pairing link that the computer shows under
Settings → Other devices → Pair a phone → Show code: by pasting it, by reading its QR code
with the camera (Photo) or from a picture of it (Picture), or by opening the deep link
vfoxplus://pair?link=…. A deep link only fills in the link and starts the check; the phone pairs when the person chooses Trust and pair. A link ishttps://host[:port]/auth/connect/<token>, and a barehost[:port]/auth/connect/<token>is read as https. A query, a fragment, user information or another path is refused before any request is made. - Fingerprint. Before it trusts the computer, the phone looks at its certificate. No connection
of the phone skips the verification of a certificate (
InsecureSkipVerifyis not used): the phone connects over TLS and verifies the certificate as any is verified, with the roots of the system. The certificate that the computer makes for itself fails that, and the error of a connection that is verified and fails has the certificate that was presented, which the phone shows by its SHA-256 fingerprint in the form that the computer shows: 32 pairs of upper-case hexadecimal digits separated by colons. The person compares it with the fingerprint under Other devices on the computer. Trust and pair then callsGET /auth/connect/<token>over a connection whose only root is that certificate: it is verified as any certificate is, its dates and its use included, for a name that it has, since the computer names its own addresses in it and the phone may reach it by another. The phone saves the host, the address, the fingerprint and that certificate, which is public, in the record of the computer, and every later connection has the same only root. A certificate that is another one is refused, and the pairing page says that the computer's certificate changed. A certificate that the roots of the system vouch for (a computer behind a public name) is trusted as it is and is not pinned, so that its renewal needs no pairing. The gateway trusts a certificate the same way (see the gateway). - Session. A successful pairing answers
204 No Contentwith the session cookievfox-plus-session. The phone keeps its value in a file of its private directory, with mode0600, apart from the saved address and fingerprint, which hold no secret. It sends the cookie with every call and with the event stream, and it does not follow redirects, so the cookie goes only to the address of the computer. Disconnect (in Settings → This phone) forgets the computer and the session on the phone. The API has no call that ends a session on the computer, so the phone does not ask the computer to end it. - Events. While the app is in the foreground, the phone keeps
GET /api/eventsopen with the session and reads itsevent:lines. Each kind marks what it names as out of date:hello(everything, and the phone is paired),task(the tasks),inventory(the inventory, the doctor, and the versions, profiles, aliases and plugin information of the SDKs),vfox(the inventory and the doctor) andweb(how other devices connect). The events carry no data: a resource is loaded again when the screen reads it next. The stream ends when the app goes to the background; when the app comes back, the phone connects again and loads everything anew. A broken stream is tried again after three seconds. An answer of401means that the computer no longer accepts the session, and the phone asks the person to pair again. - Calls. The phone reads
GET /api/inventory,GET /api/doctor, theinfo,versions,profileandaliasesroutes of an SDK,GET /api/taskswithGET /api/tasks/<id>and its/log, andGET /api/settingsandGET /api/web. It changes the computer with the other routes of this document:POST /api/tasksstarts a task, such as an install, a use or an uninstall (see Tasks);POST /api/pluginsadds a plugin, from a source URL or from the file that the person chose with the picker of the system (a.zipor a.luaof at most 32 MiB, sent as the form that Plugins describes, with its length declared);PUT /api/sdks/<name>/searchandPUT /api/sdks/<name>/variablesset an SDK's search and environment variables;PUTandDELETE /api/configset and reset a vfox key;PUT /api/settingsandPUT /api/webchange the settings and how other devices connect;POST /api/web/pairingmakes a pairing link for another device, which the phone shows as text and as a QR code; andPOST /api/quitquits the application on the computer, after the person confirms it. A call waits for its answer for at most 150 seconds, which is longer than the two minutes that the server waits for vfox before it answers504. The phone accepts an answer of up to 64 MiB, the size of the largest answer, a full task log.
mygo/gateway (the Docker image, see the gateway) serves the interface
of one instance to the browsers that are paired with it, over HTTPS on port 8080. It speaks this
protocol twice. To its browsers it is a server: the same one-time links (/auth/connect/<token>, five
minutes) and sessions (24 hours), with the cookie vfox-plus-gateway. To the remote server of an
instance it is a client, as the phone app is: a pairing link that a person pasted, the session cookie
vfox-plus-session, and the certificate trusted by the roots or by a fingerprint.
| Route | Answered by | Notes |
|---|---|---|
GET / |
the gateway | The page that says how to pair, for a browser that is not paired; for one that is, the instance it is paired with and the forms below. |
GET /auth/connect/<token> |
the gateway | Pairs the browser: 303 to /app when the gateway is paired with an instance, to / when it is not. 403 for a link that is not valid, was used or expired. |
GET /api/token |
the gateway | A session of the gateway: {"url": "https://<host of the request>/auth/connect/<token>"}, a link for a second browser. |
POST /gateway/connect |
the gateway | A paired browser, from the page, with the form field link: a pairing link of an instance. 303 to /app when the gateway is paired with it; 200 with the fingerprint to compare when nobody vouches for its certificate and it is not the one that was trusted; 400 when it is not a pairing link (an address that is not a host name or an IP address, with a port from 1 to 65535 or none, is not one); 403 when the instance refused it; 502 when it cannot be reached. |
POST /gateway/trust |
the gateway | link and fingerprint, from the page that shows it: pairs with the certificate that has that fingerprint (409 when the certificate at the address is not the one that was shown). |
POST /gateway/invite |
the gateway | A page with a link for another browser. |
POST /gateway/forget |
the gateway | Forgets the instance and the session at it; 303 to /. |
GET /app |
the gateway | The single page of the interface, for a browser that is paired with the gateway while the gateway holds a session at an instance: 200, Cache-Control: no-store, and no request to the instance (the page makes its calls to /api/*). Any other browser is redirected to / (302). |
GET /manifest.webmanifest |
the gateway | The web app manifest of the page, to any browser, with no session. GET and HEAD; another method answers 405 with Allow: GET, HEAD. |
/api/* |
the instance | Forwarded with the session of the gateway. |
The forms of the gateway need a paired browser (401), the origin of the gateway (403) and at most 8 KiB
(400). A route of the instance, for a browser that is not paired with the gateway, is 401 with a message in
plain text; and so is every route when the gateway is paired with no instance or its session ended, but then the
answer says so in the form that the interface reads errors in, {"error": "…"}. When the instance cannot be reached the API answers 502 in the same
form, and the page of the interface is still served: it shows what its calls get.
Everything of the browser that identifies it (its cookies, Origin, Referer, the Forwarded headers)
stays with the gateway, and the Set-Cookie of the instance does not reach the browser.