Dawnline 0.9.0
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions
- Portal: Reconnect replaces New keys and the connection sheet (QR, Key,
File, and the menu's QR, key and .conf items). It gives the device new
keys, shows it as "Not set up yet" until it connects with them (in the
admin too) and opens the set-up sheet on the new configuration; "Update
the connection" goes the same way. Reconnect is orange in the menu
- iPhone: "Open in AmneziaVPN" is "Send to AmneziaVPN": the key goes in as
a .vpn file from the share sheet. AmneziaVPN takes vpn:// links only on
Android; on iOS Safari said the address was invalid, or another app that
claims vpn:// got the key. The desktop "Open in AmneziaVPN" link is gone
- A computer set up from a phone: get the app, add the connection, then
"Or open your link on the computer"; "Another app" offers AmneziaWG and
WireGuard there too and step 2 follows the pick. "Other" devices pick any
system (iPhone/iPad, Android, Windows, Mac, Linux); the page counts as the
device in hand only when the pick is its own system
- Import steps in each app's own words (iOS "+ → Create from file or
archive", Android "+ → Import from file or archive", Mac, Windows "Add
Tunnel → Import tunnel(s) from file"); Linux gets the awg-quick command
- Files are shared only on iOS (on Android the apps take no shared files:
a download there), and alone: with a title, "Save to Files" also wrote
the title as a .txt
- Files and tunnels are named after the server ("Outline Home" →
Outline-Home.conf and .vpn) in the form every client accepts: letters,
digits and "-", 15 characters, no Windows device names. The admin's
downloads keep the device in the name. The AmneziaVPN key's description
is the server's name alone
- The AmneziaVPN QR code holds the key without "vpn://": AmneziaVPN's
scanner decodes the text as it is and failed on the prefix
- "This device" also when the page is opened beside the tunnel: the apps
route the VPN's own address, which the portal shares, around their
tunnel, so the one online device whose tunnel comes from the page's
address is the one
- Fixed: "Already has AmneziaVPN?Copy the key" lost its space
This commit is contained in:
1 parent
7a6370aa9e
commit
edeb1506fd
22 files changed
+401
-486
No files matched your search
@@ -660,3 +660,33 @@ export function mark_issued(m, id) {
|
||||
unlock(l);
|
||||
};
|
||||
|
||||
/* ---------- set up again (Reconnect) ---------- */
|
||||
|
||||
const RECONNECT = `${DATA_DIR}/reconnect.json`;
|
||||
|
||||
/** Device id → when the person asked to set it up again (router clock). */
|
||||
export function reconnects() {
|
||||
return read_json(RECONNECT, {});
|
||||
};
|
||||
|
||||
/**
|
||||
* The handshake a device counts with: none from before it was set up again,
|
||||
* so it shows "Not set up yet" until it connects after that.
|
||||
*/
|
||||
export function handshake_since(hs, since) {
|
||||
return since && hs <= since ? 0 : hs;
|
||||
};
|
||||
|
||||
/** A device is set up again: handshakes up to `at` (router clock) are its old configuration's. */
|
||||
export function mark_reconnect(m, id, at) {
|
||||
let l = lock('reconnect');
|
||||
let all = reconnects();
|
||||
all[id] = at ?? time();
|
||||
for (let k in keys(all))
|
||||
if (!m.devices[k])
|
||||
delete all[k];
|
||||
ensure_dir(DATA_DIR, 0o700);
|
||||
write_json(RECONNECT, all, 0o600);
|
||||
unlock(l);
|
||||
};
|
||||
|
||||
@@ -104,6 +104,21 @@ export function rotate(id, opts) {
|
||||
return cfg;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set a device up from scratch (a new phone, the app reinstalled, settings
|
||||
* the admin changed): new keys, so the configuration it holds stops working
|
||||
* with the sync, and it counts as not set up until it connects with the new
|
||||
* one. The usage keeps the old keys' last handshake: awg.handshake_since hides
|
||||
* it. Returns the new configuration, as rotate.
|
||||
*/
|
||||
export function reconnect(id, opts) {
|
||||
opts ??= {};
|
||||
let cfg = rotate(id, opts);
|
||||
// A deferred sync (the page came through this device) lets the old keys live a few seconds more.
|
||||
awg.mark_reconnect(core.load(), id, time() + (opts.defer ? 5 : 0));
|
||||
return cfg;
|
||||
};
|
||||
|
||||
/** Remove a device. Returns the runtime sync. */
|
||||
export function remove(id, opts) {
|
||||
opts ??= {};
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
// that answers anything not shaped like a link (its not_found() twin).
|
||||
|
||||
import { stat, readfile } from 'fs';
|
||||
import { read_json, write_json, ensure_dir, lock, unlock, cloudflare_ip, ip2int, today, VERSION, RUN_DIR } from 'dawnline.util';
|
||||
import { read_json, write_json, ensure_dir, lock, unlock, cloudflare_ip, ip2int, today, tunnel_name, VERSION, RUN_DIR } from 'dawnline.util';
|
||||
import * as core from 'dawnline.core';
|
||||
import * as awg from 'dawnline.awg';
|
||||
import * as live from 'dawnline.live';
|
||||
@@ -345,11 +345,8 @@ function state(r) {
|
||||
let v = view.person_view(m, person, usage, live.dump(m), view.states(m, usage));
|
||||
v.state = person_state(m, person, usage);
|
||||
let srv = m.servers[person.server];
|
||||
// The device this page was opened from, when it came through the tunnel.
|
||||
let here = null;
|
||||
for (let id, d in m.devices)
|
||||
if (d.person == person.id && d.address == r.peer)
|
||||
here = id;
|
||||
// The device this page was opened from, through the tunnel or beside it.
|
||||
let here = view.device_here(v.devices, r.peer);
|
||||
return {
|
||||
title: r.title,
|
||||
person: v,
|
||||
@@ -386,6 +383,15 @@ function api_state(r) {
|
||||
send_json(r, '200 OK', state(r));
|
||||
}
|
||||
|
||||
/**
|
||||
* A configuration as the person gets it: the file, and so the tunnel the apps
|
||||
* name after it, is the server's name. The admin's downloads keep the device
|
||||
* in the name: one browser fetches many of them.
|
||||
*/
|
||||
function own_config(c) {
|
||||
return c ? { ...c, filename: `${tunnel_name(c.server)}.conf` } : c;
|
||||
}
|
||||
|
||||
function api_add(r) {
|
||||
need_open(r);
|
||||
need_https(r);
|
||||
@@ -395,7 +401,7 @@ function api_add(r) {
|
||||
rate_action(r);
|
||||
let res = guard(r, () => devices.add(r.person.id, b.name, b.kind, { by: 'portal', public_key: b.public_key }));
|
||||
reload(r);
|
||||
send_json(r, '200 OK', { id: res.id, config: res.config, state: state(r) });
|
||||
send_json(r, '200 OK', { id: res.id, config: own_config(res.config), state: state(r) });
|
||||
}
|
||||
|
||||
function api_config(r, id) {
|
||||
@@ -403,7 +409,7 @@ function api_config(r, id) {
|
||||
need_open(r);
|
||||
need_https(r);
|
||||
awg.mark_issued(r.m, d.id);
|
||||
send_json(r, '200 OK', awg.client_config(r.m, d));
|
||||
send_json(r, '200 OK', own_config(awg.client_config(r.m, d)));
|
||||
}
|
||||
|
||||
/** POST /devices/<id> { action }: what each action does; the answer carries the new state. */
|
||||
@@ -412,12 +418,13 @@ const ACTIONS = {
|
||||
guard(r, () => devices.update(d.id, { name: b.name }, { by: 'portal', person: r.person.id }));
|
||||
return {};
|
||||
},
|
||||
rotate: (r, d, b) => {
|
||||
// Set up from scratch: new keys and the new configuration, which the set-up sheet takes in.
|
||||
reconnect: (r, d, b) => {
|
||||
need_https(r);
|
||||
if (!devices.ready())
|
||||
fail(r, '503 Service Unavailable', NOT_READY);
|
||||
let config = guard(r, () => devices.rotate(d.id, { by: 'portal', person: r.person.id, defer: d.address == r.peer }));
|
||||
return { config };
|
||||
let config = guard(r, () => devices.reconnect(d.id, { by: 'portal', person: r.person.id, defer: d.address == r.peer }));
|
||||
return { config: own_config(config) };
|
||||
},
|
||||
'delete': (r, d, b) => {
|
||||
guard(r, () => devices.remove(d.id, { by: 'portal', person: r.person.id }));
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs';
|
||||
|
||||
export const VERSION = '0.8.1';
|
||||
export const VERSION = '0.9.0';
|
||||
/** GitHub repository with Dawnline releases (updates and the installer). */
|
||||
export const REPO = 'tickcount/luci-app-dawnline';
|
||||
export const RUN_DIR = '/var/run/dawnline';
|
||||
@@ -588,6 +588,18 @@ export function host_label(s) {
|
||||
return l || 'device';
|
||||
};
|
||||
|
||||
/**
|
||||
* A server's name as a tunnel name ("Outline Home" → "Outline-Home"): the
|
||||
* AmneziaWG and WireGuard apps name the tunnel after the file, and Android and
|
||||
* wg-quick refuse anything but [a-zA-Z0-9_=+.-] up to 15 characters; Windows
|
||||
* refuses its device names (CON, NUL, COM1…). "dawnline" when nothing is left.
|
||||
*/
|
||||
export function tunnel_name(s) {
|
||||
let l = replace(translit(`${s ?? ''}`), /[^A-Za-z0-9]+/g, '-');
|
||||
l = replace(substr(replace(l, /^-+|-+$/g, ''), 0, 15), /-+$/g, '');
|
||||
return l && !match(l, /^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i) ? l : 'dawnline';
|
||||
};
|
||||
|
||||
/* ---------- time ---------- */
|
||||
|
||||
/** "YYYY-MM-DD" → epoch of the end of that local day (23:59:59). */
|
||||
|
||||
@@ -23,11 +23,35 @@ function config_stale(m, d) {
|
||||
return was != null && was != awg.config_fingerprint(m, d);
|
||||
}
|
||||
|
||||
/**
|
||||
* The device a page request came from (`devs`: one person's device views):
|
||||
* through the tunnel, by its tunnel address; outside it, the one online device
|
||||
* whose tunnel comes from the request's address. The apps route the VPN's own
|
||||
* address around their tunnel, and the portal shares it, so a device on the VPN
|
||||
* opens the page from where its tunnel comes from. Two such devices behind one
|
||||
* address (one NAT): neither.
|
||||
*/
|
||||
export function device_here(devs, peer) {
|
||||
peer = replace(peer ?? '', /^::ffff:/, '');
|
||||
if (!peer)
|
||||
return null;
|
||||
let near = [];
|
||||
for (let d in devs) {
|
||||
if (d.address == peer)
|
||||
return d.id;
|
||||
if (d.online && d.endpoint == peer)
|
||||
push(near, d.id);
|
||||
}
|
||||
return length(near) == 1 ? near[0] : null;
|
||||
};
|
||||
|
||||
export function device_view(m, d, usage, dmp) {
|
||||
let u = usage.devices?.[d.id];
|
||||
let peer = dmp.peers[d.public_key];
|
||||
let ts = time();
|
||||
let hs = peer?.handshake || u?.handshake || 0;
|
||||
// Set up again (Reconnect): a handshake from before it does not count.
|
||||
m._reconnect ??= awg.reconnects();
|
||||
let hs = awg.handshake_since(peer?.handshake || u?.handshake || 0, m._reconnect[d.id]);
|
||||
let p = m.people[d.person];
|
||||
// The same label /tmp/hosts carries (core.device_labels), so what is shown resolves.
|
||||
let label = '';
|
||||
@@ -44,7 +68,7 @@ export function device_view(m, d, usage, dmp) {
|
||||
disabled: d.disabled,
|
||||
created: d.created,
|
||||
created_by: d.created_by,
|
||||
online: live.online(dmp, d.id, peer),
|
||||
online: hs > 0 && live.online(dmp, d.id, peer),
|
||||
handshake: hs,
|
||||
endpoint: live.endpoint_ip(peer?.endpoint) || u?.endpoint || '',
|
||||
active: !!peer,
|
||||
|
||||
Reference in new issue
Block a user