@fungi.computer/spore 0.0.0-stage → 0.1.1

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.
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Preloaded into the computerd 0.2.1 daemon that Fungi Local starts for an
3
+ * attached folder. computerd binds 0.0.0.0 with no option to change it; its
4
+ * RPC runs commands as this user, so it must never be reachable from the
5
+ * network. Rebind every listener that asks for all interfaces to loopback.
6
+ * Remove this once computerd accepts a listen host.
7
+ */
8
+ "use strict";
9
+ const net = require("node:net");
10
+
11
+ // computerd calls listen(port, "0.0.0.0", callback).
12
+ const listen = net.Server.prototype.listen;
13
+ net.Server.prototype.listen = function loopbackListen(...args) {
14
+ if (args[1] === "0.0.0.0") args[1] = "127.0.0.1";
15
+ return listen.apply(this, args);
16
+ };