WIP: SPF. Add Qualifier type.
This commit is contained in:
parent
0beba6ea6d
commit
73fcdd0b7c
@ -35,7 +35,7 @@ type ResourceRecord
|
|||||||
, v :: Maybe String -- Default: spf1
|
, v :: Maybe String -- Default: spf1
|
||||||
, mechanisms :: Maybe (Array Mechanism)
|
, mechanisms :: Maybe (Array Mechanism)
|
||||||
, modifiers :: Maybe (Array Modifier)
|
, modifiers :: Maybe (Array Modifier)
|
||||||
, q :: Maybe String -- Qualifier for default mechanism (`all`).
|
, q :: Maybe Qualifier -- Qualifier for default mechanism (`all`).
|
||||||
|
|
||||||
-- TODO: DKIM specific entries.
|
-- TODO: DKIM specific entries.
|
||||||
-- TODO: DMARC specific entries.
|
-- TODO: DMARC specific entries.
|
||||||
@ -72,11 +72,11 @@ codec = CA.object "ResourceRecord"
|
|||||||
, v: CAR.optional CA.string
|
, v: CAR.optional CA.string
|
||||||
, mechanisms: CAR.optional (CA.array codecMechanism)
|
, mechanisms: CAR.optional (CA.array codecMechanism)
|
||||||
, modifiers: CAR.optional (CA.array codecModifier)
|
, modifiers: CAR.optional (CA.array codecModifier)
|
||||||
, q: CAR.optional CA.string
|
, q: CAR.optional codecQualifier
|
||||||
})
|
})
|
||||||
|
|
||||||
type Mechanism
|
type Mechanism
|
||||||
= { q :: Maybe Int -- Qualifier (0 = Pass, 1 = Neutral, 2 = soft fail, 3 = hard fail)
|
= { q :: Maybe Qualifier
|
||||||
, t :: Int -- Type of mechanism (0 = A, 1 = IP4, 2 = IP6, 3 = MX, 4 = PTR, 5 = EXISTS, 6 = INCLUDE)
|
, t :: Int -- Type of mechanism (0 = A, 1 = IP4, 2 = IP6, 3 = MX, 4 = PTR, 5 = EXISTS, 6 = INCLUDE)
|
||||||
, v :: String -- Value (IP addresses or ranges, or domains).
|
, v :: String -- Value (IP addresses or ranges, or domains).
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ type Mechanism
|
|||||||
codecMechanism :: JsonCodec Mechanism
|
codecMechanism :: JsonCodec Mechanism
|
||||||
codecMechanism = CA.object "Mechanism"
|
codecMechanism = CA.object "Mechanism"
|
||||||
(CAR.record
|
(CAR.record
|
||||||
{ q: CAR.optional CA.int
|
{ q: CAR.optional codecQualifier
|
||||||
, t: CA.int
|
, t: CA.int
|
||||||
, v: CA.string
|
, v: CA.string
|
||||||
})
|
})
|
||||||
@ -129,3 +129,25 @@ emptyRR
|
|||||||
, modifiers: Nothing
|
, modifiers: Nothing
|
||||||
, q: Nothing
|
, q: Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data Qualifier = Pass | None | SoftFail | HardFail
|
||||||
|
|
||||||
|
-- | Codec for just encoding a single value of type `Qualifier`.
|
||||||
|
codecQualifier :: CA.JsonCodec Qualifier
|
||||||
|
codecQualifier =
|
||||||
|
CA.prismaticCodec "Qualifier" from to CA.string
|
||||||
|
where
|
||||||
|
from :: String -> Maybe Qualifier
|
||||||
|
from = case _ of
|
||||||
|
"pass" -> Just Pass -- +
|
||||||
|
"none" -> Just None -- ?
|
||||||
|
"soft_fail" -> Just SoftFail -- ~
|
||||||
|
"hard_fail" -> Just HardFail -- -
|
||||||
|
_ -> Nothing
|
||||||
|
|
||||||
|
to :: Qualifier -> String
|
||||||
|
to = case _ of
|
||||||
|
Pass -> "pass"
|
||||||
|
None -> "none"
|
||||||
|
SoftFail -> "soft_fail"
|
||||||
|
HardFail -> "hard_fail"
|
||||||
|
@ -39,7 +39,7 @@ import Bulma as Bulma
|
|||||||
import CSSClasses as C
|
import CSSClasses as C
|
||||||
|
|
||||||
import App.AcceptedRRTypes (AcceptedRRTypes(..))
|
import App.AcceptedRRTypes (AcceptedRRTypes(..))
|
||||||
import App.ResourceRecord (ResourceRecord, emptyRR, Mechanism, Modifier)
|
import App.ResourceRecord (ResourceRecord, emptyRR, Mechanism, Modifier, Qualifier)
|
||||||
|
|
||||||
import App.DisplayErrors (error_to_paragraph)
|
import App.DisplayErrors (error_to_paragraph)
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ data Field
|
|||||||
| Field_SPF_v String
|
| Field_SPF_v String
|
||||||
| Field_SPF_mechanisms (Array Mechanism)
|
| Field_SPF_mechanisms (Array Mechanism)
|
||||||
| Field_SPF_modifiers (Array Modifier)
|
| Field_SPF_modifiers (Array Modifier)
|
||||||
| Field_SPF_q String
|
| Field_SPF_q Qualifier
|
||||||
|
|
||||||
-- | Steps to create a new RR:
|
-- | Steps to create a new RR:
|
||||||
-- | 1. `CreateNewRRModal AcceptedRRTypes`: create a modal with default values based on selected accepted type.
|
-- | 1. `CreateNewRRModal AcceptedRRTypes`: create a modal with default values based on selected accepted type.
|
||||||
|
Loading…
Reference in New Issue
Block a user