项目作者: cirocosta

项目描述 :
A records resolver from scratch - raw UDP packets
高级语言: Go
项目地址: git://github.com/cirocosta/rawdns.git
创建时间: 2017-12-29T13:04:39Z
项目社区:https://github.com/cirocosta/rawdns

开源协议:MIT License

下载


rawdns 📡

DNS messages (un)marshaller and UDP client


Overview

rawdns a small DNS client library that performs A records queries against a given nameserver.

It relies only on net to perform the UDP queries, constructing and parsing all the messages in transit manually.

This is a project that is not intended to be used in production at all. It’s not as efficient as it should and does not handle all the cases you’d expect from a production-ready library.

For real use, see miekg/dns.

Usage

CLI:

  1. rawdns example.com
  2. msg sent labels=[example com]
  3. &{ID:0 QR:1 Opcode:0 AA:0 TC:0 RD:1 RA:1 Z:0 RCODE:0 QDCOUNT:1 ANCOUNT:1 NSCOUNT:0 ARCOUNT:0}
  4. ANSWER: [93 184 216 34]

Programatically:

  1. import "github.com/cirocosta/rawdns/lib"
  2. client, err := lib.NewClient(lib.ClientConfig{
  3. Address: "8.8.8.8:53",
  4. })
  5. must(err)
  6. defer client.Close()
  7. ips, err := client.LookupAddr("example.com")
  8. must(err)
  9. for _, ip := range ips {
  10. fmt.Println(ip)
  11. }