Skip to content

cirocosta/rawdns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

rawdns example.com
msg sent labels=[example com]
&{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}
ANSWER: [93 184 216 34]

Programatically:

import "github.com/cirocosta/rawdns/lib"

client, err := lib.NewClient(lib.ClientConfig{
        Address: "8.8.8.8:53",
})
must(err)
defer client.Close()

ips, err := client.LookupAddr("example.com")
must(err)

for _, ip := range ips {
        fmt.Println(ip)
}

Releases

No releases published

Packages

No packages published