Skip to content

LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.

Remote desktop video: Settings → Sharing → Video, the remote-ice action, and hardening found in testing

Federico Pereira2e6702ee2311
diff --git a/apps/settings/Sharing.jsx b/apps/settings/Sharing.jsx
index a3a7dfe..e813c44 100644
--- a/apps/settings/Sharing.jsx
+++ b/apps/settings/Sharing.jsx
@@ -4,7 +4,7 @@
// server is installed, the first time, with the package engine's own pkg-install action.
import {
View, Text, Button, Toggle, Segmented, TextInput, useTheme, useLocale, useStore, admin, remote, remoteViewers, sshLogin, remoteCidr,
- remoteMinutesLeft, statusText, useSystemInfo, spacing, typeScale,
+ remoteMinutesLeft, remoteVideo, remoteIceServer, statusText, useSystemInfo, spacing, typeScale,
} from '@lordos/sdk';
import { useEffect, useState } from 'react';
import { Stack, Section, SettingRow, Note, Message, StatusDot, tint } from './ui.jsx';
@@ -103,6 +103,73 @@ function AccessSection({ st, isAdmin, busy, act }) {
);
}
+// The video path (docs/REMOTE.md, "Video (WebRTC)"): on by default; the built-in STUN server covers the
+// local network; external STUN and a TURN relay are for connecting across networks. The TURN password
+// goes to the admin helper once and is never read back (only "saved" is shown).
+function VideoSection({ st, isAdmin, busy, run }) {
+ const t = useTheme();
+ const { t: tr } = useLocale();
+ const [stun, setStun] = useState(st.stun.join(', '));
+ const [turn, setTurn] = useState(st.turn);
+ const [user, setUser] = useState(st.turnUser);
+ const [pass, setPass] = useState('');
+ const [bad, setBad] = useState('');
+ useEffect(() => { setStun(st.stun.join(', ')); setTurn(st.turn); setUser(st.turnUser); }, [st.stun.join(','), st.turn, st.turnUser]);
+ const list = stun.split(',').map((x) => x.trim()).filter(Boolean);
+ const stunOk = list.length <= 4 && list.every((x) => remoteIceServer(x));
+ const turnOk = !turn.trim() || (remoteIceServer(turn) && /^[\x21-\x7e]{1,128}$/.test(user) && !/["\\]/.test(user) && (pass || st.turnKey));
+ const saveStun = () => { if (!stunOk) { setBad('stun'); return; } setBad(''); run(() => remoteVideo.setStun(list)); };
+ const saveTurn = () => {
+ if (!turnOk) { setBad('turn'); return; }
+ setBad('');
+ run(() => (turn.trim() ? remoteVideo.setTurn(turn.trim(), user, pass) : remoteVideo.clearTurn())).then(() => setPass(''));
+ };
+ const label = { fontSize: typeScale.caption, color: t.textDim, textAlign: 'start' };
+ const err = (k) => (bad === k ? <Text style={{ fontSize: typeScale.caption, color: tint.error, textAlign: 'start' }}>{tr(k === 'stun' ? 'errors.remote.badIceServer' : 'errors.remote.badTurnUser')}</Text> : null);
+ const off = !isAdmin || busy;
+ return (
+ <>
+ <Section title={tr('settings.sharing.video')}>
+ <SettingRow label={tr('settings.sharing.videoToggle')} hint={tr(st.video ? 'settings.sharing.videoHint' : 'settings.sharing.videoOffHint')}>
+ <Toggle small on={st.video} onChange={(on) => !off && run(() => remoteVideo.setVideo(on))} />
+ </SettingRow>
+ </Section>
+ {st.video && (
+ <Section title={tr('settings.sharing.stun')} footer={tr('settings.sharing.stunHint')}>
+ <View style={{ paddingVertical: spacing.s, gap: 4 }}>
+ <View style={{ flexDirection: 'row', alignItems: 'center', gap: spacing.s }}>
+ <TextInput value={stun} placeholder={tr('settings.sharing.stunPlaceholder')} style={{ flex: 1, direction: 'ltr' }}
+ onChange={(v) => { setStun(v.slice(0, 400)); setBad(''); }} onSubmit={saveStun} />
+ {isAdmin && <Button small label={tr('settings.sharing.save')} disabled={off} onClick={saveStun} />}
+ </View>
+ {err('stun')}
+ </View>
+ </Section>
+ )}
+ {st.video && (
+ <Section title={tr('settings.sharing.turn')} footer={tr('settings.sharing.turnFooter')}>
+ <View style={{ paddingVertical: spacing.s, gap: 6 }}>
+ <Text style={label}>{tr('settings.sharing.turnServer')}</Text>
+ <TextInput value={turn} placeholder={tr('settings.sharing.turnServerPlaceholder')} style={{ direction: 'ltr' }} onChange={(v) => { setTurn(v.slice(0, 95)); setBad(''); }} />
+ <Text style={label}>{tr('settings.sharing.turnUser')}</Text>
+ <TextInput value={user} style={{ direction: 'ltr' }} onChange={(v) => { setUser(v.slice(0, 128)); setBad(''); }} />
+ <Text style={label}>{tr('settings.sharing.turnPass')}</Text>
+ <TextInput secure value={pass} placeholder={st.turnKey ? tr('settings.sharing.turnPassSaved') : ''} style={{ direction: 'ltr' }}
+ onChange={(v) => { setPass(v.slice(0, 128)); setBad(''); }} onSubmit={saveTurn} />
+ {err('turn')}
+ {isAdmin && (
+ <View style={{ flexDirection: 'row', gap: spacing.s, justifyContent: 'flex-end' }}>
+ {st.turn ? <Button small label={tr('settings.sharing.turnRemove')} disabled={off} onClick={() => run(() => remoteVideo.clearTurn())} /> : null}
+ <Button small label={tr('settings.sharing.save')} disabled={off} onClick={saveTurn} />
+ </View>
+ )}
+ </View>
+ </Section>
+ )}
+ </>
+ );
+}
+
// openssh-sftp-server too: scp and sftp need it (a Recommends the package engine skips).
const SSH_PACKAGES = 'openssh-server openssh-sftp-server';
@@ -188,6 +255,14 @@ export function SharingSettings() {
(r) => { setMsg({ ok: true, text: ok || statusText(r) }); setTimeout(() => setSt(remote.status()), 300); return true; },
(e) => { setMsg({ ok: false, text: e.message }); return false; }).finally(() => setBusy(false));
};
+ // an admin call from a section with its own fields (the video settings)
+ const run = (fn) => {
+ setBusy(true);
+ setMsg(null);
+ return fn().then(
+ (r) => { setMsg({ ok: true, text: statusText(r) }); setTimeout(() => setSt(remote.status()), 300); return true; },
+ (e) => { setMsg({ ok: false, text: e.message }); return false; }).finally(() => setBusy(false));
+ };
const ips = lanAddresses();
const urls = ips.map((ip) => `https://${ip}:${st.port}`);
return (
@@ -218,6 +293,7 @@ export function SharingSettings() {
{!st.installed && <Note tone="warn">{tr('settings.sharing.notInstalled')}</Note>}
<Message msg={msg} />
<AccessSection st={st} isAdmin={isAdmin} busy={busy} act={act} />
+ <VideoSection st={st} isAdmin={isAdmin} busy={busy} run={run} />
<Section title={tr('settings.sharing.connected')} footer={tr('settings.sharing.security')}>
{!st.clients.length ? <SettingRow label={tr('settings.sharing.nobody')} labelStyle={{ color: t.textDim }} /> : st.clients.map((c) => (
<SettingRow key={c.pid} icon={<StatusDot color={tint.ok} />} label={`${c.user} · ${c.ip}`}
diff --git a/assets/locales/en/errors.json b/assets/locales/en/errors.json
index f6df753..25676ab 100644
--- a/assets/locales/en/errors.json
+++ b/assets/locales/en/errors.json
@@ -566,5 +566,8 @@
"hw.noKernelLog": "The kernel log could not be read",
"app.codeRefused": "This app's code was modified and was not loaded",
"remote.badAddress": "Not a valid address or network",
- "remote.listFull": "The list is full (64 entries)"
+ "remote.listFull": "The list is full (64 entries)",
+ "remote.badIceServer": "Not a valid server: use name:port, like stun.example.org:3478 (at most 4)",
+ "remote.badTurnUser": "Not a valid relay user name (no spaces, at most 128 characters)",
+ "remote.badTurnPassword": "Not a valid relay password (at most 128 characters, no line breaks)"
}
diff --git a/assets/locales/en/settings.json b/assets/locales/en/settings.json
index 2f7e16a..87e46ad 100644
--- a/assets/locales/en/settings.json
+++ b/assets/locales/en/settings.json
@@ -307,5 +307,22 @@
"sharing.blocklist": "Blocklist",
"sharing.blocklistFooter": "Always refused, before anything else, until you remove them.",
"sharing.listEmpty": "The list is empty.",
- "sharing.blockForever": "Block permanently"
+ "sharing.blockForever": "Block permanently",
+ "sharing.video": "Video",
+ "sharing.videoToggle": "Stream as video (WebRTC)",
+ "sharing.videoHint": "Smoother and sharper than images, with sound. Falls back to images when the browser or the network can’t.",
+ "sharing.videoOffHint": "The browser gets the screen as images.",
+ "sharing.stun": "STUN servers",
+ "sharing.stunPlaceholder": "stun.example.org:3478",
+ "sharing.stunHint": "This computer answers STUN itself, which is enough on the local network. Add a public server only to connect across networks (up to 4, separated by commas).",
+ "sharing.turn": "Relay (TURN)",
+ "sharing.turnServer": "Server",
+ "sharing.turnServerPlaceholder": "turn.example.org:3478",
+ "sharing.turnUser": "User name",
+ "sharing.turnPass": "Password",
+ "sharing.turnPassSaved": "Saved (it is never shown)",
+ "sharing.turnRemove": "Remove relay",
+ "sharing.turnFooter": "Only when neither side can reach the other directly. The relay only sees encrypted video and input; its password stays on this computer, readable only by the system.",
+ "sharing.save": "Save",
+ "sharing.noneSet": "None"
}
diff --git a/assets/locales/es/errors.json b/assets/locales/es/errors.json
index dbe9f7e..2047d66 100644
--- a/assets/locales/es/errors.json
+++ b/assets/locales/es/errors.json
@@ -566,5 +566,8 @@
"hw.noKernelLog": "No se pudo leer el registro del kernel",
"app.codeRefused": "El código de esta app fue modificado y no se cargó",
"remote.badAddress": "No es una dirección o red válida",
- "remote.listFull": "La lista está llena (64 entradas)"
+ "remote.listFull": "La lista está llena (64 entradas)",
+ "remote.badIceServer": "No es un servidor válido: usá nombre:puerto, como stun.ejemplo.org:3478 (como mucho 4)",
+ "remote.badTurnUser": "No es un usuario de relé válido (sin espacios, hasta 128 caracteres)",
+ "remote.badTurnPassword": "No es una contraseña de relé válida (hasta 128 caracteres, sin saltos de línea)"
}
diff --git a/assets/locales/es/settings.json b/assets/locales/es/settings.json
index da10d4b..5ef5543 100644
--- a/assets/locales/es/settings.json
+++ b/assets/locales/es/settings.json
@@ -307,5 +307,22 @@
"sharing.blocklist": "Lista de bloqueadas",
"sharing.blocklistFooter": "Siempre rechazadas, antes que cualquier otra regla, hasta que las quites.",
"sharing.listEmpty": "La lista está vacía.",
- "sharing.blockForever": "Bloquear siempre"
+ "sharing.blockForever": "Bloquear siempre",
+ "sharing.video": "Video",
+ "sharing.videoToggle": "Transmitir como video (WebRTC)",
+ "sharing.videoHint": "Más fluido y nítido que con imágenes, y con sonido. Vuelve a imágenes cuando el navegador o la red no pueden.",
+ "sharing.videoOffHint": "El navegador recibe la pantalla como imágenes.",
+ "sharing.stun": "Servidores STUN",
+ "sharing.stunPlaceholder": "stun.ejemplo.org:3478",
+ "sharing.stunHint": "Esta computadora responde STUN por sí misma, y en la red local alcanza. Agregá un servidor público solo para conectarte entre redes (hasta 4, separados por comas).",
+ "sharing.turn": "Relé (TURN)",
+ "sharing.turnServer": "Servidor",
+ "sharing.turnServerPlaceholder": "turn.ejemplo.org:3478",
+ "sharing.turnUser": "Usuario",
+ "sharing.turnPass": "Contraseña",
+ "sharing.turnPassSaved": "Guardada (nunca se muestra)",
+ "sharing.turnRemove": "Quitar el relé",
+ "sharing.turnFooter": "Solo cuando ninguno de los dos lados puede llegar al otro directamente. El relé solo ve video y entrada cifrados; su contraseña queda en esta computadora y solo el sistema puede leerla.",
+ "sharing.save": "Guardar",
+ "sharing.noneSet": "Ninguno"
}
diff --git a/assets/locales/pt/errors.json b/assets/locales/pt/errors.json
index 4c53558..7096b0f 100644
--- a/assets/locales/pt/errors.json
+++ b/assets/locales/pt/errors.json
@@ -566,5 +566,8 @@
"hw.noKernelLog": "Não foi possível ler o registro do kernel",
"app.codeRefused": "O código deste app foi modificado e não foi carregado",
"remote.badAddress": "Não é um endereço ou rede válida",
- "remote.listFull": "A lista está cheia (64 entradas)"
+ "remote.listFull": "A lista está cheia (64 entradas)",
+ "remote.badIceServer": "Não é um servidor válido: use nome:porta, como stun.exemplo.org:3478 (no máximo 4)",
+ "remote.badTurnUser": "Não é um usuário de retransmissor válido (sem espaços, até 128 caracteres)",
+ "remote.badTurnPassword": "Não é uma senha de retransmissor válida (até 128 caracteres, sem quebras de linha)"
}
diff --git a/assets/locales/pt/settings.json b/assets/locales/pt/settings.json
index 019014f..f800115 100644
--- a/assets/locales/pt/settings.json
+++ b/assets/locales/pt/settings.json
@@ -307,5 +307,22 @@
"sharing.blocklist": "Lista de bloqueados",
"sharing.blocklistFooter": "Sempre recusados, antes de qualquer outra regra, até você removê-los.",
"sharing.listEmpty": "A lista está vazia.",
- "sharing.blockForever": "Bloquear sempre"
+ "sharing.blockForever": "Bloquear sempre",
+ "sharing.video": "Vídeo",
+ "sharing.videoToggle": "Transmitir como vídeo (WebRTC)",
+ "sharing.videoHint": "Mais fluido e nítido que com imagens, e com som. Volta para imagens quando o navegador ou a rede não conseguem.",
+ "sharing.videoOffHint": "O navegador recebe a tela como imagens.",
+ "sharing.stun": "Servidores STUN",
+ "sharing.stunPlaceholder": "stun.exemplo.org:3478",
+ "sharing.stunHint": "Este computador responde STUN sozinho, o que basta na rede local. Adicione um servidor público só para conectar entre redes (até 4, separados por vírgulas).",
+ "sharing.turn": "Retransmissor (TURN)",
+ "sharing.turnServer": "Servidor",
+ "sharing.turnServerPlaceholder": "turn.exemplo.org:3478",
+ "sharing.turnUser": "Usuário",
+ "sharing.turnPass": "Senha",
+ "sharing.turnPassSaved": "Salva (nunca é exibida)",
+ "sharing.turnRemove": "Remover retransmissor",
+ "sharing.turnFooter": "Só quando nenhum dos lados consegue chegar ao outro diretamente. O retransmissor só vê vídeo e entrada criptografados; a senha fica neste computador e só o sistema pode lê-la.",
+ "sharing.save": "Salvar",
+ "sharing.noneSet": "Nenhum"
}
diff --git a/docs/ISO.md b/docs/ISO.md
index 01cb492..cc5db61 100644
--- a/docs/ISO.md
+++ b/docs/ISO.md
@@ -375,7 +375,7 @@ installing packages and compressing.
sudo apt-get install -y --no-install-recommends debootstrap squashfs-tools xorriso grub-pc-bin \
grub-efi-amd64-bin grub-common mtools dosfstools lintian libgbm-dev libegl-dev libgles-dev libssl-dev \
libpoppler-glib-dev libarchive-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev \
- libswresample-dev libva-dev clang
+ libswresample-dev libva-dev libsrtp2-dev libusrsctp-dev clang
```
| Package | What for |
@@ -384,6 +384,7 @@ sudo apt-get install -y --no-install-recommends debootstrap squashfs-tools xorri
| `libpoppler-glib-dev`, `libarchive-dev` | compiling `lord-doc` (PDF and archives); without them `make` skips it and the package ships without a PDF viewer |
| `libavcodec-dev`, `libavformat-dev`, `libavutil-dev`, `libswscale-dev`, `libswresample-dev` | compiling `lord-media` (video, photos, camera, recorder); without them `make` skips it |
| `libva-dev` | optional: GPU decoding (VA-API) in `lord-media` |
+| `libsrtp2-dev`, `libusrsctp-dev` | the remote desktop's video (WebRTC: SRTP and the data channels) in `lord-sessiond`; without them `make` builds the tile path only and the package doesn't depend on `libsrtp2-1`/`libusrsctp2` |
| `clang` | compiling `lord-netperm`'s BPF programs (per-app network permissions); without it the build still works, but no rules are applied |
| `debootstrap` | the Debian base system |
| `squashfs-tools` | `mksquashfs` |
diff --git a/sdk/index.js b/sdk/index.js
index 876e321..e5bd8f0 100644
--- a/sdk/index.js
+++ b/sdk/index.js
@@ -20,7 +20,7 @@ import { ImeOverlay } from './ime.js';
import { ClipboardPanel, ClipboardToast, clipboard as clipboardApi } from './clipboard.js';
import { SpotlightPanel } from './spotlight.js';
import { RemoteBadge } from './remote.js';
-export { remote, remoteViewers, sshLogin, remoteCidr, remoteMinutesLeft, remoteAccess } from './remote.js';
+export { remote, remoteViewers, sshLogin, remoteCidr, remoteMinutesLeft, remoteAccess, remoteVideo, remoteIceServer } from './remote.js';
export { perms, permsRev, requestPermission, markDeviceUse, useIndicators, PrivacyIndicators, PermissionPrompt, registerPrivacySection, privacySections, PERMISSIONS, onPermissionRevoked, micStart, micStop, micLevel } from './privacy.js';
import { PermissionPrompt } from './privacy.js';
import { Powerbox } from './powerbox.jsx';
diff --git a/sdk/remote.js b/sdk/remote.js
index 7518bb7..5c4f4b8 100644
--- a/sdk/remote.js
+++ b/sdk/remote.js
@@ -7,6 +7,7 @@
// useStore(remoteViewers) → [{ ip, user }]
// remote.status() → { enabled, installed, port, allow, net: 'lan'|'list'|'any', fingerprint, clients: [...],
// sessions: [...], monitor, blocked: [{ ip, until, strikes, manual }], allowed: ['cidr'] }
+// remoteVideo.setVideo(on) / setStun([...]) / setTurn(server, user, pass) / clearTurn() (remote-ice)
// remoteCidr(text) → canonical-looking text if it's an address or network the admin actions accept, else ''
// (lord-sessiond's helper checks again, strictly: server/src/remote/ipnet.c)
// lord-sessiond's notice "this source was blocked after failed logins" arrives as __lordRemoteNotice and is
@@ -81,9 +82,14 @@ export const remoteAccess = {
};
function parseConfig(text) {
- const c = { port: 5673, allow: 'all', net: 'lan' };
+ const c = { port: 5673, allow: 'all', net: 'lan', video: true, stun: [], turn: '', turnUser: '', turnKey: false };
for (const line of String(text || '').split('\n')) {
const m = /^(\w+)=(.*)$/.exec(line.trim());
+ if (m && m[1] === 'video') c.video = m[2] !== '0';
+ if (m && m[1] === 'stun' && c.stun.length < 4) c.stun.push(m[2]);
+ if (m && m[1] === 'turn') c.turn = m[2];
+ if (m && m[1] === 'turn_user') c.turnUser = m[2];
+ if (m && m[1] === 'turn_key') c.turnKey = m[2] === '1';
if (m && m[1] === 'port') c.port = Number(m[2]) || 5673;
if (m && m[1] === 'allow') c.allow = m[2] === 'group' ? 'group' : 'all';
if (m && m[1] === 'net') c.net = ['lan', 'list', 'any'].includes(m[2]) ? m[2] : 'lan';
@@ -103,10 +109,27 @@ export const remote = {
installed: !!s.installed, enabled: !!(st && st.running), port: st?.port || cfg.port, allow: st?.allow || cfg.allow,
fingerprint: s.fingerprint || '', clients: st?.clients || [], sessions: st?.sessions || [], monitor: st?.monitor || '',
net: st?.net || cfg.net, blocked: Array.isArray(st?.blocked) ? st.blocked : [], allowed: Array.isArray(st?.allowed) ? st.allowed : [],
+ video: cfg.video, stun: cfg.stun, turn: cfg.turn, turnUser: cfg.turnUser, turnKey: cfg.turnKey,
};
},
};
+// Mirrors rw_ice_server_valid (server/src/remote/rtcwire.c): host:port with a name, an IPv4 or [IPv6].
+export function remoteIceServer(text) {
+ const s = String(text || '').trim();
+ const m = /^(\[[0-9a-fA-F:.]+\]|[A-Za-z0-9](?:[A-Za-z0-9.-]{0,61}[A-Za-z0-9])?):([1-9][0-9]{0,4})$/.exec(s);
+ return m && Number(m[2]) <= 65535 && !m[1].includes('..') ? s : '';
+}
+
+// The video path's settings (docs/REMOTE.md, "Video (WebRTC)"), through the remote-ice admin action;
+// the TURN password goes quietly (never into the visible admin log) and is never read back.
+export const remoteVideo = {
+ setVideo: (on) => admin.run('remote-ice', `video=${on ? 'on' : 'off'}`),
+ setStun: (list) => admin.run('remote-ice', `stun=${list.join(',')}`),
+ setTurn: (server, user, pass) => admin.run('remote-ice', [`turn=${server}`, `turn_user=${user}`, ...(pass ? [`turn_pass=${pass}`] : [])].join('\n'), undefined, { quiet: true }),
+ clearTurn: () => admin.run('remote-ice', 'turn='),
+};
+
// Remote login (SSH): read-only state; changes go through the ssh-set / ssh-allow admin actions.
export const sshLogin = {
available: () => typeof lord.ssh !== 'undefined',
diff --git a/server/src/media/helper/lm_stream.c b/server/src/media/helper/lm_stream.c
index 63c22fc..bf7be48 100644
--- a/server/src/media/helper/lm_stream.c
+++ b/server/src/media/helper/lm_stream.c
@@ -114,10 +114,12 @@ static AVCodecContext *open_sw(Vid *e, const char *name, int fps) {
c->framerate = (AVRational){ fps, 1 };
c->gop_size = fps * 60;
c->max_b_frames = 0;
+ /* the desktop is sRGB: BT.709 primaries and matrix with the sRGB transfer, so the browser doesn't
+ * re-shape the tones (dark greys came out lighter than the lossless tiles next to them) */
c->color_range = AVCOL_RANGE_MPEG;
- c->colorspace = AVCOL_SPC_SMPTE170M;
- c->color_primaries = AVCOL_PRI_SMPTE170M;
- c->color_trc = AVCOL_TRC_SMPTE170M;
+ c->colorspace = AVCOL_SPC_BT709;
+ c->color_primaries = AVCOL_PRI_BT709;
+ c->color_trc = AVCOL_TRC_IEC61966_2_1;
AVDictionary *o = NULL;
if (e->codec == CODEC_H264) {
c->thread_count = 2;
@@ -191,6 +193,7 @@ static int vid_frame(Vid *e, const uint8_t *bgra, int w, int h, int64_t ms) {
if (!e->sws) {
e->sws = sws_getContext(w, h, AV_PIX_FMT_BGRA, e->w, e->h, e->yuv->format, SWS_POINT, NULL, NULL, NULL);
if (!e->sws) return -1;
+ sws_setColorspaceDetails(e->sws, sws_getCoefficients(SWS_CS_ITU709), 1, sws_getCoefficients(SWS_CS_ITU709), 0, 0, 1 << 16, 1 << 16);
}
if (av_frame_make_writable(e->yuv) < 0) return -1;
const uint8_t *src[1] = { bgra };
diff --git a/server/src/remote/client.html b/server/src/remote/client.html
index a854ccc..b392471 100644
--- a/server/src/remote/client.html
+++ b/server/src/remote/client.html
@@ -251,6 +251,7 @@ function pinch(scale, rot) {
}
cv.addEventListener('wheel', (e) => {
e.preventDefault();
+ [mx, my] = pos(e); pend = [mx, my]; flushMove(); // the wheel goes where the pointer is now
const k = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? H : 1; // to pixels
if (e.ctrlKey) { pinch(pinchScale * Math.max(0.8, Math.min(1.25, Math.exp(-e.deltaY * k / 100))), pinchRot); return; }
const wheelLike = e.deltaMode !== 0 || (!e.deltaX && Number.isInteger(e.deltaY) && Math.abs(e.deltaY) >= 50 && !scrollOn);
diff --git a/server/src/remote/rtc.c b/server/src/remote/rtc.c
index 99eec02..f389c36 100644
--- a/server/src/remote/rtc.c
+++ b/server/src/remote/rtc.c
@@ -57,7 +57,7 @@ typedef struct {
double last_ms;
Hist *hist;
} Track;
-typedef struct { RwAddr a; int relay, valid, nominated; double last; } Path;
+typedef struct { RwAddr a; int relay, valid, nominated, proven; double last; } Path;
typedef struct {
int state; /* 0 off, 1 asked, 2 asked with credentials, 3 allocated, -1 failed */
RwAddr srv, relayed, mapped;
@@ -106,7 +106,7 @@ struct Rtc {
/* congestion: the viewer's target */
unsigned kbps;
double rate_at, kf_at, lost;
- unsigned long nacks, plis, resent;
+ unsigned long nacks, plis, resent, dtls_rx;
double last_sr, created, last_consent, stun_win;
int stun_n, failed;
/* external STUN, TURN */
@@ -504,6 +504,7 @@ static void dtls_up(Rtc *r) {
r->srtp_up = 1;
r->dtls_up = 1;
Path *s = sel_path(r);
+ if (s) s->proven = 1;
char a[64] = "";
if (s) rw_addr_format(&s->a, a, sizeof a);
sd_log("video: connected (%s, %s, %s%s)", r->codec == RW_CODEC_H264 ? "H.264" : "VP8", gcm ? "AES-GCM" : "AES-CM", a, s && s->relay ? " via TURN" : "");
@@ -524,7 +525,7 @@ static void dtls_input(Rtc *r, const uint8_t *p, size_t n) {
static uint8_t buf[65536];
while (r->dtls_up && !r->failed) {
int k = SSL_read(r->ssl, buf, sizeof buf);
- if (k > 0) { if (r->sctp_on) usrsctp_conninput(r, buf, (size_t)k, 0); continue; }
+ if (k > 0) { r->dtls_rx++; if (r->sctp_on) usrsctp_conninput(r, buf, (size_t)k, 0); continue; }
int e = SSL_get_error(r->ssl, k);
if (e == SSL_ERROR_ZERO_RETURN) fail(r, "the browser closed DTLS");
else if (e != SSL_ERROR_WANT_READ && e != SSL_ERROR_WANT_WRITE) { ERR_clear_error(); fail(r, "DTLS error"); }
@@ -703,7 +704,9 @@ static void ice_check(Rtc *r, const uint8_t *p, size_t n, const RwStun *s, const
if (s->use_candidate && !pa->nominated) {
for (int i = 0; i < r->npath; i++) r->path[i].nominated = 0;
pa->nominated = 1;
- r->sel = (int)(pa - r->path);
+ /* once DTLS is up, media only moves to a path that proved to be the browser (an authenticated
+ * DTLS or SRTCP packet from it, see prove()): ICE credentials alone can't redirect the stream */
+ if (!r->dtls_up || pa->proven) r->sel = (int)(pa - r->path);
}
if (r->sel < 0) r->sel = (int)(pa - r->path);
stun_answer(r, s, from, relay);
@@ -767,6 +770,7 @@ static void turn_peer(Rtc *r, const RwAddr *a) {
}
static void handle_packet(Rtc *r, const uint8_t *p, size_t n, const RwAddr *from, int relay);
+static void prove(Rtc *r, Path *pa);
static void turn_input(Rtc *r, const uint8_t *p, size_t n, const RwStun *s) {
Turn *t = &r->turn;
@@ -829,17 +833,28 @@ static void handle_packet(Rtc *r, const uint8_t *p, size_t n, const RwAddr *from
if (p[0] >= 20 && p[0] <= 63) {
if (!r->offered) return;
if (!r->dtls_up && r->sel != (int)(pa - r->path)) r->sel = (int)(pa - r->path);
+ unsigned long before = r->dtls_rx;
dtls_input(r, p, n);
+ if (r->dtls_rx != before) prove(r, pa); /* a record that decrypted: the browser */
} else if (p[0] >= 128 && p[0] <= 191 && n >= 8 && p[1] >= 192 && p[1] <= 223 && r->srtp_up) {
uint8_t b[1500 + SRTP_MAX_TRAILER_LEN];
if (n > 1500) return;
memcpy(b, p, n);
int len = (int)n;
if (srtp_unprotect_rtcp(r->rx, b, &len) != srtp_err_status_ok) return;
+ prove(r, pa);
rw_rtcp_parse(b, (size_t)len, on_fb, r);
}
}
+/* An authenticated packet (DTLS application data or SRTCP) came from this path: it is the browser. If
+ * the browser nominated it, the media goes there now. */
+static void prove(Rtc *r, Path *pa) {
+ if (!pa || pa->proven) { if (pa && pa->nominated && r->sel != (int)(pa - r->path)) r->sel = (int)(pa - r->path); return; }
+ pa->proven = 1;
+ if (pa->nominated) r->sel = (int)(pa - r->path);
+}
+
/* ---- life cycle ---- */
int rtc_port(const Rtc *r) { return r ? r->sport : 0; }
@@ -1116,6 +1131,6 @@ int rtc_dc_open(const Rtc *r, int chan) { return r && !r->failed && chan >= 0 &&
void rtc_stats(const Rtc *r, char *out, size_t n) {
if (!r) { snprintf(out, n, "-"); return; }
- snprintf(out, n, "%s %u kbps, %.1f %% lost, %lu NACK (%lu resent), %lu PLI", r->codec == RW_CODEC_H264 ? "h264" : "vp8", r->kbps,
+ snprintf(out, n, "%s %u kbps, %.1f %% lost, %lu NACK (%lu resent), %lu PLI", r->codec == RW_CODEC_H264 ? "h264" : r->codec ? "vp8" : "no codec yet", r->kbps,
r->lost * 100, r->nacks, r->resent, r->plis);
}
diff --git a/tools/iso/build.sh b/tools/iso/build.sh
index e2e5209..9414068 100755
--- a/tools/iso/build.sh
+++ b/tools/iso/build.sh
@@ -3,7 +3,7 @@
# with BIOS and UEFI boot. See docs/ISO.md.
#
# Usage (as root, on Debian 13, from the root of the already built repository):
-# make -C server -j"$(nproc)" # lord-server and lord-sessiond (needs libssl-dev; clang for lord-netperm's BPF)
+# make -C server -j"$(nproc)" # lord-server and lord-sessiond (needs libssl-dev; libsrtp2-dev + libusrsctp-dev for the remote desktop's video; clang for lord-netperm's BPF)
# (the themes: npm run build on the development machine; the .bundle.js files travel with the tree)
# sudo tools/iso/build.sh [work folder] # default /var/tmp/lordos-iso
#
diff --git a/tools/iso/mkdeb.sh b/tools/iso/mkdeb.sh
index 86aea56..db79713 100755
--- a/tools/iso/mkdeb.sh
+++ b/tools/iso/mkdeb.sh
@@ -229,6 +229,9 @@ DOCDEPS=""
if [ -x "$L/bin/lord-doc" ]; then DOCDEPS=", libpoppler-glib8t64, libarchive13t64, libcairo2, libfreetype6, libfontconfig1, poppler-data"; fi
MEDIADEPS=""
if [ -x "$L/bin/lord-media" ]; then MEDIADEPS=", libavcodec61, libavformat61, libavutil59, libswscale8, libswresample5, libva2, libva-drm2"; fi
+# the remote desktop's video (docs/REMOTE.md, "Video (WebRTC)"): lord-sessiond built with libsrtp2 and usrsctp
+RTCDEPS=""
+if objdump -p "$L/bin/lord-sessiond" 2>/dev/null | grep -q "libsrtp2"; then RTCDEPS=", libsrtp2-1, libusrsctp2"; fi
SIZE=$(du -sk "$PKG/usr" | awk '{s += $1} END {print s}')
cat > "$PKG/DEBIAN/control" <<C
Package: lordos
@@ -236,7 +239,7 @@ Version: $VERSION
Architecture: ${DEB_ARCH:-$(dpkg --print-architecture)}
Maintainer: LordOS <[email protected]>
Installed-Size: $SIZE
-Depends: libc6 (>= 2.38), libwayland-server0 (>= 1.22), libwayland-client0 (>= 1.22), libxkbcommon0 (>= 1.5), libcrypt1, libssl3t64 | libssl3, ca-certificates, passwd, procps, xkb-data$GPUDEPS$DOCDEPS$MEDIADEPS
+Depends: libc6 (>= 2.38), libwayland-server0 (>= 1.22), libwayland-client0 (>= 1.22), libxkbcommon0 (>= 1.5), libcrypt1, libssl3t64 | libssl3, ca-certificates, passwd, procps, xkb-data$GPUDEPS$DOCDEPS$MEDIADEPS$RTCDEPS
Recommends: pipewire-pulse, wireplumber, wpasupplicant, openvpn, fonts-noto-core, locales, tzdata, sudo, cups, cups-client, avahi-daemon, mesa-va-drivers, bluez, libspa-0.2-bluetooth, power-profiles-daemon, systemd-timesyncd, shared-mime-info, gsettings-desktop-schemas, xwayland
Section: x11
Priority: optional
diff --git a/tools/rpi/build-img.sh b/tools/rpi/build-img.sh
index 207c11c..b71ab9a 100755
--- a/tools/rpi/build-img.sh
+++ b/tools/rpi/build-img.sh
@@ -95,7 +95,7 @@ PKGS_SSH="openssh-server"
PKGS_SPLASH="plymouth plymouth-label"
# to build lord-server (only in the build chroot, not in the image)
PKGS_BUILD="build-essential pkg-config libxkbcommon-dev libwayland-dev wayland-protocols libgbm-dev libegl-dev libgles-dev
- libssl-dev libcrypt-dev dpkg-dev file"
+ libssl-dev libcrypt-dev libsrtp2-dev libusrsctp-dev dpkg-dev file"
echo "== LordOS $VERSION: Raspberry Pi image in $WORK (host $(uname -m))"
kernel_warning() {