更新工作区配置,删除不再使用的Cloudflare相关文件,优化日志输出格式,增强主机信息收集功能,调整代码结构以提高可维护性。

This commit is contained in:
zeaslity
2025-03-28 00:15:08 +08:00
parent c2ca7eb6d7
commit 6816638267
19 changed files with 847 additions and 155 deletions

View File

@@ -1,7 +1,7 @@
package op
import (
"agent-wdd/config"
"agent-wdd/host_info"
"agent-wdd/log"
"encoding/json"
"fmt"
@@ -72,10 +72,10 @@ func (op *PackageOperator) Install(tools []string) bool {
func (op *PackageOperator) PackageInit() bool {
log.Info("PackageInit !")
// beautifulPrintListWithTitle(config.ConfigCache)
// beautifulPrintListWithTitle(host_info.ConfigCache)
// package init
os := config.ConfigCache.Agent.OS
os := host_info.ConfigCache.Agent.OS
if os.PackInit {
log.Info("PackageInit already done! skip!")
@@ -106,7 +106,7 @@ func (op *PackageOperator) PackageInitForce() bool {
log.Info("PackageInitForce !")
os := config.ConfigCache.Agent.OS
os := host_info.ConfigCache.Agent.OS
if os.IsUbuntuType {
ok, resultLog := SingleLineCommandExecutor(aptPackageOperator.initCommand)
@@ -143,13 +143,13 @@ func generatePackageOperator() bool {
}
// 检查是否可以连接互联网
if config.CanConnectInternet() <= 1 {
if host_info.CanConnectInternet() <= 1 {
log.Error("服务器无法连接互联网,无法初始化包管理器")
return false
}
// 检查本机是否存在OS的信息
os := config.ConfigCache.Agent.OS
os := host_info.ConfigCache.Agent.OS
if os.Hostname == "" {
os.Gather()
os.SaveConfig()
@@ -169,7 +169,7 @@ func generatePackageOperator() bool {
// GetLatestGithubReleaseVersion 获取GitHub仓库的最新版本
func GetLatestGithubReleaseVersion(repoOwner, repoName string) (string, error) {
// 检查是否可以连接互联网
if config.CanConnectInternet() <= 1 {
if host_info.CanConnectInternet() <= 1 {
return "", fmt.Errorf("服务器无法连接互联网无法获取GitHub最新版本")
}