Files
codex 877e4cf41d docs(agent): 统一中文注释并补充部署文档
将代码与测试注释改为中文以符合仓库规范;新增中文部署指南、
示例配置,并完善构建脚本对 VERSION 注入的说明。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-19 02:30:49 +00:00

28 lines
545 B
Go

package collector
import (
"net"
"sort"
)
// networkAddressSets 将接口地址拆分为确定顺序的 IPv4 与 IPv6 列表。
func networkAddressSets(values map[string]struct{}) (ipv4s []string, ipv6s []string) {
for value := range values {
host, _, err := net.ParseCIDR(value)
if err != nil {
host = net.ParseIP(value)
}
if host == nil {
continue
}
if host.To4() != nil {
ipv4s = append(ipv4s, value)
continue
}
ipv6s = append(ipv6s, value)
}
sort.Strings(ipv4s)
sort.Strings(ipv6s)
return ipv4s, ipv6s
}