mirror of
https://github.com/morluto/rea.git
synced 2026-11-04 05:46:17 +00:00
* test: strengthen integration oracles and verification * test: bound lifecycle gates and strengthen workflow checks * test: verify complete paged and extracted results * test: preserve bytecode and cancellation evidence * test: strengthen retained evidence and fixture cleanup * test: require cross-projection bridge identities * test: retain fixture owners through cleanup failures * test: verify graph examples and project selectors * test: tighten provider and lifecycle regressions * test: consolidate hex coverage and bound cutter cleanup * test: bound subprocess output waits and strengthen graph checks * test: check mcp recovery and preserve cleanup owners * test: verify structured mcp argument failures * test: preserve artifact cleanup and gdb limit evidence * test: preserve evidence identities and bound provider gates * test: retain browser and comparison cleanup owners * test: bound startup and strengthen fixture oracles * test: bound lifecycle gates and verify recovered evidence * test: verify public outcomes and lifecycle ownership * test: assert precise evidence and release lifecycle gates * test: verify selected facts and bound cleanup waits * test: check retained evidence and decoded records * test: verify final reports and retain cleanup ownership * test: bound reviewed startup gates and retain cleanup * test: verify PE errors and preserve MCP cleanup * test: preserve MCP fixture cleanup ownership * test: release provider gates before late startup
61 lines
2.2 KiB
TypeScript
61 lines
2.2 KiB
TypeScript
/** Owned offline Ethernet/IPv4/TCP fixture; no traffic or external input. */
|
|
export const offlineHttpCapture = (
|
|
uri: string,
|
|
packets = 1,
|
|
host: string | null = "example.test",
|
|
): Buffer => {
|
|
if (!Number.isSafeInteger(packets) || packets < 1 || packets > 40_000)
|
|
throw new RangeError("Offline test captures support 1..40000 packets");
|
|
const payload = Buffer.from(
|
|
`GET ${uri} HTTP/${host === null ? "1.0" : "1.1"}\r\n${host === null ? "" : `Host: ${host}\r\n`}Connection: close\r\n\r\n`,
|
|
);
|
|
const checksum = (bytes: Buffer): number => {
|
|
let total = 0;
|
|
for (let index = 0; index < bytes.length; index += 2)
|
|
total += ((bytes[index] ?? 0) << 8) | (bytes[index + 1] ?? 0);
|
|
while (total >>> 16) total = (total & 0xffff) + (total >>> 16);
|
|
return ~total & 0xffff;
|
|
};
|
|
const source = Buffer.from([192, 0, 2, 1]);
|
|
const destination = Buffer.from([198, 51, 100, 2]);
|
|
const tcp = Buffer.alloc(20);
|
|
tcp.writeUInt16BE(44000, 0);
|
|
tcp.writeUInt16BE(80, 2);
|
|
tcp.writeUInt32BE(1, 4);
|
|
tcp.writeUInt32BE(1, 8);
|
|
tcp.writeUInt16BE(0x5018, 12);
|
|
tcp.writeUInt16BE(65535, 14);
|
|
const pseudo = Buffer.concat([
|
|
source,
|
|
destination,
|
|
Buffer.from([0, 6, 0, 0]),
|
|
]);
|
|
pseudo.writeUInt16BE(tcp.length + payload.length, 10);
|
|
tcp.writeUInt16BE(checksum(Buffer.concat([pseudo, tcp, payload])), 16);
|
|
const ip = Buffer.alloc(20);
|
|
ip[0] = 0x45;
|
|
ip.writeUInt16BE(ip.length + tcp.length + payload.length, 2);
|
|
ip.writeUInt16BE(1, 4);
|
|
ip[8] = 64;
|
|
ip[9] = 6;
|
|
source.copy(ip, 12);
|
|
destination.copy(ip, 16);
|
|
ip.writeUInt16BE(checksum(ip), 10);
|
|
const ethernet = Buffer.from([2, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 1, 8, 0]);
|
|
const frame = Buffer.concat([ethernet, ip, tcp, payload]);
|
|
const record = Buffer.alloc(16 + frame.length);
|
|
record.writeUInt32LE(1_700_000_000, 0);
|
|
record.writeUInt32LE(frame.length, 8);
|
|
record.writeUInt32LE(frame.length, 12);
|
|
frame.copy(record, 16);
|
|
const capture = Buffer.alloc(24 + packets * record.length);
|
|
capture.writeUInt32LE(0xa1b2c3d4, 0);
|
|
capture.writeUInt16LE(2, 4);
|
|
capture.writeUInt16LE(4, 6);
|
|
capture.writeUInt32LE(65535, 16);
|
|
capture.writeUInt32LE(1, 20);
|
|
for (let index = 0; index < packets; index++)
|
|
record.copy(capture, 24 + index * record.length);
|
|
return capture;
|
|
};
|