@alwith/module-computer 0.1.0 → 0.1.2
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/proxy/stdio.mjs +18 -9
- package/rust/Cargo.lock +1 -1
- package/rust/Cargo.toml +1 -1
package/package.json
CHANGED
package/proxy/stdio.mjs
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
// A byte-only stdio carrier. Authentication and all scheduling live in the native host.
|
|
2
|
-
import { connect } from
|
|
3
|
-
const [address, token] = process.argv.slice(2)
|
|
4
|
-
if (!address || !token || !/^127\.0\.0\.1:\d+$/.test(address)) throw new Error(
|
|
5
|
-
const socket = connect({host:
|
|
6
|
-
socket.on(
|
|
7
|
-
socket.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import { connect } from "node:net"
|
|
3
|
+
const [address, token] = process.argv.slice(2)
|
|
4
|
+
if (!address || !token || !/^127\.0\.0\.1:\d+$/.test(address)) throw new Error("Invalid computer gateway address")
|
|
5
|
+
const socket = connect({ host: "127.0.0.1", port: Number(address.split(":")[1]) })
|
|
6
|
+
socket.on("connect", () => {
|
|
7
|
+
socket.write(`${token}\n`)
|
|
8
|
+
process.stdin.pipe(socket)
|
|
9
|
+
socket.pipe(process.stdout)
|
|
10
|
+
})
|
|
11
|
+
socket.on("error", () => {
|
|
12
|
+
process.exitCode = 1
|
|
13
|
+
process.stdin.destroy()
|
|
14
|
+
})
|
|
15
|
+
socket.on("close", () => {
|
|
16
|
+
process.stdin.destroy()
|
|
17
|
+
})
|
|
18
|
+
process.stdin.on("end", () => socket.destroy())
|
|
19
|
+
process.stdout.on("error", () => socket.destroy())
|
package/rust/Cargo.lock
CHANGED