SOA is now supported.
parent
a6e6e84cb7
commit
f883dcd27a
|
@ -39,6 +39,16 @@ type SRVRR l = RecordBase ( priority :: Priority
|
||||||
, port :: Port
|
, port :: Port
|
||||||
| l)
|
| l)
|
||||||
|
|
||||||
|
type SOARR l
|
||||||
|
= RecordBase ( mname :: String
|
||||||
|
, rname :: String
|
||||||
|
, serial :: String -- Int
|
||||||
|
, refresh :: String -- Int
|
||||||
|
, retry :: String -- Int
|
||||||
|
, expire :: String -- Int
|
||||||
|
, minttl :: String -- Int
|
||||||
|
| l)
|
||||||
|
|
||||||
--data Status
|
--data Status
|
||||||
-- = Synchronized
|
-- = Synchronized
|
||||||
-- | UnSynchronized
|
-- | UnSynchronized
|
||||||
|
|
|
@ -128,6 +128,7 @@ data Action
|
||||||
|
|
||||||
type State =
|
type State =
|
||||||
{ _current_domain :: RecordDomain
|
{ _current_domain :: RecordDomain
|
||||||
|
, _soa :: Maybe (SOARR ())
|
||||||
, _srr :: Array (SimpleRR ())
|
, _srr :: Array (SimpleRR ())
|
||||||
, _mxrr :: Array (MXRR ())
|
, _mxrr :: Array (MXRR ())
|
||||||
, _srvrr :: Array (SRVRR ())
|
, _srvrr :: Array (SRVRR ())
|
||||||
|
@ -163,6 +164,7 @@ initialState domain =
|
||||||
, active_modal: Nothing
|
, active_modal: Nothing
|
||||||
|
|
||||||
, _current_domain: domain
|
, _current_domain: domain
|
||||||
|
, _soa: Nothing
|
||||||
, _srr: []
|
, _srr: []
|
||||||
, _mxrr: []
|
, _mxrr: []
|
||||||
, _srvrr: []
|
, _srvrr: []
|
||||||
|
@ -176,9 +178,10 @@ render state
|
||||||
= Bulma.section_small
|
= Bulma.section_small
|
||||||
[ case state.wsUp, state.active_modal of
|
[ case state.wsUp, state.active_modal of
|
||||||
false, _ -> Bulma.p "You are disconnected."
|
false, _ -> Bulma.p "You are disconnected."
|
||||||
true, Just rr_id -> modal_rr_delete rr_id
|
true, Just rr_id -> modal_rr_delete rr_id
|
||||||
true, Nothing -> HH.div_ [ Bulma.h1 state._current_domain
|
true, Nothing -> HH.div_ [ Bulma.h1 state._current_domain
|
||||||
, Bulma.hr
|
, Bulma.hr
|
||||||
|
, render_soa state._soa
|
||||||
, render_records sorted
|
, render_records sorted
|
||||||
, render_mx_records state._mxrr
|
, render_mx_records state._mxrr
|
||||||
, render_srv_records state._srvrr
|
, render_srv_records state._srvrr
|
||||||
|
@ -529,12 +532,33 @@ handleQuery = case _ of
|
||||||
_, true -> Right $ add_new_entry state $ fromResourceRecordToLocalRepresentationSimpleRR new_rr
|
_, true -> Right $ add_new_entry state $ fromResourceRecordToLocalRepresentationSimpleRR new_rr
|
||||||
"MX", _ -> Right $ add_new_mx state $ fromResourceRecordToLocalRepresentationMXRR new_rr
|
"MX", _ -> Right $ add_new_mx state $ fromResourceRecordToLocalRepresentationMXRR new_rr
|
||||||
"SRV", _ -> Right $ add_new_srv state $ fromResourceRecordToLocalRepresentationSRVRR new_rr
|
"SRV", _ -> Right $ add_new_srv state $ fromResourceRecordToLocalRepresentationSRVRR new_rr
|
||||||
|
"SOA", _ -> Right $ new_soa state $ fromResourceRecordToLocalRepresentationSOARR new_rr
|
||||||
_, _ -> Left $ "TODO: cannot add '" <> new_rr.rrtype <> "' resource records at the moment."
|
_, _ -> Left $ "TODO: cannot add '" <> new_rr.rrtype <> "' resource records at the moment."
|
||||||
|
|
||||||
-- Rendering
|
-- Rendering
|
||||||
class_title_size :: Array (HH.ClassName)
|
class_title_size :: Array (HH.ClassName)
|
||||||
class_title_size = [HH.ClassName "is-4"]
|
class_title_size = [HH.ClassName "is-4"]
|
||||||
|
|
||||||
|
render_soa :: forall (w :: Type). Maybe (SOARR ()) -> HH.HTML w Action
|
||||||
|
render_soa Nothing = HH.div_ [ HH.text "SOA not loaded, yet" ]
|
||||||
|
render_soa (Just soa) = Bulma.columns [] [ left_block, right_block ]
|
||||||
|
where left_block = Bulma.column class_title_size
|
||||||
|
[ Bulma.zone_rr_title "Start Of Authority (SOA)" ]
|
||||||
|
right_block = Bulma.column_ [ Bulma.p "ALL AVAILABLE DATA"
|
||||||
|
, Bulma.p $ "rrtype: " <> soa.t
|
||||||
|
, Bulma.p $ "rrid: " <> show soa.id
|
||||||
|
, Bulma.p $ "name: " <> soa.domain
|
||||||
|
, Bulma.p $ "ttl: " <> soa.ttl
|
||||||
|
, Bulma.p $ "target: " <> soa.value
|
||||||
|
, Bulma.p $ "mname: " <> soa.mname
|
||||||
|
, Bulma.p $ "rname: " <> soa.rname
|
||||||
|
, Bulma.p $ "serial: " <> soa.serial
|
||||||
|
, Bulma.p $ "refresh: " <> soa.refresh
|
||||||
|
, Bulma.p $ "retry: " <> soa.retry
|
||||||
|
, Bulma.p $ "expire: " <> soa.expire
|
||||||
|
, Bulma.p $ "minttl: " <> soa.minttl
|
||||||
|
]
|
||||||
|
|
||||||
render_records :: forall (w :: Type). Array (SimpleRR ()) -> HH.HTML w Action
|
render_records :: forall (w :: Type). Array (SimpleRR ()) -> HH.HTML w Action
|
||||||
render_records []
|
render_records []
|
||||||
= Bulma.columns [] [ left_block, right_block ]
|
= Bulma.columns [] [ left_block, right_block ]
|
||||||
|
@ -772,6 +796,11 @@ add_new_srv state = case _ of
|
||||||
Nothing -> state
|
Nothing -> state
|
||||||
Just rr -> state { _srvrr = (state._srvrr <> [ rr ]), _current_entry_srv = defaultResourceSRV }
|
Just rr -> state { _srvrr = (state._srvrr <> [ rr ]), _current_entry_srv = defaultResourceSRV }
|
||||||
|
|
||||||
|
new_soa :: State -> Maybe (SOARR ()) -> State
|
||||||
|
new_soa state = case _ of
|
||||||
|
Nothing -> state
|
||||||
|
Just rr -> state { _soa = Just rr }
|
||||||
|
|
||||||
changeType :: forall (l :: Row Type). (SimpleRR l) -> Maybe String -> (SimpleRR l)
|
changeType :: forall (l :: Row Type). (SimpleRR l) -> Maybe String -> (SimpleRR l)
|
||||||
changeType rr Nothing = rr
|
changeType rr Nothing = rr
|
||||||
changeType rr (Just s) = rr { t = s }
|
changeType rr (Just s) = rr { t = s }
|
||||||
|
@ -860,6 +889,31 @@ fromResourceRecordToLocalRepresentationSRVRR new_rr = do
|
||||||
}
|
}
|
||||||
_, _, _ -> Nothing
|
_, _, _ -> Nothing
|
||||||
|
|
||||||
|
fromResourceRecordToLocalRepresentationSOARR :: ResourceRecord -> Maybe (SOARR ())
|
||||||
|
fromResourceRecordToLocalRepresentationSOARR new_rr = do
|
||||||
|
mname <- new_rr.mname -- :: Maybe String
|
||||||
|
rname <- new_rr.rname -- :: Maybe String
|
||||||
|
serial <- new_rr.serial -- :: Maybe Int
|
||||||
|
refresh <- new_rr.refresh -- :: Maybe Int
|
||||||
|
retry <- new_rr.retry -- :: Maybe Int
|
||||||
|
expire <- new_rr.expire -- :: Maybe Int
|
||||||
|
minttl <- new_rr.minttl -- :: Maybe Int
|
||||||
|
Just { t: new_rr.rrtype
|
||||||
|
, id: new_rr.rrid
|
||||||
|
, modified: false
|
||||||
|
, valid: true
|
||||||
|
, ttl: show new_rr.ttl
|
||||||
|
, domain: new_rr.name
|
||||||
|
, value: new_rr.target
|
||||||
|
, mname: mname -- :: RR (Maybe String) Local (String)
|
||||||
|
, rname: rname -- :: RR (Maybe String) Local (String)
|
||||||
|
, serial: show serial -- :: RR (Maybe Int) Local (String)
|
||||||
|
, refresh: show refresh -- :: RR (Maybe Int) Local (String)
|
||||||
|
, retry: show retry -- :: RR (Maybe Int) Local (String)
|
||||||
|
, expire: show expire -- :: RR (Maybe Int) Local (String)
|
||||||
|
, minttl: show minttl -- :: RR (Maybe Int) Local (String)
|
||||||
|
}
|
||||||
|
|
||||||
fromLocalSimpleRRRepresentationToResourceRecord :: SimpleRR () -> ResourceRecord
|
fromLocalSimpleRRRepresentationToResourceRecord :: SimpleRR () -> ResourceRecord
|
||||||
fromLocalSimpleRRRepresentationToResourceRecord form
|
fromLocalSimpleRRRepresentationToResourceRecord form
|
||||||
= { rrtype: form.t
|
= { rrtype: form.t
|
||||||
|
|
Loading…
Reference in New Issue