更新工作区配置,删除不再使用的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

@@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"net/url"
"strings"
"agent-wdd/log"
)
@@ -179,6 +180,23 @@ func (c *CloudflareClient) GetZone(identifier string) (*Zone, error) {
if isID {
endpoint = fmt.Sprintf("%s/zones/%s", c.baseURL, identifier)
} else {
// tc.hk.107421.xyz ipv6.t2.107421.xyz 转换为 107421.xyz
// 寻找.的个数 如果大于 从后往前找到 第二个 . 的位置
dotCount := strings.Count(identifier, ".")
if dotCount > 1 {
// 从后往前找到 第二个 . 的位置
lastDotIndex := strings.LastIndex(identifier, ".")
secondLastDotIndex := strings.LastIndex(identifier[:lastDotIndex], ".")
identifier = identifier[secondLastDotIndex+1:]
} else if dotCount == 0 {
// 没有. 报错
log.Error("未找到域名 %s 的ZoneID", identifier)
return nil, fmt.Errorf("no zone found with name: %s", identifier)
}
log.Debug("转换后的域名: %s", identifier)
// List zones with name filter
zones, err := c.ListZones(&ZoneFilter{Name: identifier})
if err != nil {