modus
Menu
On this page

The entry remote

The source src/modules/system/remote built with the setting DRAWING_THROUGH_MODULE=true. The text after this paragraph is the comment of that source.

The remote service: the calls of the host (Module contract, section 4, "A call from the host").

QUIC in the process (src/library/modus/quic), over a datagram endpoint with a listen grant of UDP on the port remote.LISTEN_PORT that admits the address of the host only (remote.HOST_ADDRESS): the network service drops a datagram of another address before this process sees it. Each call is one bidirectional stream: the request (a remote.Request header and the bytes of the call region), then the end of the stream; the answer (a remote.Answer header and the bytes of the result), then the end of the stream. A call that fails before its answer is reset with a code of remote.Stream_Error.

The key of the service: an Ed25519 key that this process makes at its start from its own generator (fill_for_a_key, the strength "processor" at least). Its public key goes on the log and in the window: the host pins it. A new start makes a new key. A seed weaker than "processor" makes no key: the process says so, and listens on nothing. The public key is also the machine identity of this start toward paired machines (mesh.odin), and the key of the client of each outbound link to a paired machine (mesh_client.odin).

The key of the client: the handshake asks each client for its own Ed25519 key, as a raw public key with its signature (mutual TLS 1.3), and takes it only when the client table that the root service writes has a row for it (remote.Client_Table, read-only). A key with no row is refused in the handshake (access_denied), with one line of the log, before any stream. Each connection is bound to its row; when the grant of the row ends (a revocation, a lock of the session of its principal), the open connection ends with the code Revoked.

It holds a ring to the root service that serves Connect and Disconnect only, to the services that the root service names for it, each for one row of the client table: the root service gives that connection the principal of the row. It copies the bytes of a whole request in the call region of its connection to the service, makes the isolated call, and writes the call answer. It does not read the descriptions: the host encoded the call with them, and the service checks the call region. It trusts nothing in a request (remote.request_check).

The window shows the public key, the counts of the calls and of the resets, the connections to services with their principals, and the last calls.

What it is for. A process on the host calls an export of a service of the machine as the console calls it: the same descriptions, the same isolated call, the same error records. The tool of the project uses it to test and to measure a running machine from outside, with no screen:

modustool call <the public key, 64 hexadecimal digits> "monitor.processes()"

Start: start("remote") in the console, or the bar of the desktop. Read the public key in its window or on the log. Then allow the key of the client from a console that acts for the principal: remote_allow("<the key of the client, 64 hexadecimal digits>").

Grants, as the root service gives them:

  • Network: a listen grant of UDP on port 7100 for the address 10.0.2.2 only. The process refuses any other grant.
  • Remote_Clients: the client table, read-only: the key of each client that a principal allowed, and that principal.
  • Connect: a ring to the root service for Connect and Disconnect, to the services of its start grant set (start_grant_sets): compositor, date, debugger, inspect, log, manual, monitor, settings and storage, each for one row of the client table. A call to another service fails with the refusal of the root service.
  • Acts_For_Principal: a service gives the caller what it holds for all callers of the principal of the row, as it does for a console of that principal.

What it proves: a call from outside the machine passes the same checks as a call from inside, a lost datagram never runs a call two times, and a call acts only for a principal that allowed the key of its client.

See: QUIC: remote over QUIC (built)

remote module with an entry

Hash
a3389e1a06d11f1312649e2f0ccaacdd5c8966a7639606db20c140fbdedb1e63
Size
482115 bytes
Exports
0
Imports
2
Imported by
0
License
MIT

The remote service: the calls of the host

FactValue
KindModules with an entry
Sourcesrc/modules/system/remote
Boot imageyes: in the boot image, 482115 bytes in this build
Build settings
  • DRAWING_THROUGH_MODULE=true
Imports
Imported bynone

Neighbours

What it imports, at its left, and what imports it, at its right: the part of the module graph that touches it.

Exports

ExportWhat it does
entry()The entry of the remote service: it makes its key, checks its grant, then runs QUIC and the calls of the host until the machine stops

entry

entry()

The entry of the remote service: it makes its key, checks its grant, then runs QUIC and the calls of the host until the machine stops.

The entry, in order:

  1. 1. takes the random generator of its context, and opens its window (it runs with no window too);
  2. 2. makes its Ed25519 key. With a seed under the strength "processor" it writes "remote: the random seed of this process is weak" and then only draws its window: it listens on nothing;
  3. 3. writes "remote: the public key of this service: " and 64 hexadecimal digits;
  4. 4. opens its datagram endpoint and the ring to the root service, maps the client table read-only, and asks the network service for its grant. A grant that is not a listen grant of UDP for the host only stops it (fail), and so does a missing client table;
  5. 5. maps the table of the connections, the streams and their buffers, starts the QUIC server, which asks each client for its key, and erases its own copy of the private key;
  6. 6. writes "remote: listening on the UDP port 7100, for the host 10.0.2.2 only, and for the client keys that a principal allowed: ...".

Then one loop runs for ever. Each pass gives the arrived datagrams to the server, makes at most one isolated call, and draws the window at most ten times in one second. After a call of 100 ms or more, the passes of the next 50 ms only move datagrams, so that the handshake of another connection goes on. The loop waits for a datagram, an event of the window, the next deadline of QUIC, or the bound of a call.

Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/system/remote/main.odin:1072

Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).

What the root service gives it

WhatValueAs the root service says
GrantsThe calls of another machine: a listen grant of UDP that admits the address of the host only (QUIC in the process, the module cryptography through its imports), the client table, which names the key of each client that a principal allowed, connections to the services of its list, each for one row of that table, and the grant to act for the principal of that row. See: Module contract: A call from the host, Principals: The client keys of remote
Other terms of its start grant setcallable = {0 = "assistant", 1 = "compositor", 2 = "date", 3 = "debugger", 4 = "inspect", 5 = "log", 6 = "manual", 7 = "monitor", 8 = "settings", 9 = "storage"}
Budget that it asks for
  • working memory pages 3421
  • pages of its threads 72
  • pages of the pictures of its window 3105
  • pages of the module and its imports from the files of the build
  • processes 1
  • threads 1
2 QUIC connections of about 85 KiB each, 8 streams of about 130 KiB for each, and a buffer of a request or an answer of about 64 KiB for each stream: about 820 pages, in one mapping of the process (QUIC, section 7), and the call regions of its connections to services: 3067 pages. And the glyph memory of the copy of the text rendering of the drawing module, which draws its text: 354 pages (display.TEXT_MEMORY_PAGES). 3067 + 354 = 3421.

The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).

start_grant_sets global variable of the package root

start_grant_sets := [?]Start_Grant_Set_Row {...}

The start grant set of each module of the boot image, with the reason of each.

src/modules/system/root/start_grant_sets.odin:73