aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mauve/source_list.rb32
-rw-r--r--test/tc_mauve_source_list.rb6
-rw-r--r--test/th_mauve_resolv.rb5
3 files changed, 29 insertions, 14 deletions
diff --git a/lib/mauve/source_list.rb b/lib/mauve/source_list.rb
index 869d99a..d1eafc6 100644
--- a/lib/mauve/source_list.rb
+++ b/lib/mauve/source_list.rb
@@ -169,21 +169,29 @@ module Mauve
#
def resolve
@last_resolved_at = Time.now
-
- url_list = []
- if @url
- url_list_s = do_get(@url)
- if url_list_s.is_a?(String)
- url_list = url_list_s.split("\n").collect{|s| do_parse_source(s)}.flatten.compact
+
+ if true == Configuration.current.minimal_dns_lookups
+
+ new_list = [] + @list
+
+ else
+
+ url_list = []
+ if @url
+ url_list_s = do_get(@url)
+ if url_list_s.is_a?(String)
+ url_list = url_list_s.split("\n").collect{|s| do_parse_source(s)}.flatten.compact
+ end
end
- end
- new_list = (url_list + @list).collect do |host|
- if host.is_a?(String)
- [host] + MauveResolv.get_ips_for(host).collect{|i| IPAddr.new(i)}
- else
- host
+ new_list = (url_list + @list).collect do |host|
+ if host.is_a?(String)
+ [host] + MauveResolv.get_ips_for(host).collect{|i| IPAddr.new(i)}
+ else
+ host
+ end
end
+
end
@resolved_list = new_list.flatten
diff --git a/test/tc_mauve_source_list.rb b/test/tc_mauve_source_list.rb
index 6241a2f..138286a 100644
--- a/test/tc_mauve_source_list.rb
+++ b/test/tc_mauve_source_list.rb
@@ -91,7 +91,11 @@ class TcMauveSourceList < Mauve::UnitTest
def test_ip_crossmatch_fail_when_minimal_dns_is_available
Configuration.current.minimal_dns_lookups = true
+ dns_lookup_count_before_test = MauveResolv.count
+ #
+ # These should all fail, since no extra cossmatching is happening.
+ #
sl = SourceList.new("test")
assert_nothing_raised { sl += "test-1.example.com" }
assert( !sl.includes?("www.example.com"), "www.example.com not found in #{sl.list}" )
@@ -99,6 +103,8 @@ class TcMauveSourceList < Mauve::UnitTest
sl = SourceList.new("test")
assert_nothing_raised { sl += "2001::/3" }
assert( !sl.includes?("www2.example.com"), "www2.example.com not found in #{sl.list}" )
+
+ assert_equal(0, MauveResolv.count - dns_lookup_count_before_test, "Some DNS lookups took place, even when minimal_dns_lookups was set")
end
def test_remote_source_list
diff --git a/test/th_mauve_resolv.rb b/test/th_mauve_resolv.rb
index 10bdacc..3451690 100644
--- a/test/th_mauve_resolv.rb
+++ b/test/th_mauve_resolv.rb
@@ -22,10 +22,11 @@ module Mauve
"www2.example.com" => %w(1.2.3.5 2001:2::2)
}
if lookup.has_key?(host)
- self.count += lookup[host].length if $debug
+ self.count += lookup[host].length
lookup[host]
else
- get_ips_for_without_testing(host)
+ self.count += 1
+ []
end
end