Buncha fixes and binaries

This commit is contained in:
K_lar 2026-02-12 14:49:56 +01:00
parent 0d0f1abbee
commit 0a52407117
10 changed files with 160 additions and 41 deletions

View file

@ -3,6 +3,7 @@
class NetAttackLab {
constructor() {
this.activeAttacks = new Map();
this.progressIntervals = new Map();
this.sessionUpdateInterval = null;
this.init();
}
@ -248,8 +249,8 @@ class NetAttackLab {
stopBtn.disabled = false;
// Add attack start log
this.addLog('attack-logs', `🔥 Initiating ${type} attack on ${target}`, 'warning');
this.addLog('attack-logs', `⚙️ Parameters: ${duration}s duration, ${intensity} req/sec`, 'info');
this.addLog('attack-logs', `🔥 Začetek ${type} napada na ${target}`, 'warning');
this.addLog('attack-logs', `⚙️ Parametri: ${duration}s trajanje, ${intensity} req/sec`, 'info');
const result = await this.makeRequest('/api/attack', {
target,
@ -259,11 +260,11 @@ class NetAttackLab {
});
if (result.error) {
this.addLog('attack-logs', `❌ Attack failed to start: ${result.error}`, 'error');
this.addLog('attack-logs', `❌ Napad ni uspel: ${result.error}`, 'error');
attackBtn.disabled = false;
stopBtn.disabled = true;
} else {
this.addLog('attack-logs', `✅ Attack session ${result.sessionId} started`, 'success');
this.addLog('attack-logs', `✅ Napadna seja ${result.sessionId} je začela`, 'success');
this.activeAttacks.set(result.sessionId, {
target,
type,
@ -278,6 +279,13 @@ class NetAttackLab {
trackAttackProgress(sessionId, duration) {
let elapsed = 0;
const progressInterval = setInterval(() => {
// Check if attack was stopped
if (!this.activeAttacks.has(sessionId)) {
clearInterval(progressInterval);
this.progressIntervals.delete(sessionId);
return;
}
elapsed++;
const remaining = duration - elapsed;
@ -286,6 +294,7 @@ class NetAttackLab {
} else {
this.addLog('attack-logs', `🏁 Attack session ${sessionId} completed`, 'success');
clearInterval(progressInterval);
this.progressIntervals.delete(sessionId);
// Re-enable attack button
document.getElementById('attack-btn').disabled = false;
@ -296,21 +305,31 @@ class NetAttackLab {
this.activeAttacks.delete(sessionId);
}
}, 1000);
// Store interval ID
this.progressIntervals.set(sessionId, progressInterval);
}
async stopAllAttacks() {
this.addLog('attack-logs', '🛑 Emergency stop initiated...', 'warning');
this.addLog('attack-logs', '🛑 Nujna ustavitev v teku...', 'warning');
for (const sessionId of this.activeAttacks.keys()) {
await this.makeRequest('/api/stop', { sessionId });
this.addLog('attack-logs', `🛑 Session ${sessionId} stopped`, 'info');
// Clear progress interval
const interval = this.progressIntervals.get(sessionId);
if (interval) {
clearInterval(interval);
this.progressIntervals.delete(sessionId);
}
}
this.activeAttacks.clear();
document.getElementById('attack-btn').disabled = false;
document.getElementById('stop-btn').disabled = true;
this.addLog('attack-logs', '✅ All attacks stopped', 'success');
this.addLog('attack-logs', '✅ Vsi napadi prekinjeni', 'success');
}
// Session Monitoring
@ -386,6 +405,15 @@ class NetAttackLab {
async stopSession(sessionId) {
await this.makeRequest('/api/stop', { sessionId });
this.addLog('attack-logs', `🛑 Session ${sessionId} stopped manually`, 'warning');
// Clear progress interval
const interval = this.progressIntervals.get(sessionId);
if (interval) {
clearInterval(interval);
this.progressIntervals.delete(sessionId);
}
this.activeAttacks.delete(sessionId);
this.updateSessionsTable();
}
}