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

- 将Config相关文件重构为独立的config模块 - 创建config/Types.go定义核心配置数据结构 - 新增config/ServiceDict.go管理服务认证字典(线程安全) - 新增config/PortMapping.go管理端口探测器映射(线程安全) - 新增config/ScanOptions.go提供扫描选项管理(线程安全) - 新增config/Manager.go统一配置管理器 - 新增Variables.go作为向后兼容桥接层 - 重构Config.go为兼容入口点,委托给新模块 - 删除原有的单体配置文件 - 修复用户字典和密码字典初始化问题 - 保持完全向后兼容性,现有API无需修改 - 提升代码组织性和可维护性
120 lines
3.1 KiB
Go
120 lines
3.1 KiB
Go
package Common
|
||
|
||
/*
|
||
Config.go - 主配置文件入口 (使用新的模块化config系统)
|
||
|
||
配置文件模块化组织:
|
||
- config/Types.go - 核心配置数据结构
|
||
- config/ServiceDict.go - 服务认证字典和默认密码配置
|
||
- config/PortMapping.go - 端口与探测器映射关系配置
|
||
- config/ScanOptions.go - 扫描选项管理
|
||
- config/Manager.go - 统一配置管理器
|
||
|
||
为了减少单文件复杂度和提高代码组织性,将原本的配置系统重构为模块化架构。
|
||
此文件现在作为向后兼容的入口点,委托给新的config模块。
|
||
|
||
注意: 所有配置功能现在通过config模块提供,保持API兼容性。
|
||
*/
|
||
|
||
import (
|
||
"github.com/schollz/progressbar/v3"
|
||
"sync"
|
||
|
||
"github.com/shadow1ng/fscan/Common/config"
|
||
)
|
||
|
||
// 向后兼容的变量和函数
|
||
// 这些变量现在委托给config模块
|
||
|
||
// 版本信息
|
||
var version = "2.0.2"
|
||
|
||
// =========================================================
|
||
// 输出配置 (向后兼容)
|
||
// =========================================================
|
||
var (
|
||
Outputfile string // 输出文件路径 - 委托给config模块
|
||
OutputFormat string // 输出格式 - 委托给config模块
|
||
)
|
||
|
||
// ProgressBar 全局进度条变量 - 委托给config模块
|
||
var ProgressBar *progressbar.ProgressBar
|
||
|
||
// OutputMutex 全局输出互斥锁 - 委托给config模块
|
||
var OutputMutex sync.Mutex
|
||
|
||
// PocInfo POC详细信息结构 - 委托给config模块
|
||
type PocInfo = config.PocInfo
|
||
|
||
// GetVersion 获取版本信息
|
||
func GetVersion() string {
|
||
return config.GetGlobalVersion()
|
||
}
|
||
|
||
// SetVersion 设置版本信息
|
||
func SetVersion(v string) {
|
||
config.SetGlobalVersion(v)
|
||
}
|
||
|
||
// GetProgressBar 获取全局进度条
|
||
func GetProgressBar() *progressbar.ProgressBar {
|
||
return config.GetGlobalProgressBar()
|
||
}
|
||
|
||
// SetConfigProgressBar 设置全局进度条(config模块)
|
||
func SetConfigProgressBar(pb *progressbar.ProgressBar) {
|
||
config.SetGlobalProgressBar(pb)
|
||
ProgressBar = pb // 保持向后兼容
|
||
}
|
||
|
||
// GetOutputMutex 获取输出互斥锁
|
||
func GetOutputMutex() *sync.Mutex {
|
||
return config.GetGlobalOutputMutex()
|
||
}
|
||
|
||
// init 初始化函数,同步config模块和兼容变量
|
||
func init() {
|
||
// 设置初始版本
|
||
config.SetGlobalVersion(version)
|
||
|
||
// 同步输出配置
|
||
syncOutputConfig()
|
||
}
|
||
|
||
// syncOutputConfig 同步输出配置
|
||
func syncOutputConfig() {
|
||
cfg := config.GetGlobalConfig()
|
||
if cfg != nil && cfg.Output != nil {
|
||
Outputfile = cfg.Output.Outputfile
|
||
OutputFormat = cfg.Output.OutputFormat
|
||
}
|
||
|
||
// 同步进度条
|
||
ProgressBar = config.GetGlobalProgressBar()
|
||
}
|
||
|
||
// SyncConfigOutputSettings 同步输出设置到config模块
|
||
func SyncConfigOutputSettings() {
|
||
cfg := config.GetGlobalConfig()
|
||
if cfg != nil && cfg.Output != nil {
|
||
cfg.Output.Outputfile = Outputfile
|
||
cfg.Output.OutputFormat = OutputFormat
|
||
config.SetGlobalManagerConfig(cfg)
|
||
}
|
||
}
|
||
|
||
// GetConfigManager 获取全局配置管理器
|
||
func GetConfigManager() *config.Manager {
|
||
return config.GetGlobalManager()
|
||
}
|
||
|
||
// GetFullConfig 获取完整配置
|
||
func GetFullConfig() *config.Config {
|
||
return config.GetGlobalConfig()
|
||
}
|
||
|
||
// SetFullConfig 设置完整配置
|
||
func SetFullConfig(cfg *config.Config) {
|
||
config.SetGlobalManagerConfig(cfg)
|
||
syncOutputConfig()
|
||
} |