moshcode 0.87.0 → 0.88.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.mjs +31 -1
package/package.json
CHANGED
package/src/dns.mjs
CHANGED
|
@@ -1695,6 +1695,36 @@ export function proxyProbeFromArgs(args = [], claimed = []) {
|
|
|
1695
1695
|
return { name: claimed[0] ? `a.${claimed[0]}` : null, invalid: false };
|
|
1696
1696
|
}
|
|
1697
1697
|
|
|
1698
|
+
/**
|
|
1699
|
+
* A Moshpit name to test this machine's setup with.
|
|
1700
|
+
*
|
|
1701
|
+
* Synthetic on purpose — the proxy mints a certificate for any name inside the
|
|
1702
|
+
* namespace, so the probe does not have to name something anybody registered.
|
|
1703
|
+
* What it does have to be is a hostname the rest of the program can parse.
|
|
1704
|
+
*
|
|
1705
|
+
* `a.${tlds[0]}` was not. The first ending the registry returns is `00`, and
|
|
1706
|
+
* `https://a.00/` is rejected outright by the WHATWG URL parser: a final label
|
|
1707
|
+
* of digits makes the whole host a candidate IPv4 literal, and `a.00` is not a
|
|
1708
|
+
* valid one. So proxy detection asked about a name that could not be looked up,
|
|
1709
|
+
* concluded there was no proxy on a machine that had one running and holding
|
|
1710
|
+
* 443, and started the bridge without proxy mode — leaving every name to answer
|
|
1711
|
+
* its origin with a certificate no CA has signed.
|
|
1712
|
+
*
|
|
1713
|
+
* An all-numeric ending is legal and wanted (`.420`, `.2600`); it is unusable
|
|
1714
|
+
* only here, which is why this skips them for the probe rather than the registry
|
|
1715
|
+
* refusing to sell them. `--proxy-probe <name>` overrides, for a machine where
|
|
1716
|
+
* the choice has to be a specific real name.
|
|
1717
|
+
*/
|
|
1718
|
+
export function probeName(tlds = [], args = []) {
|
|
1719
|
+
const at = args.indexOf("--proxy-probe");
|
|
1720
|
+
if (at >= 0) {
|
|
1721
|
+
const given = args[at + 1];
|
|
1722
|
+
if (given && !given.startsWith("--")) return given;
|
|
1723
|
+
}
|
|
1724
|
+
const usable = tlds.find((t) => !/^\d+$/.test(String(t)));
|
|
1725
|
+
return usable ? `a.${usable}` : null;
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1698
1728
|
export function upstreamsFromArgs(args = []) {
|
|
1699
1729
|
const servers = [];
|
|
1700
1730
|
const invalid = [];
|
|
@@ -3095,7 +3125,7 @@ export async function dnsCommand(args = [], out = console.log, deps = {}) {
|
|
|
3095
3125
|
|
|
3096
3126
|
// The name whose resolution proves the bridge is answering, alongside the
|
|
3097
3127
|
// clearnet one that proves it is forwarding.
|
|
3098
|
-
const moshpitProbe = tlds
|
|
3128
|
+
const moshpitProbe = probeName(tlds, rest);
|
|
3099
3129
|
// Restoring files is not a rollback on Windows: NRPT rules are not files,
|
|
3100
3130
|
// so the undo is the disable plan's commands rather than the enable plan's.
|
|
3101
3131
|
const undoSteps = platform === "windows" ? disablePlan({ platform, tlds, linuxBackend }).steps : undefined;
|