sigelo-contact 0.1.13 → 0.1.14
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/carrier.mjs +277 -35
- package/enrol.mjs +34 -17
- package/group.mjs +597 -0
- package/link.mjs +23 -15
- package/package.json +19 -4
- package/page.mjs +278 -19
- package/platform-node.mjs +15 -5
- package/short.mjs +12 -0
- package/store.mjs +21 -2
- package/test-carrier.mjs +18 -4
- package/test-enrol.mjs +36 -2
- package/test-group.mjs +383 -0
- package/test-link.mjs +5 -2
- package/test-presence.mjs +169 -0
- package/test-short.mjs +4 -1
- package/test-transfer.mjs +435 -0
- package/transfer-node.mjs +845 -0
- package/transfer.mjs +371 -0
- package/words-lock.mjs +100 -0
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Transfers (transfer.mjs, transfer-node.mjs, sigelo-transfer; design/transfer.md): the messages and
|
|
3
|
+
// frames; the chunk protocol over a fake channel (a whole file, a drop and the resume, a chunk altered
|
|
4
|
+
// once and always, the list altered, the 16 GiB cap, back-pressure); the path order; then with the
|
|
5
|
+
// relay checkout beside contact/ (SIGELO_RELAY_DIR, else ../relay) two agents on a loopback relay:
|
|
6
|
+
// consent (nothing written before yes; decline; busy past the caps), the direct switch, a 50 MB file
|
|
7
|
+
// over werift (MB/s printed), a drop and a resume, file_changed; and the Tor path against a fake tor
|
|
8
|
+
// (a control port that answers PROTOCOLINFO, AUTHENTICATE, ADD_ONION, ONION_CLIENT_AUTH_ADD and
|
|
9
|
+
// DEL_ONION, and a SOCKS5 port that connects the onion to the service's local port), or the real one
|
|
10
|
+
// when SIGELO_TEST_TOR names its control port. SIGELO_TEST_MB: the size of the direct file (default 50).
|
|
11
|
+
// node contact/test-transfer.mjs → ALL PASS (n)
|
|
12
|
+
import { createHash } from 'node:crypto';
|
|
13
|
+
import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
14
|
+
import net from 'node:net';
|
|
15
|
+
import { tmpdir } from 'node:os';
|
|
16
|
+
import { basename, dirname, join } from 'node:path';
|
|
17
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
18
|
+
import { keygen } from 'sigelo';
|
|
19
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
20
|
+
import {
|
|
21
|
+
CHUNK, DATA_MAX, FRAME, HIGH, LOW, MAX_SIZE, OUTSTANDING, REASONS, T, TRANSFER_LABEL, Have, Pull, Serve, channelLabel, checkMessage, chunkLength, chunksOf,
|
|
22
|
+
deframer, enframe, frames, listOf, manifest, newId, pathOrder, readFrame, torRoles,
|
|
23
|
+
} from './transfer.mjs';
|
|
24
|
+
|
|
25
|
+
let count = 0;
|
|
26
|
+
const fails = [];
|
|
27
|
+
const ok = (cond, what, more) => { count++; if (!cond) fails.push(more === undefined ? what : `${what} (${String(more).slice(0, 600)})`); };
|
|
28
|
+
const checkOf = (f) => { try { f(); return 'accepted'; } catch (e) { return e.check ?? `exception ${e.constructor.name}: ${e.message}`; } };
|
|
29
|
+
const report = () => {
|
|
30
|
+
for (const f of fails) console.log('FAIL ' + f);
|
|
31
|
+
if (fails.length) { console.log(`${fails.length} FAILED, ${count - fails.length} passed`); process.exit(1); }
|
|
32
|
+
};
|
|
33
|
+
export const seeded = (seed, n) => {
|
|
34
|
+
const out = Buffer.alloc(n);
|
|
35
|
+
for (let i = 0, off = 0; off < n; i++, off += 32) createHash('sha256').update(`${seed}\n${i}`).digest().copy(out, off, 0, Math.min(32, n - off));
|
|
36
|
+
return new Uint8Array(out.buffer, out.byteOffset, n);
|
|
37
|
+
};
|
|
38
|
+
const hashesOf = (bytes) => {
|
|
39
|
+
const n = chunksOf(bytes.length), out = new Uint8Array(n * 32);
|
|
40
|
+
for (let i = 0; i < n; i++) out.set(sha256(bytes.subarray(i * CHUNK, (i + 1) * CHUNK)), i * 32);
|
|
41
|
+
return out;
|
|
42
|
+
};
|
|
43
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
44
|
+
const NOW = Date.parse('2026-11-03T12:00:00Z') / 1000;
|
|
45
|
+
|
|
46
|
+
// ================================================================ the messages and the frames
|
|
47
|
+
{
|
|
48
|
+
ok(TRANSFER_LABEL === 'sigelo-transfer/0' && CHUNK === 1048576 && FRAME === 65536 && OUTSTANDING === 8 && MAX_SIZE === 16 * 2 ** 30, 'label sigelo-transfer/0, 1 MiB chunks, 64 KiB frames, 8 outstanding, 16 GiB');
|
|
49
|
+
const bytes = seeded('m', 3 * CHUNK + 5), hashes = hashesOf(bytes);
|
|
50
|
+
const m = manifest({ id: 'ab'.repeat(16), name: 'film.mkv', size: bytes.length, sha256: createHash('sha256').update(bytes).digest('hex'), hashes, now: NOW });
|
|
51
|
+
ok(m.chunks === 4 && m.chunk === CHUNK && m.list === listOf(hashes) && m.exp === NOW + 7 * 86400 && checkOf(() => checkMessage(m)) === 'accepted', 'manifest: 4 chunks, the list, 7 days; checkMessage accepts it');
|
|
52
|
+
ok(JSON.stringify(m).length < 1024, `a manifest is under 1 KiB (${JSON.stringify(m).length})`);
|
|
53
|
+
ok(checkOf(() => manifest({ name: 'x', size: MAX_SIZE + 1, sha256: 'a', hashes: new Uint8Array(0), now: NOW })) === 'transfer_too_large', 'manifest of 16 GiB + 1: transfer_too_large');
|
|
54
|
+
ok(checkOf(() => checkMessage({ ...m, size: MAX_SIZE + 1, chunks: chunksOf(MAX_SIZE + 1) })) === 'transfer_too_large', 'a received manifest past 16 GiB: transfer_too_large');
|
|
55
|
+
const big = { ...m, size: MAX_SIZE, chunks: MAX_SIZE / CHUNK };
|
|
56
|
+
ok(checkOf(() => checkMessage(big)) === 'accepted', 'a manifest of exactly 16 GiB (16,384 chunks): accepted');
|
|
57
|
+
const id = 'cd'.repeat(16), tor = { serve: false, connect: true };
|
|
58
|
+
const offer = { typ: 'offer', id, attempt: 1, sdp: 'v=0\r\n', tor }, answer = { typ: 'answer', id, attempt: 1, sdp: null, tor };
|
|
59
|
+
const onion = { typ: 'onion', id, attempt: 2, onion: 'a'.repeat(56), port: 4242, auth: 'A'.repeat(43) + '=', token: 'ef'.repeat(32) };
|
|
60
|
+
for (const x of [offer, { ...offer, via: 'tor', sdp: null }, answer, onion, { ...onion, auth: null }, { typ: 'end', id, reason: 'try_tor', attempt: 1 }, { typ: 'end', id, reason: 'busy' }]) ok(checkOf(() => checkMessage(x)) === 'accepted', `checkMessage: a well-formed ${x.typ}`);
|
|
61
|
+
const bad = [
|
|
62
|
+
[{ ...m, typ: 'hello' }, 'an unknown typ'], [{ ...m, id: 'AB'.repeat(16) }, 'an id in capitals'], [{ ...m, extra: 1 }, 'an extra key'], [{ ...m, chunk: 65536 }, 'chunk 64 KiB'],
|
|
63
|
+
[{ ...m, chunks: 3 }, 'chunks not the size\'s'], [{ ...m, name: '' }, 'an empty name'], [{ ...m, name: 'n'.repeat(1025) }, 'a name past 1024'], [{ ...m, sha256: 'x' }, 'sha256 not hex'],
|
|
64
|
+
[{ ...offer, attempt: 0 }, 'attempt 0'], [{ ...offer, sdp: 's'.repeat(16385) }, 'an sdp past 16 KiB'], [{ ...offer, tor: { serve: 1, connect: true } }, 'tor.serve not a boolean'],
|
|
65
|
+
[{ ...offer, via: 'turn' }, 'via turn'], [{ ...answer, via: 'tor' }, 'via on an answer'], [{ ...onion, onion: 'a'.repeat(56) + '.onion' }, 'an onion with .onion'], [{ ...onion, port: 0 }, 'port 0'],
|
|
66
|
+
[{ ...onion, token: 'ef' }, 'a short token'], [{ typ: 'end', id, reason: 'bored' }, 'reason bored'], [(({ tor: _t, ...x }) => x)(offer), 'an offer without tor'],
|
|
67
|
+
];
|
|
68
|
+
for (const [x, what] of bad) ok(checkOf(() => checkMessage(x)) === 'transfer_message', `checkMessage, ${what}: transfer_message`, checkOf(() => checkMessage(x)));
|
|
69
|
+
ok(channelLabel(id, 3) === `sigelo-transfer/0 ${id} 3` && /^[0-9a-f]{32}$/.test(newId()), 'channel label names id and attempt; ids are 32 hex');
|
|
70
|
+
|
|
71
|
+
// Frames round trip, and their shapes refused.
|
|
72
|
+
const d = readFrame(frames.data(7, 65527, new Uint8Array([1, 2, 3])));
|
|
73
|
+
ok(d.type === T.DATA && d.index === 7 && d.offset === 65527 && d.bytes.length === 3, 'DATA round trip');
|
|
74
|
+
const w = readFrame(frames.want(4000000000, 8));
|
|
75
|
+
ok(w.type === T.WANT && w.from === 4000000000 && w.n === 8, 'WANT round trip (u32 from)');
|
|
76
|
+
ok(readFrame(frames.end('file_changed')).reason === 'file_changed' && REASONS.every((r) => readFrame(frames.end(r)).reason === r), 'END round trip for every reason');
|
|
77
|
+
ok(readFrame(frames.list(5, new Uint8Array(64))).first === 5 && readFrame(frames.token(new Uint8Array(32))).type === T.TOKEN, 'LIST and TOKEN round trip');
|
|
78
|
+
for (const [f, what] of [[new Uint8Array([9, 0]), 'type 9'], [new Uint8Array([T.WANT, 0, 0]), 'a short WANT'], [new Uint8Array(FRAME + 1), 'past 64 KiB'], [new Uint8Array([T.END, 99]), 'an END reason past the list'], [new Uint8Array([T.LIST, 0, 0, 0, 0, 1]), 'a LIST of part of a hash']]) {
|
|
79
|
+
ok(checkOf(() => readFrame(f)) === 'transfer_frame', `readFrame, ${what}: transfer_frame`);
|
|
80
|
+
}
|
|
81
|
+
ok(frames.data(0, 0, new Uint8Array(DATA_MAX)).length === FRAME && Math.ceil(CHUNK / DATA_MAX) === 17, 'a full DATA frame is 64 KiB; a chunk goes in 17');
|
|
82
|
+
const df = deframer(), parts = [enframe(frames.want(1, 2)), enframe(frames.end('done'))], all = new Uint8Array([...parts[0], ...parts[1]]);
|
|
83
|
+
const got = [...df(all.subarray(0, 5)), ...df(all.subarray(5, 12)), ...df(all.subarray(12))];
|
|
84
|
+
ok(got.length === 2 && readFrame(got[0]).n === 2 && readFrame(got[1]).reason === 'done', 'stream frames: split anywhere, read whole');
|
|
85
|
+
ok(checkOf(() => deframer()(new Uint8Array([0, 1, 0, 1]))) === 'transfer_frame', 'a stream frame length past 64 KiB: transfer_frame');
|
|
86
|
+
|
|
87
|
+
// The bitmap.
|
|
88
|
+
const h = new Have(10);
|
|
89
|
+
h.set(0); h.set(9);
|
|
90
|
+
ok(h.has(0) && h.has(9) && !h.has(5) && h.count() === 2 && !h.done() && new Have(10, h.bits).count() === 2 && h.bits.length === 2, 'Have: a bit a chunk, kept as bytes');
|
|
91
|
+
ok(checkOf(() => new Have(10, new Uint8Array(3))) === 'transfer_have', 'Have of the wrong length: transfer_have');
|
|
92
|
+
ok(chunkLength(3 * CHUNK + 5, 3) === 5 && chunkLength(3 * CHUNK + 5, 2) === CHUNK, 'chunkLength: the last chunk is the rest');
|
|
93
|
+
|
|
94
|
+
// The path order (design §2, §9).
|
|
95
|
+
ok(JSON.stringify(pathOrder({ direct: true, tor: true })) === '["direct","tor"]', 'free: direct, then Tor');
|
|
96
|
+
ok(JSON.stringify(pathOrder({ direct: false, tor: true })) === '["tor"]' && JSON.stringify(pathOrder({ direct: true, tor: false })) === '["direct"]' && pathOrder({ direct: false, tor: false }).length === 0, 'free: what is allowed only; nothing: refused');
|
|
97
|
+
ok(JSON.stringify(pathOrder({ pro: true, prefer: 'fast', direct: true, tor: true })) === '["direct","tor"]', 'Pro fast without TURN yet: direct, then Tor (TURN is T4)');
|
|
98
|
+
ok(JSON.stringify(pathOrder({ pro: true, prefer: 'fast', direct: true, tor: true, turn: true })) === '["direct","turn","tor"]', 'Pro fast with TURN: direct, TURN, Tor');
|
|
99
|
+
ok(JSON.stringify(pathOrder({ pro: true, prefer: 'private', direct: true, tor: true })) === '["tor","direct"]', 'Pro private: Tor first');
|
|
100
|
+
ok(JSON.stringify(pathOrder({ via: 'tor', direct: true, tor: true })) === '["tor"]' && pathOrder({ via: 'tor', direct: true, tor: false }).length === 0, '--via tor: Tor only, never direct');
|
|
101
|
+
ok(torRoles({ serve: true, connect: true }, { serve: true, connect: true }) === 'sender' && torRoles({ serve: false, connect: true }, { serve: true, connect: true }) === 'receiver'
|
|
102
|
+
&& torRoles({ serve: false, connect: true }, { serve: false, connect: true }) === null, 'Tor: the sender serves if it can, else the receiver; two connect-only sides: none');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ================================================================ the chunk protocol over a fake channel
|
|
106
|
+
|
|
107
|
+
/** Two ends of a fake channel: frames arrive in order, asynchronously; buffered counts what the other side has not read. */
|
|
108
|
+
export function fakePair({ dropAfter = Infinity, alter = () => null } = {}) {
|
|
109
|
+
const mk = () => ({ handlers: { frame: [], low: [], close: [] }, buffered: 0, closed: false, sent: 0 });
|
|
110
|
+
const a = mk(), b = mk();
|
|
111
|
+
const end = (me, other) => ({
|
|
112
|
+
send(f) {
|
|
113
|
+
if (me.closed) throw new Error('closed');
|
|
114
|
+
me.sent++;
|
|
115
|
+
if (me.sent + other.sent > dropAfter) { close(); return; }
|
|
116
|
+
const g = alter(f, me === a ? 'a' : 'b') ?? f;
|
|
117
|
+
me.buffered += g.length;
|
|
118
|
+
setImmediate(() => {
|
|
119
|
+
me.buffered -= g.length;
|
|
120
|
+
if (me.buffered < LOW) for (const fn of me.handlers.low) fn();
|
|
121
|
+
if (!other.closed) for (const fn of other.handlers.frame) fn(g);
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
buffered: () => me.buffered,
|
|
125
|
+
close,
|
|
126
|
+
on(e, fn) { me.handlers[e].push(fn); },
|
|
127
|
+
});
|
|
128
|
+
let shut = false;
|
|
129
|
+
function close() { if (shut) return; shut = true; a.closed = b.closed = true; setImmediate(() => { for (const fn of [...a.handlers.close, ...b.handlers.close]) fn(); }); }
|
|
130
|
+
return [end(a, b), end(b, a), { a, b }];
|
|
131
|
+
}
|
|
132
|
+
/** One attempt: the sender serving bytes, the receiver pulling into disk (a Map). → { reason, disk, have, hashes, maxOut }. */
|
|
133
|
+
export function attempt(bytes, m, hashes, { have, known = null, drop, alter, readHook, disk = new Map() } = {}) {
|
|
134
|
+
return new Promise((resolve) => {
|
|
135
|
+
const [ca, cb, raw] = fakePair({ dropAfter: drop, alter });
|
|
136
|
+
let ends = 0, result = {}, maxBuf = 0, out = 0, maxOut = 0;
|
|
137
|
+
const done = () => { if (++ends === 2) resolve({ ...result, disk, have, maxBuf, maxOut }); };
|
|
138
|
+
const serve = new Serve({ m, hashes, channel: ca, read: async (i) => { await readHook?.(i); maxBuf = Math.max(maxBuf, raw.a.buffered); return bytes.subarray(i * CHUNK, (i + 1) * CHUNK); }, onEnd: (r, o) => { result.sender = r; result.senderRemote = o.remote; done(); } });
|
|
139
|
+
const pull = new Pull({
|
|
140
|
+
m, have, hashes: known, channel: cb,
|
|
141
|
+
write: async (i, b) => { disk.set(i, b); out--; },
|
|
142
|
+
flush: async () => {},
|
|
143
|
+
onList: (h) => { result.hashes = h; },
|
|
144
|
+
onEnd: (r) => {
|
|
145
|
+
result.receiver = r;
|
|
146
|
+
if (r === 'complete') {
|
|
147
|
+
const whole = Buffer.concat([...Array(m.chunks).keys()].map((i) => disk.get(i)));
|
|
148
|
+
const good = createHash('sha256').update(whole).digest('hex') === m.sha256;
|
|
149
|
+
result.receiver = good ? 'done' : 'chunk_hash';
|
|
150
|
+
pull.finish(result.receiver);
|
|
151
|
+
}
|
|
152
|
+
done();
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
// Outstanding: asked and not yet written.
|
|
156
|
+
const send = cb.send.bind(cb);
|
|
157
|
+
cb.send = (f) => { if (f[0] === T.WANT) { out += readFrame(f).n; maxOut = Math.max(maxOut, out); } send(f); };
|
|
158
|
+
serve.start(); pull.start();
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
{
|
|
162
|
+
const bytes = seeded('fake', 20 * CHUNK + 777), hashes = hashesOf(bytes);
|
|
163
|
+
const m = manifest({ name: 'f.bin', size: bytes.length, sha256: createHash('sha256').update(bytes).digest('hex'), hashes, now: NOW });
|
|
164
|
+
const r1 = await attempt(bytes, m, hashes, { have: new Have(m.chunks) });
|
|
165
|
+
ok(r1.receiver === 'done' && r1.sender === 'done' && r1.senderRemote && r1.have.done() && r1.disk.size === m.chunks, 'a whole file: every chunk checked and written, done on both sides', JSON.stringify({ r: r1.receiver, s: r1.sender }));
|
|
166
|
+
ok(r1.maxOut <= OUTSTANDING, `at most ${OUTSTANDING} chunks outstanding (${r1.maxOut})`);
|
|
167
|
+
ok(r1.maxBuf <= HIGH + CHUNK + 17 * 9, `the sender stops above 4 MiB buffered (${r1.maxBuf})`);
|
|
168
|
+
|
|
169
|
+
// A drop midway, then the resume: a new attempt asks only for what the bitmap lacks.
|
|
170
|
+
const r2 = await attempt(bytes, m, hashes, { have: new Have(m.chunks), drop: 200 });
|
|
171
|
+
const had = r2.have.count();
|
|
172
|
+
ok(r2.receiver === 'cancelled' && had > 0 && had < m.chunks, `a drop: cancelled, ${had} of ${m.chunks} chunks kept`, r2.receiver);
|
|
173
|
+
const asked = [];
|
|
174
|
+
const r3 = await attempt(bytes, m, hashes, { have: r2.have, known: r2.hashes, disk: new Map(r2.disk), readHook: (i) => asked.push(i) });
|
|
175
|
+
ok(r3.receiver === 'done' && r3.have.done() && asked.length === m.chunks - had, `the resume: only the ${m.chunks - had} missing chunks asked, done`, `${asked.length} asked`);
|
|
176
|
+
const keptBefore = [...Array(m.chunks).keys()].filter((i) => r2.disk.has(i));
|
|
177
|
+
ok(keptBefore.every((i) => !asked.includes(i)), 'the resume never asks for a chunk the bitmap holds');
|
|
178
|
+
|
|
179
|
+
// A chunk altered once in transit: asked again, done. Always: chunk_hash.
|
|
180
|
+
let altered = 0;
|
|
181
|
+
const once = (f) => { if (f[0] === T.DATA && readFrame(f).index === 3 && readFrame(f).offset === 0 && altered++ === 0) { const g = f.slice(); g[20] ^= 1; return g; } return null; };
|
|
182
|
+
const r4 = await attempt(bytes, m, hashes, { have: new Have(m.chunks), alter: once });
|
|
183
|
+
ok(r4.receiver === 'done' && altered === 2, 'a chunk altered once: asked again, then done', `${r4.receiver}, ${altered}`);
|
|
184
|
+
const always = (f) => { if (f[0] === T.DATA && readFrame(f).index === 5 && readFrame(f).offset === 0) { const g = f.slice(); g[20] ^= 1; return g; } return null; };
|
|
185
|
+
const r5 = await attempt(bytes, m, hashes, { have: new Have(m.chunks), alter: always });
|
|
186
|
+
ok(r5.receiver === 'chunk_hash' && r5.sender === 'chunk_hash' && !r5.disk.has(5), 'a chunk altered every time: chunk_hash on both sides, never written', `${r5.receiver}/${r5.sender}`);
|
|
187
|
+
// The list altered: chunk_hash before any chunk is asked.
|
|
188
|
+
const list = (f) => { if (f[0] === T.LIST) { const g = f.slice(); g[10] ^= 1; return g; } return null; };
|
|
189
|
+
const r6 = await attempt(bytes, m, hashes, { have: new Have(m.chunks), alter: list });
|
|
190
|
+
ok(r6.receiver === 'chunk_hash' && r6.disk.size === 0, 'the list altered: chunk_hash, nothing written');
|
|
191
|
+
// The file changed under the sender: file_changed.
|
|
192
|
+
const r7 = await attempt(bytes, m, hashes, { have: new Have(m.chunks), readHook: (i) => { if (i === 4) throw Object.assign(new Error('moved'), { check: 'file_changed' }); } });
|
|
193
|
+
ok(r7.sender === 'file_changed' && r7.receiver === 'file_changed', 'the file changed at the sender: file_changed on both sides', `${r7.sender}/${r7.receiver}`);
|
|
194
|
+
// An empty file, and one of one byte.
|
|
195
|
+
for (const n of [0, 1]) {
|
|
196
|
+
const b = seeded('tiny', n), hs = hashesOf(b), mm = manifest({ name: 'e', size: n, sha256: createHash('sha256').update(b).digest('hex'), hashes: hs, now: NOW });
|
|
197
|
+
const r = await attempt(b, mm, hs, { have: new Have(mm.chunks) });
|
|
198
|
+
ok(r.receiver === 'done', `a file of ${n} bytes: done`, r.receiver);
|
|
199
|
+
}
|
|
200
|
+
// A receiver that asks past the file, or more than 8 at once: the sender stops (cancelled).
|
|
201
|
+
const [ca, cb] = fakePair();
|
|
202
|
+
const ended = new Promise((res) => new Serve({ m, hashes, channel: ca, read: async () => new Uint8Array(1), onEnd: (r) => res(r) }).start());
|
|
203
|
+
cb.send(frames.want(m.chunks - 1, 2));
|
|
204
|
+
ok(await ended === 'cancelled', 'a WANT past the file: the sender ends it');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const RELAY_DIR = process.env.SIGELO_RELAY_DIR ?? join(HERE, '..', 'relay');
|
|
208
|
+
if (!existsSync(join(RELAY_DIR, 'server.mjs')) || !existsSync(join(RELAY_DIR, 'node_modules'))) {
|
|
209
|
+
report();
|
|
210
|
+
console.log(`ALL PASS (${count}): the unit part; SKIP the flows, no relay checkout with its dependencies beside contact/: set SIGELO_RELAY_DIR`);
|
|
211
|
+
process.exit(0);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// The direct path needs sigelo-transfer installed beside contact/ (npm ci in sigelo-transfer/).
|
|
215
|
+
if (!existsSync(join(HERE, '..', 'sigelo-transfer', 'node_modules', 'werift'))) {
|
|
216
|
+
report();
|
|
217
|
+
console.log(`ALL PASS (${count}): the unit part; SKIP the flows, sigelo-transfer has no node_modules: npm ci in sigelo-transfer/`);
|
|
218
|
+
process.exit(0);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// ================================================================ two agents on a loopback relay
|
|
222
|
+
const { startRelay } = await import(pathToFileURL(join(RELAY_DIR, 'server.mjs')).href);
|
|
223
|
+
const { relayPolicy } = await import(pathToFileURL(join(RELAY_DIR, 'allowance.mjs')).href);
|
|
224
|
+
const { Carrier, pathsFor } = await import('./carrier.mjs');
|
|
225
|
+
const X = await import('./transfer-node.mjs');
|
|
226
|
+
setTimeout(() => { console.log(`FAIL the run did not finish in 1500 s (${count} checks so far)`); process.exit(1); }, 1_500_000).unref();
|
|
227
|
+
|
|
228
|
+
const HOST = 'relay.test', now = NOW;
|
|
229
|
+
const dir = mkdtempSync(join(tmpdir(), 'sigelo-transfer-'));
|
|
230
|
+
const relay = await startRelay({ host: HOST, db: join(dir, 'relay.db'), tcpPort: 0, httpPort: 0, loginRate: 100000, verifyBudget: 1e9, clock: () => now, diskUsed: () => 0.1,
|
|
231
|
+
log: () => {}, policy: (ctx) => relayPolicy(ctx, { pow: { bits: 8, loadBits: 12, loadPerHour: 1000 } }) });
|
|
232
|
+
const endpoints = { [HOST]: { mqtt: `mqtt://127.0.0.1:${relay.ports.tcp}`, http: `http://127.0.0.1:${relay.ports.http}` } };
|
|
233
|
+
const seed = (l) => new Uint8Array(createHash('sha256').update(`sigelo-transfer-test/0 ${l}`).digest());
|
|
234
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
235
|
+
const until = async (f, ms = 60000) => { const t = Date.now() + ms; while (Date.now() < t) { if (await f()) return true; await sleep(100); } return false; };
|
|
236
|
+
const failure = async (f) => { try { await f(); return 'accepted'; } catch (e) { return e.check ?? `exception ${e.message}`; } };
|
|
237
|
+
function agent(label, { tor = null, rtc } = {}) {
|
|
238
|
+
const k = keygen({ seed: seed(label), recovery: 'sha256:' + '0'.repeat(64), created: '2026-10-01T00:00:00Z', nonce: seed(`${label} nonce`).slice(0, 16) });
|
|
239
|
+
const a = { label, did: k.did, identity: join(dir, `${label}.local.json`), events: [] };
|
|
240
|
+
const bundle = { v: 'sigelo/0', typ: 'bundle', genesis: k.genesis, rotations: [], bindings: [], attestations: [], issuers: [] };
|
|
241
|
+
a.c = new Carrier({ identity: () => ({ secret: k.secret, bundle }), ...pathsFor(a.identity), relay: HOST, endpoints, clock: () => now, keep: true, backoff: [100, 400], retentionDays: 7,
|
|
242
|
+
onEvent: (e) => { if (e.type === 'transfer') a.e?.kick(); } });
|
|
243
|
+
a.newEngine = (o = {}) => { a.e = new X.Engine({ carrier: a.c, identity: a.identity, stun: [], tor, retryMs: 300, torConnectMs: 20000, onEvent: (e) => a.events.push(e), ...(rtc && { rtc }), ...o }); return a.e; };
|
|
244
|
+
a.newEngine();
|
|
245
|
+
a.rec = (side, id) => X.list({ carrier: a.c, identity: a.identity })[side].find((r) => r.id === id);
|
|
246
|
+
return a;
|
|
247
|
+
}
|
|
248
|
+
const A = agent('alice'), B = agent('bob');
|
|
249
|
+
try {
|
|
250
|
+
const inv = await A.c.invite({ name: 'bob' });
|
|
251
|
+
await B.c.accept(inv.code, { name: 'alice', wait: 0.3 });
|
|
252
|
+
await A.c.inbox(); await B.c.inbox(); await A.c.inbox();
|
|
253
|
+
await A.c.start(); await B.c.start();
|
|
254
|
+
const file = (name, bytes) => { const f = join(dir, name); writeFileSync(f, bytes); return f; };
|
|
255
|
+
const send = (path, o = {}) => X.send({ carrier: A.c, identity: A.identity, to: 'bob', path, ...o });
|
|
256
|
+
|
|
257
|
+
// The direct switch: friend contacts are asked once; own ones are on.
|
|
258
|
+
ok(await failure(() => send(file('small.bin', seeded('s', 1000)))) === 'direct_ask', 'send to a friend contact, the direct switch not set: direct_ask');
|
|
259
|
+
ok(X.list({ carrier: A.c, identity: A.identity }).out.length === 0, 'and nothing was sent');
|
|
260
|
+
A.c.setTier('bob', 'own'); B.c.setTier('alice', 'own');
|
|
261
|
+
ok(X.directFor({ direct: {} }, { tier: 'own' }) === true && X.directFor({ direct: {} }, { tier: 'friend' }) === null && X.directFor({ direct: { d: false } }, { did: 'd', tier: 'own' }) === false, 'directFor: own on, others asked (null), a kept choice wins');
|
|
262
|
+
|
|
263
|
+
// Consent: a manifest is a question; nothing is written before the yes; decline tells the sender.
|
|
264
|
+
const r1 = await send(file('small.bin', seeded('s', 1000)));
|
|
265
|
+
ok(await until(() => B.rec('in', r1.id)?.state === 'asked'), 'the manifest reaches bob: asked');
|
|
266
|
+
ok(!existsSync(join(B.c.filesDir, '.transfer', `${r1.id}.part`)), 'nothing is written before the yes');
|
|
267
|
+
ok(B.events.some((e) => e.what === 'asked' && e.id === r1.id && e.name === 'small.bin' && e.size === 1000), 'an asked event: name and size, for the page, watch and MCP');
|
|
268
|
+
const hist = B.c.history({ since: 0 }).messages;
|
|
269
|
+
ok(!hist.some((m) => m.label === TRANSFER_LABEL) && !(await B.c.inbox()).messages.some((m) => m.label === TRANSFER_LABEL), 'transfer messages never reach inbox() nor the log');
|
|
270
|
+
await X.decline({ carrier: B.c, identity: B.identity, id: r1.id });
|
|
271
|
+
ok(await until(() => A.rec('out', r1.id)?.state === 'declined'), 'decline: the sender\'s record says declined');
|
|
272
|
+
|
|
273
|
+
// Busy: past 8 waiting from one contact, the next gets busy.
|
|
274
|
+
const many = [];
|
|
275
|
+
for (let i = 0; i < 9; i++) many.push(await send(file(`m${i}.bin`, seeded(`m${i}`, 10))));
|
|
276
|
+
ok(await until(() => A.rec('out', many[8].id)?.state === 'failed' && A.rec('out', many[8].id)?.reason === 'busy'), 'a ninth manifest waiting from one contact: busy', JSON.stringify(A.rec('out', many[8].id)));
|
|
277
|
+
for (const r of many.slice(0, 8)) await X.decline({ carrier: B.c, identity: B.identity, id: r.id });
|
|
278
|
+
|
|
279
|
+
// A 50 MB file, direct over werift: done, saved as send-file saves, one inbox item, MB/s.
|
|
280
|
+
const MB = Number(process.env.SIGELO_TEST_MB ?? 50), big = seeded('big', MB * 1000 * 1000), bigPath = file('big.bin', big);
|
|
281
|
+
const want = createHash('sha256').update(big).digest('hex');
|
|
282
|
+
const r2 = await send(bigPath);
|
|
283
|
+
ok(await until(() => B.rec('in', r2.id)?.state === 'asked'), `the ${MB} MB manifest: asked`);
|
|
284
|
+
X.accept({ carrier: B.c, identity: B.identity, id: r2.id }); B.e.kick();
|
|
285
|
+
ok(await until(() => B.rec('in', r2.id)?.state === 'done', 900000), `${MB} MB direct: done`, JSON.stringify(B.rec('in', r2.id)));
|
|
286
|
+
// From the channel open to the file read back and placed.
|
|
287
|
+
const at = (w) => B.events.find((e) => e.id === r2.id && e.what === w)?.at_ms;
|
|
288
|
+
await until(() => at('done') !== undefined);
|
|
289
|
+
const secs = (at('done') - at('active')) / 1000, rate = (MB / secs).toFixed(2);
|
|
290
|
+
console.log(`direct over werift, both agents in this process: ${MB} MB in ${secs.toFixed(1)} s = ${rate} MB/s`);
|
|
291
|
+
const doneIn = B.rec('in', r2.id);
|
|
292
|
+
ok(doneIn.path_used === 'direct' && existsSync(doneIn.saved) && createHash('sha256').update(readFileSync(doneIn.saved)).digest('hex') === want && (statSync(doneIn.saved).mode & 0o777) === 0o600, 'saved whole, 0600, the SHA-256 of the file sent');
|
|
293
|
+
ok(doneIn.saved.startsWith(join(B.c.filesDir, '')) && basename(doneIn.saved) === `${want.slice(0, 8)}-big.bin`, 'placed as send-file places one: <files>/<contact>-<hex>/<sha8>-<name>');
|
|
294
|
+
ok(await until(() => A.rec('out', r2.id)?.state === 'done'), 'the sender: done');
|
|
295
|
+
const box = (await B.c.inbox()).messages.filter((m) => m.type === 'file' && m.transfer === r2.id);
|
|
296
|
+
ok(box.length === 1 && box[0].path === doneIn.saved && box[0].size === big.length, 'one inbox item {type: "file", transfer}');
|
|
297
|
+
ok(readdirSync(join(B.c.filesDir, '.transfer')).filter((n) => n.startsWith(r2.id)).length === 0, 'no partials left');
|
|
298
|
+
|
|
299
|
+
// A drop midway: interrupted, resumed by a new offer, only the rest asked; done.
|
|
300
|
+
const mid = seeded('mid', 24 * CHUNK + 3), r3 = await send(file('mid.bin', mid));
|
|
301
|
+
await until(() => B.rec('in', r3.id)?.state === 'asked');
|
|
302
|
+
X.accept({ carrier: B.c, identity: B.identity, id: r3.id }); B.e.kick();
|
|
303
|
+
ok(await until(() => (B.e.progress(r3.id)?.got ?? 0) >= 4 * CHUNK, 300000), 'the second transfer is under way');
|
|
304
|
+
B.e.attempts.get(r3.id)?.channel?.close();
|
|
305
|
+
ok(await until(() => B.rec('in', r3.id)?.state === 'done', 300000), 'cut midway: resumed and done', JSON.stringify(B.rec('in', r3.id)));
|
|
306
|
+
ok(B.rec('in', r3.id).attempt >= 2 && B.events.some((e) => e.what === 'interrupted' && e.id === r3.id), `the resume was a new attempt (${B.rec('in', r3.id).attempt})`);
|
|
307
|
+
ok(createHash('sha256').update(readFileSync(B.rec('in', r3.id).saved)).digest('hex') === createHash('sha256').update(mid).digest('hex'), 'the resumed file is whole');
|
|
308
|
+
|
|
309
|
+
// The file changed after it was offered: file_changed on both sides.
|
|
310
|
+
const chPath = file('ch.bin', seeded('ch', 3000)), r4 = await send(chPath);
|
|
311
|
+
await until(() => B.rec('in', r4.id)?.state === 'asked');
|
|
312
|
+
writeFileSync(chPath, seeded('ch2', 3001));
|
|
313
|
+
X.accept({ carrier: B.c, identity: B.identity, id: r4.id }); B.e.kick();
|
|
314
|
+
ok(await until(() => A.rec('out', r4.id)?.reason === 'file_changed' && B.rec('in', r4.id)?.reason === 'file_changed'), 'changed after the offer: file_changed on both sides', JSON.stringify([A.rec('out', r4.id), B.rec('in', r4.id)]));
|
|
315
|
+
|
|
316
|
+
// Cancel by the sender while waiting: the receiver's record says cancelled.
|
|
317
|
+
const r5 = await send(file('c.bin', seeded('c', 10)));
|
|
318
|
+
await until(() => B.rec('in', r5.id)?.state === 'asked');
|
|
319
|
+
await X.cancel({ carrier: A.c, identity: A.identity, id: r5.id, engine: A.e });
|
|
320
|
+
ok(await until(() => B.rec('in', r5.id)?.state === 'cancelled'), 'the sender cancels: cancelled at the receiver');
|
|
321
|
+
ok(await failure(() => X.accept({ carrier: B.c, identity: B.identity, id: r5.id })) === 'transfer_state', 'a cancelled transfer cannot be accepted');
|
|
322
|
+
|
|
323
|
+
// No path: direct off on the receiver, no Tor: no_path, the free refusal's words.
|
|
324
|
+
X.setDirect({ carrier: B.c, identity: B.identity, contact: 'alice', on: false });
|
|
325
|
+
X.settings({ identity: B.identity, patch: { tor: false } });
|
|
326
|
+
const r6 = await send(file('np.bin', seeded('np', 10)));
|
|
327
|
+
await until(() => B.rec('in', r6.id)?.state === 'asked');
|
|
328
|
+
X.accept({ carrier: B.c, identity: B.identity, id: r6.id }); B.e.kick();
|
|
329
|
+
ok(await until(() => B.rec('in', r6.id)?.reason === 'no_path' && A.rec('out', r6.id)?.reason === 'no_path'), 'direct off and no Tor: no_path on both sides');
|
|
330
|
+
ok(/No direct path to alice .* and no Tor\. Up to 8 MiB: send-file/.test(B.rec('in', r6.id).detail ?? ''), 'the refusal names send-file', B.rec('in', r6.id).detail);
|
|
331
|
+
X.settings({ identity: B.identity, patch: { tor: true } });
|
|
332
|
+
|
|
333
|
+
// ============================================================ Tor, against a fake tor (or a real one: SIGELO_TEST_TOR)
|
|
334
|
+
const fake = await fakeTor();
|
|
335
|
+
for (const x of [A, B]) { await x.e.close(); x.newEngine({ tor: { control: ['127.0.0.1', fake.control], socks: ['127.0.0.1', fake.socks], password: null } }); }
|
|
336
|
+
ok(JSON.stringify(await X.torCaps({ control: ['127.0.0.1', fake.control], socks: ['127.0.0.1', fake.socks], password: null })) === '{"serve":true,"connect":true}', 'torCaps: the fake tor serves and connects');
|
|
337
|
+
ok(JSON.stringify(await X.torCaps({ control: ['127.0.0.1', 1], socks: ['127.0.0.1', 1], password: null })) === '{"serve":false,"connect":false}', 'torCaps: no daemon: off');
|
|
338
|
+
const tf = seeded('tor', 5 * CHUNK + 9), r7 = await send(file('tor.bin', tf));
|
|
339
|
+
await until(() => B.rec('in', r7.id)?.state === 'asked');
|
|
340
|
+
X.accept({ carrier: B.c, identity: B.identity, id: r7.id }); B.e.kick(); // direct is off at bob: Tor
|
|
341
|
+
ok(await until(() => B.rec('in', r7.id)?.state === 'done', 120000), 'direct off at the receiver: over Tor, done', JSON.stringify(B.rec('in', r7.id)));
|
|
342
|
+
ok(B.rec('in', r7.id)?.path_used === 'tor' && createHash('sha256').update(readFileSync(B.rec('in', r7.id).saved)).digest('hex') === createHash('sha256').update(tf).digest('hex'), 'the file came over the onion stream, whole');
|
|
343
|
+
ok(fake.log.some((l) => /^ADD_ONION NEW:ED25519-V3 Flags=DiscardPK,V3Auth Port=\d+,127\.0\.0\.1:\d+ ClientAuthV3=[A-Z2-7]{52}$/.test(l)), 'ADD_ONION: a fresh key discarded, client authorization', fake.log.join(' | '));
|
|
344
|
+
ok(fake.log.some((l) => /^ONION_CLIENT_AUTH_ADD [a-z2-7]{56} x25519:/.test(l)) && fake.authOk > 0, 'the connector adds the client key, and it is the service\'s');
|
|
345
|
+
ok(await until(() => fake.log.some((l) => l.startsWith('DEL_ONION '))), 'DEL_ONION when done');
|
|
346
|
+
ok(fake.wrongToken === 0, 'the stream proved its token');
|
|
347
|
+
// A stream without the token: closed, nothing served.
|
|
348
|
+
fake.stranger = true;
|
|
349
|
+
X.setDirect({ carrier: B.c, identity: B.identity, contact: 'alice', on: true });
|
|
350
|
+
const r8 = await send(file('via.bin', seeded('via', 2 * CHUNK)), { via: 'tor' });
|
|
351
|
+
await until(() => B.rec('in', r8.id)?.state === 'asked');
|
|
352
|
+
X.accept({ carrier: B.c, identity: B.identity, id: r8.id }); B.e.kick();
|
|
353
|
+
ok(await until(() => B.rec('in', r8.id)?.state === 'done', 120000), '--via tor with direct on: Tor all the same, done', JSON.stringify(B.rec('in', r8.id)));
|
|
354
|
+
ok(B.rec('in', r8.id)?.path_used === 'tor', 'via tor: never direct');
|
|
355
|
+
ok(fake.strangerClosed === true, 'a connection to the onion without the token is closed');
|
|
356
|
+
// The real tor, when one runs here.
|
|
357
|
+
if (process.env.SIGELO_TEST_TOR) console.log('SIGELO_TEST_TOR set: see the real-tor run in test-transfer-tor (not in this file)');
|
|
358
|
+
await fake.close();
|
|
359
|
+
} finally {
|
|
360
|
+
await A.e?.close().catch(() => {}); await B.e?.close().catch(() => {});
|
|
361
|
+
await A.c.stop().catch(() => {}); await B.c.stop().catch(() => {});
|
|
362
|
+
await relay.close();
|
|
363
|
+
rmSync(dir, { recursive: true, force: true });
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* A fake tor: a control port (PROTOCOLINFO with METHODS=NULL, AUTHENTICATE, ADD_ONION, DEL_ONION,
|
|
368
|
+
* ONION_CLIENT_AUTH_ADD, ONION_CLIENT_AUTH_REMOVE) and a SOCKS5 port that connects <service>.onion:port to
|
|
369
|
+
* the target ADD_ONION named, once the client key that matches the service's ClientAuthV3 was added.
|
|
370
|
+
*/
|
|
371
|
+
async function fakeTor() {
|
|
372
|
+
const services = new Map(), auth = new Map(), log = [];
|
|
373
|
+
const t = { log, authOk: 0, wrongToken: 0, stranger: false, strangerClosed: false };
|
|
374
|
+
const control = net.createServer((s) => {
|
|
375
|
+
let buf = '';
|
|
376
|
+
s.on('error', () => {});
|
|
377
|
+
s.on('data', (d) => {
|
|
378
|
+
buf += d;
|
|
379
|
+
let i;
|
|
380
|
+
while ((i = buf.indexOf('\r\n')) >= 0) {
|
|
381
|
+
const line = buf.slice(0, i); buf = buf.slice(i + 2);
|
|
382
|
+
log.push(line);
|
|
383
|
+
const [cmd] = line.split(' ');
|
|
384
|
+
if (cmd === 'PROTOCOLINFO') s.write('250-PROTOCOLINFO 1\r\n250-AUTH METHODS=NULL\r\n250-VERSION Tor="0.4.8.0"\r\n250 OK\r\n');
|
|
385
|
+
else if (cmd === 'AUTHENTICATE') s.write('250 OK\r\n');
|
|
386
|
+
else if (cmd === 'ADD_ONION') {
|
|
387
|
+
const port = /Port=(\d+),127\.0\.0\.1:(\d+)/.exec(line), key = /ClientAuthV3=([A-Z2-7]+)/.exec(line)?.[1] ?? null;
|
|
388
|
+
const id = createHash('sha256').update(line + Math.random()).digest('hex').replace(/[^a-z2-7]/g, '').padEnd(56, 'a').slice(0, 56).replace(/[0189]/g, 'q');
|
|
389
|
+
services.set(id, { virt: Number(port[1]), local: Number(port[2]), key, at: Date.now() });
|
|
390
|
+
s.write(`250-ServiceID=${id}\r\n250 OK\r\n`);
|
|
391
|
+
} else if (cmd === 'DEL_ONION') { services.delete(line.split(' ')[1]); s.write('250 OK\r\n'); }
|
|
392
|
+
else if (cmd === 'ONION_CLIENT_AUTH_ADD') { const [, id, k] = line.split(' '); auth.set(id, k.replace(/^x25519:/, '')); s.write('250 OK\r\n'); }
|
|
393
|
+
else if (cmd === 'ONION_CLIENT_AUTH_REMOVE') { auth.delete(line.split(' ')[1]); s.write('250 OK\r\n'); }
|
|
394
|
+
else if (cmd === 'QUIT') s.end('250 closing connection\r\n');
|
|
395
|
+
else s.write('510 Unrecognized command\r\n');
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
const socks = net.createServer((s) => {
|
|
400
|
+
s.on('error', () => {});
|
|
401
|
+
let stage = 0, buf = Buffer.alloc(0);
|
|
402
|
+
s.on('data', function on(d) {
|
|
403
|
+
buf = Buffer.concat([buf, d]);
|
|
404
|
+
if (stage === 0 && buf.length >= 3) { buf = buf.subarray(3); stage = 1; s.write(Buffer.from([5, 0])); }
|
|
405
|
+
if (stage === 1 && buf.length >= 5 && buf.length >= 5 + buf[4] + 2) {
|
|
406
|
+
const host = buf.subarray(5, 5 + buf[4]).toString(), port = buf.readUInt16BE(5 + buf[4]), rest = buf.subarray(7 + buf[4]);
|
|
407
|
+
const id = host.replace(/\.onion$/, ''), sv = services.get(id);
|
|
408
|
+
// Published after a second, as a real onion takes its time; client auth checked.
|
|
409
|
+
const okAuth = sv && (!sv.key || (auth.has(id) && X.clientPub(auth.get(id)) === sv.key));
|
|
410
|
+
if (sv && okAuth) t.authOk++;
|
|
411
|
+
if (!sv || sv.virt !== port || !okAuth || Date.now() - sv.at < 1000) { s.end(Buffer.from([5, 4, 0, 1, 0, 0, 0, 0, 0, 0])); return; }
|
|
412
|
+
s.off('data', on);
|
|
413
|
+
const up = net.connect(sv.local, '127.0.0.1', () => {
|
|
414
|
+
s.write(Buffer.from([5, 0, 0, 1, 127, 0, 0, 1, 0, 0]));
|
|
415
|
+
if (rest.length) up.write(rest);
|
|
416
|
+
s.pipe(up); up.pipe(s);
|
|
417
|
+
if (t.stranger) {
|
|
418
|
+
// A second connection to the same service without the token: it must be closed.
|
|
419
|
+
t.stranger = false;
|
|
420
|
+
const x = net.connect(sv.local, '127.0.0.1', () => { x.write(Buffer.from([0, 0, 0, 33, 5, ...new Uint8Array(32)])); });
|
|
421
|
+
x.on('close', () => { t.strangerClosed = true; }); x.on('error', () => {});
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
up.on('error', () => s.destroy());
|
|
425
|
+
stage = 2;
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
await new Promise((r) => control.listen(0, '127.0.0.1', r));
|
|
430
|
+
await new Promise((r) => socks.listen(0, '127.0.0.1', r));
|
|
431
|
+
return Object.assign(t, { control: control.address().port, socks: socks.address().port, close: () => { control.close(); socks.close(); } });
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
report();
|
|
435
|
+
console.log(`ALL PASS (${count})`);
|