]> gitweb @ CieloNegro.org - blackboard-dns.git/blobdiff - DDNS/Zone.hs
Code cleanup
[blackboard-dns.git] / DDNS / Zone.hs
index aca51e9b4c8b7cfafe69ae90801e5d81b9a49ab4..e5d4af519a3ef2ed485f958324366f1d1a76f839 100644 (file)
@@ -1,6 +1,8 @@
 module DDNS.Zone
     ( listZones
     , completeZoneName
+
+    , getZone
     )
     where
 
@@ -39,3 +41,21 @@ completeZoneName db
             , display     = zn
             , isFinished  = True
             }
+
+getZone :: Database -> DomainName -> IO (Maybe SOAFields)
+getZone db name
+    = do rows <- query db $
+                 do t <- table Zones.zones
+                    restrict (t!Zones.zone .==. constant (show name))
+                    return t
+         case rows of
+           [r] -> return $ Just SOAFields {
+                     soaMasterNameServer   = read $ r!Zones.ns
+                   , soaResponsibleMailbox = read $ r!Zones.owner
+                   , soaSerialNumber       = fromIntegral $ r!Zones.serial
+                   , soaRefreshInterval    = fromIntegral $ r!Zones.refresh
+                   , soaRetryInterval      = fromIntegral $ r!Zones.retry
+                   , soaExpirationLimit    = fromIntegral $ r!Zones.expire
+                   , soaMinimumTTL         = fromIntegral $ r!Zones.minTTL
+                   }
+           _   -> return Nothing
\ No newline at end of file