Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Iñaki Baz Castillo
RE: Dnsruby and EventMachine [ reply ]  
2011-02-02 11:04
Humm, not, it seems that evldns is more appropriate for building a DNS server rather than behaving as a DNS client.

By: Iñaki Baz Castillo
RE: Dnsruby and EventMachine [ reply ]  
2011-02-02 11:00
I assume ev-ldns is an async resolver suitable for being integrated within a IO reactor, am I right?

Thanks a lot.

By: Iñaki Baz Castillo
RE: Dnsruby and EventMachine [ reply ]  
2011-02-02 10:54
Thanks, I didn't know ldns. I'll take a look to it.

By: Alex D
RE: Dnsruby and EventMachine [ reply ]  
2011-02-02 10:53
P.S. You may also be interested in ev-ldns (written by a colleague here at Nominet, and which uses ldns).

By: Alex D
RE: Dnsruby and EventMachine [ reply ]  
2011-02-02 10:52
I don't know the udns library, I'm afraid. However, looking at the docs, it sounds like it is simply a stub resolver, which requires to speak to a recursive resolver. Dnsruby is, itself, a validating recursive resolver (which can also speak to recursive resolvers if desired).

I'd probably recommend the ldns library (written by friends at nlnetlabs, and used by Unbound and OpenDNSSEC). I think this library would provide much richer functionality for you - although you may well be happy to be limited to speaking to a recursive resolver.

HTH,


Alex.

By: Iñaki Baz Castillo
RE: Dnsruby and EventMachine [ reply ]  
2011-02-02 10:00
Thanks, I'll try it. I'm building a SIP server on EventMachine and need non blocking DNS resolver capable of resolving SRV and NAPTR records.

It will take some time until I can check this, but I will notify it here.

BTW: I've also in mind the posibility of coding a Ruby C extension for udns library (async DNS resolver suitable for applications based on reactor pattern). Efficiency is very important in my project so I expect that a very fast C resolver could be needed. Could I know your opinion?

Really thanks a lot for all your help.

By: Alex D
RE: Dnsruby and EventMachine [ reply ]  
2011-02-02 09:09
I think you could probably use an EM::Queue in dnsruby with no real problems. I'm not sure whether this would help with your project? You can try it simply by passing an EM::Queue in instead of the normal Queue object.

Let me know if I can help.

Thanks,


Alex.

By: Iñaki Baz Castillo
RE: Dnsruby and EventMachine [ reply ]  
2011-02-02 08:41
That's a good option :)

I've also told about other posibility: using EM::Queue which is a bit different than a normal Queue, but perhaps feasible:

http://eventmachine.rubyforge.org/EventMachine/Queue.html

By: Alex D
RE: Dnsruby and EventMachine [ reply ]  
2011-02-02 07:53
Hi -

Thinking about this some more...

Is it possible to take the Message encoding and decoding aspect of dnsruby (so that you can have SRV and NAPTR support), but to use the packet-sending logic of em-dns to actually send the packets using EventMachine? Perhaps this would be the easiest way forward?

Thanks,


Alex.

By: Iñaki Baz Castillo
RE: Dnsruby and EventMachine [ reply ]  
2011-02-01 13:41
Thanks for the explanation.

