lib/spf/model.rb in spf-0.0.14 vs lib/spf/model.rb in spf-0.0.15
- old
+ new
@@ -305,11 +305,11 @@
def match_in_domain(server, request, domain)
domain = self.domain(server, request) unless domain
ipv4_prefix_length = @ipv4_prefix_length || self.default_ipv4_prefix_length
ipv6_prefix_length = @ipv6_prefix_length || self.default_ipv6_prefix_length
- packet = server.dns_lookup(domain, 'ANY')
+ packet = server.dns_lookup(domain.to_s, 'ANY')
server.count_void_dns_lookup(request) unless (rrs = packet)
rrs.each do |rr|
if Resolv::DNS::Resource::IN::A === rr
network = IP.new("#{rr.address}/#{ipv4_prefix_length}")
@@ -409,11 +409,11 @@
def match(server, request, want_result = true)
server.count_dns_interactive_term(request)
domain = self.domain(server, request)
packet = server.dns_lookup(domain, 'A')
- rrs = (packet.answer or server.count_void_dns_lookup(request))
+ rrs = (packet.exchange or server.count_void_dns_lookup(request))
rrs.each do |rr|
return true if rr.type == 'A'
end
return false
@@ -553,22 +553,22 @@
server.count_dns_interactive_term(request)
target_domain = self.domain(server, request)
mx_packet = server.dns_lookup(target_domain, 'MX')
- mx_rrs = (mx_packet[0].answer or server.count_void_dns_lookup(request))
+ mx_rrs = (mx_packet or server.count_void_dns_lookup(request))
# Respect the MX mechanism lookups limit (RFC 4408, 5.4/3/4):
if server.max_name_lookups_per_mx_mech
- mx_rrs = max_rrs[0, server.max_name_lookups_per_mx_mech]
+ mx_rrs = mx_rrs[0, server.max_name_lookups_per_mx_mech]
end
# TODO: Use A records from packet's "additional" section? Probably not.
# Check MX records:
mx_rrs.each do |rr|
- if rr.type == 'MX'
+ if Resolv::DNS::Resource::IN::MX === rr
return true if
self.match_in_domain(server, request, rr.exchange)
else
# Unexpected RR type.
# TODO: Generate debug info or ignore silently.
@@ -662,10 +662,11 @@
class SPF::PositionalMod < SPF::Mod
end
class SPF::UnknownMod < SPF::Mod
+ NAME = 'uknown'
end
class SPF::Mod::Exp < SPF::Mod
attr_reader :domain_spec
@@ -870,11 +871,11 @@
/x, '') and $&
)
# Looks like a modifier:
mod_text = $1
mod_name = $2.downcase
- mod_class = self.class::MOD_CLASSES[mod_name.to_sym] || SPF::Mod
+ mod_class = self.class::MOD_CLASSES[mod_name.to_sym] || SPF::UnknownMod
if mod_class
# Known modifier.
term = mod = mod_class.new_from_string(mod_text, {:raise_exceptions => @raise_exceptions})
if SPF::GlobalMod === mod
# Global modifier.
@@ -955,10 +956,10 @@
:include => SPF::Mech::Include
}
MOD_CLASSES = {
:redirect => SPF::Mod::Redirect,
- :exp => SPF::Mod::Exp
+ :exp => SPF::Mod::Exp,
}
def scopes
[:helo, :mfrom]