32 lines
442 B
Go
32 lines
442 B
Go
|
|
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
|
||
|
|
|
||
|
|
|