WIP: SPF. Produce correct mechanism TXT bind9 output.
This commit is contained in:
parent
fcbed27f60
commit
9953ccfb0b
@ -260,21 +260,6 @@ class DNSManager::Storage::Zone
|
||||
# baguette.netlib.re. 3600 IN TXT "v=spf1 a mx ip4:<IP> a:mail.baguette.netlib.re ~all"
|
||||
class SPF < ResourceRecord
|
||||
|
||||
def qualifier_to_char(qualifier : Qualifier) : Char
|
||||
case qualifier
|
||||
when .pass?
|
||||
'+'
|
||||
when .none?
|
||||
'?'
|
||||
when .soft_fail?
|
||||
'~'
|
||||
# when .hard_fail?
|
||||
else '-'
|
||||
end
|
||||
end
|
||||
def qualifier_to_string(qualifier : Qualifier) : String
|
||||
"#{qualifier_to_char qualifier}all"
|
||||
end
|
||||
|
||||
# SPF mechanisms are about policy, which comes with the form of a single character:
|
||||
# - '?' means no policy (neutral),
|
||||
@ -326,8 +311,8 @@ class DNSManager::Storage::Zone
|
||||
errors
|
||||
end
|
||||
|
||||
def to_s
|
||||
"#{@t}=#{v}"
|
||||
def to_s(io : IO)
|
||||
io << "#{@t}=#{v}"
|
||||
end
|
||||
end
|
||||
|
||||
@ -353,20 +338,32 @@ class DNSManager::Storage::Zone
|
||||
# TODO
|
||||
def get_errors : Array(Error)
|
||||
errors = [] of Error
|
||||
case @t
|
||||
when Mechanism::Type::A
|
||||
when Mechanism::Type::IP4
|
||||
when Mechanism::Type::IP6
|
||||
when Mechanism::Type::MX
|
||||
when Mechanism::Type::PTR
|
||||
when Mechanism::Type::EXISTS
|
||||
when Mechanism::Type::INCLUDE
|
||||
case t
|
||||
when .a?
|
||||
when .ip4?
|
||||
when .ip6?
|
||||
when .mx?
|
||||
when .ptr?
|
||||
when .exists?
|
||||
when .include?
|
||||
end
|
||||
errors
|
||||
end
|
||||
|
||||
def to_s
|
||||
"#{qualifier_to_char @q}#{@t}=#{v}"
|
||||
def to_s(io : IO)
|
||||
to_bind9(io)
|
||||
end
|
||||
|
||||
def to_bind9(io : IO)
|
||||
case q
|
||||
when .pass?
|
||||
"#{t}=#{v}"
|
||||
else
|
||||
io << "#{qualifier_to_char q}"
|
||||
end
|
||||
|
||||
io << t.to_s.downcase
|
||||
io << "=#{v}" if v != ""
|
||||
end
|
||||
end
|
||||
|
||||
@ -704,3 +701,20 @@ class DNSManager::Storage::Zone
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def qualifier_to_char(qualifier : DNSManager::Storage::Zone::SPF::Qualifier) : Char
|
||||
case qualifier
|
||||
when .pass?
|
||||
'+'
|
||||
when .none?
|
||||
'?'
|
||||
when .soft_fail?
|
||||
'~'
|
||||
# when .hard_fail?
|
||||
else '-'
|
||||
end
|
||||
end
|
||||
|
||||
def qualifier_to_string(qualifier : DNSManager::Storage::Zone::SPF::Qualifier) : String
|
||||
"#{qualifier_to_char qualifier}all"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user