class Coppertone::Request
Represents an SPF request.
Attributes
helo_domain[R]
helo_result[R]
ip_as_s[R]
mailfrom_result[R]
options[R]
result[R]
sender[R]
Public Class Methods
new(ip_as_s, sender, helo_domain, options = {})
click to toggle source
# File lib/coppertone/request.rb, line 6 def initialize(ip_as_s, sender, helo_domain, options = {}) @ip_as_s = ip_as_s @sender = sender @helo_domain = helo_domain @options = options end
Public Instance Methods
authenticate()
click to toggle source
# File lib/coppertone/request.rb, line 13 def authenticate process_helo || process_mailfrom || default_value end
default_value()
click to toggle source
# File lib/coppertone/request.rb, line 31 def default_value no_matching_record? ? Result.none : Result.neutral end
helo_context()
click to toggle source
# File lib/coppertone/request.rb, line 43 def helo_context MacroContext.new(helo_domain, ip_as_s, sender, helo_domain, options) end
mailfrom_context()
click to toggle source
# File lib/coppertone/request.rb, line 47 def mailfrom_context MacroContext.new(nil, ip_as_s, sender, helo_domain, options) end
no_matching_record?()
click to toggle source
# File lib/coppertone/request.rb, line 35 def no_matching_record? helo_result.nil? && mailfrom_result.nil? end
process_helo()
click to toggle source
# File lib/coppertone/request.rb, line 17 def process_helo check_spf_for_helo return nil if helo_result&.none? helo_result end
process_mailfrom()
click to toggle source
# File lib/coppertone/request.rb, line 24 def process_mailfrom check_spf_for_mailfrom return nil if mailfrom_result&.none? mailfrom_result end
request_context()
click to toggle source
# File lib/coppertone/request.rb, line 39 def request_context @request_context ||= RequestContext.new(options) end
spf_record(macro_context)
click to toggle source
# File lib/coppertone/request.rb, line 51 def spf_record(macro_context) RecordFinder.new(request_context.dns_client, macro_context.domain).record end
spf_request(macro_context, record, identity)
click to toggle source
# File lib/coppertone/request.rb, line 56 def spf_request(macro_context, record, identity) return Result.new(:none) if record.nil? r = RecordEvaluator.new(record).evaluate(macro_context, request_context) r.identity = identity r end
Private Instance Methods
check_spf_for_context(macro_context, identity)
click to toggle source
# File lib/coppertone/request.rb, line 74 def check_spf_for_context(macro_context, identity) record = spf_record(macro_context) @result = spf_request(macro_context, record, identity) if record rescue DNSAdapter::Error, Coppertone::TemperrorError => e Result.temperror(e.message) rescue Coppertone::PermerrorError => e Result.permerror(e.message) end
check_spf_for_helo()
click to toggle source
# File lib/coppertone/request.rb, line 66 def check_spf_for_helo @helo_result = check_spf_for_context(helo_context, 'helo') end
check_spf_for_mailfrom()
click to toggle source
# File lib/coppertone/request.rb, line 70 def check_spf_for_mailfrom @mailfrom_result = check_spf_for_context(mailfrom_context, 'mailfrom') end