我想使用 Go 获取客户端缓存 DNS IP
看看我在下面尝试的代码
import (
"fmt"
"net"
)
func main() {
// Usually DNS Server using 53 port number
// This case, TCP protocol is not considered
port := ":53"
protocol := "udp"
var buf [2048]byte
//Build the address
udpAddr, err := net.ResolveUDPAddr(protocol, port)
if err != nil {
fmt.Println("Wrong Address")
return
}
fmt.Println("Listened " + protocol + " from " + udpAddr.String())
//Create the connection
udpConn, err := net.ListenUDP(protocol, udpAddr)
if err != nil {
fmt.Println(err)
}
// Listening 53 Port Like DNS Server
for {
// If get request,
_, err := udpConn.Read(buf[0:])
if err != nil {
fmt.Println("Error Reading")
return
} else {
// Print Remote Address,
// I Guess this is the Client Cache DNS IP, but this is print <nil>
fmt.Println(udpConn.RemoteAddr())
}
}
}
在这种情况下,如何获取客户端缓存 DNS IP?请帮助我,我想构建客户端 DNS IP 收集器,看起来像 whoami
我也将其称为https://github.com/miekg/exdns/blob/master/reflect/reflect.go 但这不是我的答案
我想要简单的服务器
紫衣仙女
相关分类