From bffb643a5623e051eae579374d8724c0384464f6 Mon Sep 17 00:00:00 2001 From: zeaslity Date: Fri, 28 Feb 2025 11:34:57 +0800 Subject: [PATCH] =?UTF-8?q?[agent-wdd]=20=E5=B0=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent-wdd/config/Config.go | 1 + agent-wdd/config/Network.go | 14 +++++----- agent-wdd/one-build-and-run.ps1 | 6 ++--- agent-wdd/readme_help.txt | 47 +++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 agent-wdd/readme_help.txt diff --git a/agent-wdd/config/Config.go b/agent-wdd/config/Config.go index 858b852..e6c361a 100644 --- a/agent-wdd/config/Config.go +++ b/agent-wdd/config/Config.go @@ -80,6 +80,7 @@ type Interface struct { IPv4 string `yaml:"ipv4"` IPv6 string `yaml:"ipv6"` MAC string `yaml:"mac"` + MTU int `yaml:"mtu"` } type CPU struct { diff --git a/agent-wdd/config/Network.go b/agent-wdd/config/Network.go index a526893..777bbb5 100644 --- a/agent-wdd/config/Network.go +++ b/agent-wdd/config/Network.go @@ -34,10 +34,7 @@ func (network *Network) Gather() { network.Internet = CanConnectInternet() // 获取公网的相关信息 - pub := PublicInfo{} - pub.GetPublicInfo() - - network.Public = pub + network.Public = network.Public.GetPublicInfo() //获取本机网卡相关的内容 network.Interfaces = GetInterfaces() @@ -49,6 +46,7 @@ func GetInterfaces() []Interface { // 获取所有网卡信息 netInterfaces, err := net.Interfaces() + log.Info("all network interfaces: %v", netInterfaces) if err != nil { log.Error("获取网卡信息失败: %v", err) return interfaces @@ -70,6 +68,7 @@ func GetInterfaces() []Interface { iface := Interface{ Name: netInterface.Name, MAC: netInterface.HardwareAddr.String(), + MTU: netInterface.MTU, } // 获取 IPv4 和 IPv6 地址 @@ -94,6 +93,7 @@ func GetInterfaces() []Interface { func (network *Network) SaveConfig() { + ConfigCache.Agent.Network = *network SaveConfig() } @@ -134,7 +134,7 @@ func judgeCanConnectInternet() int { } // GetPublicInfo 获取服务器的公网信息 -func (p PublicInfo) GetPublicInfo() { +func (p PublicInfo) GetPublicInfo() PublicInfo { if CanConnectInternet() == InternetBaseLine { // 无法联网, 假信息 @@ -147,9 +147,10 @@ func (p PublicInfo) GetPublicInfo() { ASN: "Wdd Inc", } + // 持久化保存 ConfigCache.Agent.Network.Public = fakePublicInfo - return + return fakePublicInfo } // 可以联网 @@ -203,6 +204,7 @@ func (p PublicInfo) GetPublicInfo() { ConfigCache.Agent.Network.Public = p + return p } func isValidNICName(name string) bool { diff --git a/agent-wdd/one-build-and-run.ps1 b/agent-wdd/one-build-and-run.ps1 index 1a7a03c..b76f85b 100644 --- a/agent-wdd/one-build-and-run.ps1 +++ b/agent-wdd/one-build-and-run.ps1 @@ -16,11 +16,11 @@ try { Write-Host "4. Exec the command ..." -ForegroundColor Blue Write-Host "" Write-Host "" - ssh root@192.168.35.71 "chmod +x agent-wdd_linux_amd64 && ./agent-wdd_linux_amd64 download http://192.168.35.70:9000/ping/ 123.txt" + ssh root@192.168.35.71 "chmod +x agent-wdd_linux_amd64 && ./agent-wdd_linux_amd64 info network" Write-Host "" Write-Host "" -# Write-Host "5. Cheak Info Result ..." -ForegroundColor Blue -# ssh root@192.168.35.71 "cat /usr/local/etc/wdd/agent-wdd-config.yaml" + Write-Host "5. Cheak Info Result ..." -ForegroundColor Blue + ssh root@192.168.35.71 "cat /usr/local/etc/wdd/agent-wdd-config.yaml" } catch { Write-Host "操作失败: $_" -ForegroundColor Red diff --git a/agent-wdd/readme_help.txt b/agent-wdd/readme_help.txt new file mode 100644 index 0000000..948e035 --- /dev/null +++ b/agent-wdd/readme_help.txt @@ -0,0 +1,47 @@ +Available commands: +acme acme相关的内容 +base 服务器基础操作 + docker Docker相关操作 + local 本地安装Docker + online 网络安装Docker + remove 卸载Docker + dockercompose Docker Compose相关操作 + local 本地安装Docker Compose + online 安装Docker Compose + remove 卸载Docker Compose + version 查看Docker Compose版本 + firewall 关闭防火墙 + selinux 关闭selinux + ssh 修改ssh配置 + config 修改ssh配置 为wdd默认配置! + key 安装默认的ssh-key + port 修改ssh端口 + swap 关闭系统的Swap + sysconfig 修改系统的sysconfig + tools 通用工具安装 利用本机的yum,apt等从网络安装常用的软件 +completion Generate the autocompletion script for the specified shell + bash Generate the autocompletion script for bash + fish Generate the autocompletion script for fish + powershell Generate the autocompletion script for powershell + zsh Generate the autocompletion script for zsh +config 配置文件管理 + show 显示agent运行配置 +download 文件下载,直接下载 [url] [dest_path] + proxy 使用代理下载 socks5://[username]:[password]@ip:port http://[username]:[password]@ip:port +help 帮助信息 +help Help about any command +info 打印主机详细信息 + all 主机全部相关的信息 + cpu 主机cpu相关的信息 + disk 主机disk相关的信息 + mem 主机memory相关的信息 + network 主机Network相关的信息 + os 主机操作系统相关的信息 +proxy 主机代理相关的内容 + vmess 设置VMESS代理 + xray Xray相关操作 + install 安装Xray +security 安全相关操作 +version 打印版本信息 +wdd WDD相关操作 +zsh zsh相关的内容 \ No newline at end of file