By: Alex D
RE: Dnsruby and EventMachine [ reply ]  
2011-02-01 13:38
Originally, I had two implementations of the IO thread in dnsruby : "native" select loop, and "EventMachine". When I added DNSSEC support, the IO became more complicated. Not only did we have to wait for a valid DNS response from one of several server : we now had to make potentially _many more_ queries in order to do the DNSSEC validation. This is because it is necessary to find the relevant DNSKEY records before it is possible to verify the RRSIGs in the message response. At this point, it became considerably more complex to maintain the two IO options. I had also ironed out all the bugs in the original select loop, and decided that I could no longer spare the time to maintain both systems. Additionally, the EventMachine implementation had changed, which meant that my original EM implementation no longer worked. :(

By: Iñaki Baz Castillo
RE: Dnsruby and EventMachine [ reply ]  
2011-02-01 10:54
Hi, you said that:

> Older versions of dnsruby included support for
> EventMachine - I had to take this out when I
> included support for DNSSEC validation.

Could I know why adding DNSSEC is not suitable within EventMachine? does such mechanism change something at UDP so using EM is not feasible?

Thanks for any explanation.

By: Iñaki Baz Castillo
RE: Dnsruby and EventMachine [ reply ]  
2011-02-01 10:25
Honestly no idea. By looking at the code, these are the involved functions, so I think it does require a real file descriptor:


def EventMachine::attach io, handler=nil, *args, &blk
attach_io io, false, handler, *args, &blk
end

def EventMachine::attach_io io, watch_mode, handler=nil, *args # :nodoc:
klass = klass_from_handler(Connection, handler, *args)

if !watch_mode and klass.public_instance_methods.any?{|m| [:notify_readable, :notify_writable].include? m.to_sym }
raise ArgumentError, "notify_readable/writable with EM.attach is not supported. Use EM.watch(io){ |c| c.notify_readable = true }"
end

if io.respond_to?(:fileno)
fd = defined?(JRuby) ? JRuby.runtime.getDescriptorByFileno(io.fileno).getChannel : io.fileno
else
fd = io
end

s = attach_fd fd, watch_mode
c = klass.new s, *args

c.instance_variable_set(:@io, io)
c.instance_variable_set(:@fd, fd)

@conns[s] = c
block_given? and yield c
c
end

const unsigned long EventMachine_t::AttachFD (int fd, bool watch_mode)
{
#ifdef OS_UNIX
if (fcntl(fd, F_GETFL, 0) < 0)
throw std::runtime_error ("invalid file descriptor");
#endif

#ifdef OS_WIN32
// TODO: add better check for invalid file descriptors (see ioctlsocket or getsockopt)
if (fd == INVALID_SOCKET)
throw std::runtime_error ("invalid file descriptor");
#endif

{// Check for duplicate descriptors
size_t i;
for (i = 0; i < Descriptors.size(); i++) {
EventableDescriptor *ed = Descriptors[i];
assert (ed);
if (ed->GetSocket() == fd)
throw std::runtime_error ("adding existing descriptor");
}

for (i = 0; i < NewDescriptors.size(); i++) {
EventableDescriptor *ed = NewDescriptors[i];
assert (ed);
if (ed->GetSocket() == fd)
throw std::runtime_error ("adding existing new descriptor");
}
}

if (!watch_mode)
SetSocketNonblocking(fd);

ConnectionDescriptor *cd = new ConnectionDescriptor (fd, this);
if (!cd)
throw std::runtime_error ("no connection allocated");

cd->SetWatchOnly(watch_mode);
cd->SetConnectPending (false);

Add (cd);

const unsigned long out = cd->GetBinding();
return out;
}

By: Alex D
RE: Dnsruby and EventMachine [ reply ]  
2011-02-01 10:19
Perhaps it is possible to wrap something around the queue that implements the IO methods which EM is expecting?

By: Iñaki Baz Castillo
RE: Dnsruby and EventMachine [ reply ]  
2011-02-01 09:49
Thanks for your response.

I've asked right now in EM maillist about how to integrate a Queue into EM reactor (maybe using EM.watch). I don't expect it to be possible as EM.watch expects a IO instance. In fact, EM.attach_io extracts the file descriptor of the give IO so, for sure, it's not possible to integrate Dnsruby in this way.

By: Alex D
RE: Dnsruby and EventMachine [ reply ]  
2011-02-01 09:19
Hi -

You can check the Queue whenever you like. You can either block on it (queue.pop) or else you can poll (queue.empty?). The idea is to decouple the IO thread from the client thread - hence the lack of callback to the client thread.

Older versions of dnsruby included support for EventMachine - I had to take this out when I included support for DNSSEC validation.

Is it possible to use Queue polling in conjunction with EM.watch()?

HTH,


Alex.

By: Iñaki Baz Castillo
Dnsruby and EventMachine [ reply ]  
2011-01-31 10:23
My question is related to Dnsruby and ventMachine. I know that "support for EM has been deprecated" but I need SRV and NAPTR records in a non blocking way as I'm coding a SIP server on top of EventMachine, so em-dns is not valid for me.

There is something I don't understand very well when about send_async(). After calling it I must check the Queue given as parameter but, when to check it? is there any IO-selectable object I can query to know if there is something to read? or can I assign a callback to the send_async() method? I couldn't find it in the documentation.

Also, is it possible to integrate Dnsruby with EventMachine? if for example Dnsruby provides a IO object then EM.watch could be used in conjunction with Dnsruby send_async() method. But it seems that the only way to get the result is by doing Queue#pop which can block or raise an exception if there is no data to read, so it's not suitable for EventMachine.

Do I miss something? Thanks a lot for any clarification.