Add some admin messages: GenerateAllZoneFiles + GenerateZoneFile.

beta
Philippe Pittoli 2024-02-25 06:30:28 +01:00
parent 0793b2c878
commit b155ee1d2f
1 changed files with 36 additions and 22 deletions

View File

@ -85,6 +85,16 @@ type DeleteRR = { domain :: String, rrid :: Int }
codecDeleteRR ∷ CA.JsonCodec DeleteRR codecDeleteRR ∷ CA.JsonCodec DeleteRR
codecDeleteRR = CA.object "DeleteRR" (CAR.record { domain: CA.string, rrid: CA.int }) codecDeleteRR = CA.object "DeleteRR" (CAR.record { domain: CA.string, rrid: CA.int })
{- 100 -}
type GenerateAllZoneFiles = {}
codecGenerateAllZoneFiles ∷ CA.JsonCodec GenerateAllZoneFiles
codecGenerateAllZoneFiles = CA.object "GenerateAllZoneFiles" (CAR.record {})
{- 101 -}
type GenerateZoneFile = { domain :: String }
codecGenerateZoneFile ∷ CA.JsonCodec GenerateZoneFile
codecGenerateZoneFile = CA.object "GenerateZoneFile" (CAR.record { domain: CA.string })
{- 250 -} {- 250 -}
type KeepAlive = { } type KeepAlive = { }
codecKeepAlive ∷ CA.JsonCodec KeepAlive codecKeepAlive ∷ CA.JsonCodec KeepAlive
@ -238,17 +248,19 @@ codecInsufficientRights = CA.object "InsufficientRights" (CAR.record { })
-- All possible requests. -- All possible requests.
data RequestMessage data RequestMessage
= MkLogin Login -- 0 = MkLogin Login -- 0
| MkMaintenance Maintenance -- 7 | MkMaintenance Maintenance -- 7
| MkNewDomain NewDomain -- 9 | MkNewDomain NewDomain -- 9
| MkDeleteDomain DeleteDomain -- 10 | MkDeleteDomain DeleteDomain -- 10
| MkAddOrUpdateZone AddOrUpdateZone -- 11 | MkAddOrUpdateZone AddOrUpdateZone -- 11
| MkGetZone GetZone -- 12 | MkGetZone GetZone -- 12
| MkUserDomains UserDomains -- 13 | MkUserDomains UserDomains -- 13
| MkAddRR AddRR -- 14 | MkAddRR AddRR -- 14
| MkUpdateRR UpdateRR -- 15 | MkUpdateRR UpdateRR -- 15
| MkDeleteRR DeleteRR -- 16 | MkDeleteRR DeleteRR -- 16
| MkKeepAlive KeepAlive -- 250 | MkGenerateAllZoneFiles GenerateAllZoneFiles -- 100
| MkGenerateZoneFile GenerateZoneFile -- 101
| MkKeepAlive KeepAlive -- 250
-- All possible answers from the authentication daemon (authd). -- All possible answers from the authentication daemon (authd).
data AnswerMessage data AnswerMessage
@ -282,17 +294,19 @@ data AnswerMessage
encode ∷ RequestMessage -> Tuple UInt String encode ∷ RequestMessage -> Tuple UInt String
encode m = case m of encode m = case m of
(MkLogin request) -> get_tuple 0 codecLogin request (MkLogin request) -> get_tuple 0 codecLogin request
(MkMaintenance request) -> get_tuple 7 codecMaintenance request (MkMaintenance request) -> get_tuple 7 codecMaintenance request
(MkNewDomain request) -> get_tuple 9 codecNewDomain request (MkNewDomain request) -> get_tuple 9 codecNewDomain request
(MkDeleteDomain request) -> get_tuple 10 codecDeleteDomain request (MkDeleteDomain request) -> get_tuple 10 codecDeleteDomain request
(MkAddOrUpdateZone request) -> get_tuple 11 codecAddOrUpdateZone request (MkAddOrUpdateZone request) -> get_tuple 11 codecAddOrUpdateZone request
(MkGetZone request) -> get_tuple 12 codecGetZone request (MkGetZone request) -> get_tuple 12 codecGetZone request
(MkUserDomains request) -> get_tuple 13 codecUserDomains request (MkUserDomains request) -> get_tuple 13 codecUserDomains request
(MkAddRR request) -> get_tuple 14 codecAddRR request (MkAddRR request) -> get_tuple 14 codecAddRR request
(MkUpdateRR request) -> get_tuple 15 codecUpdateRR request (MkUpdateRR request) -> get_tuple 15 codecUpdateRR request
(MkDeleteRR request) -> get_tuple 16 codecDeleteRR request (MkDeleteRR request) -> get_tuple 16 codecDeleteRR request
(MkKeepAlive request) -> get_tuple 250 codecKeepAlive request (MkGenerateAllZoneFiles request) -> get_tuple 100 codecGenerateAllZoneFiles request
(MkGenerateZoneFile request) -> get_tuple 101 codecGenerateZoneFile request
(MkKeepAlive request) -> get_tuple 250 codecKeepAlive request
where where
get_tuple :: forall a. Int -> CA.JsonCodec a -> a -> Tuple UInt String get_tuple :: forall a. Int -> CA.JsonCodec a -> a -> Tuple UInt String
get_tuple num codec request = Tuple (fromInt num) (J.stringify $ CA.encode codec request) get_tuple num codec request = Tuple (fromInt num) (J.stringify $ CA.encode codec request)