From 05b7e4bf0d2fa8fa50746c752af33a1c6b41173b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 13 May 2012 07:41:38 +0200 Subject: Don't reuse query packet for reply --- mdns-resolver | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/mdns-resolver b/mdns-resolver index 592c754..c78e9f3 100755 --- a/mdns-resolver +++ b/mdns-resolver @@ -8,7 +8,7 @@ require 'net/dns/packet' ### Config ### $domain = 'mesh.ffhl' $port = 53 -$ttl = 0 +$ttl = 10 $ns = ['mesh.ffhl. 3600 IN NS paul.ffhl.'] $soa = 'mesh.ffhl. 3600 IN SOA paul.ffhl. freifunk\.luebeck.asta.uni-luebeck.de. 1 3600 180 600 60' ### Config end ### @@ -71,20 +71,21 @@ while run do end return if pktinfo.nil? - packet = Net::DNS::Packet::parse(data) + query = Net::DNS::Packet::parse(data) - return unless packet.header.opCode == Net::DNS::Header::QUERY - return unless packet.header.query? + return unless query.header.opCode == Net::DNS::Header::QUERY + return unless query.header.query? + packet = Net::DNS::Packet.new + packet.header.id = query.header.id + packet.header.opCode = Net::DNS::Header::QUERY packet.header.qr = 1 packet.header.aa = 1 - packet.header.tc = 0 - packet.header.ra = 0 - packet.header.cd = 0 - packet.header.ad = 0 - packet.header.rCode = Net::DNS::Header::RCode::NOERROR + packet.header.rd = query.header.recursive? + + query.question.each do |q| + packet.question << q - packet.question.each do |q| next unless q.qClass.to_i == Net::DNS::IN if q.qName == $domain+'.' -- cgit v1.2.3