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.
C cdebiandesktop-environmentebpffirewalllandlocklinuxlinux-distributionopen-sourceprivacyquickjsraspberry-pi-5reactsecuritywaylandwayland-compositor
Remote desktop: VPN fail-open fix, allowlist/blocklist sections, Monitor → Network panel
Federico Pereira1859a04b5689
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7f19d66..f296ffe 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -50,11 +50,15 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),the selected sidebar row, an underline or a ring on the focused field, and bordered buttons. LordDefault looks as before; Classic uses smaller radii, borders and subtle highlights. Isolatedapps (Mail, Calendar, Contacts, Reminders, Passwords) follow it too.-- **Remote desktop: blocked and allowed addresses.** Settings → Sharing lists the addresses that- are blocked, with the time left and an **Unblock** button, blocks an address or network by hand,- and chooses who may connect: the **local network** (the default: private and link-local- addresses and connections that arrive over a VPN of this computer), **only these addresses**, or- **any address**. You get a notification when an address is blocked.+- **Remote desktop: allowlist, blocklist and temporary blocks.** Settings → Sharing chooses who+ may connect: the **local network** (the default: private and link-local addresses and+ connections over a VPN of this computer), **only these addresses** (the allowlist), or **any+ address**; keeps a **blocklist** of addresses and networks that are always refused; and lists the+ **temporarily blocked** addresses with the time left, **Unblock** and **Block permanently**. You+ get a notification when an address is blocked.+- **Monitor → Network shows the remote desktop** as one more app while it's on: the browsers+ connected with their traffic, the recent failed sign-ins (address and the name typed, for+ administrators), the blocks and the lists, with Block and Unblock.### Changeddiff --git a/apps/monitor/Network.jsx b/apps/monitor/Network.jsxindex d6bbea3..5bcfa06 100644--- a/apps/monitor/Network.jsx+++ b/apps/monitor/Network.jsx@@ -22,6 +22,7 @@ import { MapView } from './MapView.jsx';import { TrafficChart, systemBuckets } from './TrafficChart.jsx';import { RuleSheet } from './RuleSheet.jsx';import { HistoryControls, HistoryChart, useHistory } from './History.jsx';+import { REMOTE_KEY, RemoteDetail, remoteGroup, useRemoteDesktop } from './RemoteDesktop.jsx';export const appKeyOf = (c) => (c.self ? 'lordos' : c.app || c.exe || c.name || '?');const countryName = (cc) => (cc ? tOptional(`countries.${cc}`) || cc : '');@@ -718,7 +719,11 @@ export function NetworkTab({ last, prefs }) {const sys = useSystemInfo(60000);const { apps: connApps } = useGroups(conns);const launcher = useLauncherApps();- const apps = useMemo(() => withFirewall(connApps, fw, launcher), [connApps, fw, launcher]);+ const fwApps = useMemo(() => withFirewall(connApps, fw, launcher), [connApps, fw, launcher]);+ // the remote desktop (lord-sessiond, root) as one more app while it's on (RemoteDesktop.jsx)+ const rd = useRemoteDesktop();+ const rdg = remoteGroup(rd, tr);+ const apps = rdg ? [...fwApps, rdg].sort((a, b) => b.sent + b.recv - (a.sent + a.recv) || b.conns.length - a.conns.length) : fwApps;const [q, setQ] = useState('');const [open, setOpen] = useState(() => new Set());const [selected, setSelected] = useState(null); // app elegida (clave)@@ -792,7 +797,7 @@ export function NetworkTab({ last, prefs }) {<View style={{ ...column, width: 270 }}><ScrollView style={{ flex: 1, marginHorizontal: -12 }} contentStyle={{ paddingHorizontal: 12 }}><View style={{ gap: 16 }}>- {selPlace ? <PlaceDetail p={selPlace} tr={tr} /> : sel ? (+ {selPlace ? <PlaceDetail p={selPlace} tr={tr} /> : sel?.key === REMOTE_KEY ? <RemoteDetail rd={rd} Section={Section} KV={KV} tr={tr} /> : sel ? (<Detail g={sel} tr={tr} user={sys.user} names={names} host={host} onHost={setHost} hist={hist.get(sel.key)} range={range} end={end} onRule={(addr, action) => ruleFor(sel, addr, action)} />) : <Summary groups={apps} conns={conns} last={last} tr={tr} fw={fw} names={names} range={range} sysHist={sysHist} launcher={launcher} />}</View>diff --git a/apps/monitor/RemoteDesktop.jsx b/apps/monitor/RemoteDesktop.jsxnew file mode 100644index 0000000..6e39bb6--- /dev/null+++ b/apps/monitor/RemoteDesktop.jsx@@ -0,0 +1,189 @@+// RemoteDesktop.jsx — the remote desktop as one more app in Monitor → Network (0.8.3, docs/MONITOR.md,+// "Remote desktop"). lord-sessiond serves it as root, outside the session's apps, so its connections+// never show up among them: this file builds its row from lord-sessiond's own state, read-only+// (/run/lordos/status.json through remote.status(): clients with their traffic, blocks and lists),+// and, for administrators, the recent failed sign-ins through the fixed admin action+// remote-failures (an address, the cleaned name that was typed, a count; never a password). Block and+// Unblock use the same validated admin actions as Settings → Sharing (remoteAccess).+import { View, Text, Button, TextInput, useTheme, useLocale, remote, remoteAccess, remoteCidr, remoteMinutesLeft, admin, formatBytes, formatNumber, useSystemInfo } from '@lordos/sdk';+import { useEffect, useRef, useState } from 'react';++export const REMOTE_KEY = 'remote-desktop';++// The app's icon: the Sharing glyph of Settings (green, two arrows).+export function RemoteGlyph({ size = 16 }) {+ return (+ <View style={{ width: size, height: size, borderRadius: Math.round(size * 0.24), backgroundColor: '#34c759', alignItems: 'center', justifyContent: 'center' }}>+ <Text style={{ fontSize: Math.round(size * 0.68), fontWeight: 700, color: '#fff', lineHeight: 1 }}>⇄</Text>+ </View>+ );+}++const agoMin = (sec) => Math.max(0, Math.round((Date.now() / 1000 - sec) / 60));++// lord-sessiond's state every 2 s (and the failed sign-ins every 5 s, administrators only) while the+// Network tab is open; the traffic rates are the difference between two readings.+export function useRemoteDesktop() {+ const [st, setSt] = useState(() => remote.status());+ const [fails, setFails] = useState(null); // null: not available (not an administrator)+ const prev = useRef({ t: 0, bytes: new Map() });+ const rates = useRef(new Map());+ useEffect(() => {+ let alive = true;+ const read = () => {+ const s = remote.status();+ const now = Date.now(), dt = prev.current.t ? Math.max(0.5, (now - prev.current.t) / 1000) : 0;+ const bytes = new Map();+ for (const c of s.clients) {+ const old = prev.current.bytes.get(c.pid);+ bytes.set(c.pid, [c.rx || 0, c.tx || 0]);+ rates.current.set(c.pid, old && dt ? [Math.max(0, (c.rx || 0) - old[0]) / dt, Math.max(0, (c.tx || 0) - old[1]) / dt] : [0, 0]);+ }+ prev.current = { t: now, bytes };+ if (alive) setSt(s);+ };+ const failures = () => {+ if (!admin.available()) return;+ remoteAccess.failures().then((f) => alive && setFails(f), () => alive && setFails(null));+ };+ read();+ failures();+ const a = setInterval(read, 2000), b = setInterval(failures, 5000);+ return () => { alive = false; clearInterval(a); clearInterval(b); };+ }, []);+ return { st, fails, rates: rates.current };+}++// The row in the app list (the same shape as Network.jsx's groups). Only while it's on.+export function remoteGroup(rd, tr) {+ const { st, rates } = rd;+ if (!st.enabled) return null;+ const hosts = new Map();+ let sent = 0, recv = 0, rateTx = 0, rateRx = 0;+ const conns = st.clients.map((c) => {+ const r = rates.get(c.pid) || [0, 0];+ sent += c.tx || 0;+ recv += c.rx || 0;+ rateRx += r[0];+ rateTx += r[1];+ const h = hosts.get(c.ip) || { remote: c.ip, cc: '', scope: 'lan', ports: new Set([`TCP ${st.port}`]), sent: 0, recv: 0, rateTx: 0, rateRx: 0, count: 0 };+ h.sent += c.tx || 0;+ h.recv += c.rx || 0;+ h.count++;+ hosts.set(c.ip, h);+ return { id: `rd${c.pid}`, dir: 'in', proto: 'tcp', lport: st.port, rport: 0, remote: c.ip };+ });+ const listen = [{ id: 'rdl', dir: 'listen', proto: 'tcp', lport: st.port }];+ const name = tr('monitor.net.remoteDesktop');+ return { key: REMOTE_KEY, item: { app: REMOTE_KEY, appName: name, name }, name, exe: '', pids: new Set(), conns: [...conns, ...listen], listen, hosts,+ sent, recv, rateTx, rateRx, incoming: conns.length, verdict: 'allow', rule: 'allow', allowed: 0, denied: (rd.fails || []).reduce((a, f) => a + f.count, 0), remote: true };+}++// The detail panel. Section and KV come from Network.jsx (the same folding sections).+export function RemoteDetail({ rd, Section, KV, tr }) {+ const t = useTheme();+ const info = useSystemInfo(60000);+ const { st, fails, rates } = rd;+ const isAdmin = admin.available() && info.admin;+ const [busy, setBusy] = useState(false);+ const [msg, setMsg] = useState(null);+ const [text, setText] = useState('');+ const [bad, setBad] = useState(false);+ const run = (p) => {+ setBusy(true);+ setMsg(null);+ return p.then(() => true, (e) => { setMsg(e.message); return false; }).finally(() => setBusy(false));+ };+ const block = (ip) => run(remoteAccess.block(ip));+ const typed = () => {+ const v = remoteCidr(text);+ if (!v) { setBad(true); return; }+ block(v).then((ok) => { if (ok) setText(''); });+ };+ const temp = st.blocked.filter((b) => !b.manual), manual = st.blocked.filter((b) => b.manual);+ const mono = { fontSize: 11, color: t.text, fontFamily: 'monospace', direction: 'ltr', textAlign: 'start', lineHeight: 1.3 };+ const dim = { fontSize: 10, color: t.textDim, lineHeight: 1.3, textAlign: 'start' };+ const row = { gap: 3, paddingVertical: 2 };+ return (+ <>+ <View style={{ flexDirection: 'row', alignItems: 'center', gap: 10 }}>+ <RemoteGlyph size={32} />+ <View style={{ flex: 1, minWidth: 0 }}>+ <Text style={{ fontSize: 15, fontWeight: 600, color: t.text, lineHeight: 1.25, textAlign: 'start' }} numberOfLines={2}>{tr('monitor.net.remoteDesktop')}</Text>+ <Text style={{ fontSize: 11, color: t.textDim }}>{tr('monitor.net.remotePort', { port: st.port, count: st.clients.length })}</Text>+ </View>+ </View>+ {msg ? <Text style={{ fontSize: 11, color: '#ff453a', lineHeight: 1.35 }}>{msg}</Text> : null}+ <Section id="remoteClients" title={tr('monitor.net.remoteClients')}>+ {st.clients.map((c) => {+ const r = rates.get(c.pid) || [0, 0];+ return (+ <View key={c.pid} style={row}>+ <View style={{ flexDirection: 'row', alignItems: 'center', gap: 6 }}>+ <Text style={{ ...mono, flex: 1, minWidth: 0 }} numberOfLines={2}>{c.ip}</Text>+ {isAdmin ? <Button small label={tr('settings.sharing.block')} disabled={busy} onClick={() => block(c.ip)} /> : null}+ </View>+ <Text style={dim} numberOfLines={2}>{tr('monitor.net.remoteClient', { user: c.user, minutes: agoMin(c.since) })}</Text>+ <Text style={dim}>{`↓ ${formatBytes(c.rx || 0)} · ↑ ${formatBytes(c.tx || 0)} · ${formatBytes(r[0] + r[1])}/s`}</Text>+ </View>+ );+ })}+ {!st.clients.length ? <Text style={{ fontSize: 12, color: t.textDim }}>{tr('monitor.net.remoteNoClients')}</Text> : null}+ </Section>+ <Section id="remoteFailures" title={tr('monitor.net.remoteFailures')}>+ {fails === null ? <Text style={{ ...dim, fontSize: 11 }}>{tr('monitor.net.remoteAdminOnly')}</Text> : null}+ {(fails || []).slice(0, 12).map((f) => (+ <View key={`${f.key} ${f.user}`} style={row}>+ <View style={{ flexDirection: 'row', alignItems: 'center', gap: 6 }}>+ <Text style={{ ...mono, flex: 1, minWidth: 0 }} numberOfLines={2}>{f.key}</Text>+ {isAdmin ? <Button small label={tr('settings.sharing.block')} disabled={busy} onClick={() => block(f.key)} /> : null}+ </View>+ <Text style={dim} numberOfLines={2}>{tr('monitor.net.remoteFailure', { user: f.user, count: f.count, minutes: agoMin(f.last) })}</Text>+ </View>+ ))}+ {fails && !fails.length ? <Text style={{ fontSize: 12, color: t.textDim }}>{tr('monitor.net.remoteNoFailures')}</Text> : null}+ </Section>+ <Section id="remoteBlocked" title={tr('settings.sharing.blocked')}>+ {temp.map((b) => (+ <View key={`a${b.ip}`} style={row}>+ <Text style={mono} numberOfLines={2}>{b.ip}</Text>+ <Text style={dim}>{tr('settings.sharing.blockedAuto', { minutes: remoteMinutesLeft(b.until) })}</Text>+ {isAdmin ? (+ <View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 6 }}>+ <Button small label={tr('settings.sharing.unblock')} disabled={busy} onClick={() => run(remoteAccess.unblock(b.ip))} />+ <Button small label={tr('settings.sharing.blockForever')} disabled={busy}+ onClick={() => run(remoteAccess.unblock(b.ip)).then((ok) => ok && block(b.ip))} />+ </View>+ ) : null}+ </View>+ ))}+ {!temp.length ? <Text style={{ fontSize: 12, color: t.textDim }}>{tr('settings.sharing.blockedNone')}</Text> : null}+ </Section>+ <Section id="remoteLists" title={tr('monitor.net.remoteLists')}>+ <KV k={tr('settings.sharing.netFrom')} v={tr({ lan: 'settings.sharing.netLan', list: 'settings.sharing.netList', any: 'settings.sharing.netAny' }[st.net] || 'settings.sharing.netLan')} />+ <Text style={{ fontSize: 11, fontWeight: 600, color: t.textDim, marginTop: 2 }}>{tr('settings.sharing.blocklist')}</Text>+ {manual.map((b) => (+ <View key={`m${b.ip}`} style={{ flexDirection: 'row', alignItems: 'center', gap: 6 }}>+ <Text style={{ ...mono, flex: 1, minWidth: 0 }} numberOfLines={2}>{b.ip}</Text>+ {isAdmin ? <Button small label={tr('settings.sharing.unblock')} disabled={busy} onClick={() => run(remoteAccess.unblock(b.ip))} /> : null}+ </View>+ ))}+ {!manual.length ? <Text style={dim}>{tr('settings.sharing.listEmpty')}</Text> : null}+ <Text style={{ fontSize: 11, fontWeight: 600, color: t.textDim, marginTop: 2 }}>{tr('settings.sharing.allowlist')}</Text>+ {st.allowed.map((c) => <Text key={c} style={mono}>{c}</Text>)}+ {!st.allowed.length ? <Text style={dim}>{tr('settings.sharing.listEmpty')}</Text> : null}+ {isAdmin ? (+ <View style={{ gap: 4, marginTop: 4 }}>+ <View style={{ flexDirection: 'row', alignItems: 'center', gap: 6 }}>+ <TextInput value={text} placeholder={tr('settings.sharing.blockPlaceholder')} style={{ flex: 1, direction: 'ltr' }} size={12}+ onChange={(v) => { setText(v.slice(0, 60)); setBad(false); }} onSubmit={typed} />+ <Button small label={tr('settings.sharing.block')} disabled={busy || !text.trim()} onClick={typed} />+ </View>+ {bad ? <Text style={{ fontSize: 10, color: '#ff453a', lineHeight: 1.35 }}>{tr('settings.sharing.badAddress')}</Text> : null}+ </View>+ ) : null}+ <KV k={tr('monitor.net.remoteBlockedTotal')} v={formatNumber(st.blocked.length, 0)} />+ </Section>+ </>+ );+}diff --git a/apps/monitor/index.jsx b/apps/monitor/index.jsxindex 749c601..6a6bcef 100644--- a/apps/monitor/index.jsx+++ b/apps/monitor/index.jsx@@ -13,6 +13,7 @@ import { useEffect, useMemo, useState } from 'react';import { Chart } from './Chart.jsx';import { Glyph, MonitorIcon } from './icons.jsx';import { NetworkTab } from './Network.jsx';+import { RemoteGlyph } from './RemoteDesktop.jsx';import { MonitorPrivacy } from './Privacy.jsx';import { FirewallPrivacy } from './Firewall.jsx';import { FirewallRulesPrivacy } from './FwRules.jsx';@@ -328,6 +329,7 @@ export const isolatedAppOf = (item) => (typeof item?.app === 'string' && item.apexport function AppGlyph({ item, size = 16 }) {if (item.app === 'lordos') return <LordOSLogo size={size} />;+ if (item.app === 'remote-desktop') return <RemoteGlyph size={size} />;const iso = isolatedAppOf(item);if (iso?.Icon) return <iso.Icon size={size} />;if (item.appIcon) return <Image src={item.appIcon} style={{ width: size, height: size, objectFit: 'contain' }} />;diff --git a/apps/settings/Sharing.jsx b/apps/settings/Sharing.jsxindex 77623d6..a3a7dfe 100644--- a/apps/settings/Sharing.jsx+++ b/apps/settings/Sharing.jsx@@ -52,11 +52,14 @@ function AddressField({ placeholder, label, disabled, onAdd }) {);}-// Who may connect and which addresses are blocked (docs/REMOTE.md, "Blocked and allowed addresses").+// Who may connect, the allowlist, the blocklist and the temporary blocks (docs/REMOTE.md, "Blocked+// and allowed addresses"). Every change goes through the fixed admin actions (remoteAccess).function AccessSection({ st, isAdmin, busy, act }) {const t = useTheme();const { t: tr } = useLocale();const hint = { lan: 'settings.sharing.netLanHint', list: 'settings.sharing.netListHint', any: 'settings.sharing.netAnyHint' }[st.net] || 'settings.sharing.netLanHint';+ const temp = st.blocked.filter((b) => !b.manual), manual = st.blocked.filter((b) => b.manual);+ const mono = { fontFamily: 'monospace', direction: 'ltr' };return (<><Section title={tr('settings.sharing.access')}>@@ -64,32 +67,38 @@ function AccessSection({ st, isAdmin, busy, act }) {<Segmented small value={st.net} onChange={(net) => isAdmin && !busy && act('remote-config', `net=${net}`)}options={[['lan', tr('settings.sharing.netLan')], ['list', tr('settings.sharing.netList')], ['any', tr('settings.sharing.netAny')]]} /></SettingRow>- {st.net === 'list' && (- <>- {!st.allowed.length && <SettingRow label={tr('settings.sharing.allowEmpty')} labelStyle={{ color: tint.warn }} />}- {st.allowed.map((c) => (- <SettingRow key={c} label={c} labelStyle={{ fontFamily: 'monospace', direction: 'ltr' }}>- {isAdmin && <Button small label={tr('settings.sharing.remove')} disabled={busy} onClick={() => act('remote-allow', `del ${c}`)} />}- </SettingRow>- ))}- {isAdmin && <AddressField placeholder={tr('settings.sharing.allowPlaceholder')} label={tr('settings.sharing.allowAdd')} disabled={busy}- onAdd={(v) => act('remote-allow', `add ${v}`)} />}- </>- )}</Section>{st.net === 'any' && <Note tone="warn">{tr('settings.sharing.netAnyWarn')}</Note>}- <Section title={tr('settings.sharing.blocked')} footer={tr('settings.sharing.blockedFooter')}>- {!st.blocked.length ? <SettingRow label={tr('settings.sharing.blockedNone')} labelStyle={{ color: t.textDim }} /> : st.blocked.map((b) => (- <SettingRow key={`${b.manual ? 'm' : 'a'}${b.ip}`} icon={<StatusDot color={b.manual ? tint.off : tint.error} />}- label={b.ip} labelStyle={{ fontFamily: 'monospace', direction: 'ltr' }}- hint={b.manual ? tr('settings.sharing.blockedManual')- : tr('settings.sharing.blockedAuto', { minutes: remoteMinutesLeft(b.until) })}>- {isAdmin && <Button small label={tr('settings.sharing.unblock')} disabled={busy} onClick={() => act('remote-unblock', b.ip)} />}+ <Section title={tr('settings.sharing.allowlist')} footer={tr('settings.sharing.allowlistFooter')}>+ {!st.allowed.length ? <SettingRow label={tr(st.net === 'list' ? 'settings.sharing.allowEmpty' : 'settings.sharing.listEmpty')}+ labelStyle={{ color: st.net === 'list' ? tint.warn : t.textDim }} /> : null}+ {st.allowed.map((c) => (+ <SettingRow key={c} label={c} labelStyle={mono} icon={<StatusDot color={tint.ok} />}>+ {isAdmin && <Button small label={tr('settings.sharing.remove')} disabled={busy} onClick={() => act('remote-allow', `del ${c}`)} />}+ </SettingRow>+ ))}+ {isAdmin && <AddressField placeholder={tr('settings.sharing.allowPlaceholder')} label={tr('settings.sharing.allowAdd')} disabled={busy}+ onAdd={(v) => act('remote-allow', `add ${v}`)} />}+ </Section>+ <Section title={tr('settings.sharing.blocklist')} footer={tr('settings.sharing.blocklistFooter')}>+ {!manual.length ? <SettingRow label={tr('settings.sharing.listEmpty')} labelStyle={{ color: t.textDim }} /> : null}+ {manual.map((b) => (+ <SettingRow key={`m${b.ip}`} label={b.ip} labelStyle={mono} icon={<StatusDot color={tint.off} />}>+ {isAdmin && <Button small label={tr('settings.sharing.remove')} disabled={busy} onClick={() => act('remote-unblock', b.ip)} />}</SettingRow>))}{isAdmin && <AddressField placeholder={tr('settings.sharing.blockPlaceholder')} label={tr('settings.sharing.block')} disabled={busy}onAdd={(v) => act('remote-block', v)} />}</Section>+ <Section title={tr('settings.sharing.blocked')} footer={tr('settings.sharing.blockedFooter')}>+ {!temp.length ? <SettingRow label={tr('settings.sharing.blockedNone')} labelStyle={{ color: t.textDim }} /> : temp.map((b) => (+ <SettingRow key={`a${b.ip}`} icon={<StatusDot color={tint.error} />} label={b.ip} labelStyle={mono}+ hint={tr('settings.sharing.blockedAuto', { minutes: remoteMinutesLeft(b.until) })}>+ {isAdmin && <Button small label={tr('settings.sharing.unblock')} disabled={busy} onClick={() => act('remote-unblock', b.ip)} />}+ {isAdmin && <Button small label={tr('settings.sharing.blockForever')} disabled={busy} onClick={() => act('remote-unblock', b.ip).then((ok) => ok && act('remote-block', b.ip))} />}+ </SettingRow>+ ))}+ </Section></>);}diff --git a/assets/locales/en/monitor.json b/assets/locales/en/monitor.jsonindex 4a207b2..d0e3c8a 100644--- a/assets/locales/en/monitor.json+++ b/assets/locales/en/monitor.json@@ -285,5 +285,16 @@"privacy.history": "Keep a traffic history","privacy.historyHint": "Bytes received and sent per minute for 7 days and per hour for 30 days, for the computer and for each app. Never addresses, names or countries. Kept only in your home folder.","privacy.clear": "Clear History",- "privacy.cleared": "History cleared"+ "privacy.cleared": "History cleared",+ "net.remoteDesktop": "Remote desktop",+ "net.remotePort": "Port {port} · {count} connected",+ "net.remoteClients": "Connected",+ "net.remoteClient": "{user} · for {minutes} min",+ "net.remoteNoClients": "Nobody is connected.",+ "net.remoteFailures": "Failed sign-ins",+ "net.remoteFailure": "Name typed: {user} · {count}× · {minutes} min ago",+ "net.remoteNoFailures": "No failed sign-ins in the last 24 hours.",+ "net.remoteAdminOnly": "Only administrators see failed sign-ins and can block addresses.",+ "net.remoteLists": "Address lists",+ "net.remoteBlockedTotal": "Blocked in all"}diff --git a/assets/locales/en/settings.json b/assets/locales/en/settings.jsonindex 20c2d25..2f7e16a 100644--- a/assets/locales/en/settings.json+++ b/assets/locales/en/settings.json@@ -293,7 +293,7 @@"sharing.allowPlaceholder": "Address or network, e.g. 192.168.1.0/24","sharing.allowAdd": "Add","sharing.remove": "Remove",- "sharing.blocked": "Blocked addresses",+ "sharing.blocked": "Temporarily blocked","sharing.blockedFooter": "An address is blocked after 3 failed sign-ins: for 15 minutes, then 1 hour, then 24 hours if it happens again within a day. You get a notification when it happens.","sharing.blockedNone": "No address is blocked.","sharing.blockedManual": "Blocked by an administrator",@@ -301,5 +301,11 @@"sharing.unblock": "Unblock","sharing.block": "Block","sharing.blockPlaceholder": "Address or network to block",- "sharing.badAddress": "Write an IPv4 or IPv6 address, or a network such as 192.168.1.0/24 (at least /8; IPv6 at least /16)."+ "sharing.badAddress": "Write an IPv4 or IPv6 address, or a network such as 192.168.1.0/24 (at least /8; IPv6 at least /16).",+ "sharing.allowlist": "Allowlist",+ "sharing.allowlistFooter": "Addresses and networks that may connect when \"Only these addresses\" is chosen. They still get blocked after 3 failed sign-ins.",+ "sharing.blocklist": "Blocklist",+ "sharing.blocklistFooter": "Always refused, before anything else, until you remove them.",+ "sharing.listEmpty": "The list is empty.",+ "sharing.blockForever": "Block permanently"}diff --git a/assets/locales/en/status.json b/assets/locales/en/status.jsonindex 514edae..765cb0d 100644--- a/assets/locales/en/status.json+++ b/assets/locales/en/status.json@@ -122,5 +122,7 @@"ssh.saved": "Settings saved","hw.firmwareChecked": "Firmware checked","remote.blocked": "{address} blocked",- "remote.unblocked": "{address} unblocked"+ "remote.unblocked": "{address} unblocked",+ "remote.failures": "{count} failed sign-ins",+ "remote.failure": "Failed sign-in for {user} from {key} ({count})"}diff --git a/assets/locales/es/monitor.json b/assets/locales/es/monitor.jsonindex bee877d..4212db9 100644--- a/assets/locales/es/monitor.json+++ b/assets/locales/es/monitor.json@@ -285,5 +285,16 @@"privacy.history": "Guardar un historial de tráfico","privacy.historyHint": "Bytes recibidos y enviados por minuto durante 7 días y por hora durante 30 días, del equipo y de cada app. Nunca direcciones, nombres ni países. Se guarda solo en tu carpeta personal.","privacy.clear": "Borrar historial",- "privacy.cleared": "Historial borrado"+ "privacy.cleared": "Historial borrado",+ "net.remoteDesktop": "Escritorio remoto",+ "net.remotePort": "Puerto {port} · {count} conectados",+ "net.remoteClients": "Conectados",+ "net.remoteClient": "{user} · hace {minutes} min",+ "net.remoteNoClients": "No hay nadie conectado.",+ "net.remoteFailures": "Ingresos fallidos",+ "net.remoteFailure": "Nombre escrito: {user} · {count}× · hace {minutes} min",+ "net.remoteNoFailures": "No hubo ingresos fallidos en las últimas 24 horas.",+ "net.remoteAdminOnly": "Solo los administradores ven los ingresos fallidos y pueden bloquear direcciones.",+ "net.remoteLists": "Listas de direcciones",+ "net.remoteBlockedTotal": "Bloqueadas en total"}diff --git a/assets/locales/es/settings.json b/assets/locales/es/settings.jsonindex ada2594..da10d4b 100644--- a/assets/locales/es/settings.json+++ b/assets/locales/es/settings.json@@ -293,7 +293,7 @@"sharing.allowPlaceholder": "Dirección o red, p. ej. 192.168.1.0/24","sharing.allowAdd": "Agregar","sharing.remove": "Quitar",- "sharing.blocked": "Direcciones bloqueadas",+ "sharing.blocked": "Bloqueadas temporalmente","sharing.blockedFooter": "Una dirección queda bloqueada tras 3 ingresos fallidos: 15 minutos, luego 1 hora y luego 24 horas si se repite en el mismo día. Te llega una notificación cuando pasa.","sharing.blockedNone": "No hay direcciones bloqueadas.","sharing.blockedManual": "Bloqueada por un administrador",@@ -301,5 +301,11 @@"sharing.unblock": "Desbloquear","sharing.block": "Bloquear","sharing.blockPlaceholder": "Dirección o red para bloquear",- "sharing.badAddress": "Escribí una dirección IPv4 o IPv6, o una red como 192.168.1.0/24 (al menos /8; IPv6 al menos /16)."+ "sharing.badAddress": "Escribí una dirección IPv4 o IPv6, o una red como 192.168.1.0/24 (al menos /8; IPv6 al menos /16).",+ "sharing.allowlist": "Lista de permitidas",+ "sharing.allowlistFooter": "Direcciones y redes que pueden conectarse cuando se elige «Solo estas direcciones». Igual se bloquean tras 3 ingresos fallidos.",+ "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"}diff --git a/assets/locales/es/status.json b/assets/locales/es/status.jsonindex 7d9889b..b5fed5c 100644--- a/assets/locales/es/status.json+++ b/assets/locales/es/status.json@@ -122,5 +122,7 @@"ssh.saved": "Ajustes guardados","hw.firmwareChecked": "Firmware revisado","remote.blocked": "{address} bloqueada",- "remote.unblocked": "{address} desbloqueada"+ "remote.unblocked": "{address} desbloqueada",+ "remote.failures": "{count} ingresos fallidos",+ "remote.failure": "Ingreso fallido de {user} desde {key} ({count})"}diff --git a/assets/locales/pt/monitor.json b/assets/locales/pt/monitor.jsonindex e413356..c22ffc4 100644--- a/assets/locales/pt/monitor.json+++ b/assets/locales/pt/monitor.json@@ -285,5 +285,16 @@"privacy.history": "Manter um histórico de tráfego","privacy.historyHint": "Bytes recebidos e enviados por minuto durante 7 dias e por hora durante 30 dias, do computador e de cada app. Nunca endereços, nomes ou países. Fica só na sua pasta pessoal.","privacy.clear": "Apagar histórico",- "privacy.cleared": "Histórico apagado"+ "privacy.cleared": "Histórico apagado",+ "net.remoteDesktop": "Área de trabalho remota",+ "net.remotePort": "Porta {port} · {count} conectados",+ "net.remoteClients": "Conectados",+ "net.remoteClient": "{user} · há {minutes} min",+ "net.remoteNoClients": "Ninguém está conectado.",+ "net.remoteFailures": "Entradas com erro",+ "net.remoteFailure": "Nome digitado: {user} · {count}× · há {minutes} min",+ "net.remoteNoFailures": "Nenhuma entrada com erro nas últimas 24 horas.",+ "net.remoteAdminOnly": "Só administradores veem as entradas com erro e podem bloquear endereços.",+ "net.remoteLists": "Listas de endereços",+ "net.remoteBlockedTotal": "Bloqueados no total"}diff --git a/assets/locales/pt/settings.json b/assets/locales/pt/settings.jsonindex da8f5a1..019014f 100644--- a/assets/locales/pt/settings.json+++ b/assets/locales/pt/settings.json@@ -293,7 +293,7 @@"sharing.allowPlaceholder": "Endereço ou rede, ex.: 192.168.1.0/24","sharing.allowAdd": "Adicionar","sharing.remove": "Remover",- "sharing.blocked": "Endereços bloqueados",+ "sharing.blocked": "Bloqueados temporariamente","sharing.blockedFooter": "Um endereço é bloqueado após 3 entradas com erro: 15 minutos, depois 1 hora e depois 24 horas se acontecer de novo no mesmo dia. Você recebe uma notificação quando isso acontece.","sharing.blockedNone": "Nenhum endereço está bloqueado.","sharing.blockedManual": "Bloqueado por um administrador",@@ -301,5 +301,11 @@"sharing.unblock": "Desbloquear","sharing.block": "Bloquear","sharing.blockPlaceholder": "Endereço ou rede para bloquear",- "sharing.badAddress": "Digite um endereço IPv4 ou IPv6, ou uma rede como 192.168.1.0/24 (pelo menos /8; IPv6 pelo menos /16)."+ "sharing.badAddress": "Digite um endereço IPv4 ou IPv6, ou uma rede como 192.168.1.0/24 (pelo menos /8; IPv6 pelo menos /16).",+ "sharing.allowlist": "Lista de permitidos",+ "sharing.allowlistFooter": "Endereços e redes que podem se conectar quando \"Só estes endereços\" está escolhido. Ainda são bloqueados após 3 entradas com erro.",+ "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"}diff --git a/assets/locales/pt/status.json b/assets/locales/pt/status.jsonindex d462950..0ec4b16 100644--- a/assets/locales/pt/status.json+++ b/assets/locales/pt/status.json@@ -122,5 +122,7 @@"ssh.saved": "Configurações salvas","hw.firmwareChecked": "Firmware verificado","remote.blocked": "{address} bloqueado",- "remote.unblocked": "{address} desbloqueado"+ "remote.unblocked": "{address} desbloqueado",+ "remote.failures": "{count} entradas com erro",+ "remote.failure": "Entrada com erro de {user} de {key} ({count})"}diff --git a/docs/MONITOR.md b/docs/MONITOR.mdindex 069a53a..86684ea 100644--- a/docs/MONITOR.md+++ b/docs/MONITOR.md@@ -107,6 +107,36 @@ server, and this app's rule is that no address leaves the machine.**"This computer"** is placed by the time zone (`/etc/localtime` → coordinates from`/usr/share/zoneinfo/zone1970.tab`), without the network.+### Remote desktop (0.8.3)++While the remote desktop is on (Settings → Sharing), it is one more row in the app list, **Remote+desktop**, with the Sharing icon: its traffic bar and bytes, the number of browsers connected and,+in the red badge, the failed sign-ins of the last 24 hours. `lord-sessiond` serves it as root,+outside the session's apps, so its sockets never appear among them (they are counted in "From other+users"); the row is built from `lord-sessiond`'s own state (`apps/monitor/RemoteDesktop.jsx`). Its+Rule switch is fixed: the per-app firewall doesn't apply to it; its own lists do.++The detail panel, in the same folding sections:++- **Connected:** each browser's address, user, how long, and its traffic (bytes each way and the+ current rate, reported by the bridge to its root parent every 2 s), with **Block**;+- **Failed sign-ins:** address, the name that was typed (cleaned to printable ASCII), how many times+ and when, with **Block**. Administrators only: it comes from the admin action `remote-failures`,+ which re-validates every row; passwords are never kept anywhere;+- **Temporarily blocked:** the lockout's blocks with the time left, **Unblock** and **Block+ permanently**;+- **Address lists:** the mode, the blocklist (with Unblock), the allowlist, and a field to block a+ typed address or network.++Every action is one of the fixed admin actions Settings uses (`remote-block`, `remote-unblock`;+`sdk/remote.js` `remoteAccess`), validated again on the root side. Everything else is read-only:+`/run/lordos/status.json` (clients, blocks, lists; no user names typed by strangers) through+`lord.remote.status()`. See [REMOTE.md](REMOTE.md), "Blocked and allowed addresses".+++++### Blocking cuts what is open (0.8.3)Switching an app's rule off (or a destination's switch, or adding a restriction) now also ends thediff --git a/docs/REMOTE.md b/docs/REMOTE.mdindex 144363d..8dfc942 100644--- a/docs/REMOTE.md+++ b/docs/REMOTE.md@@ -101,19 +101,31 @@ takes the initials of the name being typed.**Who can connect** (Settings → Sharing, `net=` in `/etc/lordos/remote/config`):- **Local network** (the default): private ranges (10/8, 172.16/12, 192.168/16, 100.64/10),- loopback, link-local and IPv6 unique-local, plus connections that arrive on a VPN interface of- this computer (`wg-`, `ovpn-`, `ips-`, `oc-`, `fvpn-`, `ppp`, `tun`). Public addresses are- closed.+ loopback, link-local and IPv6 unique-local, plus connections over a VPN of this computer: only+ on an interface LordOS's VPN manager created (`wg-`, `ovpn-`, `ips-`, `ppp-`, `oc-`, `fvpn-` ++ the VPN's name, `vpn_ifname` in `server/src/net/wg.c`), to that interface's own address, and+ from inside its subnet or its point-to-point peer (`rs_vpn_accepts`). A bare `ppp0` (often a+ PPPoE internet uplink), `tun0` or `wg0` never counts. Public addresses are closed.- **Only these addresses**: only the networks in the list.- **Any address**: everyone who can reach the port (still with the lockout).-**Manual blocks** win over everything. The lists live in `/etc/lordos/remote/access` (root, 0600):-`allow <cidr>` and `block <cidr>`, at most 64 of each. Networks are IPv4 /8–/32 or IPv6 /16–/128;-host bits are cleared.+**Two lists and the temporary blocks**, each its own section in Settings → Sharing:-+- **Allowlist:** the addresses and networks that may connect with "Only these addresses". Being on+ it doesn't exempt an address from the lockout (an allowed machine can be compromised too), but an+ administrator can unblock it at once.+- **Blocklist:** always refused, checked before anything else, until removed.+- **Temporarily blocked:** the lockout's blocks with the time left, **Unblock** and **Block+ permanently** (moves it to the blocklist).-+The lists live in `/etc/lordos/remote/access` (root, 0600): `allow <cidr>` and `block <cidr>`, at+most 64 of each. Networks are IPv4 /8–/32 or IPv6 /16–/128; host bits are cleared. The same lists,+the clients and the failed sign-ins are also in Monitor → Network ([MONITOR.md](MONITOR.md),+"Remote desktop").++++**Admin actions** (`remote_admin.c`, administrators only, validated on the root side by`rs_cidr_parse`):@@ -123,7 +135,8 @@ host bits are cleared.| `remote-config` | `net=lan\|list\|any` | the mode (with the existing `allow=`, `port=` lines) || `remote-block` | `<cidr>` | adds a manual block to `access` || `remote-unblock` | `<cidr>` | removes manual blocks inside it and appends `unblock <cidr>` to `/var/lib/lordos/remote/requests` (root 0600, `flock`); `lord-sessiond` lifts the lockout blocks inside it on SIGHUP |-| `remote-allow` | `add\|del <cidr>` | the "only these addresses" list |+| `remote-allow` | `add\|del <cidr>` | the allowlist |+| `remote-failures` | none | read-only: the recent failed sign-ins as code lines (`remote.failure key= count= first= last= user=`), from `/run/lordos/remote-failures` (root 0600); for Monitor |Unblocking from Settings forgets that address's history (its next block is 15 minutes again).@@ -214,7 +227,7 @@ self-signed P-256, with CN equal to the machine name and ten years of validity.A review of everything the network can reach, done for 0.8.3: the HTTP parser, the login, thecookie, CSRF, the WebSocket and the input messages, the privilege drop, resource limits, TLS,headers, logging and the lock screen. Every finding below was fixed in the same release; the tests-are in `server/tests/remote_sec_test.c` (207 checks), `server/tests/remote_fuzz.c` (ASan+UBSan,+are in `server/tests/remote_sec_test.c` (218 checks), `server/tests/remote_fuzz.c` (ASan+UBSan,100,000 random and mutated inputs on every `make -C server test`), and the attack run on VM 122listed after the table.@@ -237,6 +250,7 @@ listed after the table.| 15 | Low | Log injection: `Origin`/`Host` logged raw (a bare LF forged a journal line); attempted names logged only when valid. | Everything logged is cleaned to printable ASCII; attempted names logged sanitized. | journal check. || 16 | Info | The privilege drop didn't check saved ids or groups, kept the environment and every inherited descriptor, and the bridge outlived `lord-sessiond` (the parent-death signal is cleared by `setuid`). | See "Process and privileges". | `/proc` check above. || 17 | Info | After a failure the user name went into the URL (`/?e=1&u=…`): a password typed into the user field ended up in the history. | The page keeps the name in `sessionStorage` and clears the address bar. | browser check. |+| 18 | High | (Found in review of this branch.) "Local network" counted any interface named `ppp*`, `tun*` or `wg*` as a VPN, so a public address arriving over a PPPoE uplink (`ppp0`) or any tunnel passed the default. | Only LordOS's own VPN interface names (with the dash), only to that interface's address, and only from inside its subnet or its point-to-point peer. | unit tests: `ppp0` with a public peer refused; `wg-home` with an in-subnet peer accepted and a public one refused; `/0` subnets refused. |**Greeter and lock.** A remote browser can't unlock the monitor: the monitor shows the loginscreen (a separate `lord-server` as `lordos-greeter`), and the session only reaches `lord-sessiond`@@ -262,10 +276,6 @@ scan; headers; lock. All results are in the table.----## Measurements (VM 118: Xeon Silver 4108 at 1.8 GHz, 4 cores, no GPU, 1280×800)| Situation | lord-server (session) | bridge (lord-sessiond) | monitor | network |diff --git a/docs/monitor-remote-desktop-dark.png b/docs/monitor-remote-desktop-dark.pngnew file mode 100644index 0000000..fba6a4eBinary files /dev/null and b/docs/monitor-remote-desktop-dark.png differdiff --git a/docs/monitor-remote-desktop-light.png b/docs/monitor-remote-desktop-light.pngnew file mode 100644index 0000000..e515b1aBinary files /dev/null and b/docs/monitor-remote-desktop-light.png differdiff --git a/docs/settings-sharing-allowlist-dark.png b/docs/settings-sharing-allowlist-dark.pngdeleted file mode 100644index 12b9978..0000000Binary files a/docs/settings-sharing-allowlist-dark.png and /dev/null differdiff --git a/docs/settings-sharing-allowlist-light.png b/docs/settings-sharing-allowlist-light.pngdeleted file mode 100644index 177ae96..0000000Binary files a/docs/settings-sharing-allowlist-light.png and /dev/null differdiff --git a/docs/settings-sharing-blocked-dark.png b/docs/settings-sharing-blocked-dark.pngdeleted file mode 100644index 9cad777..0000000Binary files a/docs/settings-sharing-blocked-dark.png and /dev/null differdiff --git a/docs/settings-sharing-blocked-light.png b/docs/settings-sharing-blocked-light.pngdeleted file mode 100644index 53ecea4..0000000Binary files a/docs/settings-sharing-blocked-light.png and /dev/null differdiff --git a/docs/settings-sharing-lists-dark.png b/docs/settings-sharing-lists-dark.pngnew file mode 100644index 0000000..5e73205Binary files /dev/null and b/docs/settings-sharing-lists-dark.png differdiff --git a/docs/settings-sharing-lists-light.png b/docs/settings-sharing-lists-light.pngnew file mode 100644index 0000000..87a7dbfBinary files /dev/null and b/docs/settings-sharing-lists-light.png differdiff --git a/sdk/index.js b/sdk/index.jsindex a8a1a2c..876e321 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 } from './remote.js';+export { remote, remoteViewers, sshLogin, remoteCidr, remoteMinutesLeft, remoteAccess } 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.jsindex 8a25d9e..7518bb7 100644--- a/sdk/remote.js+++ b/sdk/remote.js@@ -18,6 +18,8 @@ import { createStore, useStore } from './store.js';import { t } from './i18n.js';import { notify } from './notify.js';import { wm } from './windows.js';+import { admin } from './admin.js';+import { parseCode } from './errors.js';export const remoteViewers = createStore([]);globalThis.__lordRemote = (json) => {@@ -56,6 +58,28 @@ globalThis.__lordRemoteNotice = (n) => {};export const remoteMinutesLeft = minutesLeft;+// The address lists and blocks, through the fixed admin actions (server/src/remote/remote_admin.c,+// validated again on the root side). Used by Settings → Sharing and Monitor → Network.+// remoteAccess.failures() → [{ key, count, first, last, user }] (administrators only; never a password)+export const remoteAccess = {+ block: (cidr) => admin.run('remote-block', cidr),+ unblock: (cidr) => admin.run('remote-unblock', cidr),+ allow: (cidr) => admin.run('remote-allow', `add ${cidr}`),+ disallow: (cidr) => admin.run('remote-allow', `del ${cidr}`),+ setNet: (net) => admin.run('remote-config', `net=${net}`),+ async failures() {+ const rows = [];+ await admin.run('remote-failures', '', (line) => {+ const c = parseCode(String(line));+ const p = c?.code === 'remote.failure' ? c.params : null;+ if (p && remoteCidr(p.key) && /^[\x20-\x7e]{1,32}$/.test(p.user || '')) {+ rows.push({ key: p.key, count: Number(p.count) || 0, first: Number(p.first) || 0, last: Number(p.last) || 0, user: p.user });+ }+ }, { quiet: true });+ return rows.sort((a, b) => b.last - a.last);+ },+};+function parseConfig(text) {const c = { port: 5673, allow: 'all', net: 'lan' };for (const line of String(text || '').split('\n')) {diff --git a/server/src/remote/conn.c b/server/src/remote/conn.cindex da3dff8..2588cc1 100644--- a/server/src/remote/conn.c+++ b/server/src/remote/conn.c@@ -382,6 +382,27 @@ static void push_notice(const char *key, double until, int strikes) {rd_shared->notice_seq++;}+/* the recent failed sign-ins (under rd_lock): one row per source and attempted name */+static void note_failure(const char *key, const char *user) {+ double now = rd_now();+ RdFailLog *slot = NULL, *old = &rd_shared->faillog[0];+ for (int i = 0; i < RD_FAILLOG; i++) {+ RdFailLog *f = &rd_shared->faillog[i];+ if (f->count && !strcmp(f->key, key) && !strcmp(f->user, user)) { slot = f; break; }+ if (!f->count) { if (old->count) old = f; }+ else if (old->count && f->last < old->last) old = f;+ }+ if (!slot) {+ slot = old;+ memset(slot, 0, sizeof *slot);+ snprintf(slot->key, sizeof slot->key, "%s", key);+ snprintf(slot->user, sizeof slot->user, "%s", user);+ slot->first = now;+ }+ slot->count++;+ slot->last = now;+}+static void handle_login(const RsReq *r) {if (r->query[0]) { respond(400, NULL); return; } /* credentials never travel in a URL */if (!origin_ok(r)) {@@ -428,6 +449,7 @@ static void handle_login(const RsReq *r) {rd_lock();int blocked = rl_fail(&rd_shared->lockout, peer_key, rd_now(), &until, &strikes);if (blocked) push_notice(peer_key, until, strikes);+ note_failure(peer_key, raw[0] ? raw : "?");rd_shared->lockout_dirty = 1;rd_shared->version++;rd_unlock();@@ -470,6 +492,7 @@ static void handle_login(const RsReq *r) {static unsigned char *wout;static size_t wout_len, wout_off, wout_cap;+static unsigned long long bytes_rx, bytes_tx; /* from / to the browser, reported to the root parent */static void wput(const void *p, size_t n) {if (wout_len + n > wout_cap) {@@ -538,6 +561,7 @@ static int ws_flush(void) {return -1;}wout_off += (size_t)w;+ bytes_tx += (unsigned long long)w;}wout_off = wout_len = 0;return 0;@@ -654,7 +678,7 @@ static void from_session(int type, const unsigned char *d, uint32_t n) {case RP_SESSION:/* the user locked their session: every browser of this user has to log in again */if (n >= 10 && memmem(d, n, "\"lock\"", 6)) {- if (lock_fd >= 0 && write(lock_fd, "L", 1) != 1) { /* the root parent is gone: the cookie expires anyway */ }+ if (lock_fd >= 0 && write(lock_fd, "L\n", 2) != 2) { /* the root parent is gone: the cookie expires anyway */ }ws_text("{\"t\":\"bye\",\"lock\":1}");locked = 1;}@@ -733,6 +757,7 @@ static int ws_read(void) {return -1;}win_len += (size_t)r;+ bytes_rx += (unsigned long long)r;}size_t used = 0;int rc = rs_ws_consume(&wsr, win, win_len, &used, on_ws, NULL);@@ -772,9 +797,15 @@ static void bridge(const struct passwd *pw) {rs_ws_init(&wsr, RS_WS_MAX_MSG);unsigned char *sin = NULL;size_t sin_len = 0, sin_cap = 0;- double last_input = rd_now();+ double last_input = rd_now(), last_report = 0;for (;;) {if (ws_flush()) return;+ if (lock_fd >= 0 && rd_now() - last_report >= 2) { /* traffic, for Settings and Monitor */+ char line[64];+ int n = snprintf(line, sizeof line, "T %llu %llu\n", bytes_rx, bytes_tx);+ if (write(lock_fd, line, (size_t)n) != n) { /* parent gone */ }+ last_report = rd_now();+ }if (closing) { /* our close frame went out (or will not): done */for (int i = 0; i < 20 && wout_len; i++) { struct pollfd q = { sock, POLLOUT, 0 }; poll(&q, 1, 100); if (ws_flush()) break; }return;@@ -926,12 +957,28 @@ static void handle_ws(const RsReq *r, int logged, const char *user, uid_t uid) {close(pp[1]);close(sess);close(sock);+ /* lines from the bridge (not trusted beyond its own counters): "L" the session was locked,+ * "T <rx> <tx>" its traffic */+ char line[80];+ size_t ll = 0;for (;;) {char c;ssize_t n = read(pp[0], &c, 1);if (n < 0 && errno == EINTR) continue;if (n <= 0) break;- if (c == 'L') { rd_tokens_drop_uid(me.pw_uid); sd_log("%s locked the session: every remote cookie of that user ended", name); }+ if (c != '\n') { if (ll < sizeof line - 1) line[ll++] = c; else ll = sizeof line; continue; }+ if (ll >= sizeof line) { ll = 0; continue; }+ line[ll] = 0;+ ll = 0;+ unsigned long long rx, tx;+ char extra;+ if (!strcmp(line, "L")) { rd_tokens_drop_uid(me.pw_uid); sd_log("%s locked the session: every remote cookie of that user ended", name); }+ else if (sscanf(line, "T %llu %llu %c", &rx, &tx, &extra) == 2) {+ rd_lock();+ for (int i = 0; i < RD_MAX_CONNS; i++)+ if (rd_shared->conns[i].pid == getpid()) { rd_shared->conns[i].rx = rx; rd_shared->conns[i].tx = tx; rd_shared->version++; }+ rd_unlock();+ }}while (waitpid(b, NULL, 0) < 0 && errno == EINTR) {}}diff --git a/server/src/remote/ipnet.c b/server/src/remote/ipnet.cindex ac75695..8e77718 100644--- a/server/src/remote/ipnet.c+++ b/server/src/remote/ipnet.c@@ -208,7 +208,24 @@ int rs_access_decide(const RsAccess *acc, int mode, const RsAddr *peer, int via_}int rs_vpn_ifname(const char *name) {- static const char *const pre[] = { "wg-", "ovpn-", "ips-", "oc-", "fvpn-", "ppp", "tun", "wg", NULL };- for (int i = 0; pre[i]; i++) if (!strncmp(name, pre[i], strlen(pre[i]))) return 1;+ /* exactly the names LordOS's VPN manager gives (vpn_ifname in server/src/net/wg.c): "<type>-<name>".+ * Never a bare ppp0 (often a PPPoE internet uplink), tun0 or wg0, which anything can create. */+ static const char *const pre[] = { "wg-", "ovpn-", "ips-", "ppp-", "oc-", "fvpn-", NULL };+ if (!name) return 0;+ for (int i = 0; pre[i]; i++) {+ size_t l = strlen(pre[i]);+ if (!strncmp(name, pre[i], l) && name[l]) return 1;+ }return 0;}++int rs_vpn_accepts(const char *ifname, const RsAddr *ifaddr, int prefix, const RsAddr *ptp, const RsAddr *local, const RsAddr *peer) {+ if (!rs_vpn_ifname(ifname) || !ifaddr || !local || !peer) return 0;+ if (memcmp(ifaddr->a, local->a, 16) || ifaddr->v4 != peer->v4) return 0; /* arrived on that interface's address */+ if (ptp && !memcmp(ptp->a, peer->a, 16)) return 1; /* its point-to-point peer */+ /* inside its own subnet, and never a subnet so wide it means "anywhere" */+ if (peer->v4 ? prefix < 96 + RS_MIN_PREFIX4 || prefix > 128 : prefix < RS_MIN_PREFIX6 || prefix > 128) return 0;+ RsCidr c = { *ifaddr, prefix };+ mask(&c.net, prefix);+ return rs_cidr_contains(&c, peer);+}diff --git a/server/src/remote/ipnet.h b/server/src/remote/ipnet.hindex dbe3943..d955019 100644--- a/server/src/remote/ipnet.h+++ b/server/src/remote/ipnet.h@@ -57,7 +57,12 @@ enum { RS_ACC_OK = 0, RS_ACC_BLOCKED = 1, RS_ACC_NOT_ALLOWED = 2 };* only the listed networks, net=lan (the default) local ranges or a connection that arrived on a* VPN interface (via_vpn). */int rs_access_decide(const RsAccess *acc, int mode, const RsAddr *peer, int via_vpn);-/* Interface names of LordOS VPNs and common tunnel devices (wg-, ovpn-, ips-, ppp, oc-, fvpn-, tun, wg). */+/* Interface names LordOS's VPN manager creates: wg-, ovpn-, ips-, ppp-, oc-, fvpn- + a name. */int rs_vpn_ifname(const char *name);+/* Does a connection count as "over a LordOS VPN" for net=lan? Only if the interface is one of those,+ * the connection's local address is that interface's address, and the peer is inside the interface's+ * own subnet (prefix over the mapped form; at least /8 for IPv4, /16 for IPv6) or is its+ * point-to-point peer (ptp, may be NULL). */+int rs_vpn_accepts(const char *ifname, const RsAddr *ifaddr, int prefix, const RsAddr *ptp, const RsAddr *local, const RsAddr *peer);#endifdiff --git a/server/src/remote/remote_admin.c b/server/src/remote/remote_admin.cindex aac7c1c..ed836cf 100644--- a/server/src/remote/remote_admin.c+++ b/server/src/remote/remote_admin.c@@ -288,3 +288,38 @@ void remote_act_allow(const AdminReq *r, const char *arg, size_t len) {reload_sessiond();admin_ok("remote.saved", NULL);}++/* remote-failures: the recent failed sign-ins lord-sessiond keeps (Monitor → Network), read-only.+ * One LOG code line per row, re-validated here: remote.failure key= count= first= last= user=. The user is+ * what was typed in the name field, already cleaned to printable ASCII; passwords are never kept. */+void remote_act_failures(const AdminReq *r, const char *arg, size_t len) {+ (void)r; (void)arg;+ if (len) { admin_err("admin.invalidArgument", NULL); return; }+ char text[16384] = "";+ int fd = open("/run/lordos/remote-failures", O_RDONLY | O_NOFOLLOW | O_CLOEXEC);+ struct stat st;+ if (fd >= 0 && !fstat(fd, &st) && S_ISREG(st.st_mode) && st.st_uid == 0 && !(st.st_mode & 077)) {+ ssize_t n = read(fd, text, sizeof text - 1);+ if (n > 0) text[n] = 0;+ }+ if (fd >= 0) close(fd);+ int rows = 0;+ for (char *line = strtok(text, "\n"); line && rows < 64; line = strtok(NULL, "\n")) {+ char key[48], user[40] = "";+ int count;+ double first, last;+ int used = 0;+ RsCidr c;+ if (line[0] == '#' || sscanf(line, "%47s %d %lf %lf %n", key, &count, &first, &last, &used) != 4 || !used) continue;+ snprintf(user, sizeof user, "%.32s", line + used);+ int ok = !rs_key_parse(key, &c) && count > 0 && count < 1000000 && first > 0 && last >= first && user[0];+ for (const char *p = user; ok && *p; p++) if (*p < 0x20 || *p > 0x7e || *p == '"' || *p == '\\') ok = 0;+ if (!ok) continue;+ char f1[24], f2[24];+ snprintf(f1, sizeof f1, "%.0f", first);+ snprintf(f2, sizeof f2, "%.0f", last);+ admin_log("remote.failure", "key", key, "count", lerr_int(count), "first", f1, "last", f2, "user", user, NULL);+ rows++;+ }+ admin_ok("remote.failures", "count", lerr_int(rows), NULL);+}diff --git a/server/src/remote/remote_admin.h b/server/src/remote/remote_admin.hindex 26e15a7..044cd78 100644--- a/server/src/remote/remote_admin.h+++ b/server/src/remote/remote_admin.h@@ -12,6 +12,7 @@ void remote_act_kick(const AdminReq *r, const char *arg, size_t len);void remote_act_block(const AdminReq *r, const char *arg, size_t len);void remote_act_unblock(const AdminReq *r, const char *arg, size_t len);void remote_act_allow(const AdminReq *r, const char *arg, size_t len);+void remote_act_failures(const AdminReq *r, const char *arg, size_t len);#define REMOTE_ADMIN_ACTIONS \{ "remote-enable", remote_act_enable, A_FORK }, \@@ -21,6 +22,7 @@ void remote_act_allow(const AdminReq *r, const char *arg, size_t len);{ "remote-kick", remote_act_kick, 0 }, \{ "remote-block", remote_act_block, 0 }, \{ "remote-unblock", remote_act_unblock, 0 }, \- { "remote-allow", remote_act_allow, 0 },+ { "remote-allow", remote_act_allow, 0 }, \+ { "remote-failures", remote_act_failures, 0 },#endifdiff --git a/server/src/remote/sessiond.c b/server/src/remote/sessiond.cindex 2c59d77..50a30a0 100644--- a/server/src/remote/sessiond.c+++ b/server/src/remote/sessiond.c@@ -45,6 +45,7 @@#include <string.h>#include <grp.h>#include <ifaddrs.h>+#include <net/if.h>#include <sys/file.h>#include <sys/ioctl.h>#include <sys/mman.h>@@ -274,7 +275,8 @@ static void write_status(void) {for (int i = 0; i < RD_MAX_CONNS; i++) {RdConn *c = &rd_shared->conns[i];if (!c->pid) continue;- sput(&s, "%s{\"pid\":%d,\"ip\":\"%s\",\"user\":\"%s\",\"since\":%.0f}", first ? "" : ",", (int)c->pid, c->ip, c->user, c->since);+ sput(&s, "%s{\"pid\":%d,\"ip\":\"%s\",\"user\":\"%s\",\"since\":%.0f,\"rx\":%llu,\"tx\":%llu}", first ? "" : ",", (int)c->pid, c->ip,+ c->user, c->since, c->rx, c->tx);first = 0;}sput(&s, "],\"net\":\"%s\",\"blocked\":[", rs_net_name(rd_conf.net_mode));@@ -308,7 +310,26 @@ static void write_status(void) {first = 0;}rd_unlock();+ /* failed sign-ins: only for the admin action remote-failures (root 0600), never in status.json */+ Str fl = { 0 };+ sput(&fl, "# lord-sessiond: recent failed remote sign-ins (key count first last user)\n");+ rd_lock();+ for (int i = 0; i < RD_FAILLOG; i++) {+ RdFailLog *x = &rd_shared->faillog[i];+ if (x->count && now - x->last < 24 * 3600) sput(&fl, "%s %d %.0f %.0f %s\n", x->key, x->count, x->first, x->last, x->user);+ }+ rd_unlock();sput(&s, "]}\n");+ if (fl.p) {+ unlink(SD_FAILURES ".new");+ int ff = open(SD_FAILURES ".new", O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW | O_CLOEXEC, 0600);+ if (ff >= 0) {+ int ok = write(ff, fl.p, fl.n) == (ssize_t)fl.n;+ close(ff);+ if (!ok || rename(SD_FAILURES ".new", SD_FAILURES)) unlink(SD_FAILURES ".new");+ }+ free(fl.p);+ }FILE *f = fopen(SD_STATUS ".new", "w");if (f && s.p) { fputs(s.p, f); }if (f) {@@ -812,26 +833,53 @@ static void start_remote(void) {sd_log("remote desktop on https://*:%d", rd_conf.port);}-/* Did this connection arrive on a VPN interface? (its local address belongs to one) */-static int via_vpn(int fd) {+/* sockaddr (AF_INET or AF_INET6) → RsAddr; 0 on success */+static int sa_addr(const struct sockaddr *sa, RsAddr *x) {+ static const unsigned char pre[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };+ memset(x, 0, sizeof *x);+ if (!sa) return -1;+ if (sa->sa_family == AF_INET) {+ memcpy(x->a, pre, 12);+ memcpy(x->a + 12, &((const struct sockaddr_in *)sa)->sin_addr, 4);+ x->v4 = 1;+ return 0;+ }+ if (sa->sa_family == AF_INET6) {+ memcpy(x->a, &((const struct sockaddr_in6 *)sa)->sin6_addr, 16);+ x->v4 = !memcmp(x->a, pre, 12);+ return 0;+ }+ return -1;+}++static int mask_bits(const RsAddr *m) {+ int n = 0;+ for (int i = m->v4 ? 12 : 0; i < 16; i++) {+ unsigned char b = m->a[i];+ while (b & 0x80) { n++; b = (unsigned char)(b << 1); }+ if (m->a[i] != 0xff) break;+ }+ return m->v4 ? n + 96 : n;+}++/* Does this connection count as "over a LordOS VPN" for net=lan? Only on an interface LordOS's VPN+ * manager created (wg-, ovpn-, ips-, ppp-, oc-, fvpn- + name), to that interface's own address, and+ * from inside its subnet or its point-to-point peer (ipnet.c rs_vpn_accepts). A bare ppp0 (a PPPoE+ * uplink), tun0 or wg0 never counts. */+static int via_vpn(int fd, const RsAddr *peer) {struct sockaddr_in6 me;socklen_t ml = sizeof me;if (getsockname(fd, (struct sockaddr *)&me, &ml)) return 0;- RsAddr local = { 0 };- memcpy(local.a, &me.sin6_addr, 16);- struct ifaddrs *ifs = NULL, *i;+ RsAddr local;+ if (sa_addr((struct sockaddr *)&me, &local)) return 0;+ struct ifaddrs *ifs = NULL;if (getifaddrs(&ifs)) return 0;int vpn = 0;- for (i = ifs; i && !vpn; i = i->ifa_next) {- if (!i->ifa_addr || !i->ifa_name || !rs_vpn_ifname(i->ifa_name)) continue;- RsAddr x = { 0 };- if (i->ifa_addr->sa_family == AF_INET) {- static const unsigned char pre[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };- memcpy(x.a, pre, 12);- memcpy(x.a + 12, &((struct sockaddr_in *)i->ifa_addr)->sin_addr, 4);- } else if (i->ifa_addr->sa_family == AF_INET6) memcpy(x.a, &((struct sockaddr_in6 *)i->ifa_addr)->sin6_addr, 16);- else continue;- if (!memcmp(x.a, local.a, 16)) vpn = 1;+ for (struct ifaddrs *i = ifs; i && !vpn; i = i->ifa_next) {+ RsAddr x, m, d;+ if (!i->ifa_name || !rs_vpn_ifname(i->ifa_name) || sa_addr(i->ifa_addr, &x) || sa_addr(i->ifa_netmask, &m)) continue;+ int ptp = (i->ifa_flags & IFF_POINTOPOINT) && !sa_addr(i->ifa_dstaddr, &d);+ vpn = rs_vpn_accepts(i->ifa_name, &x, mask_bits(&m), ptp ? &d : NULL, &local, peer);}freeifaddrs(ifs);return vpn;@@ -868,7 +916,7 @@ static void accept_remote(void) {char key[48];rs_addr_key(&a, key, sizeof key);/* everything here is cheap and happens before any TLS work: refused sources are just closed */- int vpn = rd_conf.net_mode == RS_NET_LAN && !rs_addr_is_local(&a) ? via_vpn(fd) : 0;+ int vpn = rd_conf.net_mode == RS_NET_LAN && !rs_addr_is_local(&a) ? via_vpn(fd, &a) : 0;int acc = rs_access_decide(&rd_conf.access, rd_conf.net_mode, &a, vpn);if (acc != RS_ACC_OK) {refuse_log(key, acc == RS_ACC_BLOCKED ? "blocked in Settings" :diff --git a/server/src/remote/sessiond.h b/server/src/remote/sessiond.hindex 46cf676..f662d40 100644--- a/server/src/remote/sessiond.h+++ b/server/src/remote/sessiond.h@@ -43,7 +43,12 @@ typedef struct { unsigned char hash[32], pwh[16]; uid_t uid; char user[33]; doub* monitor's session (RP_NOTICE) */typedef struct { char key[48]; double until, at; int strikes; } RdNotice;#define RD_NOTICES 8-typedef struct { pid_t pid; char ip[48]; char user[33]; double since; } RdConn;+typedef struct { pid_t pid; char ip[48]; char user[33]; double since; unsigned long long rx, tx; } RdConn; /* rx/tx: bytes from/to the browser */+/* Recent failed sign-ins (source, attempted name already cleaned to printable ASCII), for Monitor →+ * Network through the admin action remote-failures (administrators only; never a password). */+typedef struct { char key[48]; char user[33]; int count; double first, last; } RdFailLog;+#define RD_FAILLOG 32+#define SD_FAILURES SD_RUN_DIR "/remote-failures" /* root 0600: "key count first last user" */typedef struct { pid_t pid; uid_t uid; char user[33]; double since; } SdSession; /* a user's lord-server */typedef struct {pthread_mutex_t lock;@@ -52,6 +57,7 @@ typedef struct {RlTable lockout; /* failed-login blocks per source (lockout.h) */int lockout_dirty; /* changed: the main process saves RL_FILE */RdNotice notices[RD_NOTICES];+ RdFailLog faillog[RD_FAILLOG];unsigned notice_seq;RdConn conns[RD_MAX_CONNS];SdSession sessions[SD_MAX_SESSIONS];diff --git a/server/tests/remote_sec_test.c b/server/tests/remote_sec_test.cindex c4deafe..771f23e 100644--- a/server/tests/remote_sec_test.c+++ b/server/tests/remote_sec_test.c@@ -352,7 +352,39 @@ static void test_ipnet(void) {rs_cidr_parse("10.9.9.9", &c);CHECK(rs_access_add(acc.block, &acc.nblock, &c) == -1);CHECK(rs_net_mode("lan") == RS_NET_LAN && rs_net_mode("any") == RS_NET_ANY && rs_net_mode("list") == RS_NET_LIST && rs_net_mode("all") < 0);- CHECK(rs_vpn_ifname("wg-home") && rs_vpn_ifname("ovpn-work") && rs_vpn_ifname("tun0") && !rs_vpn_ifname("eth0") && !rs_vpn_ifname("wlan0"));+ /* VPN interfaces: only the names LordOS's VPN manager gives */+ CHECK(rs_vpn_ifname("wg-home") && rs_vpn_ifname("ovpn-work") && rs_vpn_ifname("ips-office") && rs_vpn_ifname("ppp-pptp") &&+ rs_vpn_ifname("oc-corp") && rs_vpn_ifname("fvpn-x"));+ CHECK(!rs_vpn_ifname("ppp0") && !rs_vpn_ifname("tun0") && !rs_vpn_ifname("wg0") && !rs_vpn_ifname("eth0") &&+ !rs_vpn_ifname("wlan0") && !rs_vpn_ifname("wg-") && !rs_vpn_ifname(NULL));+ {+ RsAddr ifa, peer, ptp, other;+ rs_addr_parse("10.8.0.2", &ifa); /* wg-home 10.8.0.2/24 */+ rs_addr_parse("10.8.0.7", &peer);+ CHECK(rs_vpn_accepts("wg-home", &ifa, 96 + 24, NULL, &ifa, &peer)); /* in its subnet: OK */+ rs_addr_parse("203.0.113.9", &peer);+ CHECK(!rs_vpn_accepts("wg-home", &ifa, 96 + 24, NULL, &ifa, &peer)); /* public, outside: no */+ rs_addr_parse("10.8.0.7", &peer);+ rs_addr_parse("192.168.1.2", &other);+ CHECK(!rs_vpn_accepts("wg-home", &ifa, 96 + 24, NULL, &other, &peer)); /* arrived on another address */+ CHECK(!rs_vpn_accepts("wg-home", &ifa, 96 + 0, NULL, &ifa, &peer)); /* a /0 "subnet": never */+ rs_addr_parse("100.64.3.4", &ifa); /* ppp0, PPPoE uplink */+ rs_addr_parse("198.51.100.20", &peer);+ CHECK(!rs_vpn_accepts("ppp0", &ifa, 96 + 32, &peer, &ifa, &peer)); /* a public peer on ppp0: no */+ rs_addr_parse("10.20.0.1", &ptp); /* ppp-pptp point to point */+ rs_addr_parse("10.20.0.2", &ifa);+ CHECK(rs_vpn_accepts("ppp-pptp", &ifa, 96 + 32, &ptp, &ifa, &ptp));+ CHECK(!rs_vpn_accepts("ppp-pptp", &ifa, 96 + 32, &ptp, &ifa, &peer));+ /* in lan mode, the decision with that result */+ RsAccess none;+ memset(&none, 0, sizeof none);+ CHECK(rs_access_decide(&none, RS_NET_LAN, &peer, rs_vpn_accepts("ppp0", &ifa, 96 + 32, &peer, &ifa, &peer)) == RS_ACC_NOT_ALLOWED);+ rs_addr_parse("fd00:8::2", &ifa);+ rs_addr_parse("fd00:8::9", &peer);+ CHECK(rs_vpn_accepts("wg-v6", &ifa, 64, NULL, &ifa, &peer));+ rs_addr_parse("2001:db8::9", &peer);+ CHECK(!rs_vpn_accepts("wg-v6", &ifa, 64, NULL, &ifa, &peer));+ }}static void test_lockout(void) {