diff options
-rwxr-xr-x | mdns-resolver | 21 |
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+'.' |