burrow-cli 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +594 -2
- package/bin/burrow.js +200 -0
- package/examples/acme-shop.tunnel.yml +18 -0
- package/package.json +45 -4
- package/src/access.js +163 -0
- package/src/add.js +106 -0
- package/src/cloudflare.js +118 -0
- package/src/commands.js +386 -0
- package/src/completion.js +127 -0
- package/src/config-file.js +31 -0
- package/src/config.js +82 -0
- package/src/dashboard/auth.js +79 -0
- package/src/dashboard/data.js +70 -0
- package/src/dashboard/logs.js +95 -0
- package/src/dashboard/manage.js +102 -0
- package/src/dashboard/panels/README.md +50 -0
- package/src/dashboard/panels/access.js +218 -0
- package/src/dashboard/panels/alerts.js +244 -0
- package/src/dashboard/panels/backup.js +193 -0
- package/src/dashboard/panels/bulk.js +246 -0
- package/src/dashboard/panels/cleanup.js +237 -0
- package/src/dashboard/panels/doctor.js +119 -0
- package/src/dashboard/panels/health.js +146 -0
- package/src/dashboard/panels/history.js +104 -0
- package/src/dashboard/panels/hooks.js +86 -0
- package/src/dashboard/panels/live.js +153 -0
- package/src/dashboard/panels/project-form.js +463 -0
- package/src/dashboard/panels/quick-actions.js +133 -0
- package/src/dashboard/panels/sessions.js +267 -0
- package/src/dashboard/panels/shares.js +280 -0
- package/src/dashboard/panels/stats.js +165 -0
- package/src/dashboard/panels/updates.js +156 -0
- package/src/dashboard/panels/uptime.js +115 -0
- package/src/dashboard/panels.js +53 -0
- package/src/dashboard/server.js +390 -0
- package/src/dashboard/session-store.js +47 -0
- package/src/dashboard/totp.js +103 -0
- package/src/dashboard/ui.js +454 -0
- package/src/doctor.js +342 -0
- package/src/edit.js +135 -0
- package/src/health-observer.js +81 -0
- package/src/history.js +145 -0
- package/src/hooks.js +256 -0
- package/src/naming.js +38 -0
- package/src/open.js +67 -0
- package/src/pending.js +72 -0
- package/src/process.js +95 -0
- package/src/project-form.js +134 -0
- package/src/project.js +114 -0
- package/src/prune.js +99 -0
- package/src/rename-state.js +39 -0
- package/src/restart.js +35 -0
- package/src/service.js +173 -0
- package/src/share-expiry.js +55 -0
- package/src/share.js +275 -0
- package/src/shell-words.js +284 -0
- package/src/stats.js +180 -0
- package/src/transfer.js +124 -0
- package/src/update.js +254 -0
- package/src/uptime.js +91 -0
- package/src/watch.js +263 -0
- package/src/zones.js +102 -0
package/src/history.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Event history: an append-only JSON Lines file of the actions that change state
|
|
2
|
+
// (up, down, destroy, restart, share, prune, …) with when, where from and the result.
|
|
3
|
+
// Recording is best effort and never makes a command fail.
|
|
4
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { constants as osConstants } from 'node:os';
|
|
7
|
+
import { stateDir } from './config.js';
|
|
8
|
+
import { findProjectFile, loadProjectFile } from './project.js';
|
|
9
|
+
|
|
10
|
+
// In a subdirectory so it is never mistaken for a project state file.
|
|
11
|
+
export const historyFile = () => join(stateDir(), 'history', 'events.jsonl');
|
|
12
|
+
export const MAX_BYTES = 1024 * 1024;
|
|
13
|
+
export const KEEP_LINES = 2000;
|
|
14
|
+
export const SOURCES = ['cli', 'dashboard', 'boot', 'watch'];
|
|
15
|
+
|
|
16
|
+
export const sourceFromEnv = (env = process.env, fallback = 'cli') =>
|
|
17
|
+
(SOURCES.includes(env.BURROW_SOURCE) ? env.BURROW_SOURCE : fallback);
|
|
18
|
+
|
|
19
|
+
function rotate(file) {
|
|
20
|
+
try {
|
|
21
|
+
if (statSync(file).size <= MAX_BYTES) return;
|
|
22
|
+
const lines = readFileSync(file, 'utf8').split('\n').filter(Boolean);
|
|
23
|
+
writeFileSync(file, lines.slice(-KEEP_LINES).join('\n') + '\n', { mode: 0o600 });
|
|
24
|
+
} catch {}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function recordEvent(e) {
|
|
28
|
+
try {
|
|
29
|
+
const file = historyFile();
|
|
30
|
+
mkdirSync(join(file, '..'), { recursive: true, mode: 0o700 });
|
|
31
|
+
const entry = {
|
|
32
|
+
at: new Date(e.at || Date.now()).toISOString(),
|
|
33
|
+
action: String(e.action || 'unknown'),
|
|
34
|
+
project: e.project ? String(e.project) : null,
|
|
35
|
+
source: SOURCES.includes(e.source) ? e.source : 'cli',
|
|
36
|
+
ok: e.ok !== false,
|
|
37
|
+
...(e.detail ? { detail: String(e.detail).slice(0, 300) } : {}),
|
|
38
|
+
...(Number.isFinite(e.durationMs) ? { durationMs: Math.round(e.durationMs) } : {}),
|
|
39
|
+
};
|
|
40
|
+
appendFileSync(file, JSON.stringify(entry) + '\n', { mode: 0o600 });
|
|
41
|
+
rotate(file);
|
|
42
|
+
return entry;
|
|
43
|
+
} catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Newest first.
|
|
49
|
+
export function readEvents({ limit = 200, project, source, action } = {}) {
|
|
50
|
+
const file = historyFile();
|
|
51
|
+
if (!existsSync(file)) return [];
|
|
52
|
+
const out = [];
|
|
53
|
+
const lines = readFileSync(file, 'utf8').split('\n');
|
|
54
|
+
for (let i = lines.length - 1; i >= 0 && out.length < limit; i--) {
|
|
55
|
+
if (!lines[i]) continue;
|
|
56
|
+
let e;
|
|
57
|
+
try { e = JSON.parse(lines[i]); } catch { continue; }
|
|
58
|
+
if (project && e.project !== project) continue;
|
|
59
|
+
if (source && e.source !== source) continue;
|
|
60
|
+
if (action && e.action !== action) continue;
|
|
61
|
+
out.push(e);
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Commands that change state. Read-only ones (ls, status, logs, stats, url, …) aren't recorded.
|
|
67
|
+
const RECORDED = new Set(['up', 'down', 'destroy', 'restart', 'share', 'prune', 'add', 'edit', 'import', 'service', 'autostart', 'dashboard', 'update']);
|
|
68
|
+
const SUB_ACTIONS = { dashboard: ['up', 'down'], service: ['install', 'uninstall'] };
|
|
69
|
+
|
|
70
|
+
// What a command would be recorded as, or null when it isn't recorded.
|
|
71
|
+
export function describeCommand(command, env = process.env) {
|
|
72
|
+
const name = command.name();
|
|
73
|
+
if (!RECORDED.has(name)) return null;
|
|
74
|
+
const opts = command.opts();
|
|
75
|
+
if (opts.dryRun || opts.check) return null;
|
|
76
|
+
const args = command.args || [];
|
|
77
|
+
let action = name;
|
|
78
|
+
if (SUB_ACTIONS[name]) {
|
|
79
|
+
if (!SUB_ACTIONS[name].includes(args[0])) return null;
|
|
80
|
+
action = `${name} ${args[0]}`;
|
|
81
|
+
}
|
|
82
|
+
let project = null;
|
|
83
|
+
if (['up', 'down', 'destroy', 'restart', 'edit', 'add'].includes(name)) {
|
|
84
|
+
if (args[0]) project = args[0];
|
|
85
|
+
else if (opts.all) project = '(all)';
|
|
86
|
+
else if (name === 'up' || name === 'edit' || opts.file) {
|
|
87
|
+
try { const f = findProjectFile(opts.file); if (f) project = loadProjectFile(f).project; } catch {}
|
|
88
|
+
} else if (name === 'down' || name === 'restart') project = '(all running)';
|
|
89
|
+
}
|
|
90
|
+
if (name === 'share') project = opts.name ? `share ${opts.name}` : null;
|
|
91
|
+
if (name === 'dashboard') project = 'burrow';
|
|
92
|
+
const detail = [
|
|
93
|
+
...(SUB_ACTIONS[name] ? args.slice(1) : name === 'share' ? [] : args.slice(project === args[0] ? 1 : 0)),
|
|
94
|
+
...['purge', 'all', 'force', 'includeActive', 'now'].filter((k) => opts[k]).map((k) => `--${k.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`),
|
|
95
|
+
].join(' ');
|
|
96
|
+
return { action, project, detail, source: sourceFromEnv(env, name === 'autostart' ? 'boot' : 'cli') };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function recordCommand(command, startedAt, { env = process.env, exitCode = process.exitCode, note = '' } = {}) {
|
|
100
|
+
const d = describeCommand(command, env);
|
|
101
|
+
if (!d) return null;
|
|
102
|
+
return recordEvent({ ...d, ok: !exitCode, detail: [d.detail, note].filter(Boolean).join(' · '), durationMs: Date.now() - startedAt });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const TRACKED_SIGNALS = ['SIGINT', 'SIGTERM', 'SIGHUP'];
|
|
106
|
+
|
|
107
|
+
// Called from bin/burrow.js before a command runs (commander preAction hook). Returns
|
|
108
|
+
// { finish() } for the postAction hook. If the process ends first, the event is still
|
|
109
|
+
// written from the 'exit' handler: on process.exit() inside a command, or on SIGINT /
|
|
110
|
+
// SIGTERM / SIGHUP. A signal only ends the process here when nothing else listens for it
|
|
111
|
+
// (e.g. `share` has its own Ctrl+C cleanup, which then exits or returns normally), so
|
|
112
|
+
// the default "terminate" behaviour is kept, with exit code 128 + signal number.
|
|
113
|
+
// SIGKILL can't be caught: such a run leaves no entry.
|
|
114
|
+
export function trackCommand(command, { env = process.env, proc = process } = {}) {
|
|
115
|
+
const d = describeCommand(command, env);
|
|
116
|
+
if (!d) return null;
|
|
117
|
+
const startedAt = Date.now();
|
|
118
|
+
let done = false;
|
|
119
|
+
let signal = null;
|
|
120
|
+
const handlers = {};
|
|
121
|
+
const cleanup = () => {
|
|
122
|
+
proc.removeListener('exit', onExit);
|
|
123
|
+
for (const sig of TRACKED_SIGNALS) proc.removeListener(sig, handlers[sig]);
|
|
124
|
+
};
|
|
125
|
+
const finish = (exitCode, note) => {
|
|
126
|
+
if (done) return null;
|
|
127
|
+
done = true;
|
|
128
|
+
cleanup();
|
|
129
|
+
return recordEvent({ ...d, ok: !exitCode, detail: [d.detail, note].filter(Boolean).join(' · '), durationMs: Date.now() - startedAt });
|
|
130
|
+
};
|
|
131
|
+
function onExit(code) {
|
|
132
|
+
finish(code, signal ? `stopped by ${signal}` : `exited before finishing (code ${code})`);
|
|
133
|
+
}
|
|
134
|
+
for (const sig of TRACKED_SIGNALS) {
|
|
135
|
+
handlers[sig] = () => {
|
|
136
|
+
signal = sig;
|
|
137
|
+
if (proc.listenerCount(sig) <= 1) proc.exit(128 + (osConstants.signals[sig] || 0));
|
|
138
|
+
};
|
|
139
|
+
proc.on(sig, handlers[sig]);
|
|
140
|
+
}
|
|
141
|
+
proc.on('exit', onExit);
|
|
142
|
+
return {
|
|
143
|
+
finish: (exitCode = proc.exitCode) => finish(exitCode, signal ? `stopped by ${signal}` : ''),
|
|
144
|
+
};
|
|
145
|
+
}
|
package/src/hooks.js
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { appendFileSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { createConnection } from 'node:net';
|
|
4
|
+
import { dirname, join, resolve } from 'node:path';
|
|
5
|
+
import YAML from 'yaml';
|
|
6
|
+
import { stateDir } from './config.js';
|
|
7
|
+
import { readMeta, runningPid } from './process.js';
|
|
8
|
+
|
|
9
|
+
// tunnel.yml `hooks:` — shell commands run in the project directory around up and down.
|
|
10
|
+
export const HOOK_NAMES = ['pre_up', 'post_up', 'pre_down', 'post_down'];
|
|
11
|
+
export const DEFAULT_TIMEOUT = 120; // seconds
|
|
12
|
+
const KEYS = ['run', 'timeout', 'background', 'wait_for'];
|
|
13
|
+
const log = (...a) => console.log(...a);
|
|
14
|
+
|
|
15
|
+
// The background pre_up process lives in a subdirectory, so its pid file is never
|
|
16
|
+
// mistaken for a project's cloudflared pid file.
|
|
17
|
+
export const hookDir = () => join(stateDir(), 'hooks');
|
|
18
|
+
export const backgroundPidFile = (project) => join(hookDir(), `${project}.pid`);
|
|
19
|
+
export const backgroundLogFile = (project) => join(hookDir(), `${project}.log`);
|
|
20
|
+
|
|
21
|
+
export function parseHooks(doc, source = 'tunnel.yml') {
|
|
22
|
+
const raw = doc?.hooks;
|
|
23
|
+
if (raw === undefined || raw === null) return {};
|
|
24
|
+
if (typeof raw !== 'object' || Array.isArray(raw)) throw new Error(`${source}: "hooks" must be a mapping of ${HOOK_NAMES.join(', ')}`);
|
|
25
|
+
const out = {};
|
|
26
|
+
for (const [name, value] of Object.entries(raw)) {
|
|
27
|
+
const where = `${source}: hooks.${name}`;
|
|
28
|
+
if (!HOOK_NAMES.includes(name)) throw new Error(`${where}: unknown hook (use ${HOOK_NAMES.join(', ')})`);
|
|
29
|
+
const h = typeof value === 'string' ? { run: value } : value;
|
|
30
|
+
if (!h || typeof h !== 'object' || Array.isArray(h) || typeof h.run !== 'string' || !h.run.trim()) {
|
|
31
|
+
throw new Error(`${where}: expected a command string or { run: "<command>" }`);
|
|
32
|
+
}
|
|
33
|
+
const unknown = Object.keys(h).filter((k) => !KEYS.includes(k));
|
|
34
|
+
if (unknown.length) throw new Error(`${where}: unknown key(s) ${unknown.join(', ')} (use ${KEYS.join(', ')})`);
|
|
35
|
+
const timeout = h.timeout === undefined ? DEFAULT_TIMEOUT : Number(h.timeout);
|
|
36
|
+
if (!(timeout > 0 && timeout <= 3600)) throw new Error(`${where}: timeout must be 1-3600 seconds`);
|
|
37
|
+
if (h.background !== undefined && typeof h.background !== 'boolean') throw new Error(`${where}: background must be true or false`);
|
|
38
|
+
const background = h.background === true;
|
|
39
|
+
if (background && name !== 'pre_up') throw new Error(`${where}: only pre_up can run in the background`);
|
|
40
|
+
let waitFor = null;
|
|
41
|
+
if (h.wait_for !== undefined) {
|
|
42
|
+
if (!background) throw new Error(`${where}: wait_for needs background: true`);
|
|
43
|
+
const m = String(h.wait_for).match(/^(?:([^:\s]+):)?(\d{1,5})$/);
|
|
44
|
+
if (!m || Number(m[2]) < 1 || Number(m[2]) > 65535) throw new Error(`${where}: wait_for must be a port or host:port`);
|
|
45
|
+
waitFor = { host: m[1] || '127.0.0.1', port: Number(m[2]) };
|
|
46
|
+
}
|
|
47
|
+
out[name] = { run: h.run, timeout, background, waitFor };
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function loadHooks(file) {
|
|
53
|
+
if (!file || !existsSync(file)) return {};
|
|
54
|
+
return parseHooks(YAML.parse(readFileSync(file, 'utf8')) || {}, file);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// What a hook gets to know: project, its tunnel.yml directory and hostnames.
|
|
58
|
+
export function hookContext(proj, file, hosts, extra = {}) {
|
|
59
|
+
const root = hosts.find((h, i) => proj.services[i]?.root) || hosts[0];
|
|
60
|
+
return { project: proj.project, file, hostnames: hosts.map((h) => h.hostname), url: root ? `https://${root.hostname}` : '', extra };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// The same, for down: from the file remembered by the last `burrow up`.
|
|
64
|
+
export function downContext(project, fileOpt) {
|
|
65
|
+
const meta = readMeta(project);
|
|
66
|
+
// A share made with -f/--project keeps that tunnel.yml as projectFile (not file, so it
|
|
67
|
+
// never looks `burrow up`-able); its hooks run on down too, unless it was shared --no-hooks.
|
|
68
|
+
const file = fileOpt ? resolve(fileOpt) : meta?.file || (meta?.share && meta.hooks !== false ? meta.projectFile : undefined);
|
|
69
|
+
const hostnames = meta?.hostnames || [];
|
|
70
|
+
return { project, file, hostnames, url: hostnames[0] ? `https://${hostnames[0]}` : '', extra: {} };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function env(ctx, name) {
|
|
74
|
+
return {
|
|
75
|
+
...process.env,
|
|
76
|
+
BURROW_PROJECT: ctx.project,
|
|
77
|
+
BURROW_HOSTNAMES: ctx.hostnames.join(','),
|
|
78
|
+
BURROW_URL: ctx.url,
|
|
79
|
+
BURROW_HOOK: name,
|
|
80
|
+
...ctx.extra,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const killGroup = (pid, sig) => {
|
|
85
|
+
try { process.kill(-pid, sig); } catch { try { process.kill(pid, sig); } catch {} }
|
|
86
|
+
};
|
|
87
|
+
const groupAlive = (pid) => {
|
|
88
|
+
if (!pid) return false;
|
|
89
|
+
try { process.kill(-pid, 0); return true; } catch (e) { return e.code === 'EPERM'; }
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// Foreground hook: own process group, killed (TERM, then KILL) when it runs out of time.
|
|
93
|
+
function runForeground(name, hook, ctx) {
|
|
94
|
+
return new Promise((resolvePromise, reject) => {
|
|
95
|
+
const child = spawn('/bin/sh', ['-c', hook.run], {
|
|
96
|
+
cwd: dirname(ctx.file), env: env(ctx, name), stdio: ['ignore', 'inherit', 'inherit'], detached: true,
|
|
97
|
+
});
|
|
98
|
+
let timedOut = false;
|
|
99
|
+
let killTimer = null;
|
|
100
|
+
const timer = setTimeout(() => {
|
|
101
|
+
timedOut = true;
|
|
102
|
+
killGroup(child.pid, 'SIGTERM');
|
|
103
|
+
killTimer = setTimeout(() => killGroup(child.pid, 'SIGKILL'), 3000);
|
|
104
|
+
}, hook.timeout * 1000);
|
|
105
|
+
child.on('error', (e) => { clearTimeout(timer); reject(new Error(`${name} hook could not start: ${e.message}`)); });
|
|
106
|
+
child.on('exit', (code, signal) => {
|
|
107
|
+
clearTimeout(timer);
|
|
108
|
+
if (killTimer) clearTimeout(killTimer);
|
|
109
|
+
if (timedOut) { killGroup(child.pid, 'SIGKILL'); return reject(new Error(`${name} hook timed out after ${hook.timeout}s: ${hook.run}`)); }
|
|
110
|
+
if (code !== 0) return reject(new Error(`${name} hook failed (${signal || `exit ${code}`}): ${hook.run}`));
|
|
111
|
+
resolvePromise();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function readBackgroundPid(project) {
|
|
117
|
+
try {
|
|
118
|
+
const pid = parseInt(readFileSync(backgroundPidFile(project), 'utf8'), 10);
|
|
119
|
+
return pid > 0 ? pid : null;
|
|
120
|
+
} catch { return null; }
|
|
121
|
+
}
|
|
122
|
+
export const backgroundPid = (project) => {
|
|
123
|
+
const pid = readBackgroundPid(project);
|
|
124
|
+
return groupAlive(pid) ? pid : null;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
function portOpen({ host, port }) {
|
|
128
|
+
return new Promise((done) => {
|
|
129
|
+
const s = createConnection({ host, port });
|
|
130
|
+
const end = (ok) => { s.destroy(); done(ok); };
|
|
131
|
+
s.setTimeout(1000, () => end(false));
|
|
132
|
+
s.once('connect', () => end(true));
|
|
133
|
+
s.once('error', () => end(false));
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function startBackground(hook, ctx) {
|
|
138
|
+
const running = backgroundPid(ctx.project);
|
|
139
|
+
if (running) { log(`pre_up (background) already running (pid ${running}); keeping it`); return; }
|
|
140
|
+
mkdirSync(hookDir(), { recursive: true, mode: 0o700 });
|
|
141
|
+
const out = openSync(backgroundLogFile(ctx.project), 'a', 0o600);
|
|
142
|
+
const child = spawn('/bin/sh', ['-c', hook.run], {
|
|
143
|
+
cwd: dirname(ctx.file), env: env(ctx, 'pre_up'), stdio: ['ignore', out, out], detached: true,
|
|
144
|
+
});
|
|
145
|
+
closeSync(out);
|
|
146
|
+
child.on('error', () => {});
|
|
147
|
+
child.unref();
|
|
148
|
+
if (!child.pid) throw new Error(`pre_up (background) could not start: ${hook.run}`);
|
|
149
|
+
writeFileSync(backgroundPidFile(ctx.project), String(child.pid), { mode: 0o600 });
|
|
150
|
+
log(`pre_up (background) started (pid ${child.pid}), log ${backgroundLogFile(ctx.project)}`);
|
|
151
|
+
if (!hook.waitFor) return;
|
|
152
|
+
const { host, port } = hook.waitFor;
|
|
153
|
+
const deadline = Date.now() + hook.timeout * 1000;
|
|
154
|
+
for (;;) {
|
|
155
|
+
if (await portOpen(hook.waitFor)) { log(`pre_up (background) is listening on ${host}:${port}`); return; }
|
|
156
|
+
if (!groupAlive(child.pid)) {
|
|
157
|
+
rmSync(backgroundPidFile(ctx.project), { force: true });
|
|
158
|
+
throw new Error(`pre_up (background) exited before ${host}:${port} opened; see ${backgroundLogFile(ctx.project)}`);
|
|
159
|
+
}
|
|
160
|
+
if (Date.now() > deadline) {
|
|
161
|
+
await stopBackground(ctx.project);
|
|
162
|
+
throw new Error(`pre_up (background): ${host}:${port} didn't open within ${hook.timeout}s; stopped it. See ${backgroundLogFile(ctx.project)}`);
|
|
163
|
+
}
|
|
164
|
+
await new Promise((r) => setTimeout(r, 250));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Stops the background pre_up process group. Returns its pid, or null.
|
|
169
|
+
export async function stopBackground(project) {
|
|
170
|
+
const pid = readBackgroundPid(project);
|
|
171
|
+
if (!pid) return null;
|
|
172
|
+
if (!groupAlive(pid)) { rmSync(backgroundPidFile(project), { force: true }); return null; }
|
|
173
|
+
killGroup(pid, 'SIGTERM');
|
|
174
|
+
for (let i = 0; i < 25 && groupAlive(pid); i++) await new Promise((r) => setTimeout(r, 200));
|
|
175
|
+
if (groupAlive(pid)) killGroup(pid, 'SIGKILL');
|
|
176
|
+
rmSync(backgroundPidFile(project), { force: true });
|
|
177
|
+
return pid;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Runs one hook if tunnel.yml defines it. pre_* failures throw (up stops there);
|
|
181
|
+
// with soft: true a failure is reported and sets the exit code instead.
|
|
182
|
+
export async function runHook(name, ctx, { dry = false, enabled = true, soft = false } = {}) {
|
|
183
|
+
if (!enabled || !ctx.file) return;
|
|
184
|
+
const hook = loadHooks(ctx.file)[name];
|
|
185
|
+
if (!hook) return;
|
|
186
|
+
const label = `${name}${hook.background ? ' (background)' : ''}`;
|
|
187
|
+
if (dry) { log(`[dry-run] would run ${label} hook in ${dirname(ctx.file)}: ${hook.run}`); return; }
|
|
188
|
+
log(`Running ${label} hook: ${hook.run}`);
|
|
189
|
+
const started = Date.now();
|
|
190
|
+
try {
|
|
191
|
+
if (hook.background) await startBackground(hook, ctx);
|
|
192
|
+
else await runForeground(name, hook, ctx);
|
|
193
|
+
recordHookResult({ project: ctx.project, hook: name, background: hook.background, ok: true, started });
|
|
194
|
+
} catch (e) {
|
|
195
|
+
recordHookResult({ project: ctx.project, hook: name, background: hook.background, ok: false, started, error: e.message.split(`: ${hook.run}`).join('') });
|
|
196
|
+
if (!soft) throw e;
|
|
197
|
+
console.error(`burrow: ${e.message}`);
|
|
198
|
+
process.exitCode = 1;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Hook results (for the dashboard): JSON Lines, newest last, without the command or its
|
|
203
|
+
// output (both can hold secrets). Best effort; never fails the command.
|
|
204
|
+
export const hookResultsFile = () => join(hookDir(), 'results.jsonl');
|
|
205
|
+
const KEEP_RESULTS = 500;
|
|
206
|
+
export function recordHookResult({ project, hook, background, ok, started, error }) {
|
|
207
|
+
try {
|
|
208
|
+
mkdirSync(hookDir(), { recursive: true, mode: 0o700 });
|
|
209
|
+
const file = hookResultsFile();
|
|
210
|
+
const entry = {
|
|
211
|
+
at: new Date(started).toISOString(), project, hook, background: !!background, ok,
|
|
212
|
+
durationMs: Date.now() - started, source: process.env.BURROW_SOURCE || 'cli',
|
|
213
|
+
...(error ? { error: String(error).slice(0, 300) } : {}),
|
|
214
|
+
};
|
|
215
|
+
appendFileSync(file, JSON.stringify(entry) + '\n', { mode: 0o600 });
|
|
216
|
+
const lines = readFileSync(file, 'utf8').split('\n').filter(Boolean);
|
|
217
|
+
if (lines.length > KEEP_RESULTS * 2) writeFileSync(file, lines.slice(-KEEP_RESULTS).join('\n') + '\n', { mode: 0o600 });
|
|
218
|
+
} catch {}
|
|
219
|
+
}
|
|
220
|
+
export function readHookResults({ limit = 100, project } = {}) {
|
|
221
|
+
let lines = [];
|
|
222
|
+
try { lines = readFileSync(hookResultsFile(), 'utf8').split('\n').filter(Boolean); } catch { return []; }
|
|
223
|
+
const out = [];
|
|
224
|
+
for (let i = lines.length - 1; i >= 0 && out.length < limit; i--) {
|
|
225
|
+
let e;
|
|
226
|
+
try { e = JSON.parse(lines[i]); } catch { continue; }
|
|
227
|
+
if (project && e.project !== project) continue;
|
|
228
|
+
out.push(e);
|
|
229
|
+
}
|
|
230
|
+
return out;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// down: pre_down runs while cloudflared is still up. Hooks only run for a project that
|
|
234
|
+
// has something running (its connector or a background pre_up process).
|
|
235
|
+
export async function beforeDown(project, opts = {}) {
|
|
236
|
+
const ctx = downContext(project, opts.file);
|
|
237
|
+
const enabled = opts.hooks !== false;
|
|
238
|
+
const active = !!(runningPid(project) || backgroundPid(project));
|
|
239
|
+
if (opts.dryRun) {
|
|
240
|
+
if (active) await runHook('pre_down', ctx, { dry: true, enabled });
|
|
241
|
+
const bg = backgroundPid(project);
|
|
242
|
+
if (bg) log(`[dry-run] would stop the pre_up background process (pid ${bg})`);
|
|
243
|
+
if (active) await runHook('post_down', ctx, { dry: true, enabled });
|
|
244
|
+
return ctx;
|
|
245
|
+
}
|
|
246
|
+
ctx.active = active;
|
|
247
|
+
if (active) await runHook('pre_down', ctx, { enabled, soft: true });
|
|
248
|
+
return ctx;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// down: after cloudflared stopped, stop the background process, then post_down.
|
|
252
|
+
export async function afterDown(project, ctx, opts = {}) {
|
|
253
|
+
const bg = await stopBackground(project);
|
|
254
|
+
if (bg) log(`${project}: stopped pre_up background process (pid ${bg})`);
|
|
255
|
+
if (ctx.active) await runHook('post_down', ctx, { enabled: opts.hooks !== false, soft: true });
|
|
256
|
+
}
|
package/src/naming.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Hostname rules. Only flat, one-level names under the tunnel domain so
|
|
2
|
+
// Cloudflare's free Universal SSL certificate (*.domain) covers them:
|
|
3
|
+
// root service -> <project>.<domain>
|
|
4
|
+
// sub-service -> <service>-<project>.<domain>
|
|
5
|
+
const LABEL_RE = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
|
|
6
|
+
|
|
7
|
+
export function assertLabel(value, what) {
|
|
8
|
+
if (typeof value !== 'string' || !LABEL_RE.test(value)) {
|
|
9
|
+
throw new Error(
|
|
10
|
+
`Invalid ${what} "${value}": use lowercase letters, digits and inner hyphens only (no dots).`
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function assertDomain(domain) {
|
|
16
|
+
if (typeof domain !== 'string' || !domain.includes('.')) {
|
|
17
|
+
throw new Error(`Invalid domain "${domain}". Set BURROW_DOMAIN in the burrow config, e.g. BURROW_DOMAIN=example.dev`);
|
|
18
|
+
}
|
|
19
|
+
for (const part of domain.split('.')) assertLabel(part, 'domain label');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function hostnameFor(project, service, domain) {
|
|
23
|
+
assertLabel(project, 'project name');
|
|
24
|
+
assertDomain(domain);
|
|
25
|
+
let label;
|
|
26
|
+
if (service.root) {
|
|
27
|
+
label = project;
|
|
28
|
+
} else {
|
|
29
|
+
assertLabel(service.name, 'service name');
|
|
30
|
+
label = `${service.name}-${project}`;
|
|
31
|
+
}
|
|
32
|
+
if (label.length > 63) throw new Error(`Hostname label "${label}" is longer than 63 characters.`);
|
|
33
|
+
return `${label}.${domain}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const tunnelName = (project) => `burrow-${project}`;
|
|
37
|
+
export const recordComment = (project) => `burrow:${project}`;
|
|
38
|
+
export const tunnelTarget = (tunnelId) => `${tunnelId}.cfargotunnel.com`;
|
package/src/open.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { loadConfig, requireConfig } from './config.js';
|
|
4
|
+
import { assertLabel } from './naming.js';
|
|
5
|
+
import { findProjectFile, loadProjectFile, hostnames, DASHBOARD_PROJECT, dashboardProject } from './project.js';
|
|
6
|
+
import { readMeta } from './process.js';
|
|
7
|
+
import { projectDomain } from './zones.js';
|
|
8
|
+
|
|
9
|
+
// [{ service, url }] for a project: from its tunnel.yml (-f, ./tunnel.yml or the
|
|
10
|
+
// remembered file), falling back to the hostnames saved by the last `burrow up`.
|
|
11
|
+
export function projectUrls(projectArg, opts = {}, cfg = loadConfig()) {
|
|
12
|
+
if (projectArg) assertLabel(projectArg, 'project name');
|
|
13
|
+
let proj = null;
|
|
14
|
+
if (projectArg === DASHBOARD_PROJECT && !opts.file) proj = dashboardProject(cfg.dashboardPort);
|
|
15
|
+
const local = !proj && findProjectFile(opts.file);
|
|
16
|
+
if (local) {
|
|
17
|
+
const p = loadProjectFile(local);
|
|
18
|
+
if (!projectArg || p.project === projectArg) proj = p;
|
|
19
|
+
}
|
|
20
|
+
const meta = projectArg ? readMeta(projectArg) : null;
|
|
21
|
+
if (!proj && meta?.file && existsSync(meta.file)) proj = loadProjectFile(meta.file);
|
|
22
|
+
if (proj) {
|
|
23
|
+
if (!proj.domain) requireConfig(cfg, ['domain']);
|
|
24
|
+
return { project: proj.project, urls: hostnames(proj, projectDomain(proj, cfg)).map((h) => ({ service: h.service, url: `https://${h.hostname}` })) };
|
|
25
|
+
}
|
|
26
|
+
if (meta?.hostnames?.length) {
|
|
27
|
+
return { project: projectArg, urls: meta.hostnames.map((h) => ({ service: h.split('.')[0], url: `https://${h}` })) };
|
|
28
|
+
}
|
|
29
|
+
throw new Error(projectArg ? `Unknown project "${projectArg}". Run burrow up -f <file> once, or pass -f.` : 'Pass a project name or run inside a directory with tunnel.yml.');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function openerCommand(url, platform = process.platform, env = process.env) {
|
|
33
|
+
if (env.BROWSER) return [env.BROWSER, [url]];
|
|
34
|
+
if (platform === 'darwin') return ['open', [url]];
|
|
35
|
+
if (platform === 'win32') return ['cmd', ['/c', 'start', '', url]];
|
|
36
|
+
return ['xdg-open', [url]];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function url(projectArg, opts = {}) {
|
|
40
|
+
const { urls } = projectUrls(projectArg, opts);
|
|
41
|
+
const width = Math.max(...urls.map((u) => u.service.length));
|
|
42
|
+
for (const u of urls) console.log(opts.plain ? u.url : `${u.service.padEnd(width)} ${u.url}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function open(projectArg, serviceArg, opts = {}) {
|
|
46
|
+
// `burrow open mail` inside a project directory: treat the only argument as a service.
|
|
47
|
+
if (projectArg && !serviceArg) {
|
|
48
|
+
const local = findProjectFile(opts.file);
|
|
49
|
+
if (local) {
|
|
50
|
+
const p = loadProjectFile(local);
|
|
51
|
+
if (p.project !== projectArg && p.services.some((s) => s.name === projectArg)) {
|
|
52
|
+
serviceArg = projectArg;
|
|
53
|
+
projectArg = undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const { project, urls } = projectUrls(projectArg, opts);
|
|
58
|
+
const target = serviceArg ? urls.find((u) => u.service === serviceArg) : urls.find((u) => u.service === 'app') || urls[0];
|
|
59
|
+
if (!target) throw new Error(`${project} has no service "${serviceArg}" (has: ${urls.map((u) => u.service).join(', ')})`);
|
|
60
|
+
if (opts.print) { console.log(target.url); return; }
|
|
61
|
+
const [bin, args] = openerCommand(target.url);
|
|
62
|
+
await new Promise((resolve) => {
|
|
63
|
+
const child = spawn(bin, args, { stdio: 'ignore', detached: true });
|
|
64
|
+
child.once('error', () => { console.log(`Couldn't start a browser (${bin}). Open ${target.url}`); resolve(); });
|
|
65
|
+
child.once('spawn', () => { child.unref(); console.log(`Opening ${target.url}`); resolve(); });
|
|
66
|
+
});
|
|
67
|
+
}
|
package/src/pending.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { stateDir } from './config.js';
|
|
4
|
+
import { inZone } from './zones.js';
|
|
5
|
+
import { readMeta, runningPid } from './process.js';
|
|
6
|
+
|
|
7
|
+
// DNS deletions that couldn't happen yet. When `burrow destroy` (or a dashboard delete)
|
|
8
|
+
// can't read one of the zones a project may have records in, the tunnel still goes, and
|
|
9
|
+
// { zoneId, domain, comment, project, at, error } is queued here so the records aren't
|
|
10
|
+
// silently left behind. `burrow prune` and the dashboard's Cleanup panel retry them.
|
|
11
|
+
export const pendingFile = () => join(stateDir(), 'cleanup', 'pending.json');
|
|
12
|
+
|
|
13
|
+
export function listPending() {
|
|
14
|
+
try {
|
|
15
|
+
const list = JSON.parse(readFileSync(pendingFile(), 'utf8'));
|
|
16
|
+
return Array.isArray(list) ? list : [];
|
|
17
|
+
} catch { return []; }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function savePending(list) {
|
|
21
|
+
const file = pendingFile();
|
|
22
|
+
mkdirSync(dirname(file), { recursive: true, mode: 0o700 });
|
|
23
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
24
|
+
writeFileSync(tmp, JSON.stringify(list, null, 2) + '\n', { mode: 0o600 });
|
|
25
|
+
renameSync(tmp, file);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const same = (a, b) => a.zoneId === b.zoneId && a.comment === b.comment;
|
|
29
|
+
|
|
30
|
+
export function addPending({ zoneId, domain, comment, project, error }, now = Date.now()) {
|
|
31
|
+
const list = listPending().filter((e) => !same(e, { zoneId, comment }));
|
|
32
|
+
list.push({ zoneId, domain: domain || zoneId, comment, project, at: new Date(now).toISOString(), error: String(error || '') });
|
|
33
|
+
savePending(list);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// A project that is back (state file or running connector) owns its records again.
|
|
37
|
+
const isBack = (project) => !!(readMeta(project) || runningPid(project));
|
|
38
|
+
|
|
39
|
+
// Retry every queued deletion. Returns { done: [...], dropped: [...], left: [...] } with
|
|
40
|
+
// human-readable `lines`. Entries stay queued (with the new error) when the zone still can't
|
|
41
|
+
// be read.
|
|
42
|
+
export async function retryPending(cf, { log = () => {} } = {}) {
|
|
43
|
+
const done = [];
|
|
44
|
+
const dropped = [];
|
|
45
|
+
const left = [];
|
|
46
|
+
const lines = [];
|
|
47
|
+
for (const e of listPending()) {
|
|
48
|
+
if (isBack(e.project)) {
|
|
49
|
+
dropped.push(e);
|
|
50
|
+
lines.push(`${e.project}: is set up again; kept its DNS records in ${e.domain}`);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const zc = inZone(cf, e.zoneId);
|
|
55
|
+
const recs = await zc.recordsByComment(e.comment);
|
|
56
|
+
for (const r of recs) {
|
|
57
|
+
await zc.deleteRecord(r.id);
|
|
58
|
+
lines.push(`${e.project}: deleted DNS ${r.type} ${r.name}`);
|
|
59
|
+
}
|
|
60
|
+
if (!recs.length) lines.push(`${e.project}: no DNS records left in ${e.domain}`);
|
|
61
|
+
done.push(e);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
left.push({ ...e, error: err.message, retriedAt: new Date().toISOString() });
|
|
64
|
+
lines.push(`${e.project}: still can't clean up DNS in ${e.domain}: ${err.message}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Keep anything queued meanwhile by another process.
|
|
68
|
+
const handled = [...done, ...dropped, ...left];
|
|
69
|
+
savePending([...left, ...listPending().filter((e) => !handled.some((h) => same(h, e)))]);
|
|
70
|
+
for (const l of lines) log(l);
|
|
71
|
+
return { done, dropped, left, lines };
|
|
72
|
+
}
|
package/src/process.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { openSync, closeSync, readFileSync, writeFileSync, existsSync, rmSync, mkdirSync, readdirSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { stateDir } from './config.js';
|
|
5
|
+
|
|
6
|
+
export const pidFile = (project) => join(stateDir(), `${project}.pid`);
|
|
7
|
+
export const logFile = (project) => join(stateDir(), `${project}.log`);
|
|
8
|
+
export const metaFile = (project) => join(stateDir(), `${project}.json`);
|
|
9
|
+
|
|
10
|
+
export function readPid(project) {
|
|
11
|
+
const f = pidFile(project);
|
|
12
|
+
if (!existsSync(f)) return null;
|
|
13
|
+
const pid = parseInt(readFileSync(f, 'utf8'), 10);
|
|
14
|
+
return Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const HAS_PROC = existsSync('/proc/self');
|
|
18
|
+
|
|
19
|
+
// A process that exits between kill(0) and reading /proc is gone, not alive: only trust
|
|
20
|
+
// kill(0) alone where there is no /proc at all (macOS).
|
|
21
|
+
export function isAlive(pid, match = 'cloudflared', { proc = HAS_PROC } = {}) {
|
|
22
|
+
if (!pid) return false;
|
|
23
|
+
try { process.kill(pid, 0); } catch (e) { if (e.code !== 'EPERM') return false; }
|
|
24
|
+
if (!proc) return true;
|
|
25
|
+
try {
|
|
26
|
+
const cmd = readFileSync(`/proc/${pid}/cmdline`, 'utf8');
|
|
27
|
+
return cmd.includes(match);
|
|
28
|
+
} catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// kill() that treats "no such process" as done: the process may exit on its own between
|
|
34
|
+
// the liveness check and the signal (seen under load as "kill ESRCH").
|
|
35
|
+
function signal(pid, sig) {
|
|
36
|
+
try { process.kill(pid, sig); return true; } catch (e) { if (e.code === 'ESRCH') return false; throw e; }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function runningPid(project) {
|
|
40
|
+
const pid = readPid(project);
|
|
41
|
+
return isAlive(pid) ? pid : null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Starts cloudflared detached. The tunnel token goes through the TUNNEL_TOKEN
|
|
45
|
+
// env var so it never shows in `ps` output or on disk.
|
|
46
|
+
export function startConnector(project, token, bin = 'cloudflared') {
|
|
47
|
+
mkdirSync(stateDir(), { recursive: true, mode: 0o700 });
|
|
48
|
+
const log = openSync(logFile(project), 'a', 0o600);
|
|
49
|
+
const child = spawn(bin, ['tunnel', '--no-autoupdate', 'run'], {
|
|
50
|
+
detached: true,
|
|
51
|
+
stdio: ['ignore', log, log],
|
|
52
|
+
env: { ...process.env, TUNNEL_TOKEN: token },
|
|
53
|
+
});
|
|
54
|
+
closeSync(log);
|
|
55
|
+
child.on('error', () => {});
|
|
56
|
+
child.unref();
|
|
57
|
+
if (!child.pid) throw new Error(`Could not start ${bin}. Is cloudflared installed?`);
|
|
58
|
+
writeFileSync(pidFile(project), String(child.pid), { mode: 0o600 });
|
|
59
|
+
return child.pid;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export async function stopConnector(project, timeoutMs = 10000) {
|
|
63
|
+
const pid = readPid(project);
|
|
64
|
+
if (!isAlive(pid)) {
|
|
65
|
+
rmSync(pidFile(project), { force: true });
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
if (signal(pid, 'SIGTERM')) {
|
|
69
|
+
const start = Date.now();
|
|
70
|
+
while (isAlive(pid) && Date.now() - start < timeoutMs) await new Promise((r) => setTimeout(r, 200));
|
|
71
|
+
if (isAlive(pid)) signal(pid, 'SIGKILL');
|
|
72
|
+
}
|
|
73
|
+
rmSync(pidFile(project), { force: true });
|
|
74
|
+
return pid;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function saveMeta(project, meta) {
|
|
78
|
+
mkdirSync(stateDir(), { recursive: true, mode: 0o700 });
|
|
79
|
+
writeFileSync(metaFile(project), JSON.stringify(meta, null, 2) + '\n', { mode: 0o600 });
|
|
80
|
+
}
|
|
81
|
+
export function readMeta(project) {
|
|
82
|
+
try { return JSON.parse(readFileSync(metaFile(project), 'utf8')); } catch { return null; }
|
|
83
|
+
}
|
|
84
|
+
export function removeMeta(project) {
|
|
85
|
+
rmSync(metaFile(project), { force: true });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Projects that have a pid file in the state dir (running or stale).
|
|
89
|
+
export function localProjects() {
|
|
90
|
+
try {
|
|
91
|
+
return readdirSync(stateDir()).filter((f) => f.endsWith('.pid')).map((f) => f.slice(0, -4)).sort();
|
|
92
|
+
} catch {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
}
|