Class: Coppertone::Request
- Inherits:
-
Object
- Object
- Coppertone::Request
- Defined in:
- lib/coppertone/request.rb
Overview
Represents an SPF request.
Instance Attribute Summary collapse
-
#helo_domain ⇒ Object
readonly
Returns the value of attribute helo_domain.
-
#helo_result ⇒ Object
readonly
Returns the value of attribute helo_result.
-
#ip_as_s ⇒ Object
readonly
Returns the value of attribute ip_as_s.
-
#mailfrom_result ⇒ Object
readonly
Returns the value of attribute mailfrom_result.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#sender ⇒ Object
readonly
Returns the value of attribute sender.
Instance Method Summary collapse
- #authenticate ⇒ Object
- #default_value ⇒ Object
- #helo_context ⇒ Object
-
#initialize(ip_as_s, sender, helo_domain, options = {}) ⇒ Request
constructor
A new instance of Request.
- #mailfrom_context ⇒ Object
- #no_matching_record? ⇒ Boolean
- #process_helo ⇒ Object
- #process_mailfrom ⇒ Object
- #request_context ⇒ Object
- #spf_record(macro_context) ⇒ Object
- #spf_request(macro_context, record, identity) ⇒ Object
Constructor Details
#initialize(ip_as_s, sender, helo_domain, options = {}) ⇒ Request
Returns a new instance of Request.
6 7 8 9 10 11 |
# File 'lib/coppertone/request.rb', line 6 def initialize(ip_as_s, sender, helo_domain, = {}) @ip_as_s = ip_as_s @sender = sender @helo_domain = helo_domain = end |
Instance Attribute Details
#helo_domain ⇒ Object (readonly)
Returns the value of attribute helo_domain.
4 5 6 |
# File 'lib/coppertone/request.rb', line 4 def helo_domain @helo_domain end |
#helo_result ⇒ Object (readonly)
Returns the value of attribute helo_result.
4 5 6 |
# File 'lib/coppertone/request.rb', line 4 def helo_result @helo_result end |
#ip_as_s ⇒ Object (readonly)
Returns the value of attribute ip_as_s.
4 5 6 |
# File 'lib/coppertone/request.rb', line 4 def ip_as_s @ip_as_s end |
#mailfrom_result ⇒ Object (readonly)
Returns the value of attribute mailfrom_result.
4 5 6 |
# File 'lib/coppertone/request.rb', line 4 def mailfrom_result @mailfrom_result end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/coppertone/request.rb', line 4 def end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
4 5 6 |
# File 'lib/coppertone/request.rb', line 4 def result @result end |
#sender ⇒ Object (readonly)
Returns the value of attribute sender.
4 5 6 |
# File 'lib/coppertone/request.rb', line 4 def sender @sender end |
Instance Method Details
#authenticate ⇒ Object
13 14 15 |
# File 'lib/coppertone/request.rb', line 13 def authenticate process_helo || process_mailfrom || default_value end |
#default_value ⇒ Object
31 32 33 |
# File 'lib/coppertone/request.rb', line 31 def default_value no_matching_record? ? Result.none : Result.neutral end |
#helo_context ⇒ Object
43 44 45 |
# File 'lib/coppertone/request.rb', line 43 def helo_context MacroContext.new(helo_domain, ip_as_s, sender, helo_domain, ) end |
#mailfrom_context ⇒ Object
47 48 49 |
# File 'lib/coppertone/request.rb', line 47 def mailfrom_context MacroContext.new(nil, ip_as_s, sender, helo_domain, ) end |
#no_matching_record? ⇒ Boolean
35 36 37 |
# File 'lib/coppertone/request.rb', line 35 def no_matching_record? helo_result.nil? && mailfrom_result.nil? end |
#process_helo ⇒ Object
17 18 19 20 21 22 |
# 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 ⇒ Object
24 25 26 27 28 29 |
# 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 ⇒ Object
39 40 41 |
# File 'lib/coppertone/request.rb', line 39 def request_context @request_context ||= RequestContext.new() end |
#spf_record(macro_context) ⇒ Object
51 52 53 54 |
# 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) ⇒ Object
56 57 58 59 60 61 62 |
# 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 |