summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-05-13 07:41:38 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-05-13 07:41:38 +0200
commit05b7e4bf0d2fa8fa50746c752af33a1c6b41173b (patch)
tree7fa7c96a5bd678e5de042fd62c59e8bf552fad21
parentb4608ac16c27647721dfe5ee56bf9709a827c486 (diff)
downloadmdns-resolver-05b7e4bf0d2fa8fa50746c752af33a1c6b41173b.tar
mdns-resolver-05b7e4bf0d2fa8fa50746c752af33a1c6b41173b.zip
Don't reuse query packet for reply
-rwxr-xr-xmdns-resolver21
1 files 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+'.'