moshcode 0.84.0 → 0.85.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/package.json +1 -1
- package/src/dns-service.mjs +4 -3
- package/src/trust.mjs +42 -4
package/package.json
CHANGED
package/src/dns-service.mjs
CHANGED
|
@@ -33,6 +33,7 @@ import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
|
33
33
|
import { existsSync } from "node:fs";
|
|
34
34
|
import { homedir } from "node:os";
|
|
35
35
|
import { dirname, join } from "node:path";
|
|
36
|
+
import { operatorHome } from "./trust.mjs";
|
|
36
37
|
|
|
37
38
|
export const UNIT_NAME = "moshcode-dns.service";
|
|
38
39
|
|
|
@@ -217,7 +218,7 @@ export function proxyServicePaths() {
|
|
|
217
218
|
export function proxyServiceUnit({
|
|
218
219
|
wrapper,
|
|
219
220
|
nodeDir,
|
|
220
|
-
home =
|
|
221
|
+
home = operatorHome(),
|
|
221
222
|
user = process.env.SUDO_USER || process.env.USER || process.env.LOGNAME,
|
|
222
223
|
port = 443,
|
|
223
224
|
tlds = [],
|
|
@@ -273,7 +274,7 @@ export function proxyServiceUnit({
|
|
|
273
274
|
}
|
|
274
275
|
|
|
275
276
|
/** Where moshpit-proxy's installer puts its wrapper, if it ran. */
|
|
276
|
-
export function proxyWrapperPath({ home =
|
|
277
|
+
export function proxyWrapperPath({ home = operatorHome(), exists = existsSync } = {}) {
|
|
277
278
|
const candidate = join(home, ".local/bin/moshpit-proxy");
|
|
278
279
|
return exists(candidate) ? candidate : null;
|
|
279
280
|
}
|
|
@@ -293,7 +294,7 @@ export function proxyWrapperPath({ home = homedir(), exists = existsSync } = {})
|
|
|
293
294
|
* answer, so the wait is generous.
|
|
294
295
|
*/
|
|
295
296
|
export async function ensureProxyService({
|
|
296
|
-
home =
|
|
297
|
+
home = operatorHome(),
|
|
297
298
|
user = process.env.SUDO_USER || process.env.USER || process.env.LOGNAME,
|
|
298
299
|
nodeDir = dirname(process.execPath),
|
|
299
300
|
tlds = [],
|
package/src/trust.mjs
CHANGED
|
@@ -151,8 +151,24 @@ export function requireNameConstraints(text, { tlds = [] } = {}) {
|
|
|
151
151
|
const permits = (tld) => constraints.permitted.some((entry) => bare(entry) === String(tld).toLowerCase());
|
|
152
152
|
|
|
153
153
|
const missing = tlds.filter((tld) => !permits(tld));
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
// Not a refusal, and this was the single most damaging line in the file.
|
|
155
|
+
//
|
|
156
|
+
// The root is minted by moshpit-proxy for the endings it was configured to
|
|
157
|
+
// serve — a handful. `tlds` is every ending the registry has sold, which is
|
|
158
|
+
// 18224 and climbing. So this could never pass on a real machine: it refused
|
|
159
|
+
// to install a perfectly good root because it did not also cover 18000
|
|
160
|
+
// endings nobody on that machine was trying to reach, and printed all of them
|
|
161
|
+
// as evidence. The advice it gave — regenerate the root — cannot help,
|
|
162
|
+
// because the new root is scoped to the same handful.
|
|
163
|
+
//
|
|
164
|
+
// A root that covers some of what you resolve is worth exactly what it
|
|
165
|
+
// covers. So it goes in, and the shortfall is a count rather than a wall.
|
|
166
|
+
if (missing.length === tlds.length) {
|
|
167
|
+
return {
|
|
168
|
+
ok: false,
|
|
169
|
+
kind: "out-of-step",
|
|
170
|
+
why: `the root permits none of the endings claimed (${summarise(missing)}) — it is for a different namespace`,
|
|
171
|
+
};
|
|
156
172
|
}
|
|
157
173
|
// And nothing beyond them. One `DNS:.com` in the permitted subtree is the
|
|
158
174
|
// whole hole this gate exists to close, and it would otherwise sail through
|
|
@@ -163,10 +179,32 @@ export function requireNameConstraints(text, { tlds = [] } = {}) {
|
|
|
163
179
|
return {
|
|
164
180
|
ok: false,
|
|
165
181
|
kind: "out-of-step",
|
|
166
|
-
why: `the root also permits ${foreign
|
|
182
|
+
why: `the root also permits ${summarise(foreign)}, which is not an ending we resolve — it reaches past Moshpit`,
|
|
167
183
|
};
|
|
168
184
|
}
|
|
169
|
-
|
|
185
|
+
// Carried, not printed here: the caller decides how loud a partial root is,
|
|
186
|
+
// and it is the only place that knows whether the person asked about a name
|
|
187
|
+
// the root actually covers.
|
|
188
|
+
return missing.length
|
|
189
|
+
? {
|
|
190
|
+
ok: true,
|
|
191
|
+
why: `constrained to Moshpit endings — covers ${tlds.length - missing.length} of ${tlds.length}`,
|
|
192
|
+
missing,
|
|
193
|
+
}
|
|
194
|
+
: { ok: true, why: "constrained to Moshpit endings" };
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* A list a person can read, rather than one that fills the terminal.
|
|
199
|
+
*
|
|
200
|
+
* A registry with 18224 endings turns any "these are wrong" message into
|
|
201
|
+
* several screens of text, which is not a diagnostic — it is the reason nobody
|
|
202
|
+
* reads the line above it.
|
|
203
|
+
*/
|
|
204
|
+
export function summarise(items, show = 8) {
|
|
205
|
+
const list = [...items];
|
|
206
|
+
if (list.length <= show) return list.join(", ");
|
|
207
|
+
return `${list.slice(0, show).join(", ")} and ${list.length - show} more`;
|
|
170
208
|
}
|
|
171
209
|
|
|
172
210
|
/**
|