mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-09-14 14:06:44 +08:00

移除了36个静态分析工具识别的未使用函数,减少代码体积534行: 核心模块: - core/PluginAdapter.go: 移除7个未使用的插件适配器方法 - core/Registry.go: 移除5个未使用的注册器方法 - core/Scanner.go: 移除1个未使用的扫描方法 - core/WebDetection.go: 移除4个未使用的Web检测方法 通用模块: - common/ConcurrencyMonitor.go: 移除3个未使用的并发监控方法 - common/common.go: 移除1个未使用的插件注册方法 - common/base/Plugin.go: 移除4个未使用的插件管理方法 - common/parsers/Simple.go: 移除1个未使用的端口解析方法 - common/utils/memmonitor.go: 移除9个未使用的内存监控方法 - common/utils/slicepool.go: 移除1个未使用的切片去重方法 插件模块: - plugins/services/vnc/plugin.go: 移除1个未使用的服务识别方法 所有移除的函数均替换为中文注释标记,保持代码可读性。
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package utils
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// MemoryMonitor 内存监控器
|
|
type MemoryMonitor struct {
|
|
maxHeapMB uint64 // 最大堆内存阈值(MB)
|
|
maxGoroutines int // 最大goroutine数量阈值
|
|
checkInterval time.Duration // 检查间隔
|
|
running bool // 是否运行中
|
|
stopChan chan bool
|
|
}
|
|
|
|
// NewMemoryMonitor 创建新的内存监控器
|
|
func NewMemoryMonitor(maxHeapMB uint64, maxGoroutines int, checkInterval time.Duration) *MemoryMonitor {
|
|
return &MemoryMonitor{
|
|
maxHeapMB: maxHeapMB,
|
|
maxGoroutines: maxGoroutines,
|
|
checkInterval: checkInterval,
|
|
stopChan: make(chan bool, 1),
|
|
}
|
|
}
|
|
|
|
// 已移除未使用的 Start 方法
|
|
|
|
// 已移除未使用的 Stop 方法
|
|
|
|
// 已移除未使用的 monitor 方法
|
|
|
|
// 已移除未使用的 checkMemory 方法
|
|
|
|
// 已移除未使用的 GetMemoryStats 方法
|
|
|
|
// 已移除未使用的 ForceGC 方法
|
|
|
|
// 已移除未使用的 getHeapSize 方法
|
|
|
|
// 默认内存监控器实例
|
|
var DefaultMemMonitor = NewMemoryMonitor(
|
|
512, // 最大堆内存512MB
|
|
1000, // 最大1000个goroutines
|
|
30*time.Second, // 30秒检查一次
|
|
)
|
|
|
|
// 已移除未使用的 StartDefaultMonitor 方法
|
|
|
|
// 已移除未使用的 StopDefaultMonitor 方法
|