@dolthub/doltlite-wasm 0.50.2 → 0.50.3
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/LICENSE.md +28 -19
- package/package.json +1 -1
- package/sqlite3-bundler-friendly.mjs +11 -1182
- package/sqlite3-node.mjs +11 -1232
- package/sqlite3.mjs +11 -1182
- package/sqlite3.wasm +0 -0
|
@@ -342,7 +342,6 @@ if (!Module['noFSInit'] && !FS.initialized)
|
|
|
342
342
|
FS.ignorePermissions = false;
|
|
343
343
|
|
|
344
344
|
TTY.init();
|
|
345
|
-
SOCKFS.root = FS.mount(SOCKFS, {}, null);
|
|
346
345
|
callRuntimeCallbacks(__ATINIT__);
|
|
347
346
|
}
|
|
348
347
|
|
|
@@ -618,6 +617,11 @@ async function createWasm() {
|
|
|
618
617
|
// include: runtime_debug.js
|
|
619
618
|
// end include: runtime_debug.js
|
|
620
619
|
// === Body ===
|
|
620
|
+
|
|
621
|
+
function doltliteWasmHttpSend(zUrl,zMethod,zAuth,pBody,nBody,timeoutMs) { var st = Module.__doltliteHttp || (Module.__doltliteHttp = {}); st.resp = null; var url = UTF8ToString(zUrl); var method = UTF8ToString(zMethod); var auth = zAuth ? UTF8ToString(zAuth) : ""; var body = null; if (nBody > 0) { body = new Uint8Array(nBody); body.set(HEAPU8.subarray(pBody, pBody + nBody)); } try { if (typeof XMLHttpRequest !== "undefined") { var xhr = new XMLHttpRequest(); xhr.open(method, url, false); var binaryString = false; try { xhr.responseType = "arraybuffer"; } catch (e) { binaryString = true; } if (xhr.responseType !== "arraybuffer") binaryString = true; if (binaryString && xhr.overrideMimeType) { xhr.overrideMimeType("text/plain; charset=x-user-defined"); } if (auth) xhr.setRequestHeader("Authorization", auth); if (body) xhr.setRequestHeader("Content-Type", "application/octet-stream"); xhr.send(body); if (binaryString) { var text = xhr.responseText || ""; var out = new Uint8Array(text.length); for (var i = 0; i < text.length; i++) out[i] = text.charCodeAt(i) & 0xff; st.resp = out; } else { st.resp = xhr.response ? new Uint8Array(xhr.response) : new Uint8Array(0); } return xhr.status; } if (typeof require === "function" && typeof SharedArrayBuffer !== "undefined") { if (!st.node) { var wt = require("node:worker_threads"); var src = [ "const { workerData } = require('node:worker_threads');", "const ctl = new Int32Array(workerData.ctl);", "const req = workerData.req;", "const data = workerData.data;", "const dec = new TextDecoder();", "(async function(){ for(;;){", " Atomics.wait(ctl, 0, 0);", " if(Atomics.load(ctl,0) !== 1) continue;", " let status = 0, len = 0, over = 0, bad = 0;", " try {", " const nj = Atomics.load(ctl,4), nb = Atomics.load(ctl,5);", " const spec = JSON.parse(dec.decode(new Uint8Array(req, 0, nj)));", " const opt = { method: spec.method };", " if(spec.timeoutMs > 0 && typeof AbortSignal !== 'undefined'", " && AbortSignal.timeout) opt.signal = AbortSignal.timeout(spec.timeoutMs);", " if(spec.auth) opt.headers = { Authorization: spec.auth };", " if(nb > 0){", " opt.body = Buffer.from(new Uint8Array(req, nj, nb));", " opt.headers = Object.assign({}, opt.headers, {'Content-Type':'application/octet-stream'});", " }", " const r = await fetch(spec.url, opt);", " status = r.status;", " const b = new Uint8Array(await r.arrayBuffer());", " len = b.length;", " if(len > data.byteLength){ over = 1; }", " else { new Uint8Array(data).set(b); }", " } catch(e){ bad = 1; }", " Atomics.store(ctl,1,status); Atomics.store(ctl,2,len);", " Atomics.store(ctl,3,bad); Atomics.store(ctl,6,over);", " Atomics.store(ctl,0,2); Atomics.notify(ctl,0);", "} })();" ].join("\n"); var ctlSab = new SharedArrayBuffer(32); st.node = { ctl: new Int32Array(ctlSab), ctlSab: ctlSab, req: new SharedArrayBuffer(8 * 1024 * 1024), data: new SharedArrayBuffer(8 * 1024 * 1024), src: src, wt: wt }; st.node.worker = new wt.Worker(src, { eval: true, workerData: { ctl: ctlSab, req: st.node.req, data: st.node.data } }); st.node.worker.unref(); } var n = st.node; for (;;) { var spec = JSON.stringify({ url: url, method: method, auth: auth, timeoutMs: timeoutMs }); var enc = new TextEncoder().encode(spec); if (enc.length + (body ? body.length : 0) > n.req.byteLength) return 0; new Uint8Array(n.req).set(enc, 0); if (body) new Uint8Array(n.req).set(body, enc.length); Atomics.store(n.ctl, 4, enc.length); Atomics.store(n.ctl, 5, body ? body.length : 0); Atomics.store(n.ctl, 6, 0); Atomics.store(n.ctl, 0, 1); Atomics.notify(n.ctl, 0); Atomics.wait(n.ctl, 0, 1); var over = Atomics.load(n.ctl, 6); var need = Atomics.load(n.ctl, 2); var bad = Atomics.load(n.ctl, 3); var status = Atomics.load(n.ctl, 1); Atomics.store(n.ctl, 0, 0); if (over) { var grow = n.data.byteLength; while (grow < need) grow *= 2; n.data = new SharedArrayBuffer(grow); n.worker.terminate(); n.worker = new n.wt.Worker(n.src, { eval: true, workerData: { ctl: n.ctlSab, req: n.req, data: n.data } }); n.worker.unref(); continue; } if (bad) return 0; st.resp = new Uint8Array(need); st.resp.set(new Uint8Array(n.data, 0, need)); return status; } } } catch (e) { st.resp = null; return 0; } return 0; }
|
|
622
|
+
function doltliteWasmHttpRespLen() { var st = Module.__doltliteHttp; return (st && st.resp) ? st.resp.length : 0; }
|
|
623
|
+
function doltliteWasmHttpRespTake(pDest) { var st = Module.__doltliteHttp; if (st && st.resp) HEAPU8.set(st.resp, pDest); if (st) st.resp = null; }
|
|
624
|
+
|
|
621
625
|
// end include: preamble.js
|
|
622
626
|
|
|
623
627
|
|
|
@@ -3212,865 +3216,6 @@ async function createWasm() {
|
|
|
3212
3216
|
}
|
|
3213
3217
|
}
|
|
3214
3218
|
|
|
3215
|
-
var SOCKFS = {
|
|
3216
|
-
websocketArgs:{
|
|
3217
|
-
},
|
|
3218
|
-
callbacks:{
|
|
3219
|
-
},
|
|
3220
|
-
on(event, callback) {
|
|
3221
|
-
SOCKFS.callbacks[event] = callback;
|
|
3222
|
-
},
|
|
3223
|
-
emit(event, param) {
|
|
3224
|
-
SOCKFS.callbacks[event]?.(param);
|
|
3225
|
-
},
|
|
3226
|
-
mount(mount) {
|
|
3227
|
-
// The incomming Module['websocket'] can be used for configuring
|
|
3228
|
-
// configuring subprotocol/url, etc
|
|
3229
|
-
SOCKFS.websocketArgs = Module['websocket'] || {};
|
|
3230
|
-
// Add the Event registration mechanism to the exported websocket configuration
|
|
3231
|
-
// object so we can register network callbacks from native JavaScript too.
|
|
3232
|
-
// For more documentation see system/include/emscripten/emscripten.h
|
|
3233
|
-
(Module['websocket'] ??= {})['on'] = SOCKFS.on;
|
|
3234
|
-
|
|
3235
|
-
return FS.createNode(null, '/', 16895, 0);
|
|
3236
|
-
},
|
|
3237
|
-
createSocket(family, type, protocol) {
|
|
3238
|
-
type &= ~526336; // Some applications may pass it; it makes no sense for a single process.
|
|
3239
|
-
var streaming = type == 1;
|
|
3240
|
-
if (streaming && protocol && protocol != 6) {
|
|
3241
|
-
throw new FS.ErrnoError(66); // if SOCK_STREAM, must be tcp or 0.
|
|
3242
|
-
}
|
|
3243
|
-
|
|
3244
|
-
// create our internal socket structure
|
|
3245
|
-
var sock = {
|
|
3246
|
-
family,
|
|
3247
|
-
type,
|
|
3248
|
-
protocol,
|
|
3249
|
-
server: null,
|
|
3250
|
-
error: null, // Used in getsockopt for SOL_SOCKET/SO_ERROR test
|
|
3251
|
-
peers: {},
|
|
3252
|
-
pending: [],
|
|
3253
|
-
recv_queue: [],
|
|
3254
|
-
sock_ops: SOCKFS.websocket_sock_ops
|
|
3255
|
-
};
|
|
3256
|
-
|
|
3257
|
-
// create the filesystem node to store the socket structure
|
|
3258
|
-
var name = SOCKFS.nextname();
|
|
3259
|
-
var node = FS.createNode(SOCKFS.root, name, 49152, 0);
|
|
3260
|
-
node.sock = sock;
|
|
3261
|
-
|
|
3262
|
-
// and the wrapping stream that enables library functions such
|
|
3263
|
-
// as read and write to indirectly interact with the socket
|
|
3264
|
-
var stream = FS.createStream({
|
|
3265
|
-
path: name,
|
|
3266
|
-
node,
|
|
3267
|
-
flags: 2,
|
|
3268
|
-
seekable: false,
|
|
3269
|
-
stream_ops: SOCKFS.stream_ops
|
|
3270
|
-
});
|
|
3271
|
-
|
|
3272
|
-
// map the new stream to the socket structure (sockets have a 1:1
|
|
3273
|
-
// relationship with a stream)
|
|
3274
|
-
sock.stream = stream;
|
|
3275
|
-
|
|
3276
|
-
return sock;
|
|
3277
|
-
},
|
|
3278
|
-
getSocket(fd) {
|
|
3279
|
-
var stream = FS.getStream(fd);
|
|
3280
|
-
if (!stream || !FS.isSocket(stream.node.mode)) {
|
|
3281
|
-
return null;
|
|
3282
|
-
}
|
|
3283
|
-
return stream.node.sock;
|
|
3284
|
-
},
|
|
3285
|
-
stream_ops:{
|
|
3286
|
-
poll(stream) {
|
|
3287
|
-
var sock = stream.node.sock;
|
|
3288
|
-
return sock.sock_ops.poll(sock);
|
|
3289
|
-
},
|
|
3290
|
-
ioctl(stream, request, varargs) {
|
|
3291
|
-
var sock = stream.node.sock;
|
|
3292
|
-
return sock.sock_ops.ioctl(sock, request, varargs);
|
|
3293
|
-
},
|
|
3294
|
-
read(stream, buffer, offset, length, position /* ignored */) {
|
|
3295
|
-
var sock = stream.node.sock;
|
|
3296
|
-
var msg = sock.sock_ops.recvmsg(sock, length);
|
|
3297
|
-
if (!msg) {
|
|
3298
|
-
// socket is closed
|
|
3299
|
-
return 0;
|
|
3300
|
-
}
|
|
3301
|
-
buffer.set(msg.buffer, offset);
|
|
3302
|
-
return msg.buffer.length;
|
|
3303
|
-
},
|
|
3304
|
-
write(stream, buffer, offset, length, position /* ignored */) {
|
|
3305
|
-
var sock = stream.node.sock;
|
|
3306
|
-
return sock.sock_ops.sendmsg(sock, buffer, offset, length);
|
|
3307
|
-
},
|
|
3308
|
-
close(stream) {
|
|
3309
|
-
var sock = stream.node.sock;
|
|
3310
|
-
sock.sock_ops.close(sock);
|
|
3311
|
-
},
|
|
3312
|
-
},
|
|
3313
|
-
nextname() {
|
|
3314
|
-
if (!SOCKFS.nextname.current) {
|
|
3315
|
-
SOCKFS.nextname.current = 0;
|
|
3316
|
-
}
|
|
3317
|
-
return `socket[${SOCKFS.nextname.current++}]`;
|
|
3318
|
-
},
|
|
3319
|
-
websocket_sock_ops:{
|
|
3320
|
-
createPeer(sock, addr, port) {
|
|
3321
|
-
var ws;
|
|
3322
|
-
|
|
3323
|
-
if (typeof addr == 'object') {
|
|
3324
|
-
ws = addr;
|
|
3325
|
-
addr = null;
|
|
3326
|
-
port = null;
|
|
3327
|
-
}
|
|
3328
|
-
|
|
3329
|
-
if (ws) {
|
|
3330
|
-
// for sockets that've already connected (e.g. we're the server)
|
|
3331
|
-
// we can inspect the _socket property for the address
|
|
3332
|
-
if (ws._socket) {
|
|
3333
|
-
addr = ws._socket.remoteAddress;
|
|
3334
|
-
port = ws._socket.remotePort;
|
|
3335
|
-
}
|
|
3336
|
-
// if we're just now initializing a connection to the remote,
|
|
3337
|
-
// inspect the url property
|
|
3338
|
-
else {
|
|
3339
|
-
var result = /ws[s]?:\/\/([^:]+):(\d+)/.exec(ws.url);
|
|
3340
|
-
if (!result) {
|
|
3341
|
-
throw new Error('WebSocket URL must be in the format ws(s)://address:port');
|
|
3342
|
-
}
|
|
3343
|
-
addr = result[1];
|
|
3344
|
-
port = parseInt(result[2], 10);
|
|
3345
|
-
}
|
|
3346
|
-
} else {
|
|
3347
|
-
// create the actual websocket object and connect
|
|
3348
|
-
try {
|
|
3349
|
-
// The default value is 'ws://' the replace is needed because the compiler replaces '//' comments with '#'
|
|
3350
|
-
// comments without checking context, so we'd end up with ws:#, the replace swaps the '#' for '//' again.
|
|
3351
|
-
var url = 'ws:#'.replace('#', '//');
|
|
3352
|
-
// Make the WebSocket subprotocol (Sec-WebSocket-Protocol) default to binary if no configuration is set.
|
|
3353
|
-
var subProtocols = 'binary'; // The default value is 'binary'
|
|
3354
|
-
// The default WebSocket options
|
|
3355
|
-
var opts = undefined;
|
|
3356
|
-
|
|
3357
|
-
// Fetch runtime WebSocket URL config.
|
|
3358
|
-
if (SOCKFS.websocketArgs['url']) {
|
|
3359
|
-
url = SOCKFS.websocketArgs['url'];
|
|
3360
|
-
}
|
|
3361
|
-
// Fetch runtime WebSocket subprotocol config.
|
|
3362
|
-
if (SOCKFS.websocketArgs['subprotocol']) {
|
|
3363
|
-
subProtocols = SOCKFS.websocketArgs['subprotocol'];
|
|
3364
|
-
} else if (SOCKFS.websocketArgs['subprotocol'] === null) {
|
|
3365
|
-
subProtocols = 'null'
|
|
3366
|
-
}
|
|
3367
|
-
|
|
3368
|
-
if (url === 'ws://' || url === 'wss://') { // Is the supplied URL config just a prefix, if so complete it.
|
|
3369
|
-
var parts = addr.split('/');
|
|
3370
|
-
url = url + parts[0] + ":" + port + "/" + parts.slice(1).join('/');
|
|
3371
|
-
}
|
|
3372
|
-
|
|
3373
|
-
if (subProtocols !== 'null') {
|
|
3374
|
-
// The regex trims the string (removes spaces at the beginning and end, then splits the string by
|
|
3375
|
-
// <any space>,<any space> into an Array. Whitespace removal is important for Websockify and ws.
|
|
3376
|
-
subProtocols = subProtocols.replace(/^ +| +$/g,"").split(/ *, */);
|
|
3377
|
-
|
|
3378
|
-
opts = subProtocols;
|
|
3379
|
-
}
|
|
3380
|
-
|
|
3381
|
-
// If node we use the ws library.
|
|
3382
|
-
var WebSocketConstructor;
|
|
3383
|
-
{
|
|
3384
|
-
WebSocketConstructor = WebSocket;
|
|
3385
|
-
}
|
|
3386
|
-
ws = new WebSocketConstructor(url, opts);
|
|
3387
|
-
ws.binaryType = 'arraybuffer';
|
|
3388
|
-
} catch (e) {
|
|
3389
|
-
throw new FS.ErrnoError(23);
|
|
3390
|
-
}
|
|
3391
|
-
}
|
|
3392
|
-
|
|
3393
|
-
var peer = {
|
|
3394
|
-
addr,
|
|
3395
|
-
port,
|
|
3396
|
-
socket: ws,
|
|
3397
|
-
msg_send_queue: []
|
|
3398
|
-
};
|
|
3399
|
-
|
|
3400
|
-
SOCKFS.websocket_sock_ops.addPeer(sock, peer);
|
|
3401
|
-
SOCKFS.websocket_sock_ops.handlePeerEvents(sock, peer);
|
|
3402
|
-
|
|
3403
|
-
// if this is a bound dgram socket, send the port number first to allow
|
|
3404
|
-
// us to override the ephemeral port reported to us by remotePort on the
|
|
3405
|
-
// remote end.
|
|
3406
|
-
if (sock.type === 2 && typeof sock.sport != 'undefined') {
|
|
3407
|
-
peer.msg_send_queue.push(new Uint8Array([
|
|
3408
|
-
255, 255, 255, 255,
|
|
3409
|
-
'p'.charCodeAt(0), 'o'.charCodeAt(0), 'r'.charCodeAt(0), 't'.charCodeAt(0),
|
|
3410
|
-
((sock.sport & 0xff00) >> 8) , (sock.sport & 0xff)
|
|
3411
|
-
]));
|
|
3412
|
-
}
|
|
3413
|
-
|
|
3414
|
-
return peer;
|
|
3415
|
-
},
|
|
3416
|
-
getPeer(sock, addr, port) {
|
|
3417
|
-
return sock.peers[addr + ':' + port];
|
|
3418
|
-
},
|
|
3419
|
-
addPeer(sock, peer) {
|
|
3420
|
-
sock.peers[peer.addr + ':' + peer.port] = peer;
|
|
3421
|
-
},
|
|
3422
|
-
removePeer(sock, peer) {
|
|
3423
|
-
delete sock.peers[peer.addr + ':' + peer.port];
|
|
3424
|
-
},
|
|
3425
|
-
handlePeerEvents(sock, peer) {
|
|
3426
|
-
var first = true;
|
|
3427
|
-
|
|
3428
|
-
var handleOpen = function () {
|
|
3429
|
-
|
|
3430
|
-
sock.connecting = false;
|
|
3431
|
-
SOCKFS.emit('open', sock.stream.fd);
|
|
3432
|
-
|
|
3433
|
-
try {
|
|
3434
|
-
var queued = peer.msg_send_queue.shift();
|
|
3435
|
-
while (queued) {
|
|
3436
|
-
peer.socket.send(queued);
|
|
3437
|
-
queued = peer.msg_send_queue.shift();
|
|
3438
|
-
}
|
|
3439
|
-
} catch (e) {
|
|
3440
|
-
// not much we can do here in the way of proper error handling as we've already
|
|
3441
|
-
// lied and said this data was sent. shut it down.
|
|
3442
|
-
peer.socket.close();
|
|
3443
|
-
}
|
|
3444
|
-
};
|
|
3445
|
-
|
|
3446
|
-
function handleMessage(data) {
|
|
3447
|
-
if (typeof data == 'string') {
|
|
3448
|
-
var encoder = new TextEncoder(); // should be utf-8
|
|
3449
|
-
data = encoder.encode(data); // make a typed array from the string
|
|
3450
|
-
} else {
|
|
3451
|
-
assert(data.byteLength !== undefined); // must receive an ArrayBuffer
|
|
3452
|
-
if (data.byteLength == 0) {
|
|
3453
|
-
// An empty ArrayBuffer will emit a pseudo disconnect event
|
|
3454
|
-
// as recv/recvmsg will return zero which indicates that a socket
|
|
3455
|
-
// has performed a shutdown although the connection has not been disconnected yet.
|
|
3456
|
-
return;
|
|
3457
|
-
}
|
|
3458
|
-
data = new Uint8Array(data); // make a typed array view on the array buffer
|
|
3459
|
-
}
|
|
3460
|
-
|
|
3461
|
-
// if this is the port message, override the peer's port with it
|
|
3462
|
-
var wasfirst = first;
|
|
3463
|
-
first = false;
|
|
3464
|
-
if (wasfirst &&
|
|
3465
|
-
data.length === 10 &&
|
|
3466
|
-
data[0] === 255 && data[1] === 255 && data[2] === 255 && data[3] === 255 &&
|
|
3467
|
-
data[4] === 'p'.charCodeAt(0) && data[5] === 'o'.charCodeAt(0) && data[6] === 'r'.charCodeAt(0) && data[7] === 't'.charCodeAt(0)) {
|
|
3468
|
-
// update the peer's port and it's key in the peer map
|
|
3469
|
-
var newport = ((data[8] << 8) | data[9]);
|
|
3470
|
-
SOCKFS.websocket_sock_ops.removePeer(sock, peer);
|
|
3471
|
-
peer.port = newport;
|
|
3472
|
-
SOCKFS.websocket_sock_ops.addPeer(sock, peer);
|
|
3473
|
-
return;
|
|
3474
|
-
}
|
|
3475
|
-
|
|
3476
|
-
sock.recv_queue.push({ addr: peer.addr, port: peer.port, data: data });
|
|
3477
|
-
SOCKFS.emit('message', sock.stream.fd);
|
|
3478
|
-
};
|
|
3479
|
-
|
|
3480
|
-
if (ENVIRONMENT_IS_NODE) {
|
|
3481
|
-
peer.socket.on('open', handleOpen);
|
|
3482
|
-
peer.socket.on('message', function(data, isBinary) {
|
|
3483
|
-
if (!isBinary) {
|
|
3484
|
-
return;
|
|
3485
|
-
}
|
|
3486
|
-
handleMessage((new Uint8Array(data)).buffer); // copy from node Buffer -> ArrayBuffer
|
|
3487
|
-
});
|
|
3488
|
-
peer.socket.on('close', function() {
|
|
3489
|
-
SOCKFS.emit('close', sock.stream.fd);
|
|
3490
|
-
});
|
|
3491
|
-
peer.socket.on('error', function(error) {
|
|
3492
|
-
// Although the ws library may pass errors that may be more descriptive than
|
|
3493
|
-
// ECONNREFUSED they are not necessarily the expected error code e.g.
|
|
3494
|
-
// ENOTFOUND on getaddrinfo seems to be node.js specific, so using ECONNREFUSED
|
|
3495
|
-
// is still probably the most useful thing to do.
|
|
3496
|
-
sock.error = 14; // Used in getsockopt for SOL_SOCKET/SO_ERROR test.
|
|
3497
|
-
SOCKFS.emit('error', [sock.stream.fd, sock.error, 'ECONNREFUSED: Connection refused']);
|
|
3498
|
-
// don't throw
|
|
3499
|
-
});
|
|
3500
|
-
} else {
|
|
3501
|
-
peer.socket.onopen = handleOpen;
|
|
3502
|
-
peer.socket.onclose = function() {
|
|
3503
|
-
SOCKFS.emit('close', sock.stream.fd);
|
|
3504
|
-
};
|
|
3505
|
-
peer.socket.onmessage = function peer_socket_onmessage(event) {
|
|
3506
|
-
handleMessage(event.data);
|
|
3507
|
-
};
|
|
3508
|
-
peer.socket.onerror = function(error) {
|
|
3509
|
-
// The WebSocket spec only allows a 'simple event' to be thrown on error,
|
|
3510
|
-
// so we only really know as much as ECONNREFUSED.
|
|
3511
|
-
sock.error = 14; // Used in getsockopt for SOL_SOCKET/SO_ERROR test.
|
|
3512
|
-
SOCKFS.emit('error', [sock.stream.fd, sock.error, 'ECONNREFUSED: Connection refused']);
|
|
3513
|
-
};
|
|
3514
|
-
}
|
|
3515
|
-
},
|
|
3516
|
-
poll(sock) {
|
|
3517
|
-
if (sock.type === 1 && sock.server) {
|
|
3518
|
-
// listen sockets should only say they're available for reading
|
|
3519
|
-
// if there are pending clients.
|
|
3520
|
-
return sock.pending.length ? (64 | 1) : 0;
|
|
3521
|
-
}
|
|
3522
|
-
|
|
3523
|
-
var mask = 0;
|
|
3524
|
-
var dest = sock.type === 1 ? // we only care about the socket state for connection-based sockets
|
|
3525
|
-
SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport) :
|
|
3526
|
-
null;
|
|
3527
|
-
|
|
3528
|
-
if (sock.recv_queue.length ||
|
|
3529
|
-
!dest || // connection-less sockets are always ready to read
|
|
3530
|
-
(dest && dest.socket.readyState === dest.socket.CLOSING) ||
|
|
3531
|
-
(dest && dest.socket.readyState === dest.socket.CLOSED)) { // let recv return 0 once closed
|
|
3532
|
-
mask |= (64 | 1);
|
|
3533
|
-
}
|
|
3534
|
-
|
|
3535
|
-
if (!dest || // connection-less sockets are always ready to write
|
|
3536
|
-
(dest && dest.socket.readyState === dest.socket.OPEN)) {
|
|
3537
|
-
mask |= 4;
|
|
3538
|
-
}
|
|
3539
|
-
|
|
3540
|
-
if ((dest && dest.socket.readyState === dest.socket.CLOSING) ||
|
|
3541
|
-
(dest && dest.socket.readyState === dest.socket.CLOSED)) {
|
|
3542
|
-
// When an non-blocking connect fails mark the socket as writable.
|
|
3543
|
-
// Its up to the calling code to then use getsockopt with SO_ERROR to
|
|
3544
|
-
// retrieve the error.
|
|
3545
|
-
// See https://man7.org/linux/man-pages/man2/connect.2.html
|
|
3546
|
-
if (sock.connecting) {
|
|
3547
|
-
mask |= 4;
|
|
3548
|
-
} else {
|
|
3549
|
-
mask |= 16;
|
|
3550
|
-
}
|
|
3551
|
-
}
|
|
3552
|
-
|
|
3553
|
-
return mask;
|
|
3554
|
-
},
|
|
3555
|
-
ioctl(sock, request, arg) {
|
|
3556
|
-
switch (request) {
|
|
3557
|
-
case 21531:
|
|
3558
|
-
var bytes = 0;
|
|
3559
|
-
if (sock.recv_queue.length) {
|
|
3560
|
-
bytes = sock.recv_queue[0].data.length;
|
|
3561
|
-
}
|
|
3562
|
-
HEAP32[((arg)>>2)] = bytes;
|
|
3563
|
-
return 0;
|
|
3564
|
-
default:
|
|
3565
|
-
return 28;
|
|
3566
|
-
}
|
|
3567
|
-
},
|
|
3568
|
-
close(sock) {
|
|
3569
|
-
// if we've spawned a listen server, close it
|
|
3570
|
-
if (sock.server) {
|
|
3571
|
-
try {
|
|
3572
|
-
sock.server.close();
|
|
3573
|
-
} catch (e) {
|
|
3574
|
-
}
|
|
3575
|
-
sock.server = null;
|
|
3576
|
-
}
|
|
3577
|
-
// close any peer connections
|
|
3578
|
-
var peers = Object.keys(sock.peers);
|
|
3579
|
-
for (var i = 0; i < peers.length; i++) {
|
|
3580
|
-
var peer = sock.peers[peers[i]];
|
|
3581
|
-
try {
|
|
3582
|
-
peer.socket.close();
|
|
3583
|
-
} catch (e) {
|
|
3584
|
-
}
|
|
3585
|
-
SOCKFS.websocket_sock_ops.removePeer(sock, peer);
|
|
3586
|
-
}
|
|
3587
|
-
return 0;
|
|
3588
|
-
},
|
|
3589
|
-
bind(sock, addr, port) {
|
|
3590
|
-
if (typeof sock.saddr != 'undefined' || typeof sock.sport != 'undefined') {
|
|
3591
|
-
throw new FS.ErrnoError(28); // already bound
|
|
3592
|
-
}
|
|
3593
|
-
sock.saddr = addr;
|
|
3594
|
-
sock.sport = port;
|
|
3595
|
-
// in order to emulate dgram sockets, we need to launch a listen server when
|
|
3596
|
-
// binding on a connection-less socket
|
|
3597
|
-
// note: this is only required on the server side
|
|
3598
|
-
if (sock.type === 2) {
|
|
3599
|
-
// close the existing server if it exists
|
|
3600
|
-
if (sock.server) {
|
|
3601
|
-
sock.server.close();
|
|
3602
|
-
sock.server = null;
|
|
3603
|
-
}
|
|
3604
|
-
// swallow error operation not supported error that occurs when binding in the
|
|
3605
|
-
// browser where this isn't supported
|
|
3606
|
-
try {
|
|
3607
|
-
sock.sock_ops.listen(sock, 0);
|
|
3608
|
-
} catch (e) {
|
|
3609
|
-
if (!(e.name === 'ErrnoError')) throw e;
|
|
3610
|
-
if (e.errno !== 138) throw e;
|
|
3611
|
-
}
|
|
3612
|
-
}
|
|
3613
|
-
},
|
|
3614
|
-
connect(sock, addr, port) {
|
|
3615
|
-
if (sock.server) {
|
|
3616
|
-
throw new FS.ErrnoError(138);
|
|
3617
|
-
}
|
|
3618
|
-
|
|
3619
|
-
// TODO autobind
|
|
3620
|
-
// if (!sock.addr && sock.type == 2) {
|
|
3621
|
-
// }
|
|
3622
|
-
|
|
3623
|
-
// early out if we're already connected / in the middle of connecting
|
|
3624
|
-
if (typeof sock.daddr != 'undefined' && typeof sock.dport != 'undefined') {
|
|
3625
|
-
var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
|
|
3626
|
-
if (dest) {
|
|
3627
|
-
if (dest.socket.readyState === dest.socket.CONNECTING) {
|
|
3628
|
-
throw new FS.ErrnoError(7);
|
|
3629
|
-
} else {
|
|
3630
|
-
throw new FS.ErrnoError(30);
|
|
3631
|
-
}
|
|
3632
|
-
}
|
|
3633
|
-
}
|
|
3634
|
-
|
|
3635
|
-
// add the socket to our peer list and set our
|
|
3636
|
-
// destination address / port to match
|
|
3637
|
-
var peer = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
|
|
3638
|
-
sock.daddr = peer.addr;
|
|
3639
|
-
sock.dport = peer.port;
|
|
3640
|
-
|
|
3641
|
-
// because we cannot synchronously block to wait for the WebSocket
|
|
3642
|
-
// connection to complete, we return here pretending that the connection
|
|
3643
|
-
// was a success.
|
|
3644
|
-
sock.connecting = true;
|
|
3645
|
-
},
|
|
3646
|
-
listen(sock, backlog) {
|
|
3647
|
-
if (!ENVIRONMENT_IS_NODE) {
|
|
3648
|
-
throw new FS.ErrnoError(138);
|
|
3649
|
-
}
|
|
3650
|
-
},
|
|
3651
|
-
accept(listensock) {
|
|
3652
|
-
if (!listensock.server || !listensock.pending.length) {
|
|
3653
|
-
throw new FS.ErrnoError(28);
|
|
3654
|
-
}
|
|
3655
|
-
var newsock = listensock.pending.shift();
|
|
3656
|
-
newsock.stream.flags = listensock.stream.flags;
|
|
3657
|
-
return newsock;
|
|
3658
|
-
},
|
|
3659
|
-
getname(sock, peer) {
|
|
3660
|
-
var addr, port;
|
|
3661
|
-
if (peer) {
|
|
3662
|
-
if (sock.daddr === undefined || sock.dport === undefined) {
|
|
3663
|
-
throw new FS.ErrnoError(53);
|
|
3664
|
-
}
|
|
3665
|
-
addr = sock.daddr;
|
|
3666
|
-
port = sock.dport;
|
|
3667
|
-
} else {
|
|
3668
|
-
// TODO saddr and sport will be set for bind()'d UDP sockets, but what
|
|
3669
|
-
// should we be returning for TCP sockets that've been connect()'d?
|
|
3670
|
-
addr = sock.saddr || 0;
|
|
3671
|
-
port = sock.sport || 0;
|
|
3672
|
-
}
|
|
3673
|
-
return { addr, port };
|
|
3674
|
-
},
|
|
3675
|
-
sendmsg(sock, buffer, offset, length, addr, port) {
|
|
3676
|
-
if (sock.type === 2) {
|
|
3677
|
-
// connection-less sockets will honor the message address,
|
|
3678
|
-
// and otherwise fall back to the bound destination address
|
|
3679
|
-
if (addr === undefined || port === undefined) {
|
|
3680
|
-
addr = sock.daddr;
|
|
3681
|
-
port = sock.dport;
|
|
3682
|
-
}
|
|
3683
|
-
// if there was no address to fall back to, error out
|
|
3684
|
-
if (addr === undefined || port === undefined) {
|
|
3685
|
-
throw new FS.ErrnoError(17);
|
|
3686
|
-
}
|
|
3687
|
-
} else {
|
|
3688
|
-
// connection-based sockets will only use the bound
|
|
3689
|
-
addr = sock.daddr;
|
|
3690
|
-
port = sock.dport;
|
|
3691
|
-
}
|
|
3692
|
-
|
|
3693
|
-
// find the peer for the destination address
|
|
3694
|
-
var dest = SOCKFS.websocket_sock_ops.getPeer(sock, addr, port);
|
|
3695
|
-
|
|
3696
|
-
// early out if not connected with a connection-based socket
|
|
3697
|
-
if (sock.type === 1) {
|
|
3698
|
-
if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
|
|
3699
|
-
throw new FS.ErrnoError(53);
|
|
3700
|
-
}
|
|
3701
|
-
}
|
|
3702
|
-
|
|
3703
|
-
// create a copy of the incoming data to send, as the WebSocket API
|
|
3704
|
-
// doesn't work entirely with an ArrayBufferView, it'll just send
|
|
3705
|
-
// the entire underlying buffer
|
|
3706
|
-
if (ArrayBuffer.isView(buffer)) {
|
|
3707
|
-
offset += buffer.byteOffset;
|
|
3708
|
-
buffer = buffer.buffer;
|
|
3709
|
-
}
|
|
3710
|
-
|
|
3711
|
-
var data = buffer.slice(offset, offset + length);
|
|
3712
|
-
|
|
3713
|
-
// if we don't have a cached connectionless UDP datagram connection, or
|
|
3714
|
-
// the TCP socket is still connecting, queue the message to be sent upon
|
|
3715
|
-
// connect, and lie, saying the data was sent now.
|
|
3716
|
-
if (!dest || dest.socket.readyState !== dest.socket.OPEN) {
|
|
3717
|
-
// if we're not connected, open a new connection
|
|
3718
|
-
if (sock.type === 2) {
|
|
3719
|
-
if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
|
|
3720
|
-
dest = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
|
|
3721
|
-
}
|
|
3722
|
-
}
|
|
3723
|
-
dest.msg_send_queue.push(data);
|
|
3724
|
-
return length;
|
|
3725
|
-
}
|
|
3726
|
-
|
|
3727
|
-
try {
|
|
3728
|
-
// send the actual data
|
|
3729
|
-
dest.socket.send(data);
|
|
3730
|
-
return length;
|
|
3731
|
-
} catch (e) {
|
|
3732
|
-
throw new FS.ErrnoError(28);
|
|
3733
|
-
}
|
|
3734
|
-
},
|
|
3735
|
-
recvmsg(sock, length) {
|
|
3736
|
-
// http://pubs.opengroup.org/onlinepubs/7908799/xns/recvmsg.html
|
|
3737
|
-
if (sock.type === 1 && sock.server) {
|
|
3738
|
-
// tcp servers should not be recv()'ing on the listen socket
|
|
3739
|
-
throw new FS.ErrnoError(53);
|
|
3740
|
-
}
|
|
3741
|
-
|
|
3742
|
-
var queued = sock.recv_queue.shift();
|
|
3743
|
-
if (!queued) {
|
|
3744
|
-
if (sock.type === 1) {
|
|
3745
|
-
var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
|
|
3746
|
-
|
|
3747
|
-
if (!dest) {
|
|
3748
|
-
// if we have a destination address but are not connected, error out
|
|
3749
|
-
throw new FS.ErrnoError(53);
|
|
3750
|
-
}
|
|
3751
|
-
if (dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
|
|
3752
|
-
// return null if the socket has closed
|
|
3753
|
-
return null;
|
|
3754
|
-
}
|
|
3755
|
-
// else, our socket is in a valid state but truly has nothing available
|
|
3756
|
-
throw new FS.ErrnoError(6);
|
|
3757
|
-
}
|
|
3758
|
-
throw new FS.ErrnoError(6);
|
|
3759
|
-
}
|
|
3760
|
-
|
|
3761
|
-
// queued.data will be an ArrayBuffer if it's unadulterated, but if it's
|
|
3762
|
-
// requeued TCP data it'll be an ArrayBufferView
|
|
3763
|
-
var queuedLength = queued.data.byteLength || queued.data.length;
|
|
3764
|
-
var queuedOffset = queued.data.byteOffset || 0;
|
|
3765
|
-
var queuedBuffer = queued.data.buffer || queued.data;
|
|
3766
|
-
var bytesRead = Math.min(length, queuedLength);
|
|
3767
|
-
var res = {
|
|
3768
|
-
buffer: new Uint8Array(queuedBuffer, queuedOffset, bytesRead),
|
|
3769
|
-
addr: queued.addr,
|
|
3770
|
-
port: queued.port
|
|
3771
|
-
};
|
|
3772
|
-
|
|
3773
|
-
// push back any unread data for TCP connections
|
|
3774
|
-
if (sock.type === 1 && bytesRead < queuedLength) {
|
|
3775
|
-
var bytesRemaining = queuedLength - bytesRead;
|
|
3776
|
-
queued.data = new Uint8Array(queuedBuffer, queuedOffset + bytesRead, bytesRemaining);
|
|
3777
|
-
sock.recv_queue.unshift(queued);
|
|
3778
|
-
}
|
|
3779
|
-
|
|
3780
|
-
return res;
|
|
3781
|
-
},
|
|
3782
|
-
},
|
|
3783
|
-
};
|
|
3784
|
-
|
|
3785
|
-
var getSocketFromFD = (fd) => {
|
|
3786
|
-
var socket = SOCKFS.getSocket(fd);
|
|
3787
|
-
if (!socket) throw new FS.ErrnoError(8);
|
|
3788
|
-
return socket;
|
|
3789
|
-
};
|
|
3790
|
-
|
|
3791
|
-
var Sockets = {
|
|
3792
|
-
BUFFER_SIZE:10240,
|
|
3793
|
-
MAX_BUFFER_SIZE:10485760,
|
|
3794
|
-
nextFd:1,
|
|
3795
|
-
fds:{
|
|
3796
|
-
},
|
|
3797
|
-
nextport:1,
|
|
3798
|
-
maxport:65535,
|
|
3799
|
-
peer:null,
|
|
3800
|
-
connections:{
|
|
3801
|
-
},
|
|
3802
|
-
portmap:{
|
|
3803
|
-
},
|
|
3804
|
-
localAddr:4261412874,
|
|
3805
|
-
addrPool:[33554442,50331658,67108874,83886090,100663306,117440522,134217738,150994954,167772170,184549386,201326602,218103818,234881034],
|
|
3806
|
-
};
|
|
3807
|
-
|
|
3808
|
-
var inetNtop4 = (addr) =>
|
|
3809
|
-
(addr & 0xff) + '.' + ((addr >> 8) & 0xff) + '.' + ((addr >> 16) & 0xff) + '.' + ((addr >> 24) & 0xff);
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
var inetNtop6 = (ints) => {
|
|
3813
|
-
// ref: http://www.ietf.org/rfc/rfc2373.txt - section 2.5.4
|
|
3814
|
-
// Format for IPv4 compatible and mapped 128-bit IPv6 Addresses
|
|
3815
|
-
// 128-bits are split into eight 16-bit words
|
|
3816
|
-
// stored in network byte order (big-endian)
|
|
3817
|
-
// | 80 bits | 16 | 32 bits |
|
|
3818
|
-
// +-----------------------------------------------------------------+
|
|
3819
|
-
// | 10 bytes | 2 | 4 bytes |
|
|
3820
|
-
// +--------------------------------------+--------------------------+
|
|
3821
|
-
// + 5 words | 1 | 2 words |
|
|
3822
|
-
// +--------------------------------------+--------------------------+
|
|
3823
|
-
// |0000..............................0000|0000| IPv4 ADDRESS | (compatible)
|
|
3824
|
-
// +--------------------------------------+----+---------------------+
|
|
3825
|
-
// |0000..............................0000|FFFF| IPv4 ADDRESS | (mapped)
|
|
3826
|
-
// +--------------------------------------+----+---------------------+
|
|
3827
|
-
var str = "";
|
|
3828
|
-
var word = 0;
|
|
3829
|
-
var longest = 0;
|
|
3830
|
-
var lastzero = 0;
|
|
3831
|
-
var zstart = 0;
|
|
3832
|
-
var len = 0;
|
|
3833
|
-
var i = 0;
|
|
3834
|
-
var parts = [
|
|
3835
|
-
ints[0] & 0xffff,
|
|
3836
|
-
(ints[0] >> 16),
|
|
3837
|
-
ints[1] & 0xffff,
|
|
3838
|
-
(ints[1] >> 16),
|
|
3839
|
-
ints[2] & 0xffff,
|
|
3840
|
-
(ints[2] >> 16),
|
|
3841
|
-
ints[3] & 0xffff,
|
|
3842
|
-
(ints[3] >> 16)
|
|
3843
|
-
];
|
|
3844
|
-
|
|
3845
|
-
// Handle IPv4-compatible, IPv4-mapped, loopback and any/unspecified addresses
|
|
3846
|
-
|
|
3847
|
-
var hasipv4 = true;
|
|
3848
|
-
var v4part = "";
|
|
3849
|
-
// check if the 10 high-order bytes are all zeros (first 5 words)
|
|
3850
|
-
for (i = 0; i < 5; i++) {
|
|
3851
|
-
if (parts[i] !== 0) { hasipv4 = false; break; }
|
|
3852
|
-
}
|
|
3853
|
-
|
|
3854
|
-
if (hasipv4) {
|
|
3855
|
-
// low-order 32-bits store an IPv4 address (bytes 13 to 16) (last 2 words)
|
|
3856
|
-
v4part = inetNtop4(parts[6] | (parts[7] << 16));
|
|
3857
|
-
// IPv4-mapped IPv6 address if 16-bit value (bytes 11 and 12) == 0xFFFF (6th word)
|
|
3858
|
-
if (parts[5] === -1) {
|
|
3859
|
-
str = "::ffff:";
|
|
3860
|
-
str += v4part;
|
|
3861
|
-
return str;
|
|
3862
|
-
}
|
|
3863
|
-
// IPv4-compatible IPv6 address if 16-bit value (bytes 11 and 12) == 0x0000 (6th word)
|
|
3864
|
-
if (parts[5] === 0) {
|
|
3865
|
-
str = "::";
|
|
3866
|
-
//special case IPv6 addresses
|
|
3867
|
-
if (v4part === "0.0.0.0") v4part = ""; // any/unspecified address
|
|
3868
|
-
if (v4part === "0.0.0.1") v4part = "1";// loopback address
|
|
3869
|
-
str += v4part;
|
|
3870
|
-
return str;
|
|
3871
|
-
}
|
|
3872
|
-
}
|
|
3873
|
-
|
|
3874
|
-
// Handle all other IPv6 addresses
|
|
3875
|
-
|
|
3876
|
-
// first run to find the longest contiguous zero words
|
|
3877
|
-
for (word = 0; word < 8; word++) {
|
|
3878
|
-
if (parts[word] === 0) {
|
|
3879
|
-
if (word - lastzero > 1) {
|
|
3880
|
-
len = 0;
|
|
3881
|
-
}
|
|
3882
|
-
lastzero = word;
|
|
3883
|
-
len++;
|
|
3884
|
-
}
|
|
3885
|
-
if (len > longest) {
|
|
3886
|
-
longest = len;
|
|
3887
|
-
zstart = word - longest + 1;
|
|
3888
|
-
}
|
|
3889
|
-
}
|
|
3890
|
-
|
|
3891
|
-
for (word = 0; word < 8; word++) {
|
|
3892
|
-
if (longest > 1) {
|
|
3893
|
-
// compress contiguous zeros - to produce "::"
|
|
3894
|
-
if (parts[word] === 0 && word >= zstart && word < (zstart + longest) ) {
|
|
3895
|
-
if (word === zstart) {
|
|
3896
|
-
str += ":";
|
|
3897
|
-
if (zstart === 0) str += ":"; //leading zeros case
|
|
3898
|
-
}
|
|
3899
|
-
continue;
|
|
3900
|
-
}
|
|
3901
|
-
}
|
|
3902
|
-
// converts 16-bit words from big-endian to little-endian before converting to hex string
|
|
3903
|
-
str += Number(_ntohs(parts[word] & 0xffff)).toString(16);
|
|
3904
|
-
str += word < 7 ? ":" : "";
|
|
3905
|
-
}
|
|
3906
|
-
return str;
|
|
3907
|
-
};
|
|
3908
|
-
|
|
3909
|
-
var readSockaddr = (sa, salen) => {
|
|
3910
|
-
// family / port offsets are common to both sockaddr_in and sockaddr_in6
|
|
3911
|
-
var family = HEAP16[((sa)>>1)];
|
|
3912
|
-
var port = _ntohs(HEAPU16[(((sa)+(2))>>1)]);
|
|
3913
|
-
var addr;
|
|
3914
|
-
|
|
3915
|
-
switch (family) {
|
|
3916
|
-
case 2:
|
|
3917
|
-
if (salen !== 16) {
|
|
3918
|
-
return { errno: 28 };
|
|
3919
|
-
}
|
|
3920
|
-
addr = HEAP32[(((sa)+(4))>>2)];
|
|
3921
|
-
addr = inetNtop4(addr);
|
|
3922
|
-
break;
|
|
3923
|
-
case 10:
|
|
3924
|
-
if (salen !== 28) {
|
|
3925
|
-
return { errno: 28 };
|
|
3926
|
-
}
|
|
3927
|
-
addr = [
|
|
3928
|
-
HEAP32[(((sa)+(8))>>2)],
|
|
3929
|
-
HEAP32[(((sa)+(12))>>2)],
|
|
3930
|
-
HEAP32[(((sa)+(16))>>2)],
|
|
3931
|
-
HEAP32[(((sa)+(20))>>2)]
|
|
3932
|
-
];
|
|
3933
|
-
addr = inetNtop6(addr);
|
|
3934
|
-
break;
|
|
3935
|
-
default:
|
|
3936
|
-
return { errno: 5 };
|
|
3937
|
-
}
|
|
3938
|
-
|
|
3939
|
-
return { family: family, addr: addr, port: port };
|
|
3940
|
-
};
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
var inetPton4 = (str) => {
|
|
3944
|
-
var b = str.split('.');
|
|
3945
|
-
for (var i = 0; i < 4; i++) {
|
|
3946
|
-
var tmp = Number(b[i]);
|
|
3947
|
-
if (isNaN(tmp)) return null;
|
|
3948
|
-
b[i] = tmp;
|
|
3949
|
-
}
|
|
3950
|
-
return (b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)) >>> 0;
|
|
3951
|
-
};
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
/** @suppress {checkTypes} */
|
|
3955
|
-
var jstoi_q = (str) => parseInt(str);
|
|
3956
|
-
var inetPton6 = (str) => {
|
|
3957
|
-
var words;
|
|
3958
|
-
var w, offset, z, i;
|
|
3959
|
-
/* http://home.deds.nl/~aeron/regex/ */
|
|
3960
|
-
var valid6regx = /^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i
|
|
3961
|
-
var parts = [];
|
|
3962
|
-
if (!valid6regx.test(str)) {
|
|
3963
|
-
return null;
|
|
3964
|
-
}
|
|
3965
|
-
if (str === "::") {
|
|
3966
|
-
return [0, 0, 0, 0, 0, 0, 0, 0];
|
|
3967
|
-
}
|
|
3968
|
-
// Z placeholder to keep track of zeros when splitting the string on ":"
|
|
3969
|
-
if (str.startsWith("::")) {
|
|
3970
|
-
str = str.replace("::", "Z:"); // leading zeros case
|
|
3971
|
-
} else {
|
|
3972
|
-
str = str.replace("::", ":Z:");
|
|
3973
|
-
}
|
|
3974
|
-
|
|
3975
|
-
if (str.indexOf(".") > 0) {
|
|
3976
|
-
// parse IPv4 embedded stress
|
|
3977
|
-
str = str.replace(new RegExp('[.]', 'g'), ":");
|
|
3978
|
-
words = str.split(":");
|
|
3979
|
-
words[words.length-4] = jstoi_q(words[words.length-4]) + jstoi_q(words[words.length-3])*256;
|
|
3980
|
-
words[words.length-3] = jstoi_q(words[words.length-2]) + jstoi_q(words[words.length-1])*256;
|
|
3981
|
-
words = words.slice(0, words.length-2);
|
|
3982
|
-
} else {
|
|
3983
|
-
words = str.split(":");
|
|
3984
|
-
}
|
|
3985
|
-
|
|
3986
|
-
offset = 0; z = 0;
|
|
3987
|
-
for (w=0; w < words.length; w++) {
|
|
3988
|
-
if (typeof words[w] == 'string') {
|
|
3989
|
-
if (words[w] === 'Z') {
|
|
3990
|
-
// compressed zeros - write appropriate number of zero words
|
|
3991
|
-
for (z = 0; z < (8 - words.length+1); z++) {
|
|
3992
|
-
parts[w+z] = 0;
|
|
3993
|
-
}
|
|
3994
|
-
offset = z-1;
|
|
3995
|
-
} else {
|
|
3996
|
-
// parse hex to field to 16-bit value and write it in network byte-order
|
|
3997
|
-
parts[w+offset] = _htons(parseInt(words[w],16));
|
|
3998
|
-
}
|
|
3999
|
-
} else {
|
|
4000
|
-
// parsed IPv4 words
|
|
4001
|
-
parts[w+offset] = words[w];
|
|
4002
|
-
}
|
|
4003
|
-
}
|
|
4004
|
-
return [
|
|
4005
|
-
(parts[1] << 16) | parts[0],
|
|
4006
|
-
(parts[3] << 16) | parts[2],
|
|
4007
|
-
(parts[5] << 16) | parts[4],
|
|
4008
|
-
(parts[7] << 16) | parts[6]
|
|
4009
|
-
];
|
|
4010
|
-
};
|
|
4011
|
-
var DNS = {
|
|
4012
|
-
address_map:{
|
|
4013
|
-
id:1,
|
|
4014
|
-
addrs:{
|
|
4015
|
-
},
|
|
4016
|
-
names:{
|
|
4017
|
-
},
|
|
4018
|
-
},
|
|
4019
|
-
lookup_name(name) {
|
|
4020
|
-
// If the name is already a valid ipv4 / ipv6 address, don't generate a fake one.
|
|
4021
|
-
var res = inetPton4(name);
|
|
4022
|
-
if (res !== null) {
|
|
4023
|
-
return name;
|
|
4024
|
-
}
|
|
4025
|
-
res = inetPton6(name);
|
|
4026
|
-
if (res !== null) {
|
|
4027
|
-
return name;
|
|
4028
|
-
}
|
|
4029
|
-
|
|
4030
|
-
// See if this name is already mapped.
|
|
4031
|
-
var addr;
|
|
4032
|
-
|
|
4033
|
-
if (DNS.address_map.addrs[name]) {
|
|
4034
|
-
addr = DNS.address_map.addrs[name];
|
|
4035
|
-
} else {
|
|
4036
|
-
var id = DNS.address_map.id++;
|
|
4037
|
-
assert(id < 65535, 'exceeded max address mappings of 65535');
|
|
4038
|
-
|
|
4039
|
-
addr = '172.29.' + (id & 0xff) + '.' + (id & 0xff00);
|
|
4040
|
-
|
|
4041
|
-
DNS.address_map.names[addr] = name;
|
|
4042
|
-
DNS.address_map.addrs[name] = addr;
|
|
4043
|
-
}
|
|
4044
|
-
|
|
4045
|
-
return addr;
|
|
4046
|
-
},
|
|
4047
|
-
lookup_addr(addr) {
|
|
4048
|
-
if (DNS.address_map.names[addr]) {
|
|
4049
|
-
return DNS.address_map.names[addr];
|
|
4050
|
-
}
|
|
4051
|
-
|
|
4052
|
-
return null;
|
|
4053
|
-
},
|
|
4054
|
-
};
|
|
4055
|
-
var getSocketAddress = (addrp, addrlen) => {
|
|
4056
|
-
var info = readSockaddr(addrp, addrlen);
|
|
4057
|
-
if (info.errno) throw new FS.ErrnoError(info.errno);
|
|
4058
|
-
info.addr = DNS.lookup_addr(info.addr) || info.addr;
|
|
4059
|
-
return info;
|
|
4060
|
-
};
|
|
4061
|
-
function ___syscall_connect(fd, addr, addrlen, d1, d2, d3) {
|
|
4062
|
-
try {
|
|
4063
|
-
|
|
4064
|
-
var sock = getSocketFromFD(fd);
|
|
4065
|
-
var info = getSocketAddress(addr, addrlen);
|
|
4066
|
-
sock.sock_ops.connect(sock, info.addr, info.port);
|
|
4067
|
-
return 0;
|
|
4068
|
-
} catch (e) {
|
|
4069
|
-
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
4070
|
-
return -e.errno;
|
|
4071
|
-
}
|
|
4072
|
-
}
|
|
4073
|
-
|
|
4074
3219
|
function ___syscall_faccessat(dirfd, path, amode, flags) {
|
|
4075
3220
|
try {
|
|
4076
3221
|
|
|
@@ -4297,27 +3442,6 @@ async function createWasm() {
|
|
|
4297
3442
|
}
|
|
4298
3443
|
}
|
|
4299
3444
|
|
|
4300
|
-
function ___syscall_getsockopt(fd, level, optname, optval, optlen, d1) {
|
|
4301
|
-
try {
|
|
4302
|
-
|
|
4303
|
-
var sock = getSocketFromFD(fd);
|
|
4304
|
-
// Minimal getsockopt aimed at resolving https://github.com/emscripten-core/emscripten/issues/2211
|
|
4305
|
-
// so only supports SOL_SOCKET with SO_ERROR.
|
|
4306
|
-
if (level === 1) {
|
|
4307
|
-
if (optname === 4) {
|
|
4308
|
-
HEAP32[((optval)>>2)] = sock.error;
|
|
4309
|
-
HEAP32[((optlen)>>2)] = 4;
|
|
4310
|
-
sock.error = null; // Clear the error (The SO_ERROR option obtains and then clears this field).
|
|
4311
|
-
return 0;
|
|
4312
|
-
}
|
|
4313
|
-
}
|
|
4314
|
-
return -50; // The option is unknown at the level indicated.
|
|
4315
|
-
} catch (e) {
|
|
4316
|
-
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
4317
|
-
return -e.errno;
|
|
4318
|
-
}
|
|
4319
|
-
}
|
|
4320
|
-
|
|
4321
3445
|
|
|
4322
3446
|
function ___syscall_ioctl(fd, op, varargs) {
|
|
4323
3447
|
SYSCALLS.varargs = varargs;
|
|
@@ -4468,33 +3592,6 @@ async function createWasm() {
|
|
|
4468
3592
|
}
|
|
4469
3593
|
}
|
|
4470
3594
|
|
|
4471
|
-
function ___syscall_poll(fds, nfds, timeout) {
|
|
4472
|
-
try {
|
|
4473
|
-
|
|
4474
|
-
var nonzero = 0;
|
|
4475
|
-
for (var i = 0; i < nfds; i++) {
|
|
4476
|
-
var pollfd = fds + 8 * i;
|
|
4477
|
-
var fd = HEAP32[((pollfd)>>2)];
|
|
4478
|
-
var events = HEAP16[(((pollfd)+(4))>>1)];
|
|
4479
|
-
var mask = 32;
|
|
4480
|
-
var stream = FS.getStream(fd);
|
|
4481
|
-
if (stream) {
|
|
4482
|
-
mask = SYSCALLS.DEFAULT_POLLMASK;
|
|
4483
|
-
if (stream.stream_ops.poll) {
|
|
4484
|
-
mask = stream.stream_ops.poll(stream, -1);
|
|
4485
|
-
}
|
|
4486
|
-
}
|
|
4487
|
-
mask &= events | 8 | 16;
|
|
4488
|
-
if (mask) nonzero++;
|
|
4489
|
-
HEAP16[(((pollfd)+(6))>>1)] = mask;
|
|
4490
|
-
}
|
|
4491
|
-
return nonzero;
|
|
4492
|
-
} catch (e) {
|
|
4493
|
-
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
4494
|
-
return -e.errno;
|
|
4495
|
-
}
|
|
4496
|
-
}
|
|
4497
|
-
|
|
4498
3595
|
|
|
4499
3596
|
|
|
4500
3597
|
function ___syscall_readlinkat(dirfd, path, buf, bufsize) {
|
|
@@ -4518,21 +3615,6 @@ async function createWasm() {
|
|
|
4518
3615
|
}
|
|
4519
3616
|
}
|
|
4520
3617
|
|
|
4521
|
-
function ___syscall_renameat(olddirfd, oldpath, newdirfd, newpath) {
|
|
4522
|
-
try {
|
|
4523
|
-
|
|
4524
|
-
oldpath = SYSCALLS.getStr(oldpath);
|
|
4525
|
-
newpath = SYSCALLS.getStr(newpath);
|
|
4526
|
-
oldpath = SYSCALLS.calculateAt(olddirfd, oldpath);
|
|
4527
|
-
newpath = SYSCALLS.calculateAt(newdirfd, newpath);
|
|
4528
|
-
FS.rename(oldpath, newpath);
|
|
4529
|
-
return 0;
|
|
4530
|
-
} catch (e) {
|
|
4531
|
-
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
4532
|
-
return -e.errno;
|
|
4533
|
-
}
|
|
4534
|
-
}
|
|
4535
|
-
|
|
4536
3618
|
function ___syscall_rmdir(path) {
|
|
4537
3619
|
try {
|
|
4538
3620
|
|
|
@@ -4545,35 +3627,6 @@ async function createWasm() {
|
|
|
4545
3627
|
}
|
|
4546
3628
|
}
|
|
4547
3629
|
|
|
4548
|
-
|
|
4549
|
-
function ___syscall_sendto(fd, message, length, flags, addr, addr_len) {
|
|
4550
|
-
try {
|
|
4551
|
-
|
|
4552
|
-
var sock = getSocketFromFD(fd);
|
|
4553
|
-
if (!addr) {
|
|
4554
|
-
// send, no address provided
|
|
4555
|
-
return FS.write(sock.stream, HEAP8, message, length);
|
|
4556
|
-
}
|
|
4557
|
-
var dest = getSocketAddress(addr, addr_len);
|
|
4558
|
-
// sendto an address
|
|
4559
|
-
return sock.sock_ops.sendmsg(sock, HEAP8, message, length, dest.addr, dest.port);
|
|
4560
|
-
} catch (e) {
|
|
4561
|
-
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
4562
|
-
return -e.errno;
|
|
4563
|
-
}
|
|
4564
|
-
}
|
|
4565
|
-
|
|
4566
|
-
function ___syscall_socket(domain, type, protocol) {
|
|
4567
|
-
try {
|
|
4568
|
-
|
|
4569
|
-
var sock = SOCKFS.createSocket(domain, type, protocol);
|
|
4570
|
-
return sock.stream.fd;
|
|
4571
|
-
} catch (e) {
|
|
4572
|
-
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
4573
|
-
return -e.errno;
|
|
4574
|
-
}
|
|
4575
|
-
}
|
|
4576
|
-
|
|
4577
3630
|
function ___syscall_stat64(path, buf) {
|
|
4578
3631
|
try {
|
|
4579
3632
|
|
|
@@ -5152,219 +4205,6 @@ async function createWasm() {
|
|
|
5152
4205
|
}
|
|
5153
4206
|
}
|
|
5154
4207
|
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
/** @param {number=} addrlen */
|
|
5166
|
-
var writeSockaddr = (sa, family, addr, port, addrlen) => {
|
|
5167
|
-
switch (family) {
|
|
5168
|
-
case 2:
|
|
5169
|
-
addr = inetPton4(addr);
|
|
5170
|
-
zeroMemory(sa, 16);
|
|
5171
|
-
if (addrlen) {
|
|
5172
|
-
HEAP32[((addrlen)>>2)] = 16;
|
|
5173
|
-
}
|
|
5174
|
-
HEAP16[((sa)>>1)] = family;
|
|
5175
|
-
HEAP32[(((sa)+(4))>>2)] = addr;
|
|
5176
|
-
HEAP16[(((sa)+(2))>>1)] = _htons(port);
|
|
5177
|
-
break;
|
|
5178
|
-
case 10:
|
|
5179
|
-
addr = inetPton6(addr);
|
|
5180
|
-
zeroMemory(sa, 28);
|
|
5181
|
-
if (addrlen) {
|
|
5182
|
-
HEAP32[((addrlen)>>2)] = 28;
|
|
5183
|
-
}
|
|
5184
|
-
HEAP32[((sa)>>2)] = family;
|
|
5185
|
-
HEAP32[(((sa)+(8))>>2)] = addr[0];
|
|
5186
|
-
HEAP32[(((sa)+(12))>>2)] = addr[1];
|
|
5187
|
-
HEAP32[(((sa)+(16))>>2)] = addr[2];
|
|
5188
|
-
HEAP32[(((sa)+(20))>>2)] = addr[3];
|
|
5189
|
-
HEAP16[(((sa)+(2))>>1)] = _htons(port);
|
|
5190
|
-
break;
|
|
5191
|
-
default:
|
|
5192
|
-
return 5;
|
|
5193
|
-
}
|
|
5194
|
-
return 0;
|
|
5195
|
-
};
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
var _getaddrinfo = (node, service, hint, out) => {
|
|
5200
|
-
// Note getaddrinfo currently only returns a single addrinfo with ai_next defaulting to NULL. When NULL
|
|
5201
|
-
// hints are specified or ai_family set to AF_UNSPEC or ai_socktype or ai_protocol set to 0 then we
|
|
5202
|
-
// really should provide a linked list of suitable addrinfo values.
|
|
5203
|
-
var addrs = [];
|
|
5204
|
-
var canon = null;
|
|
5205
|
-
var addr = 0;
|
|
5206
|
-
var port = 0;
|
|
5207
|
-
var flags = 0;
|
|
5208
|
-
var family = 0;
|
|
5209
|
-
var type = 0;
|
|
5210
|
-
var proto = 0;
|
|
5211
|
-
var ai, last;
|
|
5212
|
-
|
|
5213
|
-
function allocaddrinfo(family, type, proto, canon, addr, port) {
|
|
5214
|
-
var sa, salen, ai;
|
|
5215
|
-
var errno;
|
|
5216
|
-
|
|
5217
|
-
salen = family === 10 ?
|
|
5218
|
-
28 :
|
|
5219
|
-
16;
|
|
5220
|
-
addr = family === 10 ?
|
|
5221
|
-
inetNtop6(addr) :
|
|
5222
|
-
inetNtop4(addr);
|
|
5223
|
-
sa = _malloc(salen);
|
|
5224
|
-
errno = writeSockaddr(sa, family, addr, port);
|
|
5225
|
-
assert(!errno);
|
|
5226
|
-
|
|
5227
|
-
ai = _malloc(32);
|
|
5228
|
-
HEAP32[(((ai)+(4))>>2)] = family;
|
|
5229
|
-
HEAP32[(((ai)+(8))>>2)] = type;
|
|
5230
|
-
HEAP32[(((ai)+(12))>>2)] = proto;
|
|
5231
|
-
HEAPU32[(((ai)+(24))>>2)] = canon;
|
|
5232
|
-
HEAPU32[(((ai)+(20))>>2)] = sa;
|
|
5233
|
-
if (family === 10) {
|
|
5234
|
-
HEAP32[(((ai)+(16))>>2)] = 28;
|
|
5235
|
-
} else {
|
|
5236
|
-
HEAP32[(((ai)+(16))>>2)] = 16;
|
|
5237
|
-
}
|
|
5238
|
-
HEAP32[(((ai)+(28))>>2)] = 0;
|
|
5239
|
-
|
|
5240
|
-
return ai;
|
|
5241
|
-
}
|
|
5242
|
-
|
|
5243
|
-
if (hint) {
|
|
5244
|
-
flags = HEAP32[((hint)>>2)];
|
|
5245
|
-
family = HEAP32[(((hint)+(4))>>2)];
|
|
5246
|
-
type = HEAP32[(((hint)+(8))>>2)];
|
|
5247
|
-
proto = HEAP32[(((hint)+(12))>>2)];
|
|
5248
|
-
}
|
|
5249
|
-
if (type && !proto) {
|
|
5250
|
-
proto = type === 2 ? 17 : 6;
|
|
5251
|
-
}
|
|
5252
|
-
if (!type && proto) {
|
|
5253
|
-
type = proto === 17 ? 2 : 1;
|
|
5254
|
-
}
|
|
5255
|
-
|
|
5256
|
-
// If type or proto are set to zero in hints we should really be returning multiple addrinfo values, but for
|
|
5257
|
-
// now default to a TCP STREAM socket so we can at least return a sensible addrinfo given NULL hints.
|
|
5258
|
-
if (proto === 0) {
|
|
5259
|
-
proto = 6;
|
|
5260
|
-
}
|
|
5261
|
-
if (type === 0) {
|
|
5262
|
-
type = 1;
|
|
5263
|
-
}
|
|
5264
|
-
|
|
5265
|
-
if (!node && !service) {
|
|
5266
|
-
return -2;
|
|
5267
|
-
}
|
|
5268
|
-
if (flags & ~(1|2|4|
|
|
5269
|
-
1024|8|16|32)) {
|
|
5270
|
-
return -1;
|
|
5271
|
-
}
|
|
5272
|
-
if (hint !== 0 && (HEAP32[((hint)>>2)] & 2) && !node) {
|
|
5273
|
-
return -1;
|
|
5274
|
-
}
|
|
5275
|
-
if (flags & 32) {
|
|
5276
|
-
// TODO
|
|
5277
|
-
return -2;
|
|
5278
|
-
}
|
|
5279
|
-
if (type !== 0 && type !== 1 && type !== 2) {
|
|
5280
|
-
return -7;
|
|
5281
|
-
}
|
|
5282
|
-
if (family !== 0 && family !== 2 && family !== 10) {
|
|
5283
|
-
return -6;
|
|
5284
|
-
}
|
|
5285
|
-
|
|
5286
|
-
if (service) {
|
|
5287
|
-
service = UTF8ToString(service);
|
|
5288
|
-
port = parseInt(service, 10);
|
|
5289
|
-
|
|
5290
|
-
if (isNaN(port)) {
|
|
5291
|
-
if (flags & 1024) {
|
|
5292
|
-
return -2;
|
|
5293
|
-
}
|
|
5294
|
-
// TODO support resolving well-known service names from:
|
|
5295
|
-
// http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt
|
|
5296
|
-
return -8;
|
|
5297
|
-
}
|
|
5298
|
-
}
|
|
5299
|
-
|
|
5300
|
-
if (!node) {
|
|
5301
|
-
if (family === 0) {
|
|
5302
|
-
family = 2;
|
|
5303
|
-
}
|
|
5304
|
-
if ((flags & 1) === 0) {
|
|
5305
|
-
if (family === 2) {
|
|
5306
|
-
addr = _htonl(2130706433);
|
|
5307
|
-
} else {
|
|
5308
|
-
addr = [0, 0, 0, _htonl(1)];
|
|
5309
|
-
}
|
|
5310
|
-
}
|
|
5311
|
-
ai = allocaddrinfo(family, type, proto, null, addr, port);
|
|
5312
|
-
HEAPU32[((out)>>2)] = ai;
|
|
5313
|
-
return 0;
|
|
5314
|
-
}
|
|
5315
|
-
|
|
5316
|
-
//
|
|
5317
|
-
// try as a numeric address
|
|
5318
|
-
//
|
|
5319
|
-
node = UTF8ToString(node);
|
|
5320
|
-
addr = inetPton4(node);
|
|
5321
|
-
if (addr !== null) {
|
|
5322
|
-
// incoming node is a valid ipv4 address
|
|
5323
|
-
if (family === 0 || family === 2) {
|
|
5324
|
-
family = 2;
|
|
5325
|
-
}
|
|
5326
|
-
else if (family === 10 && (flags & 8)) {
|
|
5327
|
-
addr = [0, 0, _htonl(0xffff), addr];
|
|
5328
|
-
family = 10;
|
|
5329
|
-
} else {
|
|
5330
|
-
return -2;
|
|
5331
|
-
}
|
|
5332
|
-
} else {
|
|
5333
|
-
addr = inetPton6(node);
|
|
5334
|
-
if (addr !== null) {
|
|
5335
|
-
// incoming node is a valid ipv6 address
|
|
5336
|
-
if (family === 0 || family === 10) {
|
|
5337
|
-
family = 10;
|
|
5338
|
-
} else {
|
|
5339
|
-
return -2;
|
|
5340
|
-
}
|
|
5341
|
-
}
|
|
5342
|
-
}
|
|
5343
|
-
if (addr != null) {
|
|
5344
|
-
ai = allocaddrinfo(family, type, proto, node, addr, port);
|
|
5345
|
-
HEAPU32[((out)>>2)] = ai;
|
|
5346
|
-
return 0;
|
|
5347
|
-
}
|
|
5348
|
-
if (flags & 4) {
|
|
5349
|
-
return -2;
|
|
5350
|
-
}
|
|
5351
|
-
|
|
5352
|
-
//
|
|
5353
|
-
// try as a hostname
|
|
5354
|
-
//
|
|
5355
|
-
// resolve the hostname to a temporary fake address
|
|
5356
|
-
node = DNS.lookup_name(node);
|
|
5357
|
-
addr = inetPton4(node);
|
|
5358
|
-
if (family === 0) {
|
|
5359
|
-
family = 2;
|
|
5360
|
-
} else if (family === 10) {
|
|
5361
|
-
addr = [0, 0, _htonl(0xffff), addr];
|
|
5362
|
-
}
|
|
5363
|
-
ai = allocaddrinfo(family, type, proto, null, addr, port);
|
|
5364
|
-
HEAPU32[((out)>>2)] = ai;
|
|
5365
|
-
return 0;
|
|
5366
|
-
};
|
|
5367
|
-
|
|
5368
4208
|
FS.createPreloadedFile = FS_createPreloadedFile;
|
|
5369
4209
|
FS.staticInit();
|
|
5370
4210
|
// Set module methods based on EXPORTED_RUNTIME_METHODS
|
|
@@ -5380,8 +4220,6 @@ var wasmImports = {
|
|
|
5380
4220
|
/** @export */
|
|
5381
4221
|
__syscall_chmod: ___syscall_chmod,
|
|
5382
4222
|
/** @export */
|
|
5383
|
-
__syscall_connect: ___syscall_connect,
|
|
5384
|
-
/** @export */
|
|
5385
4223
|
__syscall_faccessat: ___syscall_faccessat,
|
|
5386
4224
|
/** @export */
|
|
5387
4225
|
__syscall_fchmod: ___syscall_fchmod,
|
|
@@ -5400,8 +4238,6 @@ var wasmImports = {
|
|
|
5400
4238
|
/** @export */
|
|
5401
4239
|
__syscall_getdents64: ___syscall_getdents64,
|
|
5402
4240
|
/** @export */
|
|
5403
|
-
__syscall_getsockopt: ___syscall_getsockopt,
|
|
5404
|
-
/** @export */
|
|
5405
4241
|
__syscall_ioctl: ___syscall_ioctl,
|
|
5406
4242
|
/** @export */
|
|
5407
4243
|
__syscall_lstat64: ___syscall_lstat64,
|
|
@@ -5412,18 +4248,10 @@ var wasmImports = {
|
|
|
5412
4248
|
/** @export */
|
|
5413
4249
|
__syscall_openat: ___syscall_openat,
|
|
5414
4250
|
/** @export */
|
|
5415
|
-
__syscall_poll: ___syscall_poll,
|
|
5416
|
-
/** @export */
|
|
5417
4251
|
__syscall_readlinkat: ___syscall_readlinkat,
|
|
5418
4252
|
/** @export */
|
|
5419
|
-
__syscall_renameat: ___syscall_renameat,
|
|
5420
|
-
/** @export */
|
|
5421
4253
|
__syscall_rmdir: ___syscall_rmdir,
|
|
5422
4254
|
/** @export */
|
|
5423
|
-
__syscall_sendto: ___syscall_sendto,
|
|
5424
|
-
/** @export */
|
|
5425
|
-
__syscall_socket: ___syscall_socket,
|
|
5426
|
-
/** @export */
|
|
5427
4255
|
__syscall_stat64: ___syscall_stat64,
|
|
5428
4256
|
/** @export */
|
|
5429
4257
|
__syscall_unlinkat: ___syscall_unlinkat,
|
|
@@ -5444,6 +4272,12 @@ var wasmImports = {
|
|
|
5444
4272
|
/** @export */
|
|
5445
4273
|
clock_time_get: _clock_time_get,
|
|
5446
4274
|
/** @export */
|
|
4275
|
+
doltliteWasmHttpRespLen,
|
|
4276
|
+
/** @export */
|
|
4277
|
+
doltliteWasmHttpRespTake,
|
|
4278
|
+
/** @export */
|
|
4279
|
+
doltliteWasmHttpSend,
|
|
4280
|
+
/** @export */
|
|
5447
4281
|
emscripten_date_now: _emscripten_date_now,
|
|
5448
4282
|
/** @export */
|
|
5449
4283
|
emscripten_get_heap_max: _emscripten_get_heap_max,
|
|
@@ -5470,8 +4304,6 @@ var wasmImports = {
|
|
|
5470
4304
|
/** @export */
|
|
5471
4305
|
fd_write: _fd_write,
|
|
5472
4306
|
/** @export */
|
|
5473
|
-
getaddrinfo: _getaddrinfo,
|
|
5474
|
-
/** @export */
|
|
5475
4307
|
memory: wasmMemory
|
|
5476
4308
|
};
|
|
5477
4309
|
var wasmExports;
|
|
@@ -5734,10 +4566,7 @@ var _sqlite3_preupdate_count = Module['_sqlite3_preupdate_count'] = (a0) => (_sq
|
|
|
5734
4566
|
var _sqlite3_preupdate_depth = Module['_sqlite3_preupdate_depth'] = (a0) => (_sqlite3_preupdate_depth = Module['_sqlite3_preupdate_depth'] = wasmExports['sqlite3_preupdate_depth'])(a0);
|
|
5735
4567
|
var _sqlite3_preupdate_blobwrite = Module['_sqlite3_preupdate_blobwrite'] = (a0) => (_sqlite3_preupdate_blobwrite = Module['_sqlite3_preupdate_blobwrite'] = wasmExports['sqlite3_preupdate_blobwrite'])(a0);
|
|
5736
4568
|
var _sqlite3_preupdate_new = Module['_sqlite3_preupdate_new'] = (a0, a1, a2) => (_sqlite3_preupdate_new = Module['_sqlite3_preupdate_new'] = wasmExports['sqlite3_preupdate_new'])(a0, a1, a2);
|
|
5737
|
-
var _htonl = (a0) => (_htonl = wasmExports['htonl'])(a0);
|
|
5738
|
-
var _htons = (a0) => (_htons = wasmExports['htons'])(a0);
|
|
5739
4569
|
var _emscripten_builtin_memalign = (a0, a1) => (_emscripten_builtin_memalign = wasmExports['emscripten_builtin_memalign'])(a0, a1);
|
|
5740
|
-
var _ntohs = (a0) => (_ntohs = wasmExports['ntohs'])(a0);
|
|
5741
4570
|
var __emscripten_stack_restore = (a0) => (__emscripten_stack_restore = wasmExports['_emscripten_stack_restore'])(a0);
|
|
5742
4571
|
var __emscripten_stack_alloc = (a0) => (__emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc'])(a0);
|
|
5743
4572
|
var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])();
|