Files

32 lines
442 B
Go
Raw Permalink Normal View History

2026-05-03 23:58:06 +08:00
package netx
import (
"fmt"
"net"
)
type dns struct{}
func NewDNS() *dns {
return &dns{}
}
// 查询A记录,返回IPV4和IPV6的切片
func GetA(domain string) ([]string, error) {
iprecords, _ := net.LookupIP("facebook.com")
for _, ip := range iprecords {
fmt.Println(ip)
}
}
// 查询CNAME记录
func GetCNAME(domain string) (string, error) {
cname, _ := net.LookupCNAME("m.facebook.com")
fmt.Println(cname)
}
// chaxun