Class: MailAuth::Spf::Evaluation

Inherits:
Object
  • Object
show all
Defined in:
lib/mailauth/spf.rb

Overview

One run of RFC 7208's check_host(), plus every recursion an include or redirect drags in. Single use: it carries the shared lookup budget.

Constant Summary collapse

LABEL =
/[a-z0-9](?:[a-z0-9\-]{0,61}[a-z0-9])?/i
DOMAIN =
/\A(?:#{LABEL}\.)+#{Macro::TOPLABEL}\z/o

Instance Method Summary collapse

Constructor Details

#initialize(ip:, helo:, mail_from:, resolver:) ⇒ Evaluation

Returns a new instance of Evaluation.



76
77
78
79
80
81
82
83
# File 'lib/mailauth/spf.rb', line 76

def initialize(ip:, helo:, mail_from:, resolver:)
  @ip = client_address(ip)
  @helo = helo
  @sender = identity(mail_from)
  @domain = @sender.split("@", 2).last.downcase
  @context = Context.new(ip: @ip, sender: @sender, helo: @helo, domain: @domain)
  @budget = Budget.new(resolver, charging: false)
end

Instance Method Details

#runObject



85
86
87
88
89
90
91
92
93
# File 'lib/mailauth/spf.rb', line 85

def run
  if checkable?(@domain)
    result check(@domain)
  else
    result Status::NONE
  end
rescue Error => error
  result error.status, error.message
end