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: peer numbers in signaling, the TURN key for later peers, clearer failure reasons

Federico Pereirad56a82ecbacf
diff --git a/apps/settings/Sharing.jsx b/apps/settings/Sharing.jsx
index 3db09cb..0d37b3c 100644
--- a/apps/settings/Sharing.jsx
+++ b/apps/settings/Sharing.jsx
@@ -154,8 +154,10 @@ function ConnectionSection({ st, isAdmin, busy, run }) {
<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.turnTransport')}</Text>
- <Segmented small value={transport} onChange={(v) => { setTransport(v); setBad(''); }}
- options={[['udp', tr('settings.sharing.turnUdp')], ['tcp', tr('settings.sharing.turnTcp')], ['tls', tr('settings.sharing.turnTls')]]} />
+ <View style={{ alignSelf: 'flex-start' }}>
+ <Segmented small value={transport} onChange={(v) => { setTransport(v); setBad(''); }}
+ options={[['udp', tr('settings.sharing.turnUdp')], ['tcp', tr('settings.sharing.turnTcp')], ['tls', tr('settings.sharing.turnTls')]]} />
+ </View>
{transport === 'tls' && <Text style={label}>{tr('settings.sharing.turnFp')}</Text>}
{transport === 'tls' && <TextInput value={fp} placeholder={tr('settings.sharing.turnFpPlaceholder')} style={{ direction: 'ltr', fontFamily: 'monospace' }}
onChange={(v) => { setFp(v.slice(0, 95)); setBad(''); }} />}
diff --git a/server/src/remote/client.html b/server/src/remote/client.html
index b575985..794eefa 100644
--- a/server/src/remote/client.html
+++ b/server/src/remote/client.html
@@ -71,7 +71,7 @@ const L = {
dtlsWhat: 'Try again. If it keeps happening, something between you (a proxy or security software) is altering the connection.',
lost: 'The connection was lost and didn’t come back.', lostWhat: 'Check the network on both sides. When it is back, try again: you stay signed in.',
server: 'The computer couldn’t start the video connection.', serverWhat: 'Try again. If it keeps happening, turn the remote desktop off and on in Settings → Sharing.',
- offer: 'The computer refused this browser’s connection offer.', offerWhat: 'Update the browser and try again.',
+ offer: 'The computer refused or didn’t answer this browser’s connection offer.', offerWhat: 'Update the browser and try again. If it keeps happening, an extension may be changing the page.',
media: 'The connection is up, but no picture arrived.', mediaWhat: 'This browser may not be able to play H.264 or VP8 video right now (hardware decoding turned off, or a codec blocked). Try another browser.',
wsdown: 'The computer can’t be reached: the connection to it was lost.', wsdownWhat: 'Check that the computer is on and on the network. This page keeps trying on its own.',
},
@@ -89,7 +89,7 @@ const L = {
dtlsWhat: 'Reintentá. Si sigue pasando, algo entre ustedes (un proxy o un programa de seguridad) está alterando la conexión.',
lost: 'La conexión se cortó y no volvió.', lostWhat: 'Revisá la red de los dos lados. Cuando vuelva, reintentá: la sesión sigue iniciada.',
server: 'La computadora no pudo iniciar la conexión de video.', serverWhat: 'Reintentá. Si sigue pasando, apagá y encendé el escritorio remoto en Ajustes → Compartir.',
- offer: 'La computadora rechazó la propuesta de conexión de este navegador.', offerWhat: 'Actualizá el navegador y reintentá.',
+ offer: 'La computadora rechazó o no respondió la propuesta de conexión de este navegador.', offerWhat: 'Actualizá el navegador y reintentá. Si sigue pasando, puede que una extensión esté modificando la página.',
media: 'La conexión está establecida, pero no llegó imagen.', mediaWhat: 'Puede que este navegador no pueda reproducir video H.264 o VP8 ahora (decodificación por hardware apagada o un códec bloqueado). Probá con otro navegador.',
wsdown: 'No se puede llegar a la computadora: se perdió la conexión.', wsdownWhat: 'Comprobá que la computadora esté encendida y en la red. Esta página sigue intentando sola.',
},
@@ -107,7 +107,7 @@ const L = {
dtlsWhat: 'Tente de novo. Se continuar, algo entre vocês (um proxy ou um programa de segurança) está alterando a conexão.',
lost: 'A conexão caiu e não voltou.', lostWhat: 'Verifique a rede dos dois lados. Quando voltar, tente de novo: a sessão continua iniciada.',
server: 'O computador não conseguiu iniciar a conexão de vídeo.', serverWhat: 'Tente de novo. Se continuar, desligue e ligue a área de trabalho remota em Ajustes → Compartilhar.',
- offer: 'O computador recusou a proposta de conexão deste navegador.', offerWhat: 'Atualize o navegador e tente de novo.',
+ offer: 'O computador recusou ou não respondeu a proposta de conexão deste navegador.', offerWhat: 'Atualize o navegador e tente de novo. Se continuar, uma extensão pode estar modificando a página.',
media: 'A conexão está estabelecida, mas nenhuma imagem chegou.', mediaWhat: 'Este navegador talvez não consiga reproduzir vídeo H.264 ou VP8 agora (decodificação por hardware desligada ou um codec bloqueado). Tente outro navegador.',
wsdown: 'Não é possível alcançar o computador: a conexão caiu.', wsdownWhat: 'Verifique se o computador está ligado e na rede. Esta página continua tentando sozinha.',
},
@@ -218,7 +218,7 @@ function failure(why, detail) {
// ---- the WebRTC peer: H.264/VP8 + Opus from the session's encoder; input and the lossless refresh
// of still areas over data channels ----
-let pc = null, dcIn = null, vmode = false, codec = '', iceServers = [], offering = false, offersSent = 0, answersGot = 0;
+let pc = null, dcIn = null, vmode = false, codec = '', iceServers = [], offering = false, offersSent = 0, answersGot = 0, peerNo = 0;
let playTimer = 0, discTimer = 0, restartTimer = 0, restartTries = 0, peerFails = 0, everPlayed = false, serverWhy = '';
function setMode() { $('mode').textContent = vmode ? `${T.video} · ${codec.toUpperCase()}${rd.path ? ' · ' + rd.path.toUpperCase() : ''}` : ''; }
function clearTimers() { clearTimeout(playTimer); clearTimeout(discTimer); clearTimeout(restartTimer); }
@@ -260,7 +260,7 @@ function offer(restart) {
const p = pc;
offering = true;
p.createOffer(restart ? { iceRestart: true } : {}).then((o) => p.setLocalDescription(o)).then(() => gathered(p))
- .then(() => { if (pc === p) { offersSent++; send({ t: 'rtc', sdp: p.localDescription.sdp }); } })
+ .then(() => { if (pc === p) { offersSent++; send({ t: 'rtc', sdp: p.localDescription.sdp, p: peerNo }); } })
.catch(() => { offering = false; if (pc === p) peerFailed('offer', 'createOffer'); });
}
function startPeer() {
@@ -285,7 +285,7 @@ function startPeer() {
if (vid.srcObject !== ms) vid.srcObject = ms;
vid.play().catch(() => {});
};
- pc.onicecandidate = (e) => { if (e.candidate && e.candidate.candidate && !offering) send({ t: 'ice', c: e.candidate.candidate }); };
+ pc.onicecandidate = (e) => { if (e.candidate && e.candidate.candidate && !offering) send({ t: 'ice', c: e.candidate.candidate, p: peerNo }); };
pc.oniceconnectionstatechange = () => iceState(pc && pc.iceConnectionState);
offer(false);
// no picture within 15 s: say why (the server's reason if it gave one, else what this side saw)
@@ -358,7 +358,7 @@ function diagnose(p) {
});
const ice = p.iceConnectionState, dtls = p.connectionState;
let why = serverWhy;
- if (!why) why = ok === 0 ? 'noroute' : dtls !== 'connected' ? 'dtls' : 'media';
+ if (!why) why = answersGot === 0 ? 'offer' : ok === 0 ? 'noroute' : dtls !== 'connected' ? 'dtls' : 'media';
if (why === 'noroute' && ok > 0) why = 'dtls';
return { why, text: `ICE ${ice}, ${dtls}; ${pairs} candidate pairs (${ok} succeeded), the computer offered ${udp} UDP and ${tcp} TCP addresses still listed; ${gotFrames} frames decoded${serverWhy ? '; the computer said: ' + serverWhy : ''}` };
}).catch(() => base);
@@ -445,8 +445,11 @@ function onText(m) {
$('who').textContent = `${m.user}@${location.hostname}`;
if (!m.rtc || !Array.isArray(m.ice)) { failure('server', 'the computer has no WebRTC peer for this connection'); return; }
iceServers = m.ice;
+ peerNo = m.p || 1;
startPeer();
} else if (m.t === 'rtc') {
+ if (m.ready && m.p) peerNo = m.p;
+ if (m.sdp && m.p && m.p !== peerNo) return; // the answer of a peer that's already gone
if (m.fail) {
// the bridge closed this peer and says why (RTC_WHY_* in rtc.h, or codec, offer, restart, or
// browser: the page asked for it); a new peer comes with "ready" (or in a later message)
diff --git a/server/src/remote/conn.c b/server/src/remote/conn.c
index 843b126..8de1d4d 100644
--- a/server/src/remote/conn.c
+++ b/server/src/remote/conn.c
@@ -74,6 +74,9 @@ static double deadline;
static int lock_fd = -1; /* bridge → root parent: "L" = the session was locked */
static char *turn_pass; /* read as root before the bridge drops root; the bridge's rtc.c owns it */
static int ice_lfd = -1; /* ICE-TCP handoff: root's /run/lordos/rtc/<route>, kept by the bridge */
+static int turn_has_key; /* the TURN key a peer derived, for the next peer (the password is gone) */
+static uint8_t turn_key_saved[16];
+static char turn_realm_saved[256];
static char ice_route[9];
static char ice_path[64];
@@ -604,7 +607,7 @@ static int tiles_lost; /* a refresh tile didn't fit the data cha
static double tiles_lost_at;
static Rtc *rtc;
static const char *rtc_dead; /* RTC_WHY_* of a peer that just failed */
-static int resets;
+static int resets; /* peers made after the first; the current one is number resets + 1 */
static double reset_at;
static int W, H;
static int locked, closing;
@@ -789,13 +792,16 @@ static void from_browser(const char *j, size_t n, int dc) {
case RS_IN_PING: ws_text("{\"t\":\"pong\",\"ts\":%lld}", in.ts); break;
case RS_IN_CLIP: sess_send(RP_SETCLIP, in.text, in.tlen); break;
case RS_IN_RTC:
+ /* an offer for an older peer of this connection (sent before the page learned of the new
+ * one): never the new peer's first offer */
+ if (rtc && in.a && in.a != resets + 1) { sd_log("video: ignored an offer for an older peer"); break; }
if (rtc) {
int first = rtc_codec(rtc) == 0, e = rtc_offer(rtc, in.text, in.tlen, 1);
if (e < 0) video_reset(e == RW_ECODEC ? "codec" : first ? "offer" : "restart",
e == RW_ECODEC ? "the browser offers neither H.264 nor VP8" : first ? "the offer was refused" : "the ICE restart was refused");
}
break;
- case RS_IN_ICE: if (rtc) rtc_candidate(rtc, in.text, in.tlen); break;
+ case RS_IN_ICE: if (rtc && (!in.a || in.a == resets + 1)) rtc_candidate(rtc, in.text, in.tlen); break;
case RS_IN_VMODE: if (in.a) video_mode(); else video_reset("browser", "the browser closed this peer"); break;
default: break;
}
@@ -929,10 +935,16 @@ static int rtc_start(void) {
memcpy(c.turn_fp, rd_conf.turn_fp, 32);
c.turn_pass = turn_pass; /* rtc.c owns it now and wipes it */
turn_pass = NULL;
+ if (!c.turn_pass && turn_has_key) {
+ c.turn_has_key = 1;
+ memcpy(c.turn_key, turn_key_saved, 16);
+ memcpy(c.turn_realm, turn_realm_saved, sizeof c.turn_realm);
+ }
c.max_kbps = 12000;
c.ice_lfd = ice_lfd;
memcpy(c.route, ice_route, sizeof c.route);
c.tcp_port = rd_conf.port;
+ c.peer_no = resets + 1;
RtcCallbacks cb = { rtc_signal, rtc_state, rtc_message, rtc_key, rtc_rate, NULL };
rtc = rtc_new(&c, &cb);
return rtc ? 0 : -1;
@@ -948,6 +960,7 @@ static void video_reset(const char *code, const char *why) {
if (vmode) { unsigned char v = 0; sess_send(RP_VMODE, &v, 1); vmode = 0; }
unsigned char v[8] = { 0 };
sess_send(RP_VIDEO, v, 8);
+ if (!rtc_turn_key(rtc, turn_key_saved, turn_realm_saved)) turn_has_key = 1;
rtc_free(rtc);
rtc = NULL;
tiles_lost = 0;
@@ -959,7 +972,7 @@ static void video_reset(const char *code, const char *why) {
char ice[600];
if (rtc_start()) { ws_text("{\"t\":\"rtc\",\"fail\":\"%s\",\"why2\":\"server\"}", code); return; }
ice_list(ice, sizeof ice);
- ws_text("{\"t\":\"rtc\",\"fail\":\"%s\",\"ready\":1,\"ice\":%s}", code, ice);
+ ws_text("{\"t\":\"rtc\",\"fail\":\"%s\",\"ready\":1,\"p\":%d,\"ice\":%s}", code, resets + 1, ice);
}
static void bridge(const struct passwd *pw) {
@@ -971,7 +984,7 @@ static void bridge(const struct passwd *pw) {
if (rtc_start() == 0) {
char ice[600];
ice_list(ice, sizeof ice);
- ws_text("{\"t\":\"hello\",\"user\":\"%s\",\"rtc\":1,\"ice\":%s}", pw->pw_name, ice);
+ ws_text("{\"t\":\"hello\",\"user\":\"%s\",\"rtc\":1,\"p\":1,\"ice\":%s}", pw->pw_name, ice);
} else ws_text("{\"t\":\"hello\",\"user\":\"%s\",\"rtc\":0}", pw->pw_name);
rs_ws_init(&wsr, RS_WS_MAX_MSG);
unsigned char *sin = NULL;
@@ -1049,7 +1062,7 @@ static void bridge(const struct passwd *pw) {
} else if (reset_at && rd_now() >= reset_at && !closing) { /* a reset that had to wait: the new peer */
reset_at = rd_now();
char ice[600];
- if (rtc_start() == 0) { ice_list(ice, sizeof ice); ws_text("{\"t\":\"rtc\",\"ready\":1,\"ice\":%s}", ice); }
+ if (rtc_start() == 0) { ice_list(ice, sizeof ice); ws_text("{\"t\":\"rtc\",\"ready\":1,\"p\":%d,\"ice\":%s}", resets + 1, ice); }
else { ws_text("{\"t\":\"rtc\",\"fail\":\"server\"}"); reset_at = 0; }
}
if (locked) { ws_flush(); return; }
diff --git a/server/src/remote/rsec.c b/server/src/remote/rsec.c
index 4b27e6f..d162986 100644
--- a/server/src/remote/rsec.c
+++ b/server/src/remote/rsec.c
@@ -530,6 +530,7 @@ int rs_browser_input(const RsJson *j, int W, int H, RsInput *in) {
size_t tl = 0;
const char *t = rs_json_str(j, "t", &tl);
long long a, b;
+ size_t pl = 0;
if (!t || tl > 6) return RS_IN_NONE;
if (!strcmp(t, "m")) {
if (W <= 0 || H <= 0 || rs_json_num(j, "x", &a) || rs_json_num(j, "y", &b)) return RS_IN_NONE;
@@ -595,6 +596,8 @@ int rs_browser_input(const RsJson *j, int W, int H, RsInput *in) {
size_t l = 0;
const char *x = rs_json_str(j, "sdp", &l);
if (!x || l < 10 || l > RS_SDP_MAX) return RS_IN_NONE;
+ if (rs_json_str(j, "p", &pl) || (!rs_json_num(j, "p", &a) && (a < 1 || a > 1000000))) return RS_IN_NONE;
+ in->a = rs_json_num(j, "p", &a) ? 0 : (int)a; /* the peer it is for (0: not said) */
in->text = x;
in->tlen = l;
return in->type = RS_IN_RTC;
@@ -603,6 +606,8 @@ int rs_browser_input(const RsJson *j, int W, int H, RsInput *in) {
size_t l = 0;
const char *x = rs_json_str(j, "c", &l);
if (!x || l > 512) return RS_IN_NONE;
+ if (rs_json_str(j, "p", &pl) || (!rs_json_num(j, "p", &a) && (a < 1 || a > 1000000))) return RS_IN_NONE;
+ in->a = rs_json_num(j, "p", &a) ? 0 : (int)a;
in->text = x;
in->tlen = l;
return in->type = RS_IN_ICE;
diff --git a/server/src/remote/rsec.h b/server/src/remote/rsec.h
index 5c2c613..50d19fe 100644
--- a/server/src/remote/rsec.h
+++ b/server/src/remote/rsec.h
@@ -108,7 +108,8 @@ enum { RS_IN_NONE = 0, RS_IN_PTR, RS_IN_BTN, RS_IN_WHEEL, RS_IN_SCROLL, RS_IN_PI
#define RS_CLIP_MAX (1u << 20)
typedef struct {
int type;
- int a, b; /* PTR x,y · BTN button,down · WHEEL steps · KEY code,down · RESIZE w,h · SCROLL/PINCH phase · VMODE on */
+ int a, b; /* PTR x,y · BTN button,down · WHEEL steps · KEY code,down · RESIZE w,h · SCROLL/PINCH phase · VMODE on
+ * · RTC/ICE the peer number "p" (0 if absent) */
int32_t v1, v2; /* SCROLL dx,dy (1/256 px) · PINCH scale ×65536, rotation ×256 */
long long ts; /* PING */
const char *text; /* CLIP, RTC (the SDP offer), ICE (a candidate; "" ends) (inside the RsJson buffer) */
diff --git a/server/src/remote/rtc.c b/server/src/remote/rtc.c
index 8107b10..7f457ad 100644
--- a/server/src/remote/rtc.c
+++ b/server/src/remote/rtc.c
@@ -879,7 +879,11 @@ static void turn_send(Rtc *r, uint16_t type, int auth, const RwAddr *peers, int
t->sent_at = now_ms();
}
+/* The TURN password (first peer) or the key a previous peer derived from it: gone once used, or when
+ * there will be no relay. */
static void wipe_pass(Rtc *r) {
+ explicit_bzero(r->cfg.turn_key, sizeof r->cfg.turn_key);
+ r->cfg.turn_has_key = 0;
if (!r->cfg.turn_pass) return;
explicit_bzero(r->cfg.turn_pass, strlen(r->cfg.turn_pass));
free(r->cfg.turn_pass);
@@ -888,6 +892,12 @@ static void wipe_pass(Rtc *r) {
/* long-term credential key: MD5(user ":" realm ":" password) (RFC 8489 §9.2.2) */
static int turn_key(Rtc *r) {
+ /* a later peer of the same bridge: the key derived by the first one, for the same realm only */
+ if (!r->cfg.turn_pass && r->cfg.turn_has_key && !strcmp(r->cfg.turn_realm, r->turn.realm)) {
+ memcpy(r->turn.key, r->cfg.turn_key, 16);
+ wipe_pass(r);
+ return 0;
+ }
if (!r->cfg.turn_pass) return -1;
char buf[1024];
int k = snprintf(buf, sizeof buf, "%s:%s:%s", r->cfg.turn_user, r->turn.realm, r->cfg.turn_pass);
@@ -1080,7 +1090,7 @@ static void tcp_input(Rtc *r, int i) {
for (int rounds = 0; c->fd >= 0 && rounds < 64; rounds++) {
if (c->inl < sizeof c->in) {
ssize_t got = recv(c->fd, c->in + c->inl, sizeof c->in - c->inl, MSG_DONTWAIT);
- if (got == 0) { tcp_close(r, i, "closed by the browser"); return; }
+ if (got == 0) { tcp_close(r, i, "closed by the other end"); return; }
if (got < 0 && errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) { tcp_close(r, i, "read failed"); return; }
if (got > 0) c->inl += (size_t)got;
}
@@ -1271,7 +1281,7 @@ Rtc *rtc_new(const RtcConfig *cfg, const RtcCallbacks *cb) {
raw_send(r, &a, o.b, o.n);
r->nstun_srv++;
}
- if (cfg->turn[0] && cfg->turn_user[0] && cfg->turn_pass) {
+ if (cfg->turn[0] && cfg->turn_user[0] && (cfg->turn_pass || cfg->turn_has_key)) {
Turn *t = &r->turn;
t->transport = cfg->turn_transport;
const char *colon = strrchr(cfg->turn, ':');
@@ -1428,8 +1438,8 @@ static void send_answer(Rtc *r) {
int l = rw_sdp_answer(r->of, &an, sdp, sizeof sdp);
if (l < 0) { fail(r, RTC_WHY_SERVER, "the answer does not fit"); return; }
json_escape(sdp, esc, sizeof esc);
- snprintf(msg, sizeof msg, "{\"t\":\"rtc\",\"sdp\":\"%s\",\"codec\":\"%s\"%s}", esc, r->codec == RW_CODEC_H264 ? "h264" : "vp8",
- r->restarts ? ",\"restart\":1" : "");
+ snprintf(msg, sizeof msg, "{\"t\":\"rtc\",\"sdp\":\"%s\",\"codec\":\"%s\",\"p\":%d%s}", esc, r->codec == RW_CODEC_H264 ? "h264" : "vp8",
+ r->cfg.peer_no, r->restarts ? ",\"restart\":1" : "");
if (r->cb.signal) r->cb.signal(r->cb.ud, msg);
}
@@ -1613,6 +1623,13 @@ void rtc_tick(Rtc *r) {
fail(r, r->checks ? RTC_WHY_DTLS : RTC_WHY_NOROUTE, r->checks ? "no DTLS after 20 s (ICE checks arrived)" : "no connection after 20 s (no ICE check arrived over UDP or TCP)");
}
+int rtc_turn_key(const Rtc *r, uint8_t key[16], char realm[256]) {
+ if (!r || r->turn.state != 3) return -1;
+ memcpy(key, r->turn.key, 16);
+ memcpy(realm, r->turn.realm, 256);
+ return 0;
+}
+
const char *rtc_path_kind(const Rtc *r) {
const Path *s = r && r->sel >= 0 ? &r->path[r->sel] : NULL;
return !s ? "" : s->relay ? "relay" : s->tcp ? "tcp" : "udp";
diff --git a/server/src/remote/rtc.h b/server/src/remote/rtc.h
index 1f0762e..d6cd6b9 100644
--- a/server/src/remote/rtc.h
+++ b/server/src/remote/rtc.h
@@ -48,6 +48,11 @@ typedef struct {
int turn_has_fp; /* TLS: pin this certificate instead of the system's CAs */
uint8_t turn_fp[32];
char *turn_pass; /* in memory only; rtc_new takes it over and wipes it when done */
+ /* or, for a later peer of the same bridge, the long-term key the first one derived (MD5 of
+ * user:realm:password, RFC 8489 §9.2.2), for that realm only; never the password again */
+ int turn_has_key;
+ uint8_t turn_key[16];
+ char turn_realm[256];
unsigned max_kbps;
/* ICE over TCP: lord-sessiond's root connection child hands us, over this listening socket (root's
* /run/lordos/rtc/<route>, created before the bridge dropped root), each TCP connection to the
@@ -55,6 +60,7 @@ typedef struct {
int ice_lfd;
char route[9]; /* 8 characters [A-Za-z0-9]: the start of every ufrag we use */
int tcp_port; /* the remote desktop port, for our passive TCP candidates */
+ int peer_no; /* this connection's peer number, echoed in our answers ("p") */
} RtcConfig;
Rtc *rtc_new(const RtcConfig *cfg, const RtcCallbacks *cb);
@@ -84,6 +90,8 @@ void rtc_audio(Rtc *r, const uint8_t *p, size_t n, uint32_t samples);
/* Data channel message; -1 if the channel isn't open or its send buffer is full (try later). */
int rtc_send(Rtc *r, int chan, const void *p, size_t n, int binary);
int rtc_dc_open(const Rtc *r, int chan);
+/* The TURN long-term key and realm of an allocated relay, for the bridge's next peer. 0 or -1. */
+int rtc_turn_key(const Rtc *r, uint8_t key[16], char realm[256]);
/* "udp", "tcp" or "relay": how the media goes now ("" before it does) */
const char *rtc_path_kind(const Rtc *r);
/* Line for the logs and the browser's status: "h264 2400 kbps 1.2 % lost" */
diff --git a/server/tests/remote_sec_test.c b/server/tests/remote_sec_test.c
index 4b62c20..6c98fd7 100644
--- a/server/tests/remote_sec_test.c
+++ b/server/tests/remote_sec_test.c
@@ -909,6 +909,17 @@ static void test_signal(void) {
CHECK(rs_json_parse(j, strlen(j), &o, sb, sizeof sb) == 0 && rs_browser_input(&o, 1280, 800, &in) == RS_IN_ICE);
j = "{\"t\":\"ice\",\"c\":\"\"}";
CHECK(rs_json_parse(j, strlen(j), &o, sb, sizeof sb) == 0 && rs_browser_input(&o, 1280, 800, &in) == RS_IN_ICE && in.tlen == 0);
+ /* the peer number: optional, 1..1000000, an integer */
+ j = "{\"t\":\"rtc\",\"sdp\":\"v=0\\r\\nm=video 9\",\"p\":3}";
+ CHECK(rs_json_parse(j, strlen(j), &o, sb, sizeof sb) == 0 && rs_browser_input(&o, 1280, 800, &in) == RS_IN_RTC && in.a == 3);
+ j = "{\"t\":\"rtc\",\"sdp\":\"v=0\\r\\nm=video 9\"}";
+ CHECK(rs_json_parse(j, strlen(j), &o, sb, sizeof sb) == 0 && rs_browser_input(&o, 1280, 800, &in) == RS_IN_RTC && in.a == 0);
+ j = "{\"t\":\"rtc\",\"sdp\":\"v=0\\r\\nm=video 9\",\"p\":0}";
+ CHECK(rs_json_parse(j, strlen(j), &o, sb, sizeof sb) == 0 && rs_browser_input(&o, 1280, 800, &in) == RS_IN_NONE);
+ j = "{\"t\":\"ice\",\"c\":\"\",\"p\":1000001}";
+ CHECK(rs_json_parse(j, strlen(j), &o, sb, sizeof sb) == 0 && rs_browser_input(&o, 1280, 800, &in) == RS_IN_NONE);
+ j = "{\"t\":\"ice\",\"c\":\"\",\"p\":\"2\"}";
+ CHECK(rs_json_parse(j, strlen(j), &o, sb, sizeof sb) == 0 && rs_browser_input(&o, 1280, 800, &in) == RS_IN_NONE); /* a string: refused */
j = "{\"t\":\"vmode\",\"on\":1}";
CHECK(rs_json_parse(j, strlen(j), &o, sb, sizeof sb) == 0 && rs_browser_input(&o, 1280, 800, &in) == RS_IN_VMODE && in.a == 1);
j = "{\"t\":\"vmode\",\"on\":2}";