2013-12-30 18:26
浏览 92


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.

图片转代码服务由CSDN问答提供 功能建议

我正在编写一个简单的golang应用程序,该应用程序需要对某些DNS数据包进行一些解码。 我注意到,在 net 库中,似乎以 net / dnsmsg.go 的形式实现了完美的实现,其中包含正确的结构,打包/解压缩函数等。

但是,该类型被标记为私有(小写的 dnsMsg )。 所以看来我无法从我的应用程序中使用它。

我对golang还是很陌生,所以不知道我唯一的选择就是重新实现 net / dnsmsg.go 我自己,或者是否有更好的解决方法。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongshuo9350 2014-12-02 21:57

    My problem was solved by using a third party dns library, specifically miekg/dns (

    点赞 打赏 评论
  • dongque20030402 2017-03-14 07:32

    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.

    点赞 打赏 评论

相关推荐 更多相似问题