mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-20 23:20:46 +00:00
* Codex worktree snapshot: startup-cleanup Co-authored-by: Codex * fix(browser): close malformed proxy connections without a reply * feat(browser): embed host browsing in terminal side panels * style(browser): blend compact browser chrome into terminal panels * feat(browser): open terminal links internally with a system browser preference * fix(browser): retain the first terminal link during panel mount replay * fix(browser): release contexts when their split pane closes * style(browser): remove the downloads panel shadow * fix(browser): ignore late downloads after panel closure * fix(browser): mount browser content on terminal auto-open * fix(browser): preserve empty-vault recovery with bookmarks * fix(browser): expose actions for supported terminal types * fix(browser): retain open requests before the panel mounts * fix(browser): align vault actions with supported hosts * fix(browser): share download controls across host contexts * fix(browser): keep vault browser requests on visible sessions * fix(browser): release contexts after workspace detach * fix(browser): enforce WebRTC routing on page contents * fix(browser): skip unsupported sessions in open requests * style(browser): encode glyphs in ASCII-safe source
47 lines
1.7 KiB
JavaScript
47 lines
1.7 KiB
JavaScript
"use strict";
|
|
|
|
const { test } = require("node:test");
|
|
const assert = require("node:assert/strict");
|
|
const { createSocks5RequestParser } = require("./socks5Request.cjs");
|
|
|
|
function harness() {
|
|
const events = [];
|
|
const parser = createSocks5RequestParser({
|
|
onConnect: (host, port, remainder) => events.push({ host, port, remainder: [...remainder] }),
|
|
onFailure: (code) => events.push({ failure: code }),
|
|
});
|
|
parser.onGreeting = () => events.push({ greeting: true });
|
|
return { parser, events };
|
|
}
|
|
|
|
test("SOCKS5 parses split greeting and domain request with retained page bytes", () => {
|
|
const { parser, events } = harness();
|
|
parser.push(Buffer.from([5]));
|
|
parser.push(Buffer.from([1, 0, 5, 1, 0, 3, 9, 108, 111]));
|
|
parser.push(Buffer.from("calhost"));
|
|
parser.push(Buffer.from([0, 80, 71, 69, 84]));
|
|
assert.deepEqual(events, [
|
|
{ greeting: true },
|
|
{ host: "localhost", port: 80, remainder: [71, 69, 84] },
|
|
]);
|
|
});
|
|
|
|
test("SOCKS5 accepts IPv4 and IPv6 CONNECT targets", () => {
|
|
const ipv4 = harness();
|
|
ipv4.parser.push(Buffer.from([5, 1, 0, 5, 1, 0, 1, 127, 0, 0, 1, 0, 80]));
|
|
assert.equal(ipv4.events[1].host, "127.0.0.1");
|
|
const ipv6 = harness();
|
|
ipv6.parser.push(Buffer.from([5, 1, 0, 5, 1, 0, 4, ...Array(15).fill(0), 1, 1, 187]));
|
|
assert.equal(ipv6.events[1].host, "0:0:0:0:0:0:0:1");
|
|
assert.equal(ipv6.events[1].port, 443);
|
|
});
|
|
|
|
test("SOCKS5 refuses unsupported commands and oversized handshakes", () => {
|
|
const command = harness();
|
|
command.parser.push(Buffer.from([5, 1, 0, 5, 3, 0, 1, 127, 0, 0, 1, 0, 80]));
|
|
assert.deepEqual(command.events.at(-1), { failure: 7 });
|
|
const oversized = harness();
|
|
oversized.parser.push(Buffer.alloc(1025, 5));
|
|
assert.deepEqual(oversized.events, [{ failure: 1 }]);
|
|
});
|