MCPcopy Index your code
hub / github.com/MengMengCode/GetRealityDomain / ResolveDomain

Function ResolveDomain

utils.go:379–398  ·  view source on GitHub ↗

ResolveDomain 解析域名为IP地址

(domain string)

Source from the content-addressed store, hash-verified

377
378// ResolveDomain 解析域名为IP地址
379func ResolveDomain(domain string) ([]net.IP, error) {
380 ips, err := net.LookupIP(domain)
381 if err != nil {
382 return nil, fmt.Errorf("域名解析失败: %v", err)
383 }
384
385 // 过滤IPv4或IPv6地址
386 var result []net.IP
387 for _, ip := range ips {
388 if config.IPv6 || ip.To4() != nil {
389 result = append(result, ip)
390 }
391 }
392
393 if len(result) == 0 {
394 return nil, fmt.Errorf("没有找到有效的IP地址")
395 }
396
397 return result, nil
398}
399
400// FormatBytes 格式化字节数为人类可读的格式
401func FormatBytes(bytes int64) string {

Callers 1

ScanTLSFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected