Method: SPF::Server#initialize

Defined in:
lib/spf/eval.rb

#initialize(options = {}) ⇒ Server

Returns a new instance of Server.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/spf/eval.rb', line 49

def initialize(options = {})
  @default_authority_explanation = options[:default_authority_explanation] ||
    DEFAULT_DEFAULT_AUTHORITY_EXPLANATION
  unless SPF::MacroString === @default_authority_explanation
    @default_authority_explanation = SPF::MacroString.new({
      :text           => @default_authority_explanation,
      :server         => self,
      :is_explanation => true
    })
  end
  @hostname                      = options[:hostname]     || SPF::Util.hostname
  @dns_resolver                  = options[:dns_resolver] || Resolv::DNS.new
  @query_rr_types                = options[:query_rr_types]                ||
    DEFAULT_QUERY_RR_TYPES
  @max_dns_interactive_terms     = options[:max_dns_interactive_terms]     ||
    DEFAULT_MAX_DNS_INTERACTIVE_TERMS
  @max_name_lookups_per_term     = options[:max_name_lookups_per_term]     ||
    DEFAULT_MAX_NAME_LOOKUPS_PER_TERM
  @max_name_lookups_per_mx_mech  = options[:max_name_lookups_per_mx_mech]  ||
    DEFAULT_MAX_NAME_LOOKUPS_PER_MX_MECH
  @max_name_lookups_per_ptr_mech = options[:max_name_lookups_per_ptr_mech] ||
    DEFAULT_MAX_NAME_LOOKUPS_PER_PTR_MECH

  # TODO: We should probably do this for the above maximums (allow nil maximums).
  @max_void_dns_lookups          = options.has_key?(:max_void_dns_lookups) ? options[:max_void_dns_lookups] : DEFAULT_MAX_VOID_DNS_LOOKUPS

  @raise_exceptions = options.has_key?(:raise_exceptions) ? options[:raise_exceptions] : true

end