- Fix "Cannot set properties of undefined (setting '_class')" after adding a person on a server page: kept Overview/People tabs are taken out before dom.content() wipes their LuCI registry - No portal links while the personal portal is off - "Off" disguise writes a plain WireGuard config (no neutral Jc..H4 lines) - Setup wizard: Settings-style groups, portal off by default, "Internet like a home device" switch; no "Link path" (server ids are picked by the router) - Server ids and imported section names may not contain dashes - Health: Cloudflare-proxied endpoint and portal address are not warnings - Themes other than Outline: solid menus, drawer, palette, toasts and tooltips (Bootstrap colour tokens as fallbacks), custom select chevron - Server section tabs scroll sideways instead of wrapping; centred empty People list; wider search; "1 device" in the palette - lint-ucode: exported functions must end with "};"
This commit is contained in:
1 parent
a3910f8b97
commit
d0955e44b8
13 files changed
+168
-112
No files matched your search
@@ -231,6 +231,16 @@ function free_ifname(m) {
|
||||
return 'dawnx';
|
||||
}
|
||||
|
||||
/** A free server id: home, then server2, server3, … (never a person, device or service id). */
|
||||
function free_server_id(m) {
|
||||
let taken = (id) => m.servers[id] || m.people[id] || m.devices[id] || m.services[id] || index([ 'settings', 'api', 'assets', 'cgi-bin' ], id) >= 0;
|
||||
if (!taken('home'))
|
||||
return 'home';
|
||||
for (let n = 2; ; n++)
|
||||
if (!taken(`server${n}`))
|
||||
return `server${n}`;
|
||||
}
|
||||
|
||||
function setup_defaults(a) {
|
||||
let m = core.load();
|
||||
let taken = ops.used_subnets(null);
|
||||
@@ -258,7 +268,7 @@ function setup_defaults(a) {
|
||||
host = live.iface_status('wan')?.['ipv4-address']?.[0]?.address ?? '';
|
||||
}
|
||||
return {
|
||||
id: length(m.servers) ? `server${length(m.servers) + 1}` : 'home',
|
||||
id: free_server_id(m),
|
||||
name: length(m.servers) ? `Server ${length(m.servers) + 1}` : 'Home',
|
||||
ifname: free_ifname(m),
|
||||
port: free_port(m),
|
||||
|
||||
@@ -472,6 +472,19 @@ export function allowed_ips(m, srv, p) {
|
||||
};
|
||||
|
||||
/** Everything a client needs; `conf` is the .conf text. */
|
||||
/** True when the obfuscation settings change nothing on the wire (plain WireGuard). */
|
||||
export function obf_neutral(o) {
|
||||
for (let k in OBF_KEYS) {
|
||||
let v = o?.[k];
|
||||
if (v == null || v == '')
|
||||
continue;
|
||||
let want = { h1: '1', h2: '2', h3: '3', h4: '4' }[k] ?? '0';
|
||||
if (`${v}` != want)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
export function client_config(m, dev) {
|
||||
let p = m.people[dev.person];
|
||||
let srv = p ? m.servers[p.server] : null;
|
||||
@@ -487,9 +500,12 @@ export function client_config(m, dev) {
|
||||
if (length(dns))
|
||||
push(lines, `DNS = ${join(', ', dns)}`);
|
||||
push(lines, `MTU = ${srv.mtu}`);
|
||||
for (let k in OBF_KEYS)
|
||||
if (srv.obf[k] != null && srv.obf[k] != '')
|
||||
push(lines, `${OBF_CONF[k]} = ${srv.obf[k]}`);
|
||||
// "Off" is plain WireGuard: neutral values (no junk, H1-H4 = 1-4) are left
|
||||
// out, so any WireGuard app accepts the file.
|
||||
if (!obf_neutral(srv.obf))
|
||||
for (let k in OBF_KEYS)
|
||||
if (srv.obf[k] != null && srv.obf[k] != '')
|
||||
push(lines, `${OBF_CONF[k]} = ${srv.obf[k]}`);
|
||||
push(lines, '', '[Peer]');
|
||||
push(lines, `PublicKey = ${srv.public_key}`);
|
||||
if (dev.preshared_key)
|
||||
@@ -916,7 +932,8 @@ export function portal_public_port(m) {
|
||||
|
||||
/** The link on one address: https for names, plain http for IP addresses. */
|
||||
export function portal_link(m, p, host) {
|
||||
if (!host || !m.servers[p.server] || !match(p.code ?? '', WORD_CODE))
|
||||
// No portal, no link: the page would not answer.
|
||||
if (!m.settings.portal_enabled || !host || !m.servers[p.server] || !match(p.code ?? '', WORD_CODE))
|
||||
return null;
|
||||
if (ip2int(host) != null) {
|
||||
let hp = portal_http_public(m);
|
||||
|
||||
@@ -377,6 +377,8 @@ export function health(m) {
|
||||
stv = 'warn';
|
||||
det = `WAN address ${wan} is private: forward UDP ${srv.port} on the upstream router, or clients cannot connect.`;
|
||||
}
|
||||
else if (length(filter(ips, (a) => cloudflare_ip(a))))
|
||||
det = `${host} → ${join(', ', ips)} (Cloudflare). The tunnel is UDP: it reaches the router only if this name is DNS-only there.`;
|
||||
else if (wan && index(ips, wan) < 0) {
|
||||
stv = 'warn';
|
||||
det = `${host} resolves to ${join(', ', ips)}, but the WAN address is ${wan}. Check your DNS / DDNS.`;
|
||||
@@ -425,7 +427,7 @@ export function health(m) {
|
||||
else {
|
||||
let ips = resolve(s.portal_host), wan = router_wan(m);
|
||||
let cf = filter(ips, (x) => cloudflare_ip(x));
|
||||
push(out, check('portal_dns', 'Portal address points here', !length(ips) ? 'error' : length(cf) ? 'warn' : wan && index(ips, wan) < 0 ? 'warn' : 'ok',
|
||||
push(out, check('portal_dns', 'Portal address points here', !length(ips) ? 'error' : length(cf) ? 'ok' : wan && index(ips, wan) < 0 ? 'warn' : 'ok',
|
||||
!length(ips) ? `${s.portal_host} does not resolve.` :
|
||||
length(cf) ? `${s.portal_host} goes through Cloudflare; in Russia such connections often stall after ~16 KB.` :
|
||||
wan && index(ips, wan) < 0 ? `${s.portal_host} points at ${join(', ', ips)}, not this router (${wan}).` :
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs';
|
||||
|
||||
export const VERSION = '0.1.0';
|
||||
export const VERSION = '0.1.1';
|
||||
/** GitHub repository with Dawnline releases (updates and the installer). */
|
||||
export const REPO = 'tickcount/luci-app-dawnline';
|
||||
export const RUN_DIR = '/var/run/dawnline';
|
||||
|
||||
Reference in new issue
Block a user