lib/dnsbl/client.rb
# takes a DNS response and converts it into a DNSBLResult
takes a DNS response and converts it into a DNSBLResult
takes a DNS response and converts it into a DNSBLResult
def _decode_response(buf)
			reply = Resolv::DNS::Message.decode(buf)
			results = []
			reply.each_answer do |name,ttl,data|
				if name.to_s =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(.+)$/
					ip = [$4,$3,$2,$1].join(".")
					domain = $5
					@dnsbls.each do |dnsblname, config|
						next unless data.is_a? Resolv::DNS::Resource::IN::A
						if domain == config['domain']
							meaning = config[data.address.to_s] || data.address.to_s
							results << DNSBLResult.new(dnsblname, ip, name.to_s, data.address.to_s, meaning, Time.now.to_f - @starttime)
							break
						end
					end
				else
					@dnsbls.each do |dnsblname, config|
						if name.to_s.end_with?(config['domain'])
							meaning = nil
							if config['decoder']
								meaning = self.send(("__"+config['decoder']).to_sym, data.address.to_s)
							elsif config[data.address.to_s]
								meaning = config[data.address.to_s]
							else 
								meaning = data.address.to_s
							end
							results << DNSBLResult.new(dnsblname, name.to_s.gsub("."+config['domain'],''), name.to_s, data.address.to_s, meaning, Time.now.to_f - @starttime)
							break
						end
					end
				end
			end
			results
		end
def _decode_response ( buf ) reply = Resolv :: DNS :: Message . decode ( buf ) results = [ ] reply . each_answer do | name , ttl , data | if name . to_s =~ / ^( \d {1,3}) \. ( \d {1,3}) \. ( \d {1,3}) \. ( \d {1,3}) \. (.+)$ / ip = [ $4 , $3 , $2 , $1 ] . join ( "." ) domain = $5 @dnsbls . each do | dnsblname , config | next unless data . is_a? Resolv :: DNS :: Resource :: IN :: A if domain == config [ 'domain' ] meaning = config [ data . address . to_s ] || data . address . to_s results << DNSBLResult . new ( dnsblname , ip , name . to_s , data . address . to_s , meaning , Time . now . to_f - @starttime ) break end end else @dnsbls . each do | dnsblname , config | if name . to_s . end_with? ( config [ 'domain' ] ) meaning = nil if config [ 'decoder' ] meaning = self . send ( ( "__" + config [ 'decoder' ] ) . to_sym , data . address . to_s ) elsif config [ data . address . to_s ] meaning = config [ data . address . to_s ] else meaning = data . address . to_s end results << DNSBLResult . new ( dnsblname , name . to_s . gsub ( "." + config [ 'domain' ] , '' ) , name . to_s , data . address . to_s , meaning , Time . now . to_f - @starttime ) break end end end end results end
takes a DNS response and converts it into a DNSBLResult
takes a DNS response and converts it into a DNSBLResult
buf
<not_specific>