Comments (9)
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.
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.
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.
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.
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.
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.
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.
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.
'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)
- Trailing backslash results in non-FQDN targets HOT 6
- RFC: Parsing record contents directly HOT 6
- Wildcard domains as per RFC-4592 HOT 10
- digest type 3 (GOST94) HOT 2
- Forwarding DNS Queries to other Handler in TCP Connections HOT 6
- Request timeout middleware dns.HandlerFunc HOT 1
- IsDomainName total length check issues HOT 1
- Idiomatic way of printing the IPs / A records returned by a query HOT 4
- NewRR accepts invalid RR string HOT 2
- Public Key size from DNSKEY HOT 3
- IsDomainName gives an ok for domains longer than the RFC maximum length HOT 2
- DNSSEC grab public key from private for DNSKEY HOT 7
- `Server.WriteTimeout` is unused HOT 1
- Passing context param to `ListenAndServe` method HOT 1
- TXT entry more than 255 characters will cause SERVFAIL HOT 1
- Is DoH supported?
- Proposal: Decorate "overflow unpacking" errors with where in the unpacking the error occurred. HOT 9
- Use of []byte in sync.Pool HOT 5
- Panic on /miekg/dns/labels HOT 1
- `NSEC(3) block too long in type bitmap` <- should the max size enforcement be relaxed? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dns.