moshcode 0.79.0 → 0.81.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/install.sh +68 -0
- package/package.json +1 -1
- package/src/dns.mjs +18 -1
- package/src/iana-tlds.mjs +1461 -0
package/install.sh
CHANGED
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
# MOSHCODE_BIN=/path/dir wrapper bin dir (default: $HOME/.local/bin)
|
|
24
24
|
# MOSHCODE_REF=vX.Y.Z pin a tag/branch (default: latest release, else main)
|
|
25
25
|
# MOSHCODE_ALLOW_ROOT=1 install as root anyway (see below)
|
|
26
|
+
# MOSHCODE_NO_PROXY=1 skip the pinned-TLS proxy (https:// on a Moshpit
|
|
27
|
+
# name will not verify without it)
|
|
26
28
|
#
|
|
27
29
|
# Do not install this with sudo. moshcode is a user-level CLI, and every path
|
|
28
30
|
# here is derived from $HOME — under sudo that is /root, so the payload and the
|
|
@@ -41,6 +43,8 @@ MOSHCODE_BIN="${MOSHCODE_BIN:-$HOME/.local/bin}"
|
|
|
41
43
|
WRAPPER="$MOSHCODE_BIN/moshcode"
|
|
42
44
|
SCRIPT_WRAPPER="$MOSHCODE_BIN/moshscript"
|
|
43
45
|
|
|
46
|
+
PROXY_INSTALLER="${MOSHCODE_PROXY_INSTALLER:-https://raw.githubusercontent.com/profullstack/moshpit-proxy/main/install.sh}"
|
|
47
|
+
|
|
44
48
|
# ---- pretty output (acid-lime, matching the CLI) --------------------------
|
|
45
49
|
if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then
|
|
46
50
|
ACID=$(printf '\033[38;2;158;240;26m'); ASH=$(printf '\033[38;2;139;147;138m')
|
|
@@ -51,6 +55,9 @@ fi
|
|
|
51
55
|
info() { printf '%s·%s %s\n' "$ASH" "$RESET" "$*"; }
|
|
52
56
|
ok() { printf '%s✓%s %s\n' "$ACID" "$RESET" "$*"; }
|
|
53
57
|
fail() { printf '%s✗%s %s\n' "$RED" "$RESET" "$*" >&2; exit 1; }
|
|
58
|
+
# Unlike fail(), does not exit: an optional component that did not install is
|
|
59
|
+
# not a reason to leave the CLI half-written.
|
|
60
|
+
warn() { printf '%s!%s %s\n' "$RED" "$RESET" "$*" >&2; }
|
|
54
61
|
|
|
55
62
|
# ---- prerequisites --------------------------------------------------------
|
|
56
63
|
need() { command -v "$1" >/dev/null 2>&1 || fail "$1 is required but not found."; }
|
|
@@ -155,6 +162,66 @@ ensure_path() {
|
|
|
155
162
|
info "add $MOSHCODE_BIN to PATH in this shell: export PATH=\"$MOSHCODE_BIN:\$PATH\""
|
|
156
163
|
}
|
|
157
164
|
|
|
165
|
+
# ---- the pinned-TLS proxy -------------------------------------------------
|
|
166
|
+
# Without this, HTTPS on a Moshpit name cannot work. No public CA will ever sign
|
|
167
|
+
# for `.eggs`, so a name answers its origin's own self-signed leaf and a stock
|
|
168
|
+
# client refuses it — correctly. moshpit-proxy generates one local root and
|
|
169
|
+
# terminates TLS in the one language a browser accepts, which turns "trust this
|
|
170
|
+
# certificate" from a thing you do per name into a thing you do once.
|
|
171
|
+
#
|
|
172
|
+
# Installed here rather than left as a follow-up step because the alternative is
|
|
173
|
+
# `moshcode dns enable` finishing successfully, every name resolving, and every
|
|
174
|
+
# https:// URL still failing — which reads as broken, not as unfinished.
|
|
175
|
+
#
|
|
176
|
+
# This is the one part of the install that touches the system's trust store, so
|
|
177
|
+
# it is the one part with an opt-out: MOSHCODE_NO_PROXY=1 skips it entirely, and
|
|
178
|
+
# `moshpit-proxy install.sh --uninstall` undoes it later. It installs no DNS
|
|
179
|
+
# routing and starts no resolver -- `moshcode dns enable` stays a thing a person
|
|
180
|
+
# types deliberately.
|
|
181
|
+
install_proxy() {
|
|
182
|
+
if [ -n "${MOSHCODE_NO_PROXY:-}" ]; then
|
|
183
|
+
info "skipping the pinned-TLS proxy (MOSHCODE_NO_PROXY is set) — https:// on a Moshpit name will not verify"
|
|
184
|
+
return 0
|
|
185
|
+
fi
|
|
186
|
+
|
|
187
|
+
info "installing the pinned-TLS proxy (so https:// on a Moshpit name verifies)"
|
|
188
|
+
|
|
189
|
+
# Downloaded first and run second, rather than `curl … | sh`.
|
|
190
|
+
#
|
|
191
|
+
# A pipeline reports the exit status of its LAST command, and a `sh` handed
|
|
192
|
+
# an empty stdin by a 404 exits 0 — so piping reports a successful install
|
|
193
|
+
# for a script that never arrived. Verified: pointed at a missing URL, the
|
|
194
|
+
# piped form printed "✓ pinned-TLS proxy installed, local root trusted".
|
|
195
|
+
_proxy_sh="$(mktemp 2>/dev/null)" || {
|
|
196
|
+
warn "could not create a temp file for the pinned-TLS proxy installer — skipping"
|
|
197
|
+
return 0
|
|
198
|
+
}
|
|
199
|
+
if ! curl -fsSL "$PROXY_INSTALLER" -o "$_proxy_sh" 2>/dev/null; then
|
|
200
|
+
rm -f "$_proxy_sh"
|
|
201
|
+
warn "could not download the pinned-TLS proxy — moshcode is fine, but https:// on a Moshpit name will not verify"
|
|
202
|
+
warn " retry: curl -fsSL $PROXY_INSTALLER | sh"
|
|
203
|
+
return 0
|
|
204
|
+
fi
|
|
205
|
+
|
|
206
|
+
# `--yes` because this installer is normally reached through a pipe, where
|
|
207
|
+
# there is no terminal to answer its prompt on. Announced above rather than
|
|
208
|
+
# asked, and MOSHCODE_NO_PROXY is the opt-out.
|
|
209
|
+
if sh "$_proxy_sh" --yes >/dev/null 2>&1; then
|
|
210
|
+
ok "pinned-TLS proxy installed, local root trusted"
|
|
211
|
+
info " it covers .moshpit by default — for other endings:"
|
|
212
|
+
info " MOSHPIT_PROXY_TLDS=moshpit,eggs,hacker,2600"
|
|
213
|
+
info " undo just this: curl -fsSL $PROXY_INSTALLER | sh -s -- --uninstall"
|
|
214
|
+
else
|
|
215
|
+
# Never fatal. moshcode is a coding CLI first, and a machine that cannot
|
|
216
|
+
# finish an optional component still wants the CLI it asked for. Said out
|
|
217
|
+
# loud so it is not discovered later as a TLS error with no explanation.
|
|
218
|
+
warn "the pinned-TLS proxy did not install — moshcode is fine, but https:// on a Moshpit name will not verify"
|
|
219
|
+
warn " retry: curl -fsSL $PROXY_INSTALLER | sh"
|
|
220
|
+
fi
|
|
221
|
+
rm -f "$_proxy_sh"
|
|
222
|
+
unset _proxy_sh
|
|
223
|
+
}
|
|
224
|
+
|
|
158
225
|
# ---- commands -------------------------------------------------------------
|
|
159
226
|
run_install() {
|
|
160
227
|
printf '\n%smoshcode installer%s %s— code hard, mosh harder 🤘%s\n\n' "$BOLD" "$RESET" "$ASH" "$RESET"
|
|
@@ -165,6 +232,7 @@ run_install() {
|
|
|
165
232
|
fetch_and_unpack "$_ref"
|
|
166
233
|
write_wrapper
|
|
167
234
|
ensure_path
|
|
235
|
+
install_proxy
|
|
168
236
|
printf '\n%sdone.%s run:\n' "$ACID" "$RESET"
|
|
169
237
|
printf ' moshcode # open the TUI shell\n'
|
|
170
238
|
printf ' moshcode start claude # raw engine session (use agents for autonomous)\n'
|
package/package.json
CHANGED
package/src/dns.mjs
CHANGED
|
@@ -1163,7 +1163,23 @@ export function forwardQuery(msg, upstream, { timeoutMs = 3000 } = {}) {
|
|
|
1163
1163
|
export function isOurs(name, tldSet) {
|
|
1164
1164
|
if (!(tldSet instanceof Set) || tldSet.size === 0) return false;
|
|
1165
1165
|
const parsed = parseRegistryName(name);
|
|
1166
|
-
|
|
1166
|
+
if (!parsed) return false;
|
|
1167
|
+
// A real top-level domain is never ours, whatever the registry says it sold.
|
|
1168
|
+
//
|
|
1169
|
+
// Answering for one does not add a name, it removes the internet: every
|
|
1170
|
+
// lookup under that TLD stops being forwarded and starts being answered from
|
|
1171
|
+
// a namespace that has never heard of it. `.sh` was claimed for $2 and took
|
|
1172
|
+
// `pit.moshcode.sh` — the registry every bridge fetches its endings from —
|
|
1173
|
+
// off the air for anyone running a bridge, which is a resolver that cannot
|
|
1174
|
+
// resolve the thing it needs in order to resolve. It also blackholed the real
|
|
1175
|
+
// Saint Helena ccTLD on those machines, quietly, with a parking IP.
|
|
1176
|
+
//
|
|
1177
|
+
// Checked here rather than trusted from the registry because this is the half
|
|
1178
|
+
// that protects a person who is already running a bridge, today, against
|
|
1179
|
+
// endings that were sold before anyone noticed. The registry refusing to sell
|
|
1180
|
+
// new ones is the other half and it fixes nothing already on disk.
|
|
1181
|
+
if (isRealTld(parsed.tld)) return false;
|
|
1182
|
+
return tldSet.has(parsed.tld);
|
|
1167
1183
|
}
|
|
1168
1184
|
|
|
1169
1185
|
export function createServer(options = {}) {
|
|
@@ -2320,6 +2336,7 @@ import { applyTrust, applyUntrust, createAutoTrust, trustName, verifyStockTls }
|
|
|
2320
2336
|
import { readFile, writeFile } from "node:fs/promises";
|
|
2321
2337
|
import { existsSync } from "node:fs";
|
|
2322
2338
|
import { fileURLToPath } from "node:url";
|
|
2339
|
+
import { isRealTld } from "./iana-tlds.mjs";
|
|
2323
2340
|
import { installService, removeService, serviceUnit, servicePaths, UNIT_NAME } from "./dns-service.mjs";
|
|
2324
2341
|
import {
|
|
2325
2342
|
applyPlan, daemonStatus, describePlan, detectPlatform, disablePlan, enablePlan,
|