Comments (9)
Bert from PowerDNS blogged about this a while back. It's the wrong end of the day for me so I haven't refreshed myself on the details or dug into go's syscall/net interfaces to see how much trouble it'd be. I'll take a look tomorrow if no one else does.
from dns.
Some magic syscall.SetsockOptInt might do the trick. I have a bug open for this on skydns as well
from dns.
I've played with this a bit, got it working on Linux, but not on OSX.
I'll keep trying
Here is my progress:
https://gist.github.com/omribahumi/5da8517497042152691e
from dns.
[ Quoting [email protected] in "Re: [dns] Send UDP DNS responses fr..." ]
I've played with this a bit, got it working on Linux, but not on OSX.
I'll keep tryingHere is my progress:
https://gist.github.com/omribahumi/5da8517497042152691e
And the magic there is this line?
syscall.SetsockoptInt(int(file.Fd()), syscall.IPPROTO_IP,
syscall.IP_PKTINFO, 1)
Sadly not portable as you say.
I wonder if this is a broader Go UDP issue, i.e. if we should look
for a solution in Go itself instead of fixing it here.
Thanks for your effort(s), I might have some time this weekend to also look
into this.
/Miek
Miek Gieben
from dns.
Not that simple. You should also be using ReadMsgUDP()
instead of RecvFromUDP()
.
Then, the oob data contains the structs syscall.Cmsghdr
and syscall.Inet4Pktinfo
, which contains the information we need.
According to Google (and the BSD man pages), the exact same implementation should be working with OSX, just by changing the setsockopt()
line to:
syscall.SetsockoptInt(int(file.Fd()), syscall.IPPROTO_IP, syscall.IP_RECVDSTADDR, 1)
But it returns invalid argument
err. I've also tried
syscall.SetsockoptByte(int(file.Fd()), syscall.IPPROTO_IP, syscall.IP_RECVDSTADDR, 1)
But it yields the same results (setsockopt()
failing). I'm not sure why.
The setsockopt()
call works in Python. I even made sure the constants are right (0 and 7, respectively).
As for the Go way of solving this - I couldn't find any, but maybe the force is just stronger with you :)
Waiting for your feedback. Thanks
from dns.
Hmm. Thanks for the thorough update.
To frame the problem state properly: this is only a problem when listening
on 0.0.0.0.for UDP.
But I also agree a elegant solution would be nice.
On 4 Jul 2014 22:13, "Omri Bahumi" [email protected] wrote:
Not that simple. You should also be using ReadMsgUDP() instead of
RecvFromUDP().
Then, the oob data contains the structs syscall.Cmsghdr and
syscall.Inet4Pktinfo, which contains the information we need.According to Google (and the BSD man pages), the exact same implementation
should be working with OSX, just by changing the setsockopt() line to:syscall.SetsockoptInt(int(file.Fd()), syscall.IPPROTO_IP, syscall.IP_RECVDSTADDR, 1)
But it returns invalid argument err. I've also tried
syscall.SetsockoptByte(int(file.Fd()), syscall.IPPROTO_IP, syscall.IP_RECVDSTADDR, 1)
But it yields the same results (setsockopt() failing). I'm not sure why.
The setsockopt() call works in Python. I even made sure the constants are
right (0 and 7, respectively).As for the Go way of solving this - I couldn't find any, but maybe the
force is just stronger with you :)Waiting for your feedback. Thanks
—
Reply to this email directly or view it on GitHub
#95 (comment).
from dns.
Another update:
https://code.google.com/p/go/issues/detail?id=8329&thanks=8329&ts=1404510948
:)
from dns.
@miekg how would you feel about it if I'd fix it only for Linux (preserving the old behavior for OSX)?
from dns.
[ Quoting [email protected] in "Re: [dns] Send UDP DNS responses fr..." ]
@miekg how would you feel about it if I'd fix it only for Linux (preserving the old behavior for OSX)?
I think that is OK and having an pull request make it easier to reason about it.
It might be worth putting this in a seperate file to make it easier to contain
(think that is needed anyway to make it compile for Linux only)
/Miek
Miek Gieben
from dns.
Related Issues (20)
- Decoding of some "special" characters results in \DDD+ HOT 1
- Optional interface for a ResponseWriter to expose Conns HOT 3
- Expose SVCB Service Params fully to clients HOT 2
- Corner case where offset is equal to len(msg), response is truncated without TC bit set and no error is raised HOT 1
- Method for creating wire-format dns.Header from *dns.Msg? HOT 2
- [Query] Type65 aka HTTPS HOT 2
- RFC 2136: Dynamic updates HOT 3
- Add isdn record HOT 1
- Message pack and unpack fails with an empty name in a RR header HOT 1
- Duplicate DNS rCode? HOT 2
- dns: overflow unpacking uint16 HOT 2
- Can't retrieve TXT records for some domains HOT 1
- 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
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.