[golang]Go net.lookup 패키지
Go 언어 중 package main
import (
"fmt"
"net"
)
func main() {
// DNS A
iprecords, _:=net.LookupIP("landv.cn")
for _,ip:=range iprecords{
fmt.Println(ip)
}
// DNS CNAME
canme, _:=net.LookupCNAME("www.baidu.com")
fmt.Println(canme)
// DNS PTR
ptr,e :=net.LookupAddr("8.8.8.8")
if e != nil {
fmt.Println(e)
}
for _, ptrval:=range ptr{
fmt.Println(ptrval)
}
// DNS NS
nameserver,_:=net.LookupNS("baidu.com")
for _,ns :=range nameserver{
fmt.Println("ns ",ns)
}
// DNS MX
mxrecods,_ :=net.LookupMX("google.com")
for _,mx :=range mxrecods{
fmt.Println("mx:",mx)
}
// DNS TXT
txtrecords, _ := net.LookupTXT("baidu.com")
for _, txt := range txtrecords {
fmt.Println("txt:",txt)
}
}
실행 결과185.199.111.153
185.199.108.153
185.199.109.153
185.199.110.153
www.a.shifen.com.
dns.google.
ns &{dns.baidu.com.}
ns &{ns7.baidu.com.}
ns &{ns2.baidu.com.}
ns &{ns3.baidu.com.}
ns &{ns4.baidu.com.}
mx: &{aspmx.l.google.com. 10}
mx: &{alt1.aspmx.l.google.com. 20}
mx: &{alt2.aspmx.l.google.com. 30}
mx: &{alt3.aspmx.l.google.com. 40}
mx: &{alt4.aspmx.l.google.com. 50}
txt: v=spf1 include:spf1.baidu.com include:spf2.baidu.com include:spf3.baidu.com a mx ptr -all
txt: google-site-verification=GHb98-6msqyx_qqjGl5eRatD3QTHyVB6-xQ3gJB5UwM
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSON
JSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다.
그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다.
저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.
package main
import (
"fmt"
"net"
)
func main() {
// DNS A
iprecords, _:=net.LookupIP("landv.cn")
for _,ip:=range iprecords{
fmt.Println(ip)
}
// DNS CNAME
canme, _:=net.LookupCNAME("www.baidu.com")
fmt.Println(canme)
// DNS PTR
ptr,e :=net.LookupAddr("8.8.8.8")
if e != nil {
fmt.Println(e)
}
for _, ptrval:=range ptr{
fmt.Println(ptrval)
}
// DNS NS
nameserver,_:=net.LookupNS("baidu.com")
for _,ns :=range nameserver{
fmt.Println("ns ",ns)
}
// DNS MX
mxrecods,_ :=net.LookupMX("google.com")
for _,mx :=range mxrecods{
fmt.Println("mx:",mx)
}
// DNS TXT
txtrecords, _ := net.LookupTXT("baidu.com")
for _, txt := range txtrecords {
fmt.Println("txt:",txt)
}
}
185.199.111.153
185.199.108.153
185.199.109.153
185.199.110.153
www.a.shifen.com.
dns.google.
ns &{dns.baidu.com.}
ns &{ns7.baidu.com.}
ns &{ns2.baidu.com.}
ns &{ns3.baidu.com.}
ns &{ns4.baidu.com.}
mx: &{aspmx.l.google.com. 10}
mx: &{alt1.aspmx.l.google.com. 20}
mx: &{alt2.aspmx.l.google.com. 30}
mx: &{alt3.aspmx.l.google.com. 40}
mx: &{alt4.aspmx.l.google.com. 50}
txt: v=spf1 include:spf1.baidu.com include:spf2.baidu.com include:spf3.baidu.com a mx ptr -all
txt: google-site-verification=GHb98-6msqyx_qqjGl5eRatD3QTHyVB6-xQ3gJB5UwM
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.