growse
growse

Reputation: 3752

How can I make use of dnsMsg in golang's net package

I'm writing a simple golang application that needs to do some decoding of some DNS packets. I noticed that in the net library, there appears to be the perfect implementation in the form of net/dnsmsg.go which contains the right structs, pack / unpack functions etc.

However, the type is marked private (lower case dnsMsg). So it appears that I have no way of using this from within my app.

I'm quite new to golang, so don't know if my only option would be to reimplement net/dnsmsg.go myself, or if there's a better way around this.

Upvotes: 1

Views: 385

Answers (2)

Rolinh
Rolinh

Reputation: 1409

Another option would be to use Google's gopacket package which provides packets decoding for Go. In particular, the layers sub-package provides logic for decoding protocol packets, among which what is necessary to decode DNS packets.

Upvotes: 0

growse
growse

Reputation: 3752

My problem was solved by using a third party dns library, specifically miekg/dns (https://github.com/miekg/dns).

Upvotes: 1

Related Questions