Max Ivak
Max Ivak

Reputation: 1549

RubyDNS otherwise not working

I am using RubyDNS. When I use match block and otherwise, I want to skip some addresses in match so they would be caught by otherwise block. But it doesn't go to otherwise block.

RubyDNS.run_server(listen: INTERFACES, asynchronous: false) do
  upstream = RubyDNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])

  match(/^([\d\.]+)\.in-addr\.arpa$/, IN::PTR) do |transaction, match_data|

    domain = nil # just for test

    if domain
      transaction.respond!(Name.create(domain))
    else
      # Pass the request to the otherwise handler
      # !!! this doesn't work
      false
    end
  end

  otherwise do |transaction|
    transaction.passthrough!(upstream)
  end
end

When I return false from match block - it doesn't go to otherwise block. How to fix this?

Upvotes: 1

Views: 83

Answers (1)

Max Ivak
Max Ivak

Reputation: 1549

I found how to continue to otherwise block from match block: use 'next!'

match(/^([\d\.]+)\.in-addr\.arpa$/, IN::PTR) do |transaction, match_data|

domain = nil # just for test

if domain
  transaction.respond!(Name.create(domain))
else
  # Pass the request to the otherwise handler
  next!
end
end
otherwise do |transaction|
   transaction.passthrough!(upstream)
end

Upvotes: 1

Related Questions