fix(network): исправить исходный адрес пинга и обновление фильтров
Docker images / prepare-release (push) Successful in 13s
Docker images / backend-test (push) Successful in 10m58s
Docker images / frontend-image (push) Successful in 3m56s
Docker images / updater-image (push) Successful in 2m37s
Docker images / netflow-agent-image (push) Successful in 39s
Docker images / backend-image (push) Successful in 3m56s
Docker images / publish-release (push) Successful in 12s
Docker images / notify-webhook (push) Successful in 2s

Оставить выбор исходного адреса пинга маршрутизатору. Читать правила и рекурсивные шлюзы последовательно, сохранить кэш при конфликте блокировки.
This commit is contained in:
Denozordec committed 2026-11-22 20:47:38 +07:00
1 parent f5914b634a
commit 80cd3a18d7
5 files changed
+173 -34

No files matched your search

@@ -64,6 +64,7 @@ export async function acceptServerProbeStorageHostSql() {
let raw = ""; for await (const chunk of request) raw += chunk
const body = JSON.parse(raw) as Record<string, unknown>
assert.equal(body.address, "127.0.0.1"); assert.equal(body.count, "1")
assert.equal(Object.hasOwn(body, "src-address"), false)
if (requests === 2) {
response.once("close", secondClosed)
secondValidated()
@@ -103,9 +103,27 @@ for (const type of ["A", "AAAA", "MX", "NS", "TXT", "CNAME", "PTR"]) {
{
const f = fixture(); f.raw([]); await failure(f.executor.execute(await f.executor.prepare(1, request("mtu"))), "MEASUREMENT_UNKNOWN"); assert.equal(f.counts().sends, 1)
}
for (const host of ["192.0.2.1", "router.example"]) {
const f = fixture()
f.source.host = host
f.raw(["192.0.2.1"])
const post = f.deps.post
f.deps.post = async (...args) => {
const source = args[2]["src-address"] ?? "10.205.1.2"
f.raw(source === "10.205.1.2"
? [{ seq: "0", ttl: "64", time: "25ms", sent: "1", received: "1", "packet-loss": "0" }]
: [{ seq: "0", status: "timeout", sent: "1", received: "0", "packet-loss": "100" }])
return post(...args)
}
const prepared = await f.executor.prepare(1, request("ping", { target: "10.205.1.1", pingCount: 1 }))
const result = await f.executor.execute(prepared)
assert.match(result.output!, /sent=1 received=1 packet-loss=0/)
assert.deepEqual(f.counts(), { sends: 1, dnsCalls: 0 })
cases++
}
{
const f = fixture(); f.source.host = "router.example"; f.sourceFailure()
const prepared = await f.executor.prepare(1, request("ping")), result = await f.executor.execute(prepared)
const prepared = await f.executor.prepare(1, request("traceroute")), result = await f.executor.execute(prepared)
assert.equal(result.state, "completed"); assert.equal(f.counts().dnsCalls, 1); assert.equal(f.counts().sends, 1)
assert.equal((f.events.find(event => event.kind === "native")!.value as { body: Record<string, string> }).body["src-address"], undefined)
assert.equal(f.events.filter(event => event.kind === "received").length, 2); cases++
@@ -137,7 +155,7 @@ for (const kind of ["claim", "intent", "receipt", "received"] as const) {
}
{
const f = fixture(); f.source.host = "router.example"; f.raw(["192.0.2.1"])
const prepared = await f.executor.prepare(1, request("ping")); f.lost("received")
const prepared = await f.executor.prepare(1, request("traceroute")); f.lost("received")
await failure(f.executor.execute(prepared), "JOURNAL_UNKNOWN"); assert.equal(f.counts().dnsCalls, 1); assert.equal(f.counts().sends, 0); assert.equal(f.events.filter(event => event.kind === "received").length, 1)
}
{
@@ -232,7 +232,8 @@ export function createServerProbeExecutor(deps: ServerProbeExecutionDependencies
}
claimed = true
let sourceIpv4: string | null = null
if (["ping", "traceroute", "mtu"].includes(plan.request.tool)) {
// Ping must let RouterOS choose the source for the route, including WireGuard.
if (plan.request.tool === "traceroute" || plan.request.tool === "mtu") {
const host = currentSource!.host.trim()
if (isIPv4(host)) sourceIpv4 = host
else {