Skip to content

Commit

Permalink
Remove raising of error on rd change.
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Bennett committed Nov 13, 2014
1 parent 4f8d7d5 commit 6c1ebab
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
16 changes: 8 additions & 8 deletions lib/dnsruby/packet_sender.rb
Expand Up @@ -305,7 +305,7 @@ def send_async(*args) # msg, client_queue, client_query_id, use_tcp=@use_tcp)
if (!client_query_id)
client_query_id = Time.now + rand(10000) # is this safe?!
end
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd

query_packet = make_query_packet(msg, use_tcp)
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
Expand All @@ -329,7 +329,7 @@ def send_async(*args) # msg, client_queue, client_query_id, use_tcp=@use_tcp)
return client_query_id
end
end
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd

# Otherwise, run the query
if (udp_packet_size < query_packet.length)
Expand All @@ -343,9 +343,9 @@ def send_async(*args) # msg, client_queue, client_query_id, use_tcp=@use_tcp)
Dnsruby.log.debug{"Query packet length exceeds max UDP packet size - using TCP"}
use_tcp = true
end
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
send_dnsruby(query_packet, msg, client_query_id, client_queue, use_tcp)
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
return client_query_id
# end
end
Expand Down Expand Up @@ -598,13 +598,13 @@ def make_query(name, type = Types::A, klass = Classes::IN, set_cd=@dnssec)
# Prepare the packet for sending
def make_query_packet(packet, use_tcp = @use_tcp) #:nodoc: all

raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if packet.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if packet.header.rd

if (!packet.send_raw) # Don't mess with this packet!
if (packet.header.opcode == OpCode.QUERY || @recurse)
packet.header.rd=@recurse
end
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if packet.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if packet.header.rd

# Only do this if the packet has not been prepared already!
if (@dnssec)
Expand All @@ -614,13 +614,13 @@ def make_query_packet(packet, use_tcp = @use_tcp) #:nodoc: all
# @TODO@ What if an existing OPT RR is not big enough? Should we replace it?
add_opt_rr(packet)
end
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if packet.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if packet.header.rd
end

if (@tsig && !packet.signed?)
@tsig.apply(packet)
end
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if packet.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if packet.header.rd
return packet.encode
end

Expand Down
26 changes: 13 additions & 13 deletions lib/dnsruby/resolver.rb
Expand Up @@ -240,12 +240,12 @@ def query_no_validation_or_recursion(name, type=Types.A, klass=Classes.IN) # :no
def send_message(message)
Dnsruby.log.debug{'Resolver : sending message'}
q = Queue.new
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if message.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if message.header.rd
send_async(message, q)
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if message.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if message.header.rd

_id, result, error = q.pop
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if message.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if message.header.rd
if error
raise error
else
Expand Down Expand Up @@ -365,17 +365,17 @@ def send_async(msg, client_queue, client_query_id = nil)
unless @resolver_ruby # @TODO@ Synchronize this?
@resolver_ruby = ResolverRuby.new(self)
end
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
# }
client_query_id = @resolver_ruby.send_async(msg, client_queue, client_query_id)
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
if @single_resolvers.length == 0
Thread.start {
sleep(@query_timeout == 0 ? 1 : @query_timeout)
client_queue.push([client_query_id, nil, ResolvTimeout.new('Query timed out - no nameservers configured')])
}
end
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
client_query_id
end

Expand Down Expand Up @@ -847,7 +847,7 @@ def send_async(msg, client_queue, client_query_id=nil)
return
end

raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd

tick_needed = false
# add to our data structures
Expand All @@ -862,23 +862,23 @@ def send_async(msg, client_queue, client_query_id=nil)
end
outstanding = []
@query_list[client_query_id]=[msg, client_queue, q, outstanding]
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd

query_timeout = Time.now + @parent.query_timeout
if @parent.query_timeout == 0
query_timeout = Time.now + 31536000 # a year from now
end
@timeouts[client_query_id] = [query_timeout, generate_timeouts]
}
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd

# Now do querying stuff using SingleResolver
# All this will be handled by the tick method (if we have 0 as the first timeout)
st = SelectThread.instance
st.add_observer(q, self)
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
tick if tick_needed
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd

client_query_id
end
Expand Down Expand Up @@ -966,15 +966,15 @@ def tick # :nodoc: all
outstanding.push(id)
timeouts_done.push(timeout)
timeouts.delete(timeout)
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd

# Pick a new QID here @TODO@ !!!
# msg.header.id = rand(65535);
# print "New query : #{new_msg}\n"

puts "res is: #{res}"
res.send_async(msg, select_queue, id)
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd
# raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if msg.header.rd

else
break
Expand Down
1 change: 1 addition & 0 deletions test/tc_resolver.rb
Expand Up @@ -291,6 +291,7 @@ def test_rd_not_overwritten
message.header.rd = false
assert(! message.header.rd)
resolver = Resolver.new
resolver.recurse = false
raise "Header rd flag was overwritten to true in #{__FILE__}:#{__LINE__}" if message.header.rd
_response = resolver.send_message(message)
puts "Header rd: #{message.header.rd}"
Expand Down

0 comments on commit 6c1ebab

Please sign in to comment.