@rocket.chat/houston 0.27.0-next.2 → 2.1.8
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 +1 -1
- package/README.md +108 -15
- package/bin/houston +62 -0
- package/data/docs/ARCHITECTURE.md +387 -0
- package/data/docs/automation.md +107 -0
- package/data/docs/e2ee.md +76 -0
- package/data/docs/eks.md +258 -0
- package/data/docs/gui.md +282 -0
- package/data/docs/guide.md +669 -0
- package/data/docs/kubernetes.md +138 -0
- package/data/docs/troubleshooting.md +193 -0
- package/data/docs/upgrading.md +84 -0
- package/data/docs/voice.md +253 -0
- package/data/iam/engineer-policy.json +11 -0
- package/data/iam/engineer-rbac.yaml +42 -0
- package/data/iam/operator-policy.json +211 -0
- package/data/loadtest/badbot.js +22 -0
- package/data/loadtest/common.js +168 -0
- package/data/loadtest/custom.js +20 -0
- package/data/loadtest/journey.js +58 -0
- package/data/loadtest/login.js +18 -0
- package/data/loadtest/messages.js +13 -0
- package/data/loadtest/mixed.js +39 -0
- package/data/loadtest/read.js +12 -0
- package/data/loadtest/webhook.js +20 -0
- package/data/monitoring/houston-logs.json +98 -0
- package/data/monitoring/k6-loadtest.json +610 -0
- package/data/monitoring/mongodb-exporter.json +3007 -0
- package/data/monitoring/node-exporter-full.json +16114 -0
- package/data/monitoring/rocketchat-metrics.json +6471 -0
- package/data/presets/airgapped.yaml +16 -0
- package/data/presets/default.yaml +9 -0
- package/data/seed/avatar-0.png +0 -0
- package/data/seed/avatar-1.png +0 -0
- package/data/seed/avatar-2.png +0 -0
- package/data/seed/avatar-3.png +0 -0
- package/data/seed/avatar-4.png +0 -0
- package/data/seed/avatar-5.png +0 -0
- package/data/seed/avatar-6.png +0 -0
- package/data/seed/avatar-7.png +0 -0
- package/data/seed/seed-metrics.csv +3 -0
- package/data/seed/seed-preview.png +0 -0
- package/data/seed/seed-report.pdf +32 -0
- package/data/seed/seed-runbook.txt +3 -0
- package/data/skill/SKILL.md +399 -0
- package/data/versions.yaml +55 -0
- package/data/voice/freeswitch/drachtio.xml +52 -0
- package/data/voice/freeswitch/public.xml +87 -0
- package/data/webui/app.css +2003 -0
- package/data/webui/index.html +678 -0
- package/data/webui/js/api.js +561 -0
- package/data/webui/js/boot.js +44 -0
- package/data/webui/js/clusters-tail.js +1377 -0
- package/data/webui/js/clusters.js +896 -0
- package/data/webui/js/create.js +276 -0
- package/data/webui/js/detail.js +507 -0
- package/data/webui/js/jobs.js +636 -0
- package/data/webui/js/logs.js +634 -0
- package/data/webui/js/main.js +14 -0
- package/data/webui/js/options.js +408 -0
- package/data/webui/js/people.js +438 -0
- package/data/webui/js/perf.js +303 -0
- package/data/webui/js/render.js +438 -0
- package/data/webui/js/shared.js +3 -0
- package/data/webui/js/state.js +583 -0
- package/data/webui/js/theme.js +123 -0
- package/data/webui/js/util.js +584 -0
- package/dist/cli/app.js +593 -0
- package/dist/cli/capabilities.js +76 -0
- package/dist/cli/cell-widths.js +495 -0
- package/dist/cli/entry.js +10 -0
- package/dist/cli/error-panel.js +492 -0
- package/dist/cli/handlers/actor.js +84 -0
- package/dist/cli/handlers/https.js +614 -0
- package/dist/cli/handlers/prompt.js +299 -0
- package/dist/cli/handlers/users.js +226 -0
- package/dist/cli/handlers.js +3678 -0
- package/dist/cli/help.js +183 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/perf.js +810 -0
- package/dist/cli/render.js +254 -0
- package/dist/cli/serve.js +858 -0
- package/dist/cli/spec-data.js +2593 -0
- package/dist/cli/spec-types.js +8 -0
- package/dist/cli/usage-error.js +520 -0
- package/dist/cli/wire.js +70 -0
- package/dist/core/audit.js +346 -0
- package/dist/core/backup-compat.js +85 -0
- package/dist/core/backup.js +1639 -0
- package/dist/core/cluster.js +1398 -0
- package/dist/core/configimport.js +344 -0
- package/dist/core/data.js +267 -0
- package/dist/core/database-of.js +82 -0
- package/dist/core/diagnose.js +159 -0
- package/dist/core/doctor.js +1518 -0
- package/dist/core/edge/acme.js +338 -0
- package/dist/core/edge/engine.js +500 -0
- package/dist/core/edge/networks.js +174 -0
- package/dist/core/edge/paths.js +107 -0
- package/dist/core/edge/routes.js +251 -0
- package/dist/core/edge/routeyml.js +195 -0
- package/dist/core/edge/runtime.js +493 -0
- package/dist/core/edge/spec.js +305 -0
- package/dist/core/edge/types.js +202 -0
- package/dist/core/eks-docs.js +135 -0
- package/dist/core/eks.js +2240 -0
- package/dist/core/envvars.js +562 -0
- package/dist/core/eventlog.js +541 -0
- package/dist/core/firstrun.js +153 -0
- package/dist/core/journal.js +691 -0
- package/dist/core/kube/ask.js +231 -0
- package/dist/core/kube/capabilities.js +269 -0
- package/dist/core/kube/certmanager.js +452 -0
- package/dist/core/kube/chart.js +413 -0
- package/dist/core/kube/cluster.js +196 -0
- package/dist/core/kube/context.js +545 -0
- package/dist/core/kube/endpoints.js +448 -0
- package/dist/core/kube/exec.js +195 -0
- package/dist/core/kube/forward.js +732 -0
- package/dist/core/kube/grafana-ingress.js +110 -0
- package/dist/core/kube/ingress.js +218 -0
- package/dist/core/kube/manifests.js +361 -0
- package/dist/core/kube/monitoring.js +768 -0
- package/dist/core/kube/names.js +237 -0
- package/dist/core/kube/namespace.js +678 -0
- package/dist/core/kube/operator.js +941 -0
- package/dist/core/kube/probe.js +202 -0
- package/dist/core/kube/reachability.js +163 -0
- package/dist/core/kube/release.js +439 -0
- package/dist/core/kube/replicaset.js +180 -0
- package/dist/core/kube/scale.js +398 -0
- package/dist/core/kube/status.js +633 -0
- package/dist/core/kube/tools.js +238 -0
- package/dist/core/kube/transfer.js +173 -0
- package/dist/core/kube/workspace.js +423 -0
- package/dist/core/lifecycle/admin.js +64 -0
- package/dist/core/lifecycle/create-docker.js +1533 -0
- package/dist/core/lifecycle/create-k8s.js +939 -0
- package/dist/core/lifecycle/destroy.js +339 -0
- package/dist/core/lifecycle/inspect.js +635 -0
- package/dist/core/lifecycle/naming.js +298 -0
- package/dist/core/lifecycle/notes.js +726 -0
- package/dist/core/lifecycle/ownership.js +313 -0
- package/dist/core/lifecycle/payload.js +401 -0
- package/dist/core/lifecycle/ports.js +388 -0
- package/dist/core/lifecycle/preconditions.js +367 -0
- package/dist/core/lifecycle/pruning.js +551 -0
- package/dist/core/lifecycle/ready.js +753 -0
- package/dist/core/lifecycle/request.js +525 -0
- package/dist/core/lifecycle/seeding.js +281 -0
- package/dist/core/lifecycle/sizing.js +392 -0
- package/dist/core/lifecycle/state.js +286 -0
- package/dist/core/lifecycle/tlsplan.js +704 -0
- package/dist/core/lifecycle/types.js +232 -0
- package/dist/core/loadtest.js +995 -0
- package/dist/core/migrate.js +612 -0
- package/dist/core/monitor.js +494 -0
- package/dist/core/postready.js +969 -0
- package/dist/core/promote.js +804 -0
- package/dist/core/rcapi.js +1285 -0
- package/dist/core/recovery.js +75 -0
- package/dist/core/runner/engine.js +394 -0
- package/dist/core/runner/host.js +298 -0
- package/dist/core/runner/locks.js +129 -0
- package/dist/core/runner/paths.js +173 -0
- package/dist/core/runner/ports.js +172 -0
- package/dist/core/runner/queries.js +612 -0
- package/dist/core/runner/record.js +563 -0
- package/dist/core/scaleseed.js +271 -0
- package/dist/core/seed-db.js +208 -0
- package/dist/core/sessions.js +472 -0
- package/dist/core/skill.js +326 -0
- package/dist/core/sso-identities.js +172 -0
- package/dist/core/sso.js +703 -0
- package/dist/core/tls-local.js +311 -0
- package/dist/core/tls.js +878 -0
- package/dist/core/topology.js +482 -0
- package/dist/core/upgrade.js +868 -0
- package/dist/core/users.js +739 -0
- package/dist/lib/audit.js +100 -0
- package/dist/lib/close-matches.js +238 -0
- package/dist/lib/compose.js +672 -0
- package/dist/lib/config.js +1398 -0
- package/dist/lib/context.js +18 -0
- package/dist/lib/errors.js +305 -0
- package/dist/lib/events.js +208 -0
- package/dist/lib/float-text.js +126 -0
- package/dist/lib/format.js +1320 -0
- package/dist/lib/home.js +325 -0
- package/dist/lib/journal.js +122 -0
- package/dist/lib/json-text.js +733 -0
- package/dist/lib/jsonout.js +382 -0
- package/dist/lib/lock.js +516 -0
- package/dist/lib/login-name.js +202 -0
- package/dist/lib/map-limit.js +29 -0
- package/dist/lib/mkdir-parents.js +90 -0
- package/dist/lib/mongo-kernel.js +67 -0
- package/dist/lib/monitoring.js +492 -0
- package/dist/lib/platform-name.js +59 -0
- package/dist/lib/presets/common.js +390 -0
- package/dist/lib/presets/composite.js +326 -0
- package/dist/lib/presets/e2ee.js +143 -0
- package/dist/lib/presets/email.js +172 -0
- package/dist/lib/presets/guides.js +27 -0
- package/dist/lib/presets/index.js +490 -0
- package/dist/lib/presets/keycloak.js +369 -0
- package/dist/lib/presets/ldap.js +1285 -0
- package/dist/lib/presets/livechat.js +220 -0
- package/dist/lib/presets/multi-instance.js +124 -0
- package/dist/lib/presets/oidc.js +161 -0
- package/dist/lib/presets/public.js +496 -0
- package/dist/lib/presets/registry.js +64 -0
- package/dist/lib/presets/s3-minio.js +300 -0
- package/dist/lib/presets/saml.js +149 -0
- package/dist/lib/presets/scenario.js +51 -0
- package/dist/lib/presets/types.js +86 -0
- package/dist/lib/presets/voice-pbx.js +320 -0
- package/dist/lib/presets/voice.js +345 -0
- package/dist/lib/presets/webhooks.js +182 -0
- package/dist/lib/redact.js +106 -0
- package/dist/lib/seed-options.js +68 -0
- package/dist/lib/seed-profiles.js +59 -0
- package/dist/lib/targz.js +1383 -0
- package/dist/lib/teammode.js +25 -0
- package/dist/lib/tempdir.js +162 -0
- package/dist/lib/unicode-tables.js +2335 -0
- package/dist/lib/version-spec.js +357 -0
- package/dist/lib/versions.js +463 -0
- package/dist/lib/yaml-dump.js +1361 -0
- package/dist/perf/baseline.js +168 -0
- package/dist/perf/constrain.js +296 -0
- package/dist/perf/k6.js +235 -0
- package/dist/perf/mongoprof.js +171 -0
- package/dist/perf/rcmetrics.js +178 -0
- package/dist/perf/report.js +386 -0
- package/dist/perf/resources.js +224 -0
- package/dist/perf/slo.js +111 -0
- package/dist/perf/timeline.js +187 -0
- package/dist/perf/timings.js +85 -0
- package/dist/perf/verdict.js +201 -0
- package/dist/seams/aws-cli.js +126 -0
- package/dist/seams/docker-cli.js +280 -0
- package/dist/seams/exec.js +861 -0
- package/dist/seams/fs/lock.js +528 -0
- package/dist/seams/kubectl.js +83 -0
- package/dist/seams/rc-http.js +921 -0
- package/dist/seed/apply.js +190 -0
- package/dist/seed/assets.js +76 -0
- package/dist/seed/check.js +391 -0
- package/dist/seed/client.js +172 -0
- package/dist/seed/executor.js +726 -0
- package/dist/seed/history.js +281 -0
- package/dist/seed/kinds.js +91 -0
- package/dist/seed/plan.js +432 -0
- package/dist/seed/receipt.js +339 -0
- package/dist/seed/repairs.js +75 -0
- package/dist/seed/verification.js +363 -0
- package/dist/seed/wording.js +248 -0
- package/dist/web/app.js +326 -0
- package/dist/web/jobs.js +510 -0
- package/dist/web/route-deps.js +211 -0
- package/dist/web/route-table.js +213 -0
- package/dist/web/routes/backup.js +244 -0
- package/dist/web/routes/clusters.js +303 -0
- package/dist/web/routes/data.js +187 -0
- package/dist/web/routes/edge.js +82 -0
- package/dist/web/routes/index.js +63 -0
- package/dist/web/routes/jobs.js +95 -0
- package/dist/web/routes/logs.js +297 -0
- package/dist/web/routes/meta.js +191 -0
- package/dist/web/routes/people.js +151 -0
- package/dist/web/routes/perf.js +95 -0
- package/dist/web/routes/repros.js +550 -0
- package/dist/web/routes/session.js +361 -0
- package/dist/web/routes/spa.js +198 -0
- package/dist/web/security.js +475 -0
- package/dist/web/signin.js +246 -0
- package/package.json +67 -32
- package/.eslintrc +0 -94
- package/.swcrc +0 -18
- package/dist/bin.js +0 -3
- package/dist/cli.js +0 -184
- package/dist/commands/createBranch.js +0 -192
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -25
- package/src-old/logs.js +0 -323
- package/src-old/md.js +0 -191
- package/src-old/release-table.js +0 -60
- package/src-old/set-version.js +0 -614
- package/src-old/utils.js +0 -15
|
@@ -0,0 +1,614 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* HTTPS on this box, as the terminal sees it: `edge`, `tls-status` and `trust-ca`.
|
|
4
|
+
*
|
|
5
|
+
* Both commands are `json: none`, so what they print and the code they exit with IS their
|
|
6
|
+
* contract -- and an earlier version answered them with a dump of the service result:
|
|
7
|
+
* `edge status` a key/value panel of four raw fields, `edge stop` "✓ edge stopped" over a
|
|
8
|
+
* compose that could not run, `edge delete` "removed" whatever went, and `tls-status` every
|
|
9
|
+
* field of the probe report and exit 0 with nothing serving TLS at all, where the
|
|
10
|
+
* established answer says why, says what to check, and exits 1. A script that branches on
|
|
11
|
+
* `tls-status` read a broken name as a healthy one.
|
|
12
|
+
*
|
|
13
|
+
* Output is what the CLI has always written off a terminal: every prose line on stdout,
|
|
14
|
+
* `error: ...` on stderr through the thrown `ReproError`.
|
|
15
|
+
*/
|
|
16
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
19
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
20
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
21
|
+
}
|
|
22
|
+
Object.defineProperty(o, k2, desc);
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
28
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
29
|
+
}) : function(o, v) {
|
|
30
|
+
o["default"] = v;
|
|
31
|
+
});
|
|
32
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
33
|
+
var ownKeys = function(o) {
|
|
34
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
35
|
+
var ar = [];
|
|
36
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
37
|
+
return ar;
|
|
38
|
+
};
|
|
39
|
+
return ownKeys(o);
|
|
40
|
+
};
|
|
41
|
+
return function (mod) {
|
|
42
|
+
if (mod && mod.__esModule) return mod;
|
|
43
|
+
var result = {};
|
|
44
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
45
|
+
__setModuleDefault(result, mod);
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
})();
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.reportGuiTls = exports.portClaimNote = void 0;
|
|
51
|
+
exports.promoteCommand = promoteCommand;
|
|
52
|
+
exports.edgeCommand = edgeCommand;
|
|
53
|
+
exports.tlsTroubleshoot = tlsTroubleshoot;
|
|
54
|
+
exports.tlsStatus = tlsStatus;
|
|
55
|
+
exports.trustCa = trustCa;
|
|
56
|
+
const fs = __importStar(require("node:fs"));
|
|
57
|
+
const config = __importStar(require("../../lib/config"));
|
|
58
|
+
const errors_1 = require("../../lib/errors");
|
|
59
|
+
const home_1 = require("../../lib/home");
|
|
60
|
+
const format_1 = require("../../lib/format");
|
|
61
|
+
const app_1 = require("../app");
|
|
62
|
+
const serve_1 = require("../serve");
|
|
63
|
+
Object.defineProperty(exports, "portClaimNote", { enumerable: true, get: function () { return serve_1.portClaimNote; } });
|
|
64
|
+
Object.defineProperty(exports, "reportGuiTls", { enumerable: true, get: function () { return serve_1.reportGuiTls; } });
|
|
65
|
+
const render_1 = require("../render");
|
|
66
|
+
/** The staging -> production command, rebuilt from what this workspace actually used. */
|
|
67
|
+
function promoteCommand(meta, host) {
|
|
68
|
+
const email = String(meta.extra.tls_email ?? '') || '<you@example.com>';
|
|
69
|
+
return [
|
|
70
|
+
`houston up -v ${meta.rcVersion}`,
|
|
71
|
+
`--name ${meta.name}`,
|
|
72
|
+
`--domain ${host}`,
|
|
73
|
+
`--email ${email}`,
|
|
74
|
+
'--force',
|
|
75
|
+
'--wait',
|
|
76
|
+
].join(' ');
|
|
77
|
+
}
|
|
78
|
+
// --- edge ---------------------------------------------------------------------------
|
|
79
|
+
/** The hostname a route file serves, for display only. `?` when it declares none. */
|
|
80
|
+
function edgeRouteHost(name) {
|
|
81
|
+
const routes = require('../../core/edge/routes');
|
|
82
|
+
return routes.routeHost(name) || '?';
|
|
83
|
+
}
|
|
84
|
+
/** Bring the front door up, and say what it is now holding. */
|
|
85
|
+
async function edgeStart(io, action) {
|
|
86
|
+
if (action !== 'start' && action !== 'restart')
|
|
87
|
+
return;
|
|
88
|
+
const runtime = require('../../core/edge/runtime');
|
|
89
|
+
// RENDERED, not raised: a ConflictError here is an edge from another HOUSTON_HOME
|
|
90
|
+
// holding the port, a real and actionable condition. It propagates as the red line.
|
|
91
|
+
const res = await runtime.up({ pull: false });
|
|
92
|
+
if (res.returncode !== 0) {
|
|
93
|
+
// Docker's own reason. A guess that something held :80 or :443 was printed for every
|
|
94
|
+
// failure, and sent the reader to `lsof` over a stale systemd unit that held neither.
|
|
95
|
+
const engine = require('../../core/edge/engine');
|
|
96
|
+
throw new errors_1.ReproError(`the edge did not start: ${engine.why(res)}`);
|
|
97
|
+
}
|
|
98
|
+
// BOUND IS NOT REACHABLE.
|
|
99
|
+
const claim = await (0, serve_1.portClaimNote)();
|
|
100
|
+
if (claim !== '')
|
|
101
|
+
(0, render_1.say)(io, ` ⚠ edge running, but NOT reachable — ${claim}`);
|
|
102
|
+
else
|
|
103
|
+
(0, render_1.say)(io, '✓ edge running — every registered name is served again.');
|
|
104
|
+
}
|
|
105
|
+
/** `edge start|stop|restart`: move the front door without losing its routes. */
|
|
106
|
+
async function edgeLifecycle(io, action) {
|
|
107
|
+
const spec = require('../../core/edge/spec');
|
|
108
|
+
const types = require('../../core/edge/types');
|
|
109
|
+
const engine = require('../../core/edge/engine');
|
|
110
|
+
if (!spec.installed() && action !== 'stop') {
|
|
111
|
+
await spec.write(types.edge());
|
|
112
|
+
}
|
|
113
|
+
else if (action === 'start' || action === 'restart') {
|
|
114
|
+
// RE-RESOLVE FROM CONFIG, so a changed `acme.challenge` or `acme.staging` reaches the
|
|
115
|
+
// container; rebuilt from the recorded spec, which is why the spec is recorded.
|
|
116
|
+
const current = spec.current();
|
|
117
|
+
if (current !== null) {
|
|
118
|
+
await spec.write(types.resolveEdge(current.domain, current.acmeEmail, {
|
|
119
|
+
guiHost: current.guiHost,
|
|
120
|
+
guiPort: current.guiPort,
|
|
121
|
+
httpPort: current.httpPort,
|
|
122
|
+
httpsPort: current.httpsPort,
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (action === 'stop' || action === 'restart') {
|
|
127
|
+
// NOTHING TO STOP IS NOT A FAILURE, AND NOT A SUCCESS EITHER.
|
|
128
|
+
if (!spec.installed()) {
|
|
129
|
+
(0, render_1.say)(io, 'no edge is set up in this home — nothing to stop. If a name is still being ' +
|
|
130
|
+
'served, the edge belongs to another houston home, usually houston run with sudo or ' +
|
|
131
|
+
'as another user; `houston edge status` says so. Run this the same way (or with ' +
|
|
132
|
+
'HOUSTON_HOME=<that home>).');
|
|
133
|
+
return 0;
|
|
134
|
+
}
|
|
135
|
+
// AND THE EXIT CODE IS READ: a compose that could not run reported the ports free.
|
|
136
|
+
if ((await engine.down()) !== 0) {
|
|
137
|
+
throw new errors_1.ReproError('could not stop the edge — `docker compose -p houston_edge ps` says what is still there.');
|
|
138
|
+
}
|
|
139
|
+
(0, render_1.say)(io, '✓ edge stopped; it no longer holds :80 or :443.');
|
|
140
|
+
if (action === 'stop') {
|
|
141
|
+
(0, render_1.say)(io, 'Every HTTPS workspace on this machine, and a `serve --domain` GUI, is offline for ' +
|
|
142
|
+
'everyone until `houston edge start`.');
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
await edgeStart(io, action);
|
|
146
|
+
return 0;
|
|
147
|
+
}
|
|
148
|
+
/** The houston home an edge directory belongs to: `/root/.houston` for `/root/.houston/edge`. */
|
|
149
|
+
function foreignHome(edgeDir) {
|
|
150
|
+
return edgeDir.replace(/\/edge\/?$/u, '');
|
|
151
|
+
}
|
|
152
|
+
/** Whether the certificate is really gone, which depends on who is running Traefik. */
|
|
153
|
+
async function reportAcmeDeletion(io, gone) {
|
|
154
|
+
const engine = require('../../core/edge/engine');
|
|
155
|
+
if (gone.acme.length === 0)
|
|
156
|
+
return;
|
|
157
|
+
(0, render_1.say)(io, `✓ Let's Encrypt certificate removed from ${gone.acme.join(', ')}`);
|
|
158
|
+
if (gone.foreign !== '') {
|
|
159
|
+
(0, render_1.say)(io, `the edge holding :443 belongs to another houston home (${foreignHome(gone.foreign)}), ` +
|
|
160
|
+
'usually houston run with sudo or as another user, and it reads its OWN certificate ' +
|
|
161
|
+
"store — so what was just deleted is this home's copy, not the certificate that name " +
|
|
162
|
+
'is being served with. Run this the same way (or with ' +
|
|
163
|
+
`HOUSTON_HOME=${foreignHome(gone.foreign)}).`);
|
|
164
|
+
}
|
|
165
|
+
else if (gone.restarted === true) {
|
|
166
|
+
(0, render_1.say)(io, 'the edge was restarted so Traefik reloads the store — it holds it in memory and ' +
|
|
167
|
+
'rewrites the whole file, so an edit made underneath it comes back. Every other ' +
|
|
168
|
+
'name is served again; routes are files.');
|
|
169
|
+
}
|
|
170
|
+
else if (gone.restarted === false) {
|
|
171
|
+
(0, render_1.say)(io, 'the edge did not come back cleanly — `houston edge status`. Until it restarts, ' +
|
|
172
|
+
'Traefik may write the deleted entry back from memory.');
|
|
173
|
+
}
|
|
174
|
+
else if (!(await engine.running())) {
|
|
175
|
+
(0, render_1.say)(io, 'the edge is stopped, so nothing can write the entry back.');
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/** `edge delete`: forget one name, with the refusals that protect a live one. */
|
|
179
|
+
async function edgeDelete(io, host, yes, confirm) {
|
|
180
|
+
const spec = require('../../core/edge/spec');
|
|
181
|
+
const runtime = require('../../core/edge/runtime');
|
|
182
|
+
// The missing host first: a usage error is one whether or not this home has an edge.
|
|
183
|
+
if (host === '') {
|
|
184
|
+
throw new errors_1.ValidationError('name the host: `houston edge delete <host>`. `houston edge status` lists what this ' +
|
|
185
|
+
'edge routes and what it holds a certificate for.');
|
|
186
|
+
}
|
|
187
|
+
if (!spec.installed()) {
|
|
188
|
+
(0, render_1.say)(io, 'no edge in this home, so it holds no names — nothing to delete.');
|
|
189
|
+
return 0;
|
|
190
|
+
}
|
|
191
|
+
// The prompt names what goes: "delete <host>" reads like removing a route, and it is
|
|
192
|
+
// removing a private key.
|
|
193
|
+
if (!yes &&
|
|
194
|
+
!(await confirm(`delete ${host} — its route, its certificate, its PRIVATE KEY and its ` +
|
|
195
|
+
"Let's Encrypt entry? This cannot be undone"))) {
|
|
196
|
+
throw new app_1.Aborted();
|
|
197
|
+
}
|
|
198
|
+
const gone = await runtime.deleteHost(host, { confirm: true });
|
|
199
|
+
// Reported per kind, and only what actually went.
|
|
200
|
+
for (const name of gone.routes) {
|
|
201
|
+
(0, render_1.say)(io, `✓ route ${name} removed` +
|
|
202
|
+
(gone.passthrough.includes(name)
|
|
203
|
+
? ' (passthrough — its certificate is in the cluster, and went with the namespace)'
|
|
204
|
+
: ''));
|
|
205
|
+
}
|
|
206
|
+
if (gone.certificate)
|
|
207
|
+
(0, render_1.say)(io, `✓ certificate and key for ${gone.host} removed`);
|
|
208
|
+
if (gone.declaration)
|
|
209
|
+
(0, render_1.say)(io, `✓ certificate declaration for ${gone.host} removed`);
|
|
210
|
+
await reportAcmeDeletion(io, gone);
|
|
211
|
+
if (!(gone.routes.length > 0 || gone.certificate || gone.declaration || gone.acme.length > 0)) {
|
|
212
|
+
(0, render_1.say)(io, `nothing here for ${gone.host} — no route, no certificate, no ACME entry. Already ` +
|
|
213
|
+
'clean, or the name belongs to another houston home (houston run with sudo or as ' +
|
|
214
|
+
'another user).');
|
|
215
|
+
return 0;
|
|
216
|
+
}
|
|
217
|
+
if (gone.kept.length > 0) {
|
|
218
|
+
(0, render_1.say)(io, `kept ${gone.kept.join(', ')} — the issuance ledger is what \`tls-status\` counts ` +
|
|
219
|
+
"against Let's Encrypt's five-a-week duplicate limit. Deleting the certificate " +
|
|
220
|
+
'does NOT give the budget back; re-issuing the same name still counts.');
|
|
221
|
+
}
|
|
222
|
+
return 0;
|
|
223
|
+
}
|
|
224
|
+
/** Certificates and ACME entries no route claims any more. */
|
|
225
|
+
function reportStrayCertificates(io, domain, routes) {
|
|
226
|
+
const acme = require('../../core/edge/acme');
|
|
227
|
+
const paths = require('../../core/edge/paths');
|
|
228
|
+
// Declared and unservable: silent apart from a log nobody was pointed at.
|
|
229
|
+
const orphans = acme.orphanCerts();
|
|
230
|
+
if (orphans.length > 0) {
|
|
231
|
+
(0, render_1.say)(io, ` ⚠ ${String(orphans.length)} name(s) declared with no certificate file — ` +
|
|
232
|
+
`${orphans.slice(0, 3).join(', ')}${orphans.length > 3 ? '…' : ''}. Traefik logs ` +
|
|
233
|
+
"'failed to find any PEM data' for each, once a second, and serves none of them. " +
|
|
234
|
+
`\`houston edge logs\`; if ${paths.certsDir()} is root-owned (Docker creates a ` +
|
|
235
|
+
'missing bind-mount target that way), `sudo chown -R $(id -u):$(id -g) ' +
|
|
236
|
+
`${paths.certsDir()}\` and re-run \`up\` for those workspaces.`);
|
|
237
|
+
}
|
|
238
|
+
// Certificates with nothing pointing at them: a name cannot be cleaned up until it can
|
|
239
|
+
// be SEEN.
|
|
240
|
+
const claimed = new Set(routes.map((name) => edgeRouteHost(name).toLowerCase()));
|
|
241
|
+
claimed.add(domain.toLowerCase());
|
|
242
|
+
const stale = acme.acmeHosts().filter((host) => !claimed.has(host.toLowerCase()));
|
|
243
|
+
if (stale.length > 0) {
|
|
244
|
+
(0, render_1.say)(io, ` ⚠ ${String(stale.length)} certificate(s) held with no route — ` +
|
|
245
|
+
`${stale.slice(0, 3).join(', ')}${stale.length > 3 ? '…' : ''}. Each is a Let's ` +
|
|
246
|
+
'Encrypt certificate AND private key on this disk for a name nothing serves. ' +
|
|
247
|
+
'`houston edge delete <host>` removes one.');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/** `edge status`: what the front door is serving, and for whom. */
|
|
251
|
+
async function edgeStatus(io) {
|
|
252
|
+
const runtime = require('../../core/edge/runtime');
|
|
253
|
+
const spec = require('../../core/edge/spec');
|
|
254
|
+
const paths = require('../../core/edge/paths');
|
|
255
|
+
const routes = require('../../core/edge/routes');
|
|
256
|
+
const st = await runtime.status();
|
|
257
|
+
if (!st.installed) {
|
|
258
|
+
(0, render_1.say)(io, 'no edge yet — it starts with the first `--https` or `--domain` workspace.');
|
|
259
|
+
return 0;
|
|
260
|
+
}
|
|
261
|
+
const domain = spec.servedDomain();
|
|
262
|
+
const rows = [
|
|
263
|
+
['State', st.running ? 'running' : 'STOPPED'],
|
|
264
|
+
['Project', `${paths.PROJECT} (${paths.edgeDir()})`],
|
|
265
|
+
];
|
|
266
|
+
if (domain !== '')
|
|
267
|
+
rows.push(['GUI name', domain]);
|
|
268
|
+
(0, render_1.writePanel)(io, 'houston edge', rows);
|
|
269
|
+
if (!st.running && (st.routes.length > 0 || domain !== '')) {
|
|
270
|
+
(0, render_1.say)(io, ' ⚠ every https name on this box is unreachable while it is stopped — `houston edge start`');
|
|
271
|
+
}
|
|
272
|
+
else if (!st.running) {
|
|
273
|
+
// Nothing to reach: "every https name is unreachable" above "no names registered yet"
|
|
274
|
+
// was the same false alarm doctor raised about a box that had finished with HTTPS.
|
|
275
|
+
(0, render_1.say)(io, ' stopped — no https workspace uses it; `houston edge start` when one does.');
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
// "running" was the whole answer here, and running is not reachable.
|
|
279
|
+
const claim = await (0, serve_1.portClaimNote)();
|
|
280
|
+
if (claim !== '')
|
|
281
|
+
(0, render_1.say)(io, ` ⚠ running but NOT reachable — ${claim}`);
|
|
282
|
+
}
|
|
283
|
+
reportStrayCertificates(io, domain, st.routes);
|
|
284
|
+
if (st.routes.length === 0) {
|
|
285
|
+
(0, render_1.say)(io, ' no names registered yet.');
|
|
286
|
+
return 0;
|
|
287
|
+
}
|
|
288
|
+
// Attachment and route side by side: a route whose network the edge never joined is a
|
|
289
|
+
// 502, not an error, and that is the hardest failure to read.
|
|
290
|
+
(0, render_1.say)(io, `\n${'NAME'.padEnd(28)} ${'SERVES'.padEnd(38)} REACHABLE`);
|
|
291
|
+
for (const name of st.routes) {
|
|
292
|
+
const ok = await routes.routeReachable(name, st.attached);
|
|
293
|
+
(0, render_1.say)(io, `${name.padEnd(28)} ${edgeRouteHost(name).padEnd(38)} ${ok ? 'yes' : 'NO (502)'}`);
|
|
294
|
+
}
|
|
295
|
+
return 0;
|
|
296
|
+
}
|
|
297
|
+
/** `houston edge <action> [host]`. Returns the exit code; a refusal is thrown. */
|
|
298
|
+
async function edgeCommand(io, action, host, { follow = false, tail = 200, yes = false }, confirm) {
|
|
299
|
+
const spec = require('../../core/edge/spec');
|
|
300
|
+
const engine = require('../../core/edge/engine');
|
|
301
|
+
const runtime = require('../../core/edge/runtime');
|
|
302
|
+
if (action === 'logs') {
|
|
303
|
+
// WHERE HTTPS FAILS, and there was no way to read it from here.
|
|
304
|
+
if (!spec.installed()) {
|
|
305
|
+
(0, render_1.say)(io, 'no edge yet — nothing to show. It starts with the first `--https` or `--domain` ' +
|
|
306
|
+
'workspace, or `serve --domain`.');
|
|
307
|
+
return 0;
|
|
308
|
+
}
|
|
309
|
+
if (!(await engine.running())) {
|
|
310
|
+
(0, render_1.say)(io, 'the edge is STOPPED — this is whatever it said before it stopped. `houston edge start`');
|
|
311
|
+
}
|
|
312
|
+
return await runtime.logs({ tail, follow });
|
|
313
|
+
}
|
|
314
|
+
if (action === 'status')
|
|
315
|
+
return await edgeStatus(io);
|
|
316
|
+
if (action === 'delete')
|
|
317
|
+
return await edgeDelete(io, host, yes, confirm);
|
|
318
|
+
if (action === 'start' || action === 'stop' || action === 'restart') {
|
|
319
|
+
return await edgeLifecycle(io, action);
|
|
320
|
+
}
|
|
321
|
+
throw new errors_1.ValidationError(`unknown action ${(0, format_1.quotedText)(action)} (want: status | start | stop | restart | logs | delete <host>)`);
|
|
322
|
+
}
|
|
323
|
+
// --- tls-status -----------------------------------------------------------------------
|
|
324
|
+
/** The next things to actually check, ordered by how often they are the cause. */
|
|
325
|
+
function tlsTroubleshoot(io, meta, mode, host, port) {
|
|
326
|
+
const topology = require('../../core/topology');
|
|
327
|
+
// Said, not claimed: nothing here asked Rocket.Chat anything.
|
|
328
|
+
(0, render_1.say)(io, ` This checks the TLS layer only; \`houston ready --name ${meta.name}\` checks Rocket.Chat ` +
|
|
329
|
+
`(${meta.rootUrl} on the machine running houston).`);
|
|
330
|
+
// A KUBERNETES WORKSPACE'S CERTIFICATE IS NOT THE EDGE'S, so none of the advice below
|
|
331
|
+
// applies to it: sending someone to `edge logs` for a certificate the edge never saw is
|
|
332
|
+
// the whole reason this branch exists.
|
|
333
|
+
if (topology.ofMeta(meta) === topology.KUBERNETES) {
|
|
334
|
+
const certmanager = require('../../core/kube/certmanager');
|
|
335
|
+
const ns = String(meta.extra.namespace ?? '') || meta.project || '';
|
|
336
|
+
(0, render_1.say)(io, ' TLS terminates in the cluster, from a Secret cert-manager filled — the edge only ' +
|
|
337
|
+
'forwards the raw connection, so its log has nothing about this name.');
|
|
338
|
+
(0, render_1.say)(io, ' Most likely, in order:');
|
|
339
|
+
(0, render_1.say)(io, ' 1. the Certificate is not Ready yet, or says why it is not');
|
|
340
|
+
(0, render_1.say)(io, ' 2. the ClusterIssuer is not Ready (created before cert-manager, or no egress for an ACME order)');
|
|
341
|
+
(0, render_1.say)(io, " 3. nothing routes to the ingress — `houston doctor` names a cluster holding this host's ports");
|
|
342
|
+
(0, render_1.say)(io, ' What cert-manager says:');
|
|
343
|
+
(0, render_1.say)(io, ` kubectl -n ${ns} describe certificate ${certmanager.tlsSecretFor(meta.name)}`);
|
|
344
|
+
(0, render_1.say)(io, ` kubectl describe clusterissuer ${mode === 'acme' ? certmanager.ACME_ISSUER : certmanager.CA_ISSUER}`);
|
|
345
|
+
if (mode === 'acme') {
|
|
346
|
+
(0, render_1.say)(io, ` kubectl -n ${ns} get order,challenge`);
|
|
347
|
+
(0, render_1.say)(io, ' Debug on staging (`houston config set acme.staging true`, then re-create the ' +
|
|
348
|
+
`workspace): production allows only 5 failed validations per hour for ${host}.`);
|
|
349
|
+
}
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
if (mode === 'acme') {
|
|
353
|
+
const tls = require('../../core/tls');
|
|
354
|
+
(0, render_1.say)(io, ' Most likely, in order:');
|
|
355
|
+
(0, render_1.say)(io, ` 1. inbound TCP/${String(port)} not reachable from the internet (cloud security group / host firewall)`);
|
|
356
|
+
(0, render_1.say)(io, ` 2. DNS: \`dig +short ${host}\` must return this host's PUBLIC IP`);
|
|
357
|
+
(0, render_1.say)(io, " 3. behind a CDN or tunnel that ends TLS (Cloudflare's orange cloud)? tlsalpn cannot " +
|
|
358
|
+
"work there - `houston config set acme.challenge http` (no token; the name's :80 must " +
|
|
359
|
+
`reach this machine), or a provider token in ${tls.dnsEnvPath()} for dns-01`);
|
|
360
|
+
// The edge's Traefik asks Let's Encrypt; the workspace's own log never sees it.
|
|
361
|
+
(0, render_1.say)(io, ' What the edge (Traefik) says: houston edge logs | grep -i acme');
|
|
362
|
+
(0, render_1.say)(io, ' Debug on staging (`houston config set acme.staging true`, then re-create the ' +
|
|
363
|
+
`workspace): production allows only 5 failed validations per hour for ${host}.`);
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
(0, render_1.say)(io, ' Check the edge (Traefik) is running: houston edge status');
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
/** The certificate actually being served; exit 1 for the placeholder. */
|
|
370
|
+
function renderTlsPanel(io, host, meta, mode, port, r) {
|
|
371
|
+
// SUBJECT OR THE NAMES: cert-manager issues with no subject at all -- the name is in the
|
|
372
|
+
// SANs only -- so every Kubernetes workspace showed `Subject: ?` for a correct one.
|
|
373
|
+
(0, render_1.writePanel)(io, `TLS: ${meta.name}`, [
|
|
374
|
+
['Endpoint', `${host}:${String(port)}`],
|
|
375
|
+
['Issuer', r.issuer || '?'],
|
|
376
|
+
['Valid for', r.subject || r.names.join(', ') || '?'],
|
|
377
|
+
['Expires', r.dates.replace('notAfter=', '')],
|
|
378
|
+
]);
|
|
379
|
+
if (!r.fallback)
|
|
380
|
+
return 0;
|
|
381
|
+
// The ingress controller's own placeholder: it started and has no certificate for this
|
|
382
|
+
// name YET. The exit code stays non-zero: whatever the cause, this name is not serving
|
|
383
|
+
// a real certificate now.
|
|
384
|
+
// Whose placeholder it is: on Docker the edge's own Traefik serves it until Let's Encrypt
|
|
385
|
+
// answers; there is no cert-manager and no cluster to name.
|
|
386
|
+
const topology = require('../../core/topology');
|
|
387
|
+
if (topology.ofMeta(meta) === topology.KUBERNETES) {
|
|
388
|
+
(0, render_1.say)(io, " ✗ this is the ingress controller's built-in placeholder certificate — cert-manager " +
|
|
389
|
+
'has not issued one for this name yet.');
|
|
390
|
+
(0, render_1.say)(io, ' On a fresh cluster that is normal for the first minute or three. Run this again; ' +
|
|
391
|
+
'if it persists, the ACME order is stuck.');
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
(0, render_1.say)(io, " ✗ this is the edge's built-in placeholder certificate (Traefik's default) — Let's " +
|
|
395
|
+
'Encrypt has not issued one for this name yet.');
|
|
396
|
+
(0, render_1.say)(io, ' The edge asks as soon as the workspace is up, so that is normal for a minute or ' +
|
|
397
|
+
'three. Run this again; if it persists, the request is failing, most likely for one ' +
|
|
398
|
+
'of the reasons below.');
|
|
399
|
+
}
|
|
400
|
+
tlsTroubleshoot(io, meta, mode, host, port);
|
|
401
|
+
return 1;
|
|
402
|
+
}
|
|
403
|
+
/** An ACME name being served an untrusted certificate: three reasons, told apart. */
|
|
404
|
+
function explainSelfSignedAcme(io, host, meta, mode, r, acmeMode) {
|
|
405
|
+
if (mode === acmeMode && r.self_signed) {
|
|
406
|
+
(0, render_1.say)(io, ' ✗ serving a self-signed certificate — nothing has issued one yet.');
|
|
407
|
+
(0, render_1.say)(io, ' On Kubernetes the ingress serves its own until cert-manager finishes, which is a ' +
|
|
408
|
+
'minute or three after the workspace answers.');
|
|
409
|
+
(0, render_1.say)(io, ` kubectl -n houston-${meta.name} describe certificate ${meta.name}-tls`);
|
|
410
|
+
}
|
|
411
|
+
else if (mode === acmeMode && r.staging) {
|
|
412
|
+
(0, render_1.say)(io, " ✓ serving HTTPS with a real Let's Encrypt-issued certificate.");
|
|
413
|
+
// WHERE STAGING CAME FROM. `config set acme.staging true` stages every `--domain`, and
|
|
414
|
+
// the advice to re-run "without --acme-staging" -- a flag never given -- changed nothing.
|
|
415
|
+
if (config.truthy(config.loadConfig().acme_staging)) {
|
|
416
|
+
(0, render_1.say)(io, " Not trusted here, which is normal for Let's Encrypt staging (`acme.staging` is on): " +
|
|
417
|
+
'DNS and the challenge both worked.');
|
|
418
|
+
(0, render_1.say)(io, ' For a trusted certificate, turn staging off and re-run the SAME command:');
|
|
419
|
+
(0, render_1.say)(io, ' houston config set acme.staging false');
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
(0, render_1.say)(io, " Not trusted here, which is normal for a Let's Encrypt staging certificate: DNS and " +
|
|
423
|
+
'the challenge both worked.');
|
|
424
|
+
(0, render_1.say)(io, ' `acme.staging` is off now, so re-run the SAME command for a trusted certificate:');
|
|
425
|
+
}
|
|
426
|
+
(0, render_1.say)(io, ` ${promoteCommand(meta, host)}`);
|
|
427
|
+
}
|
|
428
|
+
else if (mode === acmeMode) {
|
|
429
|
+
(0, render_1.say)(io, ` ✗ serving a certificate the machine running houston does not trust, from ${r.issuer || 'an unnamed issuer'}.`);
|
|
430
|
+
(0, render_1.say)(io, ' That is neither staging nor a placeholder, so something else is answering for ' +
|
|
431
|
+
'this name — a proxy in front is the usual cause.');
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
(0, render_1.say)(io, ' ✓ serving HTTPS.');
|
|
435
|
+
(0, render_1.say)(io, ' The machine running houston does not trust the issuer; that may be fine if the ' +
|
|
436
|
+
'clients that matter do.');
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
/** What a local-CA workspace needs before a browser will trust it. */
|
|
440
|
+
function explainLocalCaMode(io, host, meta, mode, port, r) {
|
|
441
|
+
if (!r.trusted_via_ca) {
|
|
442
|
+
(0, render_1.say)(io, " ✗ serving a certificate that does not chain to houston's CA.");
|
|
443
|
+
tlsTroubleshoot(io, meta, mode, host, port);
|
|
444
|
+
return 1;
|
|
445
|
+
}
|
|
446
|
+
(0, render_1.say)(io, " ✓ serving HTTPS with houston's local CA.");
|
|
447
|
+
(0, render_1.say)(io, ` ${host} opens only in a browser on the machine running houston: a .localhost name ` +
|
|
448
|
+
'never opens from another computer (`--domain` gives one that does).');
|
|
449
|
+
if (r.trusted) {
|
|
450
|
+
(0, render_1.say)(io, ' The machine running houston trusts it — `trust-ca` has been run; no browser warnings.');
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
(0, render_1.say)(io, ' Not trusted by the machine running houston yet. Run `houston trust-ca` once there to ' +
|
|
454
|
+
'silence browser warnings (the warning itself is harmless locally).');
|
|
455
|
+
}
|
|
456
|
+
return 0;
|
|
457
|
+
}
|
|
458
|
+
/** For a real domain, also what the PUBLIC name serves: a proxy in front is a different certificate. */
|
|
459
|
+
async function explainAcmeMode(io, host, mode, r) {
|
|
460
|
+
const tls = require('../../core/tls');
|
|
461
|
+
if (mode !== tls.MODE_ACME)
|
|
462
|
+
return;
|
|
463
|
+
const pub = await tls.verify(host, { port: 443 });
|
|
464
|
+
if (!pub.serving) {
|
|
465
|
+
(0, render_1.say)(io, ` ⚠ ${host}:443 is not reachable from here (${pub.error}) — this host serves TLS, but ` +
|
|
466
|
+
'the public name does not resolve to it or nothing forwards to it.');
|
|
467
|
+
}
|
|
468
|
+
else if (pub.issuer !== '' && pub.issuer !== r.issuer) {
|
|
469
|
+
(0, render_1.say)(io, ` ⚠ ${host} is fronted by something else: it serves a certificate issued by ` +
|
|
470
|
+
`${(0, format_1.quotedText)(pub.issuer)}, not the one this host serves (${(0, format_1.quotedText)(r.issuer)}).`);
|
|
471
|
+
(0, render_1.say)(io, " That is what an orange-clouded Cloudflare record looks like. Clients get the proxy's " +
|
|
472
|
+
'certificate, not this one.');
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* `houston tls-status [--name]`: what is ACTUALLY being served over HTTPS. Returns the exit
|
|
477
|
+
* code; an unknown name is thrown.
|
|
478
|
+
*/
|
|
479
|
+
async function tlsStatus(io, name) {
|
|
480
|
+
const tls = require('../../core/tls');
|
|
481
|
+
const spec = require('../../core/edge/spec');
|
|
482
|
+
const naming = require('../../core/lifecycle/naming');
|
|
483
|
+
const record = require('../../core/runner/record');
|
|
484
|
+
// THE GUI'S OWN NAME, when no workspace was asked for. `serve --domain` gives this box
|
|
485
|
+
// an https name that is not a workspace, and this was the one command whose job is
|
|
486
|
+
// "what is being served for this name". The key read is `default`, the established
|
|
487
|
+
// key.
|
|
488
|
+
if (name === '' && !(0, format_1.isTruthy)(config.loadConfig().default)) {
|
|
489
|
+
const guiDomain = spec.servedDomain();
|
|
490
|
+
if (guiDomain !== '') {
|
|
491
|
+
(0, render_1.say)(io, `Checking the GUI's own name, ${guiDomain} (no workspace given; \`--name <n>\` for one)`);
|
|
492
|
+
await (0, serve_1.reportGuiTls)(io, guiDomain, { tries: 1, pause: 0 });
|
|
493
|
+
return 0;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
const audit = require('../../core/audit');
|
|
497
|
+
const meta = await record.readMeta(await naming.resolveName(name, audit.actor()));
|
|
498
|
+
// `if not m.public_url`: a record's null or false is no https too, where `=== ''` let a
|
|
499
|
+
// null through to `.split` and a stack.
|
|
500
|
+
if (!(0, format_1.isTruthy)(meta.publicUrl)) {
|
|
501
|
+
(0, render_1.say)(io, ` ⚠ ${(0, format_1.quotedText)(meta.name)} was not created with --https - it serves plain HTTP at ${meta.rootUrl}.`);
|
|
502
|
+
return 1;
|
|
503
|
+
}
|
|
504
|
+
const mode = String(meta.extra.tls ?? '');
|
|
505
|
+
const host = meta.publicUrl.split('://').slice(1).join('://').split(':')[0] ?? '';
|
|
506
|
+
// An edge-served workspace publishes no TLS port of its own, so `tls_ports` is absent OR
|
|
507
|
+
// an empty list (adoption clears it); `[0]` on the empty list was an unhandled error.
|
|
508
|
+
const claimed = (Array.isArray(meta.extra.tls_ports) ? meta.extra.tls_ports : [])
|
|
509
|
+
.map(String)
|
|
510
|
+
.filter((port) => /^\d+$/u.test(port))
|
|
511
|
+
.map(Number);
|
|
512
|
+
const port = claimed[0] ?? 443;
|
|
513
|
+
const cafile = mode === tls.MODE_LOCAL ? (0, home_1.joinPath)(tls.caDir(), tls.CA_CRT) : '';
|
|
514
|
+
(0, render_1.say)(io, `Checking ${meta.publicUrl} ...`);
|
|
515
|
+
const r = await tls.probeServed(host, port, meta.extra, { cafile, ask: tls.verify });
|
|
516
|
+
if (!r.serving) {
|
|
517
|
+
(0, render_1.say)(io, ` ✗ nothing is serving TLS on this host's port ${String(port)} - ${r.error}`);
|
|
518
|
+
tlsTroubleshoot(io, meta, mode, host, port);
|
|
519
|
+
return 1;
|
|
520
|
+
}
|
|
521
|
+
if (renderTlsPanel(io, host, meta, mode, port, r) !== 0)
|
|
522
|
+
return 1;
|
|
523
|
+
await explainAcmeMode(io, host, mode, r);
|
|
524
|
+
if (mode === tls.MODE_LOCAL)
|
|
525
|
+
return explainLocalCaMode(io, host, meta, mode, port, r);
|
|
526
|
+
if (r.trusted) {
|
|
527
|
+
(0, render_1.say)(io, ' ✓ serving HTTPS with a certificate the machine running houston trusts.');
|
|
528
|
+
return 0;
|
|
529
|
+
}
|
|
530
|
+
explainSelfSignedAcme(io, host, meta, mode, r, tls.MODE_ACME);
|
|
531
|
+
return 0;
|
|
532
|
+
}
|
|
533
|
+
// --- trust-ca -----------------------------------------------------------------------
|
|
534
|
+
/**
|
|
535
|
+
* Run a tool for 30 s, print each line of its stdout indented two, and say
|
|
536
|
+
* `⚠ <tool> failed: <exc>` when it could not be run at all. Its stderr and its exit code
|
|
537
|
+
* are captured and dropped.
|
|
538
|
+
*/
|
|
539
|
+
async function runAndEcho(io, argv) {
|
|
540
|
+
const exec = require('../../seams/exec');
|
|
541
|
+
let out;
|
|
542
|
+
try {
|
|
543
|
+
const result = await exec.capture(argv, { encoding: 'utf8', timeoutMs: 30000 });
|
|
544
|
+
out = typeof result.stdout === 'string' ? result.stdout : '';
|
|
545
|
+
}
|
|
546
|
+
catch (error) {
|
|
547
|
+
// A spawn failure or a timeout, each saying what could not run.
|
|
548
|
+
if (error instanceof exec.SpawnFailure) {
|
|
549
|
+
(0, render_1.say)(io, ` ⚠ ${argv[0]} failed: ${(0, format_1.fileErrorText)(error.cause)}`);
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
if (error instanceof exec.ProcessTimeout) {
|
|
553
|
+
(0, render_1.say)(io, ` ⚠ ${argv[0]} failed: ${argv.join(' ')} timed out after 30 seconds`);
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
throw error;
|
|
557
|
+
}
|
|
558
|
+
for (const line of (0, format_1.splitTextLines)(out))
|
|
559
|
+
(0, render_1.say)(io, ` ${line}`);
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* `houston trust-ca [--uninstall] [--show]`: what happened to the system trust store, in
|
|
563
|
+
* the established words, and exit 0 either way.
|
|
564
|
+
*
|
|
565
|
+
* `trust()` answers `[changed, how]`, and `changed` false is its FAILURE: an earlier version
|
|
566
|
+
* read it as "already trusted", and said "✓ local CA uninstalled" for every `--uninstall`
|
|
567
|
+
* without reading it at all -- so a `sudo -n rm` that failed told the operator trust was
|
|
568
|
+
* withdrawn while a CA whose key can mint a certificate for any name stayed in the store.
|
|
569
|
+
*/
|
|
570
|
+
async function trustCa(io, uninstall, show) {
|
|
571
|
+
const local = require('../../core/tls-local');
|
|
572
|
+
if (show) {
|
|
573
|
+
// READ, never made. `--show` is "just print the CA path", and on a fresh home it minted
|
|
574
|
+
// a CA -- a key that can sign for any name -- so the command meant to look at one
|
|
575
|
+
// created one.
|
|
576
|
+
const crt = (0, home_1.joinPath)(local.caDir(), local.CA_CRT);
|
|
577
|
+
const key = (0, home_1.joinPath)(local.caDir(), local.CA_KEY);
|
|
578
|
+
if (!fs.existsSync(crt)) {
|
|
579
|
+
(0, render_1.say)(io, `no local CA yet (${crt}) — the first \`up --https\` or \`trust-ca\` makes one.`);
|
|
580
|
+
return 0;
|
|
581
|
+
}
|
|
582
|
+
(0, render_1.say)(io, `CA certificate: ${crt}`);
|
|
583
|
+
(0, render_1.say)(io, `CA key: ${key} (keep private)`);
|
|
584
|
+
await runAndEcho(io, [
|
|
585
|
+
'openssl',
|
|
586
|
+
'x509',
|
|
587
|
+
'-in',
|
|
588
|
+
crt,
|
|
589
|
+
'-noout',
|
|
590
|
+
'-subject',
|
|
591
|
+
'-fingerprint',
|
|
592
|
+
'-sha256',
|
|
593
|
+
'-dates',
|
|
594
|
+
]);
|
|
595
|
+
return 0;
|
|
596
|
+
}
|
|
597
|
+
const [, crt] = await local.ensureCa();
|
|
598
|
+
const [installed, how] = await local.trust(crt, uninstall);
|
|
599
|
+
if (installed) {
|
|
600
|
+
(0, render_1.say)(io, `✓ CA ${uninstall ? 'removed from' : 'installed into'} ${how}.`);
|
|
601
|
+
if (!uninstall) {
|
|
602
|
+
(0, render_1.say)(io, ' That is the machine running houston: a browser on another computer still warns, ' +
|
|
603
|
+
'and never opens a .localhost name at all (`--domain` gives one that does).');
|
|
604
|
+
}
|
|
605
|
+
(0, render_1.say)(io, ' Restart the browser to pick it up. Firefox keeps its own store — ' +
|
|
606
|
+
'if it still warns, import the CA under Settings → Privacy → Certificates.');
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
(0, render_1.say)(io, ` ⚠ could not ${uninstall ? 'remove' : 'install'} it automatically ` +
|
|
610
|
+
`on this platform (${how}).`);
|
|
611
|
+
(0, render_1.say)(io, local.manualTrustInstructions(crt, uninstall));
|
|
612
|
+
}
|
|
613
|
+
return 0;
|
|
614
|
+
}
|