round54: Live-Fortschritt (Prozent, Restzeit, gefundene Ports/bestaetigte Dienste) waehrend masscan-/httpx-Vorabscan

This commit is contained in:
2026-07-26 11:50:21 +02:00
parent edc4acaf3b
commit c7398ce2ba
3 changed files with 215 additions and 104 deletions

View File

@@ -257,7 +257,32 @@ export async function scanRoutes(app: FastifyInstance): Promise<void> {
// masscan-/httpx-Lauf arbeitete (siehe Bugreport).
updateJobProgress("devices", 0, `masscan läuft… (${deviceIps.length} Geräte, vollständiger Portscan)`);
const masscanStartedAt = Date.now();
const masscanBatch = await scanHostsWithMasscan(deviceIps, "1-65535");
// masscan meldet laufend Fortschritt (Prozent, Restzeit, bisherige
// Treffer) - wird hier live in die Fortschrittsanzeige gespiegelt,
// statt nur den statischen "masscan läuft…"-Text stehen zu lassen
// (siehe Bugreport: "ich sehe nicht, ob noch alles richtig läuft").
// Eine feste IP lässt sich dabei bewusst NICHT anzeigen - masscan
// arbeitet alle Ziel-Hosts gemeinsam/asynchron ab, es gibt keine
// sinnvolle "aktuell bearbeitete IP" wie bei einem sequenziellen
// Scanner.
let lastMasscanProgressUpdate = 0;
const masscanBatch = await scanHostsWithMasscan(deviceIps, "1-65535", undefined, (progress) => {
const now = Date.now();
if (now - lastMasscanProgressUpdate < 500) return; // nicht öfter als 2x/s aktualisieren
lastMasscanProgressUpdate = now;
const etaText =
progress.etaSeconds !== null
? progress.etaSeconds > 0
? `, ~${progress.etaSeconds}s verbleibend`
: ", wartet auf letzte Antworten"
: "";
updateJobProgress(
"devices",
0,
`masscan läuft… (${deviceIps.length} Geräte, vollständiger Portscan) ${progress.percent.toFixed(0)}% erledigt${etaText}, ${progress.foundSoFar} offene(r) Port(s) bisher`
);
});
const masscanDurationMs = Date.now() - masscanStartedAt;
const masscanBatchError = masscanBatch === null ? getMasscanLastError() : null;
const masscanPortsFound = masscanBatch
@@ -294,7 +319,24 @@ export async function scanRoutes(app: FastifyInstance): Promise<void> {
updateJobProgress("devices", 0, `httpx läuft… (${httpxTargets.length} Port(s) über alle Geräte)`);
const httpxStartedAt = Date.now();
httpxBatch = await probeManyWithHttpx(httpxTargets);
// httpx meldet jeden Treffer sofort, sobald er bestätigt ist -
// wird hier live in die Fortschrittsanzeige gespiegelt (Anzahl
// bereits als HTTP/HTTPS bestätigter Ports von den insgesamt zu
// prüfenden Zielen). Eine Zwischenanzeige "noch nicht geprüfte"
// Ziele ist dabei nicht sinnvoll möglich - httpx meldet erfolglose
// Versuche gar nicht erst zurück (siehe httpx.ts).
let lastHttpxProgressUpdate = 0;
httpxBatch = await probeManyWithHttpx(httpxTargets, (confirmedSoFar) => {
const now = Date.now();
if (now - lastHttpxProgressUpdate < 500) return;
lastHttpxProgressUpdate = now;
updateJobProgress(
"devices",
0,
`httpx läuft… (${httpxTargets.length} Port(s) über alle Geräte) ${confirmedSoFar} bereits als HTTP/HTTPS bestätigt`
);
});
const httpxDurationMs = Date.now() - httpxStartedAt;
if (httpxBatch === null) httpxBatchError = getHttpxLastError();