moshcode 0.81.0 → 0.82.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 +8 -0
- package/src/dns.mjs +27 -1
package/package.json
CHANGED
package/src/dns-service.mjs
CHANGED
|
@@ -67,6 +67,7 @@ export function serviceUnit({
|
|
|
67
67
|
port,
|
|
68
68
|
registryBase = null,
|
|
69
69
|
upstreams = [],
|
|
70
|
+
proxy = null,
|
|
70
71
|
user = process.env.USER || process.env.LOGNAME,
|
|
71
72
|
} = {}) {
|
|
72
73
|
if (!entry) throw new Error("serviceUnit needs the entry script to run");
|
|
@@ -80,6 +81,13 @@ export function serviceUnit({
|
|
|
80
81
|
// registry. Recorded here, while a working resolver is still around to be
|
|
81
82
|
// asked, rather than rediscovered at boot when it cannot be.
|
|
82
83
|
if (upstreams.length) args.push("--upstream", upstreams.join(","));
|
|
84
|
+
// Without this the supervised bridge answers every name with its origin, and
|
|
85
|
+
// the origin serves a certificate no CA signed — so `https://` fails on a
|
|
86
|
+
// machine where the pinned-TLS proxy is installed, trusted and running.
|
|
87
|
+
// `dns enable` has always probed for the proxy and passed it through;
|
|
88
|
+
// `dns service` did not, which made a service-managed bridge the one way to
|
|
89
|
+
// run Moshpit where HTTPS could never work.
|
|
90
|
+
if (proxy) args.push("--proxy", proxy);
|
|
83
91
|
const exec = [execPath, ...args].map((part) => (/\s/.test(part) ? JSON.stringify(part) : part)).join(" ");
|
|
84
92
|
|
|
85
93
|
const lines = [
|
package/src/dns.mjs
CHANGED
|
@@ -2788,7 +2788,33 @@ export async function dnsCommand(args = [], out = console.log, deps = {}) {
|
|
|
2788
2788
|
const upstreams = upstreamsFromArgs(rest).servers.length
|
|
2789
2789
|
? upstreamsFromArgs(rest).servers
|
|
2790
2790
|
: await discoverUpstreams();
|
|
2791
|
-
|
|
2791
|
+
// Probed the same way `enable` probes it, and for the same reason: a name
|
|
2792
|
+
// that resolves but cannot complete a TLS handshake reads as broken to the
|
|
2793
|
+
// person who typed the URL. Asked now, while this command can ask; the unit
|
|
2794
|
+
// it writes runs at boot and has no way to find out later.
|
|
2795
|
+
let proxy = null;
|
|
2796
|
+
if (!rest.includes("--no-proxy")) {
|
|
2797
|
+
const claimed = await fetchTlds({ registryBase }).catch(() => []);
|
|
2798
|
+
const probeName = claimed[0] ? `a.${claimed[0]}` : null;
|
|
2799
|
+
if (probeName) {
|
|
2800
|
+
const local = await findLocalProxyImpl(probeName).catch(() => ({ found: false }));
|
|
2801
|
+
if (local.found) proxy = local.address.v4 || local.address.v6;
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
|
|
2805
|
+
const unit = serviceUnit({ system, entry: cliEntry(), port, registryBase, upstreams, proxy });
|
|
2806
|
+
|
|
2807
|
+
if (proxy) {
|
|
2808
|
+
out(`ok pinned-TLS proxy on ${proxy}:${PROXY_PORT} — names will answer there, so https:// verifies`);
|
|
2809
|
+
out("");
|
|
2810
|
+
} else if (!rest.includes("--no-proxy")) {
|
|
2811
|
+
out("! no pinned-TLS proxy found on this machine");
|
|
2812
|
+
out(" names will answer their origin, and a stock client cannot verify those —");
|
|
2813
|
+
out(" https:// will fail even though the name resolves. Install it with:");
|
|
2814
|
+
out(" curl -fsSL https://raw.githubusercontent.com/profullstack/moshpit-proxy/main/install.sh | sh");
|
|
2815
|
+
out(" then re-run this command so the unit points names at it.");
|
|
2816
|
+
out("");
|
|
2817
|
+
}
|
|
2792
2818
|
|
|
2793
2819
|
if (!upstreams.length) {
|
|
2794
2820
|
out("! no upstream nameservers found, and none given");
|