🔥 Sync 2026-11-16 16:50:07

This commit is contained in:
github-actions[bot] committed 2026-11-16 16:50:08 +08:00
1 parent 6b8b3fec62
commit a2bf4e439b
87 files changed
+2498 -180

No files matched your search

@@ -1879,6 +1879,9 @@ table { border-collapse: collapse; border-spacing: 0; }
position: relative;
overflow: hidden;
}
/* LuCI keeps dropdown menus inside the cell; let an open menu extend beyond
the last row without changing the rounded clipping of closed tables. */
.table:has(.cbi-dropdown[open]) { overflow: visible; }
.thead { display: table-header-group; }
.tbody { display: table-row-group; }
.tr { display: table-row; }
@@ -2438,6 +2441,9 @@ textarea#syslog {
max-width: 60%;
}
.cb-card-link { font-size: 13px; font-weight: 500; white-space: nowrap; }
.cb-device-rate-note { margin: -4px 0 12px; color: var(--cb-text-2); font-size: 12px; }
.cb-device-rates { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 4px; color: var(--cb-text-2); }
.cb-device-rate { font-family: var(--cb-mono); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* hero */
.cb-hero {
@@ -2889,7 +2895,10 @@ body:has(#maincontent .table) { --cb-content-max: var(--cb-content-wide); }
text-overflow: ellipsis;
word-wrap: break-word;
}
.table .td.cbi-dropdown-open { overflow: visible; }
/* Plugin cells may contain a dropdown without LuCI's .cbi-value-field,
so they never receive the .cbi-dropdown-open helper class. */
.table .td.cbi-dropdown-open,
.table .td:has(.cbi-dropdown[open]) { overflow: visible; }
.table .tr:hover > .td { background: transparent !important; }
.tr.table-titles,
.cbi-section-table-titles,
@@ -711,6 +711,71 @@
schedule();
};
/* LuCI's legacy realtime plots cache their pixel width at initialization.
* Fit their existing coordinates to the current viewport without changing
* samples, polling or the time window. Only curves and time-grid positions
* scale horizontally; text and stroke widths retain their original size. */
const realtimeRoots = new WeakSet();
C.initRealtimeCharts = function (root) {
if (!root || realtimeRoots.has(root) ||
!/(?:^|-)status-realtime(?:-|$)/.test(document.body.getAttribute('data-page') || '')) return;
realtimeRoots.add(root);
const graphs = new Set();
let pending = false;
const schedule = () => {
if (pending) return;
pending = true;
requestAnimationFrame(sync);
};
const resize = window.ResizeObserver ? new ResizeObserver(schedule) : null;
function sync() {
pending = false;
for (const svg of graphs) {
if (!root.contains(svg)) {
if (resize) resize.unobserve(svg);
graphs.delete(svg);
}
}
root.querySelectorAll('#view svg').forEach((svg) => {
// Leave modern responsive SVGs and unrelated plugin charts alone.
if (svg.hasAttribute('viewBox') || svg.getAttribute('width') !== '100%' ||
!svg.querySelector('#label_25') || !svg.querySelector('#label_50') || !svg.querySelector('#label_75')) return;
if (!graphs.has(svg)) {
graphs.add(svg);
if (resize) resize.observe(svg);
}
const lines = Array.from(svg.children).filter((el) => el.localName === 'polyline');
const drawn = lines.find((el) => el.points.numberOfItems > 1);
if (!drawn || !svg.clientWidth) return;
// LuCI closes each filled curve at (cached width, baseline).
const width = drawn.points.getItem(drawn.points.numberOfItems - 1).x;
if (!(width > 0)) return;
const scale = svg.clientWidth / width;
for (const el of svg.children) {
const vertical = el.localName === 'line' &&
el.getAttribute('x1') === el.getAttribute('x2');
if (el.localName === 'polyline' || vertical) {
el.setAttribute('transform', 'scale(' + scale + ' 1)');
el.setAttribute('vector-effect', 'non-scaling-stroke');
}
else if (el.localName === 'text' && !el.id && el.x.baseVal.numberOfItems) {
const x = el.x.baseVal.getItem(0).value;
el.setAttribute('transform', 'translate(' + (x * (scale - 1)) + ' 0)');
}
}
});
}
const watch = new MutationObserver(schedule);
watch.observe(root, { childList: true, subtree: true, attributes: true, attributeFilter: ['points'] });
window.addEventListener('resize', schedule, { passive: true });
if (!resize) {
// Older browsers: cover sidebar transitions and reduced-motion changes.
watch.observe(rootEl, { attributes: true, attributeFilter: ['class'] });
window.addEventListener('transitionend', schedule);
}
schedule();
};
/* ------------------------------------------------------------------
* Language switch (rendered once the installed catalogues are known)
* ------------------------------------------------------------------ */
@@ -774,6 +839,7 @@
C.initShell = function (opts) {
opts = opts || {};
C.initTabs(document.getElementById('maincontent'));
C.initRealtimeCharts(document.getElementById('maincontent'));
C.initLeaseAvatars(document.getElementById('maincontent'));
const body = document.body;
const burger = document.getElementById('cb-burger');
@@ -1267,6 +1333,8 @@
* wireless() → ubus network.wireless status
* stations(ifnames) → [{ ifname, mac, signal }] from iwinfo assoclist (optional)
* neighbors() → contents of /proc/net/arp (optional)
* deviceTraffic() → { interval: seconds, columns, data } from an existing
* per-MAC collector (optional, read-only)
* hostHints() → luci-rpc getHostHints (optional)
* conntrack() → [count, max]
* temperatures() → [{ name, value (millidegrees) }]
@@ -1391,6 +1459,43 @@
* → [{ macaddr, hostname, ipaddr, ip6addr, expires, lease, active, wifi, gateway }]
* ------------------------------------------------------------------ */
const MAC_RE = /^([0-9a-f]{2}:){5}[0-9a-f]{2}$/;
/* Sampled averages from cumulative per-MAC counters. Missing records, resets,
* failed reads and suspended tabs never count as zero. Records cannot create
* discovered devices, and query frequency never exceeds the collector cadence. */
C.DeviceRates = function () { this.previous = null; };
C.DeviceRates.prototype.reset = function () { this.previous = null; };
C.DeviceRates.prototype.update = function (sample, now) {
const invalid = () => { this.reset(); return null; };
if (!sample || !Number.isFinite(now) || !Number.isFinite(sample.interval) || sample.interval < 5 ||
!Array.isArray(sample.columns) || !Array.isArray(sample.data)) return invalid();
const fields = ['mac', 'rx_bytes', 'tx_bytes'].map((k) => sample.columns.indexOf(k));
if (fields.some((i) => i < 0)) return invalid();
const counters = new Map();
for (const row of sample.data) {
if (!Array.isArray(row)) return invalid();
const mac = String(row[fields[0]] || '').toLowerCase();
if (!MAC_RE.test(mac) || mac === '00:00:00:00:00:00') continue;
const rx = row[fields[1]], tx = row[fields[2]];
if (!Number.isSafeInteger(rx) || rx < 0 || !Number.isSafeInteger(tx) || tx < 0) return invalid();
const old = counters.get(mac) || { rx: 0, tx: 0 };
if (!Number.isSafeInteger(old.rx + rx) || !Number.isSafeInteger(old.tx + tx)) return invalid();
counters.set(mac, { rx: old.rx + rx, tx: old.tx + tx });
}
const rates = new Map(), previous = this.previous;
const dt = previous ? (now - previous.time) / 1000 : 0;
const continuous = previous && previous.interval === sample.interval && dt >= sample.interval && dt <= sample.interval * 2.5;
if (continuous) counters.forEach((value, mac) => {
const old = previous.counters.get(mac);
if (old && value.rx >= old.rx && value.tx >= old.tx)
rates.set(mac, { down: (value.rx - old.rx) / dt, up: (value.tx - old.tx) / dt });
});
// An early read must not move the baseline closer to the next sample.
if (!previous || dt <= 0 || dt >= sample.interval || previous.interval !== sample.interval)
this.previous = { counters: counters, interval: sample.interval, time: now };
return { rates: rates, interval: sample.interval, seconds: continuous ? dt : null };
};
C.parseArp = function (text, devices, ifs) {
const gateways = new Set();
(ifs || []).forEach((i) => {
@@ -1708,9 +1813,11 @@
ui.clientCount = h('span', { class: 'cb-count' });
ui.clients = h('ul', { class: 'cb-list' });
ui.clientMore = h('button', { type: 'button', class: 'cb-more hidden' });
ui.clientRateNodes = new Map();
ui.clientRateNote = h('p', { class: 'cb-device-rate-note hidden', title: t('Device speeds use existing traffic statistics. Only traffic observed by this router is included.') });
dash.appendChild(h('div', { class: 'cb-card cb-clients span-8' }, [
h('div', { class: 'cb-card-head' }, [h('h3', null, [deviceTitle(), ui.clientCount]), manage(urls.devices)]),
ui.clients, ui.clientMore
ui.clientRateNote, ui.clients, ui.clientMore
]));
/* wireless + interfaces */
@@ -1736,8 +1843,10 @@
const st = {
dev: null, devAlt: null, prevNet: null, prevCpu: null, showAll: false, devices: [], wifiCount: null,
traffic: store.get('carbon.traffic', 'auto'), trafficKey: '', ifs: null, hints: null, hintsAt: 0, aps: null,
netdevs: null, netdevsAt: 0
netdevs: null, netdevsAt: 0,
rateData: null, rateSeen: false, rateNext: 0, rateGeneration: 0
};
const deviceRates = new C.DeviceRates();
const safe = (fn) => {
if (typeof fn !== 'function') return Promise.resolve(null);
try { return Promise.resolve(fn()).catch(() => null); }
@@ -1755,6 +1864,7 @@
function renderClients() {
const list = st.devices;
ui.clients.innerHTML = '';
ui.clientRateNodes.clear();
ui.clientCount.textContent = list ? String(list.length) : '';
ui.tDevices.val.textContent = list ? String(list.length) : '—';
ui.tDevices.sub.textContent = st.wifiCount != null ? t('%d on Wi-Fi', st.wifiCount) :
@@ -1776,6 +1886,10 @@
}
else if (l.active && !l.wifi) lease = t('Neighbor entry');
const wifi = l.wifi ? [l.wifi.band, l.wifi.signal != null ? l.wifi.signal + ' dBm' : null].filter(Boolean).join(' · ') : '';
const down = h('span', { class: 'cb-device-rate', title: t('Download') });
const up = h('span', { class: 'cb-device-rate', title: t('Upload') });
const speeds = h('span', { class: 'cb-device-rates hidden' }, [down, up]);
ui.clientRateNodes.set(l.macaddr, { row: speeds, down: down, up: up });
ui.clients.appendChild(h('li', null, [
deviceAvatar(l, id),
h('div', { class: 'cb-list-main' }, [
@@ -1783,7 +1897,8 @@
h('span', { class: 'cb-list-sub' }, [
kind ? h('span', { class: 'cb-kind', text: kind }) : null,
h('span', { class: 'cb-mono', text: l.ipaddr || l.ip6addr || '' })
])
]),
speeds
]),
h('div', { class: 'cb-list-aside' }, [
h('span', { class: 'cb-mono cb-hide-sm', text: (l.macaddr || '').toUpperCase() }),
@@ -1800,7 +1915,44 @@
ui.clientMore.textContent = st.showAll ? t('Show less') : t('Show all %d devices', list.length);
}
else ui.clientMore.classList.add('hidden');
renderDeviceRates();
}
function renderDeviceRates() {
const data = st.rateData;
ui.clientRateNote.classList.toggle('hidden', !st.rateSeen);
ui.clientRateNote.textContent = t('Device speeds') + ' · ' + (!data ? t('Unavailable') :
(data.seconds == null ? t('Waiting for next sample') : t('%d s average', Math.round(data.seconds))));
ui.clientRateNodes.forEach((nodes, mac) => {
nodes.row.classList.toggle('hidden', !st.rateSeen);
const rate = data && data.rates.get(mac);
const text = (v) => v == null ? '—' : fmt.bytes(v, true).join(' ');
nodes.down.textContent = '↓ ' + text(rate && rate.down);
nodes.up.textContent = '↑ ' + text(rate && rate.up);
nodes.down.setAttribute('aria-label', t('Download') + ' ' + text(rate && rate.down));
nodes.up.setAttribute('aria-label', t('Upload') + ' ' + text(rate && rate.up));
});
}
async function readDeviceRates() {
if (Date.now() < st.rateNext) return;
const generation = st.rateGeneration;
const sample = await safe(P.deviceTraffic);
if (generation !== st.rateGeneration) return;
const now = Date.now();
// Responses arriving after the page is hidden cannot establish a baseline.
st.rateData = deviceRates.update(document.hidden ? null : sample, now);
if (st.rateData) st.rateSeen = true;
st.rateNext = now + (st.rateData ? st.rateData.interval : 60) * 1000;
renderDeviceRates();
}
document.addEventListener('visibilitychange', () => {
st.rateGeneration++;
deviceRates.reset();
st.rateData = null;
st.rateNext = 0;
renderDeviceRates();
});
ui.clientMore.addEventListener('click', () => { st.showAll = !st.showAll; renderClients(); });
C.loadBrands().then((d) => { if (d && st.devices) renderClients(); });
@@ -2067,6 +2219,7 @@
setTimeout(() => loop(slow, 10000), 10000);
});
loop(mid, 5000);
if (typeof P.deviceTraffic === 'function') loop(readDeviceRates, 5000);
return dash;
}
@@ -3,6 +3,7 @@
"%d cores": "%d Kerne",
"%d min": "%d Min.",
"%d on Wi-Fi": "%d im WLAN",
"%d s average": "Durchschnitt über %d s",
"%dd %dh": "%d T. %d Std.",
"%dh %dm": "%d Std. %d Min.",
"%ds ago": "vor %d s",
@@ -40,6 +41,8 @@
"CPU": "CPU",
"Current logo": "Aktuelles Logo",
"Dark": "Dunkel",
"Device speeds": "Gerätegeschwindigkeit",
"Device speeds use existing traffic statistics. Only traffic observed by this router is included.": "Die Gerätegeschwindigkeit nutzt vorhandene Verkehrsstatistiken. Nur von diesem Router erfasster Verkehr wird berücksichtigt.",
"DHCP client": "DHCP-Client",
"DHCP lease": "DHCP-Lease",
"Discovered devices": "Erkannte Geräte",
@@ -162,6 +165,7 @@
"Used": "Belegt",
"Verifying update…": "Update wird geprüft…",
"View releases on GitHub": "Releases auf GitHub ansehen",
"Waiting for next sample": "Warten auf nächste Messung",
"WAN IP": "WAN-IP",
"WAN IPv6": "WAN-IPv6",
"Wi-Fi": "WLAN",
@@ -3,6 +3,7 @@
"%d cores": "%d núcleos",
"%d min": "%d min",
"%d on Wi-Fi": "%d por Wi-Fi",
"%d s average": "Promedio de %d s",
"%dd %dh": "%d d %d h",
"%dh %dm": "%d h %d min",
"%ds ago": "hace %d s",
@@ -40,6 +41,8 @@
"CPU": "CPU",
"Current logo": "Logotipo actual",
"Dark": "Oscuro",
"Device speeds": "Velocidad de los dispositivos",
"Device speeds use existing traffic statistics. Only traffic observed by this router is included.": "La velocidad utiliza estadísticas de tráfico existentes. Solo incluye el tráfico observado por este router.",
"DHCP client": "Cliente DHCP",
"DHCP lease": "Concesión DHCP",
"Discovered devices": "Dispositivos detectados",
@@ -162,6 +165,7 @@
"Used": "Usado",
"Verifying update…": "Verificando actualización…",
"View releases on GitHub": "Ver versiones en GitHub",
"Waiting for next sample": "Esperando la siguiente muestra",
"WAN IP": "IP WAN",
"WAN IPv6": "IPv6 WAN",
"Wi-Fi": "Wi-Fi",
@@ -3,6 +3,7 @@
"%d cores": "%d cœurs",
"%d min": "%d min",
"%d on Wi-Fi": "%d en Wi-Fi",
"%d s average": "Moyenne sur %d s",
"%dd %dh": "%d j %d h",
"%dh %dm": "%d h %d min",
"%ds ago": "il y a %d s",
@@ -40,6 +41,8 @@
"CPU": "CPU",
"Current logo": "Logo actuel",
"Dark": "Sombre",
"Device speeds": "Débit des appareils",
"Device speeds use existing traffic statistics. Only traffic observed by this router is included.": "Le débit utilise les statistiques de trafic existantes. Seul le trafic observé par ce routeur est inclus.",
"DHCP client": "Client DHCP",
"DHCP lease": "Bail DHCP",
"Discovered devices": "Appareils détectés",
@@ -162,6 +165,7 @@
"Used": "Utilisé",
"Verifying update…": "Vérification de la mise à jour…",
"View releases on GitHub": "Voir les versions sur GitHub",
"Waiting for next sample": "En attente de la prochaine mesure",
"WAN IP": "IP WAN",
"WAN IPv6": "IPv6 WAN",
"Wi-Fi": "Wi-Fi",
@@ -3,6 +3,7 @@
"%d cores": "%d core",
"%d min": "%d min",
"%d on Wi-Fi": "%d in Wi-Fi",
"%d s average": "Media su %d s",
"%dd %dh": "%d g %d h",
"%dh %dm": "%d h %d min",
"%ds ago": "%d s fa",
@@ -40,6 +41,8 @@
"CPU": "CPU",
"Current logo": "Logo attuale",
"Dark": "Scuro",
"Device speeds": "Velocità dei dispositivi",
"Device speeds use existing traffic statistics. Only traffic observed by this router is included.": "La velocità usa le statistiche di traffico esistenti. Include solo il traffico osservato da questo router.",
"DHCP client": "Client DHCP",
"DHCP lease": "Lease DHCP",
"Discovered devices": "Dispositivi rilevati",
@@ -162,6 +165,7 @@
"Used": "Usata",
"Verifying update…": "Verifica dell’aggiornamento…",
"View releases on GitHub": "Vedi le release su GitHub",
"Waiting for next sample": "In attesa del prossimo campione",
"WAN IP": "IP WAN",
"WAN IPv6": "IPv6 WAN",
"Wi-Fi": "Wi-Fi",
@@ -3,6 +3,7 @@
"%d cores": "%d コア",
"%d min": "%d 分",
"%d on Wi-Fi": "Wi-Fi 接続 %d 台",
"%d s average": "直近 %d 秒の平均",
"%dd %dh": "%d 日 %d 時間",
"%dh %dm": "%d 時間 %d 分",
"%ds ago": "%d 秒前",
@@ -40,6 +41,8 @@
"CPU": "CPU",
"Current logo": "現在のロゴ",
"Dark": "ダーク",
"Device speeds": "端末の通信速度",
"Device speeds use existing traffic statistics. Only traffic observed by this router is included.": "端末の通信速度は既存の通信統計を使用します。このルーターで観測された通信のみが対象です。",
"DHCP client": "DHCP クライアント",
"DHCP lease": "DHCP リース",
"Discovered devices": "検出したデバイス",
@@ -162,6 +165,7 @@
"Used": "使用中",
"Verifying update…": "更新を検証しています…",
"View releases on GitHub": "GitHub でリリースを見る",
"Waiting for next sample": "次の測定を待機中",
"WAN IP": "WAN IP",
"WAN IPv6": "WAN IPv6",
"Wi-Fi": "Wi-Fi",
@@ -3,6 +3,7 @@
"%d cores": "%d코어",
"%d min": "%d분",
"%d on Wi-Fi": "Wi-Fi %d대",
"%d s average": "최근 %d초 평균",
"%dd %dh": "%d일 %d시간",
"%dh %dm": "%d시간 %d분",
"%ds ago": "%d초 전",
@@ -40,6 +41,8 @@
"CPU": "CPU",
"Current logo": "현재 로고",
"Dark": "다크",
"Device speeds": "기기 통신 속도",
"Device speeds use existing traffic statistics. Only traffic observed by this router is included.": "기기 속도는 기존 트래픽 통계를 사용합니다. 이 라우터에서 관측한 트래픽만 포함됩니다.",
"DHCP client": "DHCP 클라이언트",
"DHCP lease": "DHCP 임대",
"Discovered devices": "발견된 기기",
@@ -162,6 +165,7 @@
"Used": "사용 중",
"Verifying update…": "업데이트 확인 중…",
"View releases on GitHub": "GitHub에서 릴리스 보기",
"Waiting for next sample": "다음 측정 대기 중",
"WAN IP": "WAN IP",
"WAN IPv6": "WAN IPv6",
"Wi-Fi": "Wi-Fi",
@@ -3,6 +3,7 @@
"%d cores": "%d núcleos",
"%d min": "%d min",
"%d on Wi-Fi": "%d no Wi-Fi",
"%d s average": "Média de %d s",
"%dd %dh": "%d d %d h",
"%dh %dm": "%d h %d min",
"%ds ago": "há %d s",
@@ -40,6 +41,8 @@
"CPU": "CPU",
"Current logo": "Logotipo atual",
"Dark": "Escuro",
"Device speeds": "Velocidade dos dispositivos",
"Device speeds use existing traffic statistics. Only traffic observed by this router is included.": "A velocidade usa as estatísticas de tráfego existentes. Inclui apenas o tráfego observado por este roteador.",
"DHCP client": "Cliente DHCP",
"DHCP lease": "Concessão DHCP",
"Discovered devices": "Dispositivos detectados",
@@ -162,6 +165,7 @@
"Used": "Usado",
"Verifying update…": "Verificando atualização…",
"View releases on GitHub": "Ver versões no GitHub",
"Waiting for next sample": "Aguardando a próxima amostra",
"WAN IP": "IP da WAN",
"WAN IPv6": "IPv6 da WAN",
"Wi-Fi": "Wi-Fi",
@@ -3,6 +3,7 @@
"%d cores": "Ядер: %d",
"%d min": "%d мин",
"%d on Wi-Fi": "По Wi-Fi: %d",
"%d s average": "Среднее за %d с",
"%dd %dh": "%d д %d ч",
"%dh %dm": "%d ч %d мин",
"%ds ago": "%d с назад",
@@ -40,6 +41,8 @@
"CPU": "ЦП",
"Current logo": "Текущий логотип",
"Dark": "Тёмная",
"Device speeds": "Скорость устройств",
"Device speeds use existing traffic statistics. Only traffic observed by this router is included.": "Скорость рассчитывается по существующей статистике. Учитывается только трафик, наблюдаемый этим маршрутизатором.",
"DHCP client": "DHCP-клиент",
"DHCP lease": "Аренда DHCP",
"Discovered devices": "Обнаруженные устройства",
@@ -162,6 +165,7 @@
"Used": "Занято",
"Verifying update…": "Проверка обновления…",
"View releases on GitHub": "Выпуски на GitHub",
"Waiting for next sample": "Ожидание следующего замера",
"WAN IP": "IP в WAN",
"WAN IPv6": "IPv6 в WAN",
"Wi-Fi": "Wi-Fi",
@@ -3,6 +3,7 @@
"%d cores": "%d çekirdek",
"%d min": "%d dk",
"%d on Wi-Fi": "Wi-Fi'de %d",
"%d s average": "%d sn ortalaması",
"%dd %dh": "%d g %d sa",
"%dh %dm": "%d sa %d dk",
"%ds ago": "%d sn önce",
@@ -40,6 +41,8 @@
"CPU": "CPU",
"Current logo": "Geçerli logo",
"Dark": "Koyu",
"Device speeds": "Cihaz hızları",
"Device speeds use existing traffic statistics. Only traffic observed by this router is included.": "Cihaz hızları mevcut trafik istatistiklerini kullanır. Yalnızca bu yönlendiricinin gözlemlediği trafik dahil edilir.",
"DHCP client": "DHCP istemcisi",
"DHCP lease": "DHCP kirası",
"Discovered devices": "Algılanan cihazlar",
@@ -162,6 +165,7 @@
"Used": "Kullanılan",
"Verifying update…": "Güncelleme doğrulanıyor…",
"View releases on GitHub": "Sürümleri GitHub'da görüntüle",
"Waiting for next sample": "Sonraki ölçüm bekleniyor",
"WAN IP": "WAN IP",
"WAN IPv6": "WAN IPv6",
"Wi-Fi": "Wi-Fi",
@@ -3,6 +3,7 @@
"%d cores": "%d nhân",
"%d min": "%d phút",
"%d on Wi-Fi": "%d qua Wi-Fi",
"%d s average": "Trung bình %d giây",
"%dd %dh": "%d ngày %d giờ",
"%dh %dm": "%d giờ %d phút",
"%ds ago": "%d giây trước",
@@ -40,6 +41,8 @@
"CPU": "CPU",
"Current logo": "Logo hiện tại",
"Dark": "Tối",
"Device speeds": "Tốc độ thiết bị",
"Device speeds use existing traffic statistics. Only traffic observed by this router is included.": "Tốc độ thiết bị sử dụng thống kê lưu lượng hiện có. Chỉ bao gồm lưu lượng được bộ định tuyến này quan sát.",
"DHCP client": "Máy khách DHCP",
"DHCP lease": "Bản thuê DHCP",
"Discovered devices": "Thiết bị đã phát hiện",
@@ -162,6 +165,7 @@
"Used": "Đã dùng",
"Verifying update…": "Đang xác minh bản cập nhật…",
"View releases on GitHub": "Xem các bản phát hành trên GitHub",
"Waiting for next sample": "Đang chờ lần lấy mẫu tiếp theo",
"WAN IP": "IP WAN",
"WAN IPv6": "IPv6 WAN",
"Wi-Fi": "Wi-Fi",
@@ -3,6 +3,7 @@
"%d cores": "%d 核",
"%d min": "%d 分钟",
"%d on Wi-Fi": "Wi‑Fi 连接 %d 台",
"%d s average": "近 %d 秒平均",
"%dd %dh": "%d 天 %d 小时",
"%dh %dm": "%d 小时 %d 分",
"%ds ago": "%d 秒前",
@@ -40,6 +41,8 @@
"CPU": "CPU",
"Current logo": "当前 Logo",
"Dark": "深色",
"Device speeds": "设备网速",
"Device speeds use existing traffic statistics. Only traffic observed by this router is included.": "设备网速读取已有流量统计,仅包含本机观测到的流量。",
"DHCP client": "DHCP 客户端",
"DHCP lease": "DHCP 租约",
"Discovered devices": "已发现设备",
@@ -162,6 +165,7 @@
"Used": "已用",
"Verifying update…": "正在校验更新…",
"View releases on GitHub": "在 GitHub 查看发布版本",
"Waiting for next sample": "等待下一次采样",
"WAN IP": "外网 IP",
"WAN IPv6": "外网 IPv6",
"Wi-Fi": "无线 Wi‑Fi",
@@ -3,6 +3,7 @@
"%d cores": "%d 核心",
"%d min": "%d 分鐘",
"%d on Wi-Fi": "Wi‑Fi 連線 %d 台",
"%d s average": "近 %d 秒平均",
"%dd %dh": "%d 天 %d 小時",
"%dh %dm": "%d 小時 %d 分",
"%ds ago": "%d 秒前",
@@ -40,6 +41,8 @@
"CPU": "CPU",
"Current logo": "目前的 Logo",
"Dark": "深色",
"Device speeds": "裝置網速",
"Device speeds use existing traffic statistics. Only traffic observed by this router is included.": "裝置網速讀取既有流量統計,僅包含本機觀測到的流量。",
"DHCP client": "DHCP 用戶端",
"DHCP lease": "DHCP 租約",
"Discovered devices": "已發現裝置",
@@ -162,6 +165,7 @@
"Used": "已用",
"Verifying update…": "正在驗證更新…",
"View releases on GitHub": "在 GitHub 查看發布版本",
"Waiting for next sample": "等待下一次取樣",
"WAN IP": "外部 IP",
"WAN IPv6": "外部 IPv6",
"Wi-Fi": "無線 Wi‑Fi",
@@ -0,0 +1,34 @@
'use strict';
'require baseclass';
'require fs';
'require rpc';
/* Read-only adapter for OpenWrt's optional nlbwmon collector. Never starts a
* service, flushes counters, commits a database or changes its configuration. */
const callConfig = rpc.declare({ object: 'uci', method: 'get', params: ['config'], expect: { values: {} } });
let config = null, configAt = 0;
function interval(values) {
const sections = Object.values(values || {}).filter((s) => s && s['.type'] === 'nlbwmon');
if (sections.length !== 1) return null;
// 30 seconds is the upstream default when the option is omitted.
const m = /^(\d+)([smhdw]?)$/.exec(String(sections[0].refresh_interval == null ? '30s' : sections[0].refresh_interval));
if (!m) return null;
const seconds = Number(m[1]) * ({ '': 1, s: 1, m: 60, h: 3600, d: 86400, w: 604800 })[m[2]];
return seconds > 0 && seconds <= 2147483 ? Math.max(5, seconds) : null;
}
return baseclass.extend({
async read() {
const now = Date.now();
if (!config || now - configAt >= 300000) {
config = await callConfig('nlbwmon');
configAt = now;
}
const seconds = interval(config);
if (seconds == null) return null;
// Fixed command: device addresses and user input never become arguments.
const data = await fs.exec_direct('/usr/sbin/nlbw', ['-c', 'json', '-g', 'mac', '-n'], 'json');
return { interval: seconds, columns: data && data.columns, data: data && data.data };
}
});
@@ -5,6 +5,7 @@
'require rpc';
'require fs';
'require poll';
'require carbon.traffic as traffic';
/*
* Carbon — LuCI glue.
@@ -94,6 +95,7 @@ const provider = {
return [].concat.apply([], lists.filter(Boolean));
}),
neighbors: () => fs.read('/proc/net/arp'),
deviceTraffic: () => traffic.read(),
conntrack: () => Promise.all([
fs.read('/proc/sys/net/netfilter/nf_conntrack_count'),
fs.read('/proc/sys/net/netfilter/nf_conntrack_max').catch(() => null)