@ai-ecoverse/slicc-kernel 1.154.3 → 1.156.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/README.md +2 -1
- package/dist/kernel-worker.js +70 -11
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +9 -2
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +70 -11
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +9 -2
- package/dist/process-worker.js.map +2 -2
- package/dist/types/kernel/net/tls-client.d.ts +2 -0
- package/dist/types/kernel/socket-syscalls.d.ts +3 -0
- package/dist/types/kernel/socket.d.ts +6 -0
- package/dist/types/process/js/js-net.d.ts +1 -0
- package/package.json +1 -1
package/dist/node.js
CHANGED
|
@@ -1895,8 +1895,8 @@ function link(a, b) {
|
|
|
1895
1895
|
pipe.openRead();
|
|
1896
1896
|
pipe.openWrite();
|
|
1897
1897
|
}
|
|
1898
|
-
a.attach({ rx: ba, tx: ab });
|
|
1899
|
-
b.attach({ rx: ab, tx: ba });
|
|
1898
|
+
a.attach({ rx: ba, tx: ab, peer: b });
|
|
1899
|
+
b.attach({ rx: ab, tx: ba, peer: a });
|
|
1900
1900
|
}
|
|
1901
1901
|
var SERVE_CHUNK = 64 * 1024;
|
|
1902
1902
|
var NEVER_ABORTED = new AbortController().signal;
|
|
@@ -1908,6 +1908,8 @@ var KernelSocket = class _KernelSocket {
|
|
|
1908
1908
|
dialing;
|
|
1909
1909
|
failed;
|
|
1910
1910
|
reset;
|
|
1911
|
+
abortive = false;
|
|
1912
|
+
refused;
|
|
1911
1913
|
local;
|
|
1912
1914
|
peer;
|
|
1913
1915
|
peerCred;
|
|
@@ -1944,20 +1946,25 @@ var KernelSocket = class _KernelSocket {
|
|
|
1944
1946
|
}
|
|
1945
1947
|
async read(max, signal) {
|
|
1946
1948
|
const { rx } = this.connection();
|
|
1949
|
+
if (this.refused) throw this.refused;
|
|
1947
1950
|
if (this.readShut || max <= 0) return new Uint8Array(0);
|
|
1948
1951
|
const bytes = await pipeCall(() => rx.read(max, signal));
|
|
1952
|
+
if (this.refused) throw this.refused;
|
|
1949
1953
|
if (bytes.length === 0 && this.reset) throw this.reset;
|
|
1950
1954
|
return bytes;
|
|
1951
1955
|
}
|
|
1952
1956
|
async peek(max, signal) {
|
|
1953
1957
|
const { rx } = this.connection();
|
|
1958
|
+
if (this.refused) throw this.refused;
|
|
1954
1959
|
if (this.readShut || max <= 0) return new Uint8Array(0);
|
|
1955
1960
|
const bytes = await pipeCall(() => rx.peek(max, signal));
|
|
1961
|
+
if (this.refused) throw this.refused;
|
|
1956
1962
|
if (bytes.length === 0 && this.reset) throw this.reset;
|
|
1957
1963
|
return bytes;
|
|
1958
1964
|
}
|
|
1959
1965
|
async write(bytes, signal) {
|
|
1960
1966
|
const { tx } = this.connection();
|
|
1967
|
+
if (this.refused) throw this.refused;
|
|
1961
1968
|
if (this.writeShut) throw new KernelError("EPIPE");
|
|
1962
1969
|
if (this.reset?.code === "EPROTO") throw this.reset;
|
|
1963
1970
|
return pipeCall(() => tx.write(bytes, signal));
|
|
@@ -2144,10 +2151,11 @@ var KernelSocket = class _KernelSocket {
|
|
|
2144
2151
|
handshaking = false;
|
|
2145
2152
|
signal.removeEventListener("abort", abandon);
|
|
2146
2153
|
}
|
|
2147
|
-
|
|
2154
|
+
const plain3 = uplinkLink(made2.conn, (err) => {
|
|
2148
2155
|
this.reset = err instanceof KernelError && err.code === "EPROTO" ? err : new KernelError("ECONNRESET");
|
|
2149
2156
|
this.changes.wake();
|
|
2150
2157
|
});
|
|
2158
|
+
this.link = { ...plain3, ...raw2.peer ? { peer: raw2.peer } : {} };
|
|
2151
2159
|
this.changes.wake();
|
|
2152
2160
|
return made2.info;
|
|
2153
2161
|
}
|
|
@@ -2265,8 +2273,22 @@ var KernelSocket = class _KernelSocket {
|
|
|
2265
2273
|
setOption(level, name2, value2) {
|
|
2266
2274
|
this.options.set(`${level}:${name2}`, value2);
|
|
2267
2275
|
}
|
|
2276
|
+
resetOnClose() {
|
|
2277
|
+
this.connection();
|
|
2278
|
+
this.abortive = true;
|
|
2279
|
+
}
|
|
2280
|
+
abort() {
|
|
2281
|
+
const link2 = this.link;
|
|
2282
|
+
if (link2.peer) link2.peer.resetBy();
|
|
2283
|
+
else link2.tx.closeRead();
|
|
2284
|
+
}
|
|
2285
|
+
resetBy() {
|
|
2286
|
+
this.refused ??= new KernelError("ECONNRESET");
|
|
2287
|
+
this.changes.wake();
|
|
2288
|
+
}
|
|
2268
2289
|
close() {
|
|
2269
2290
|
const was = this.state;
|
|
2291
|
+
if (this.abortive && was === "connected") this.abort();
|
|
2270
2292
|
this.state = "closed";
|
|
2271
2293
|
this.dialing?.abort(new KernelError("ECONNABORTED"));
|
|
2272
2294
|
this.dialing = void 0;
|
|
@@ -3566,7 +3588,7 @@ function satisfies(version, range2) {
|
|
|
3566
3588
|
}
|
|
3567
3589
|
|
|
3568
3590
|
// src/version.ts
|
|
3569
|
-
var KERNEL_VERSION = true ? "1.
|
|
3591
|
+
var KERNEL_VERSION = true ? "1.156.0" : "0.0.0-dev";
|
|
3570
3592
|
var OS_RELEASE = "6.0.0-slicc";
|
|
3571
3593
|
function procVersion() {
|
|
3572
3594
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -15361,6 +15383,7 @@ function openSession(o) {
|
|
|
15361
15383
|
var Ciphertext = class {
|
|
15362
15384
|
queue = [];
|
|
15363
15385
|
ended = false;
|
|
15386
|
+
opening = new Uint8Array(0);
|
|
15364
15387
|
conn;
|
|
15365
15388
|
session;
|
|
15366
15389
|
constructor(conn, session) {
|
|
@@ -15369,11 +15392,19 @@ var Ciphertext = class {
|
|
|
15369
15392
|
}
|
|
15370
15393
|
hand(bytes) {
|
|
15371
15394
|
if (bytes.length > 0) this.queue.push(bytes);
|
|
15395
|
+
this.note(bytes);
|
|
15396
|
+
}
|
|
15397
|
+
note(bytes) {
|
|
15398
|
+
if (this.opening.length >= OPENING) return;
|
|
15399
|
+
const next3 = new Uint8Array(Math.min(OPENING, this.opening.length + bytes.length));
|
|
15400
|
+
next3.set(this.opening);
|
|
15401
|
+
next3.set(bytes.subarray(0, next3.length - this.opening.length), this.opening.length);
|
|
15402
|
+
this.opening = next3;
|
|
15372
15403
|
}
|
|
15373
15404
|
async more() {
|
|
15374
15405
|
if (this.queue.length === 0 && !this.ended) {
|
|
15375
15406
|
const bytes = await this.conn.read();
|
|
15376
|
-
if (bytes) this.
|
|
15407
|
+
if (bytes) this.hand(bytes);
|
|
15377
15408
|
else this.ended = true;
|
|
15378
15409
|
}
|
|
15379
15410
|
if (this.queue.length === 0) {
|
|
@@ -15403,11 +15434,38 @@ async function send(conn, session) {
|
|
|
15403
15434
|
}
|
|
15404
15435
|
}
|
|
15405
15436
|
}
|
|
15406
|
-
|
|
15437
|
+
var OPENING = 6;
|
|
15438
|
+
var PLAIN_MAX = 16384;
|
|
15439
|
+
var ENCRYPTED_MAX = PLAIN_MAX + 320;
|
|
15440
|
+
var HTTP_METHODS = ["GET ", "POST ", "HEAD ", "PUT ", "PATCH", "OPTIO", "DELET", "TRACE"];
|
|
15441
|
+
function headerClass(head) {
|
|
15442
|
+
const [type, major, minor, hi, lo] = head;
|
|
15443
|
+
if (major === 0 && minor === 2) return ["ERR_SSL_WRONG_VERSION_NUMBER", "wrong version number"];
|
|
15444
|
+
const length2 = hi << 8 | lo;
|
|
15445
|
+
if (length2 > ENCRYPTED_MAX) return ["ERR_SSL_PACKET_LENGTH_TOO_LONG", "packet length too long"];
|
|
15446
|
+
if (major !== 3) {
|
|
15447
|
+
const text = new TextDecoder("latin1").decode(head.subarray(0, 5));
|
|
15448
|
+
if (HTTP_METHODS.some((m) => text.startsWith(m)))
|
|
15449
|
+
return ["ERR_SSL_HTTP_REQUEST", "http request"];
|
|
15450
|
+
return ["ERR_SSL_WRONG_VERSION_NUMBER", "wrong version number"];
|
|
15451
|
+
}
|
|
15452
|
+
if (length2 > PLAIN_MAX) return ["ERR_SSL_DATA_LENGTH_TOO_LONG", "data length too long"];
|
|
15453
|
+
if (type === 22 && head.length > 5 && head[5] !== 2)
|
|
15454
|
+
return ["ERR_SSL_UNEXPECTED_MESSAGE", "unexpected message"];
|
|
15455
|
+
return void 0;
|
|
15456
|
+
}
|
|
15457
|
+
function recordRefusal(opening2) {
|
|
15458
|
+
if (opening2.length < 5) return void 0;
|
|
15459
|
+
const found = headerClass(opening2);
|
|
15460
|
+
return found && new KernelError("EPROTO", `${found[0]}: ${found[1]}`);
|
|
15461
|
+
}
|
|
15462
|
+
function refused2(engine, session, err, opening2) {
|
|
15407
15463
|
const flags2 = session.verifyResult;
|
|
15408
15464
|
const code = verifyCode(flags2);
|
|
15409
15465
|
if (code && flags2 !== -1)
|
|
15410
15466
|
return new KernelError("EPROTO", `${code}: ${engine.verifyInfo(flags2).trim()}`);
|
|
15467
|
+
const record2 = recordRefusal(opening2);
|
|
15468
|
+
if (record2) return record2;
|
|
15411
15469
|
const text = err instanceof TlsError ? err.message : String(err);
|
|
15412
15470
|
return new KernelError("EPROTO", `ERR_SSL_HANDSHAKE_FAILURE: ${text}${alertOf(session)}`);
|
|
15413
15471
|
}
|
|
@@ -15422,15 +15480,12 @@ async function handshake(conn, o, session, inbox) {
|
|
|
15422
15480
|
done4 = session.handshake();
|
|
15423
15481
|
} catch (err) {
|
|
15424
15482
|
await send(conn, session).catch(() => void 0);
|
|
15425
|
-
throw refused2(o.engine, session, err);
|
|
15483
|
+
throw refused2(o.engine, session, err, inbox.opening);
|
|
15426
15484
|
}
|
|
15427
15485
|
await send(conn, session);
|
|
15428
15486
|
if (done4) return;
|
|
15429
15487
|
if (!await inbox.more()) {
|
|
15430
|
-
throw new KernelError(
|
|
15431
|
-
"ECONNRESET",
|
|
15432
|
-
"the server closed the connection during the TLS handshake"
|
|
15433
|
-
);
|
|
15488
|
+
throw recordRefusal(inbox.opening) ?? new KernelError("ECONNRESET", "the server closed the connection during the TLS handshake");
|
|
15434
15489
|
}
|
|
15435
15490
|
}
|
|
15436
15491
|
}
|
|
@@ -19188,6 +19243,7 @@ var SOCKET_OPS = [
|
|
|
19188
19243
|
"sock-accept",
|
|
19189
19244
|
"sock-connect",
|
|
19190
19245
|
"sock-shutdown",
|
|
19246
|
+
"sock-reset",
|
|
19191
19247
|
"sock-name",
|
|
19192
19248
|
"sock-getopt",
|
|
19193
19249
|
"sock-setopt",
|
|
@@ -19255,6 +19311,9 @@ async function socketSyscall(req, proc) {
|
|
|
19255
19311
|
case "sock-shutdown":
|
|
19256
19312
|
anySocketAt(fds, req.fd).shutdown(req.how);
|
|
19257
19313
|
return ok3();
|
|
19314
|
+
case "sock-reset":
|
|
19315
|
+
socketAt(fds, req.fd).resetOnClose();
|
|
19316
|
+
return ok3();
|
|
19258
19317
|
case "sock-name": {
|
|
19259
19318
|
const socket = anySocketAt(fds, req.fd);
|
|
19260
19319
|
const addr = req.peer ? socket.peer : socket.local;
|