Files
maeneko 59e076c1de Start the Go rewrite: jsjson, awg-ctrl port, differential bench
- internal/jsjson: JSON.stringify-compatible encoder and order-preserving decoder,
  tested against fixtures produced by Node itself
- internal/ctrl: awg-ctrl in Go (params, vpn:// keys, users, peers, sync, 3.1
  upgrade, CAKE shaping, metrics, monitor job, Express-compatible HTTP layer)
- internal/iauth, internal/logx: internal Ed25519 tokens and logging
- tools/diffbench: Docker bench with stubbed awg/ip/tc/nft that runs one scenario
  against the TS and Go implementations for comparison
2026-10-14 13:27:24 +00:00

24 lines
1.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Эталон для internal/jsjson: вывод JSON.stringify самого Node на каверзных значениях.
// Запуск: node tools/golden/jsjson.mjs > testdata/golden/jsjson.json
const strings = [
"", "plain", "кириллица", "emoji 😀", "<r 2><b 0x85>", "a&b<c>d", "slash/и\\обратный",
"quote\"q", "line\nbreak", "tab\tcr\r", "\b\f", "\u0000\u0001\u001f\u007f", "

",
"I2 = ", " spaces ", "ü", "日本語",
];
const numbers = [0, -0, 1, -1, 1376, 47619, 0.1, 0.5, 1.5, 2.5, 100.25, 1e21, 1e20, 123456789012345680000,
1e-7, 1e-6, 0.000001234, 1.7976931348623157e308, 5e-324, 3.14159, -273.15, 2 ** 53, 2 ** 53 + 2, 0.1 + 0.2, 250.5,
NaN, Infinity, -Infinity];
const objects = [
{ a: 1, b: "x", c: [1, 2, { d: null }], e: true, f: false },
{ rekey: false, endpoints: ["1.2.3.4:443"], servers: [{ id: 0, name: "VPN & <co>
", awg: { Jc: "6", I1: "<r 2>" } }] },
{ empty: {}, arr: [], nested: { x: [] } },
[],
{},
];
const out = {
strings: strings.map(s => ({ in: s, out: JSON.stringify(s) })),
numbers: numbers.map(n => ({ in: Number.isFinite(n) ? n : String(n), out: JSON.stringify(n), str: String(n) })),
objects: objects.map(o => ({ in: o, compact: JSON.stringify(o), indent2: JSON.stringify(o, null, 2) })),
};
process.stdout.write(JSON.stringify(out, null, 1));