Giter Site home page Giter Site logo

Comments (9)

andrewtj avatar andrewtj commented on July 19, 2024

Are you querying over TCP or UDP? If the later, are you checking that the response isn't truncated and is within the UDP payload size you have (or haven't) set? Might help to post your code and the response in a gist.

from dns.

jsgoecke avatar jsgoecke commented on July 19, 2024

In this case I am using UDP:

func queryDns(query string, dnsMaster string, queryType uint16) (*dns.Msg, error) {
    m := new(dns.Msg)
    m.SetQuestion(query, queryType)
    msg, err := dns.Exchange(m, dnsMaster)
    if err != nil {
        return nil, err
    }
    return msg, nil
}

Where the query is a token, dnsMaster is the private DNS server, and queryType is set to TypeNATPR. So, simple defaults. Not clear how I might set the UDP payload size on the client side in the lib.

from dns.

andrewtj avatar andrewtj commented on July 19, 2024

You can set the UDP size with SetEdns0 (something like m.SetEdns0(1440, false) is probably what you're after) and check if the response has been truncated by looking at the Truncated field of the message header.

from dns.

jsgoecke avatar jsgoecke commented on July 19, 2024

Yes, it is indeed being truncated. Does not like the UDP size (dns: bad rdlength), but I will figure that out. Thank you.

from dns.

jsgoecke avatar jsgoecke commented on July 19, 2024

Maybe not a re-open, but instead of changing the size (as in my case the returns vary in size) would it be good to fallback to TCP as the default Go library doe? Or, at least, how does one force a TCP query over a UDP one?

https://code.google.com/p/go/issues/detail?id=5686

from dns.

andrewtj avatar andrewtj commented on July 19, 2024

The UDP payload size you set in the client should be the largest size the client can get on and off the wire. That is it should be set based on network conditions as opposed to the query.

A TCP query can be done with something like:

tcpConn, err := Net.Dial("tcp", "example.com:53")
if err != nil {
    // appropriate action
}
dnsConn := &dns.Conn{Conn: tcpConn}
if err := dnsConn.WriteMsg(qm); err != nil {
    // appropriate action
}
rm, err := dnsConn.ReadMsg()
if err != nil {
    // appropriate action
}

from dns.

jsgoecke avatar jsgoecke commented on July 19, 2024

I did force TCP this way:

func queryDns(query string, dnsMaster string, queryType uint16) (*dns.Msg, error) {
    c := new(dns.Client)
    c.Net = "tcp"
    m := new(dns.Msg)
    m.SetQuestion(query, queryType)
    msg, _, err := c.Exchange(m, dnsMaster)
    if err != nil {
        return nil, err
    }
    return msg, nil
}

But thought, like the Go standard library, that if UDP fails it should default to TCP unless you tell it not to.

from dns.

miekg avatar miekg commented on July 19, 2024

No this package does not implement TCP fallback, nor retries. I may make
the current docs reflect this better.
On Dec 27, 2013 4:23 AM, "Jason Goecke" [email protected] wrote:

I did force TCP this way:

func queryDns(query string, dnsMaster string, queryType uint16) (*dns.Msg, error) {
c := new(dns.Client)
c.Net = "tcp"
m := new(dns.Msg)
m.SetQuestion(query, queryType)
msg, _, err := c.Exchange(m, dnsMaster)
if err != nil {
return nil, err
}
return msg, nil}

But thought, like the Go standard library, that if UDP fails it should
default to TCP unless you tell it not to.


Reply to this email directly or view it on GitHubhttps://github.com//issues/65#issuecomment-31246676
.

from dns.

miekg avatar miekg commented on July 19, 2024

'dns: bad rdlength' looks to be a bug...? Can you open another issue or send some example code my way?

from dns.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.