feat(admin): очистка всех сканов — POST /api/admin/purge-scans + UI (NETTOPO_RESET_DB_SECRET)
Made-with: Cursor
This commit is contained in:
@@ -69,6 +69,8 @@ type Store interface {
|
||||
ListLLDPResults(scanID string, limit int) []LLDPResult
|
||||
SaveInterfaceResult(scanID string, result InterfaceResult) error
|
||||
ListInterfaceResults(scanID string, filterIP string, limit int) []InterfaceResult
|
||||
// PurgeAllScanData удаляет все сканы и связанные строки (хосты, порты, SNMP, LLDP, интерфейсы).
|
||||
PurgeAllScanData() error
|
||||
}
|
||||
|
||||
type HostResult struct {
|
||||
@@ -330,6 +332,18 @@ func (s *MemoryStore) SaveInterfaceResult(scanID string, result InterfaceResult)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *MemoryStore) PurgeAllScanData() error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
s.jobs = make(map[string]ScanJob)
|
||||
s.hosts = make(map[string][]HostResult)
|
||||
s.ports = make(map[string][]OpenPortResult)
|
||||
s.snmp = make(map[string][]SNMPResult)
|
||||
s.lldp = make(map[string][]LLDPResult)
|
||||
s.ifaces = make(map[string][]InterfaceResult)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *MemoryStore) ListInterfaceResults(scanID string, filterIP string, limit int) []InterfaceResult {
|
||||
if limit <= 0 {
|
||||
limit = 4096
|
||||
|
||||
Reference in New Issue
Block a user