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

- 为所有平台特定插件添加正确的编译标签 - Linux插件添加 //go:build linux 标签 - Windows插件添加 //go:build windows 标签 - 重构本地插件注册方式 - 从main.go移至core包统一管理 - 创建平台特定的注册文件实现条件编译 - 修正参数文档中minidump平台支持描述 - 优化插件注册架构,提升代码组织性
59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
package main
|
||
|
||
import (
|
||
"fmt"
|
||
"os"
|
||
"sort"
|
||
|
||
"github.com/shadow1ng/fscan/common"
|
||
"github.com/shadow1ng/fscan/core"
|
||
"github.com/shadow1ng/fscan/plugins/base"
|
||
)
|
||
|
||
// initLocalPlugins 初始化本地插件列表
|
||
func initLocalPlugins() {
|
||
var localPlugins []string
|
||
|
||
// 获取所有注册的插件
|
||
allPlugins := base.GlobalPluginRegistry.GetAll()
|
||
|
||
for _, pluginName := range allPlugins {
|
||
metadata := base.GlobalPluginRegistry.GetMetadata(pluginName)
|
||
if metadata != nil && metadata.Category == "local" {
|
||
localPlugins = append(localPlugins, pluginName)
|
||
}
|
||
}
|
||
|
||
// 排序以保持一致性
|
||
sort.Strings(localPlugins)
|
||
|
||
// 设置全局变量
|
||
common.LocalPluginsList = localPlugins
|
||
}
|
||
|
||
func main() {
|
||
// 初始化本地插件列表
|
||
initLocalPlugins()
|
||
|
||
var Info common.HostInfo
|
||
common.Flag(&Info)
|
||
|
||
// 在flag解析后初始化logger,确保LogLevel参数生效
|
||
common.InitLogger()
|
||
|
||
// 解析 CLI 参数
|
||
if err := common.Parse(&Info); err != nil {
|
||
os.Exit(1)
|
||
}
|
||
|
||
// 初始化输出系统,如果失败则直接退出
|
||
if err := common.InitOutput(); err != nil {
|
||
common.LogError(fmt.Sprintf("初始化输出系统失败: %v", err))
|
||
os.Exit(1)
|
||
}
|
||
defer common.CloseOutput()
|
||
|
||
// 执行 CLI 扫描逻辑
|
||
core.RunScan(Info)
|
||
}
|