it
This commit is contained in:
@@ -246,7 +246,7 @@ class DNSReconApp {
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a reconnaissance scan
|
||||
* Enhanced start scan with better error handling
|
||||
*/
|
||||
async startScan(clearGraph = true) {
|
||||
console.log('=== STARTING SCAN ===');
|
||||
@@ -292,7 +292,6 @@ class DNSReconApp {
|
||||
|
||||
if (response.success) {
|
||||
this.currentSessionId = response.scan_id;
|
||||
this.startPolling();
|
||||
this.showSuccess('Reconnaissance scan started successfully');
|
||||
|
||||
if (clearGraph) {
|
||||
@@ -301,6 +300,9 @@ class DNSReconApp {
|
||||
|
||||
console.log(`Scan started for ${targetDomain} with depth ${maxDepth}`);
|
||||
|
||||
// Start polling immediately with faster interval for responsiveness
|
||||
this.startPolling(1000);
|
||||
|
||||
// Force an immediate status update
|
||||
console.log('Forcing immediate status update...');
|
||||
setTimeout(() => {
|
||||
@@ -318,18 +320,43 @@ class DNSReconApp {
|
||||
this.setUIState('idle');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the current scan
|
||||
* Enhanced scan stop with immediate UI feedback
|
||||
*/
|
||||
async stopScan() {
|
||||
try {
|
||||
console.log('Stopping scan...');
|
||||
|
||||
// Immediately disable stop button and show stopping state
|
||||
if (this.elements.stopScan) {
|
||||
this.elements.stopScan.disabled = true;
|
||||
this.elements.stopScan.innerHTML = '<span class="btn-icon">[STOPPING]</span><span>Stopping...</span>';
|
||||
}
|
||||
|
||||
// Show immediate feedback
|
||||
this.showInfo('Stopping scan...');
|
||||
|
||||
const response = await this.apiCall('/api/scan/stop', 'POST');
|
||||
|
||||
if (response.success) {
|
||||
this.showSuccess('Scan stop requested');
|
||||
console.log('Scan stop requested');
|
||||
console.log('Scan stop requested successfully');
|
||||
|
||||
// Force immediate status update
|
||||
setTimeout(() => {
|
||||
this.updateStatus();
|
||||
}, 100);
|
||||
|
||||
// Continue polling for a bit to catch the status change
|
||||
this.startPolling(500); // Fast polling to catch status change
|
||||
|
||||
// Stop fast polling after 10 seconds
|
||||
setTimeout(() => {
|
||||
if (this.scanStatus === 'stopped' || this.scanStatus === 'idle') {
|
||||
this.stopPolling();
|
||||
}
|
||||
}, 10000);
|
||||
|
||||
} else {
|
||||
throw new Error(response.error || 'Failed to stop scan');
|
||||
}
|
||||
@@ -337,6 +364,12 @@ class DNSReconApp {
|
||||
} catch (error) {
|
||||
console.error('Failed to stop scan:', error);
|
||||
this.showError(`Failed to stop scan: ${error.message}`);
|
||||
|
||||
// Re-enable stop button on error
|
||||
if (this.elements.stopScan) {
|
||||
this.elements.stopScan.disabled = false;
|
||||
this.elements.stopScan.innerHTML = '<span class="btn-icon">[STOP]</span><span>Terminate Scan</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,9 +398,9 @@ class DNSReconApp {
|
||||
}
|
||||
|
||||
/**
|
||||
* Start polling for scan updates
|
||||
* Start polling for scan updates with configurable interval
|
||||
*/
|
||||
startPolling() {
|
||||
startPolling(interval = 2000) {
|
||||
console.log('=== STARTING POLLING ===');
|
||||
|
||||
if (this.pollInterval) {
|
||||
@@ -380,9 +413,9 @@ class DNSReconApp {
|
||||
this.updateStatus();
|
||||
this.updateGraph();
|
||||
this.loadProviders();
|
||||
}, 1000); // Poll every 1 second for debugging
|
||||
}, interval);
|
||||
|
||||
console.log('Polling started with 1 second interval');
|
||||
console.log(`Polling started with ${interval}ms interval`);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -397,7 +430,7 @@ class DNSReconApp {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update scan status from server
|
||||
* Enhanced status update with better error handling
|
||||
*/
|
||||
async updateStatus() {
|
||||
try {
|
||||
@@ -406,7 +439,7 @@ class DNSReconApp {
|
||||
|
||||
console.log('Status response:', response);
|
||||
|
||||
if (response.success) {
|
||||
if (response.success && response.status) {
|
||||
const status = response.status;
|
||||
console.log('Current scan status:', status.status);
|
||||
console.log('Current progress:', status.progress_percentage + '%');
|
||||
@@ -423,6 +456,7 @@ class DNSReconApp {
|
||||
this.scanStatus = status.status;
|
||||
} else {
|
||||
console.error('Status update failed:', response);
|
||||
// Don't show error for status updates to avoid spam
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
@@ -551,7 +585,7 @@ class DNSReconApp {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle status changes
|
||||
* Handle status changes with improved state synchronization
|
||||
* @param {string} newStatus - New scan status
|
||||
*/
|
||||
handleStatusChange(newStatus) {
|
||||
@@ -561,8 +595,8 @@ class DNSReconApp {
|
||||
case 'running':
|
||||
this.setUIState('scanning');
|
||||
this.showSuccess('Scan is running');
|
||||
// Reset polling frequency for active scans
|
||||
this.pollFrequency = 2000;
|
||||
// Increase polling frequency for active scans
|
||||
this.startPolling(1000); // Poll every 1 second for running scans
|
||||
this.updateConnectionStatus('active');
|
||||
break;
|
||||
|
||||
@@ -598,6 +632,10 @@ class DNSReconApp {
|
||||
this.stopPolling();
|
||||
this.updateConnectionStatus('idle');
|
||||
break;
|
||||
|
||||
default:
|
||||
console.warn(`Unknown status: ${newStatus}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,8 +671,7 @@ class DNSReconApp {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set UI state based on scan status
|
||||
* @param {string} state - UI state
|
||||
* Enhanced UI state management with immediate button updates
|
||||
*/
|
||||
setUIState(state) {
|
||||
console.log(`Setting UI state to: ${state}`);
|
||||
@@ -645,6 +682,7 @@ class DNSReconApp {
|
||||
if (this.elements.startScan) {
|
||||
this.elements.startScan.disabled = true;
|
||||
this.elements.startScan.classList.add('loading');
|
||||
this.elements.startScan.innerHTML = '<span class="btn-icon">[SCANNING]</span><span>Scanning...</span>';
|
||||
}
|
||||
if (this.elements.addToGraph) {
|
||||
this.elements.addToGraph.disabled = true;
|
||||
@@ -653,6 +691,7 @@ class DNSReconApp {
|
||||
if (this.elements.stopScan) {
|
||||
this.elements.stopScan.disabled = false;
|
||||
this.elements.stopScan.classList.remove('loading');
|
||||
this.elements.stopScan.innerHTML = '<span class="btn-icon">[STOP]</span><span>Terminate Scan</span>';
|
||||
}
|
||||
if (this.elements.targetDomain) this.elements.targetDomain.disabled = true;
|
||||
if (this.elements.maxDepth) this.elements.maxDepth.disabled = true;
|
||||
@@ -667,6 +706,7 @@ class DNSReconApp {
|
||||
if (this.elements.startScan) {
|
||||
this.elements.startScan.disabled = false;
|
||||
this.elements.startScan.classList.remove('loading');
|
||||
this.elements.startScan.innerHTML = '<span class="btn-icon">[RUN]</span><span>Start Reconnaissance</span>';
|
||||
}
|
||||
if (this.elements.addToGraph) {
|
||||
this.elements.addToGraph.disabled = false;
|
||||
@@ -674,6 +714,7 @@ class DNSReconApp {
|
||||
}
|
||||
if (this.elements.stopScan) {
|
||||
this.elements.stopScan.disabled = true;
|
||||
this.elements.stopScan.innerHTML = '<span class="btn-icon">[STOP]</span><span>Terminate Scan</span>';
|
||||
}
|
||||
if (this.elements.targetDomain) this.elements.targetDomain.disabled = false;
|
||||
if (this.elements.maxDepth) this.elements.maxDepth.disabled = false;
|
||||
|
||||
Reference in New Issue
Block a user