From 0680c9f1abdb4ad6def91bf970c514963d797100 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Tue, 11 Jul 2023 03:43:16 +0200 Subject: [PATCH] Zone is correctly received. SOA todo. --- src/App/ZoneInterface.purs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/App/ZoneInterface.purs b/src/App/ZoneInterface.purs index 4cb8564..ee1a96b 100644 --- a/src/App/ZoneInterface.purs +++ b/src/App/ZoneInterface.purs @@ -508,6 +508,7 @@ handleQuery = case _ of H.raise $ Log $ SimpleLog $ "[🎉] Got the zone!" H.raise $ Log $ SimpleLog $ "DEBUG: the zone has domain: " <> response.zone.domain H.raise $ Log $ SimpleLog $ "DEBUG: zone: " <> show_zone response.zone + add_entries response.zone.resources (DNSManager.MkSuccess _) -> do H.raise $ Log $ SimpleLog $ "[🎉] Success!" @@ -533,6 +534,19 @@ handleQuery = case _ of Just { head: x, tail: xs } -> "(" <> x.rrtype <> ": " <> show x.rrid <> ") " <> resource_list xs Nothing -> "" + add_entries [] = H.raise $ Log $ SimpleLog "Done adding entries" + add_entries arr = do + state <- H.get + case A.head arr, A.tail arr of + Nothing, _ -> H.raise $ Log $ SimpleLog "Done adding entries (but why this didn't performed pattern matching??)" + Just new_rr, tail -> case add_entry state new_rr of + Left error_message -> do + H.raise $ Log $ SimpleLog $ "Error while adding new entry: " <> error_message + add_entries $ fromMaybe [] tail + Right new_state -> do + H.put new_state + add_entries $ fromMaybe [] tail + add_entry :: State -> ResourceRecord -> Either String State add_entry state new_rr = do case new_rr.rrtype, (A.elem new_rr.rrtype baseRecords) of