From: Eugene Crosser Date: Thu, 3 Apr 2014 14:03:09 +0000 (+0400) Subject: hack to handle ip-only value for the domain X-Git-Tag: 0.9.0.0~97 X-Git-Url: http://www.average.org/gitweb/?p=pdns-pipe-nmc.git;a=commitdiff_plain;h=5f1986b7cb4f20796429433b03205f750a611271 hack to handle ip-only value for the domain --- diff --git a/NmcJson.hs b/NmcJson.hs index c92e363..14a2f63 100644 --- a/NmcJson.hs +++ b/NmcJson.hs @@ -7,6 +7,7 @@ module NmcJson ( NmcRes(..) ) where import Data.ByteString.Lazy (ByteString) +import Data.Text as T (unpack) import Data.Map as M (Map, lookup) import Control.Applicative ((<$>), (<*>), empty) import Data.Aeson @@ -65,6 +66,9 @@ data NmcDom = NmcDom { domService :: Maybe [[String]] -- [NmcRRService] } deriving (Show, Eq) instance FromJSON NmcDom where + -- Some just put the IP address in the value, especially in the map. + -- As an ugly hack, try to interpret string as IP (v4) address. + parseJSON (String s) = return emptyNmcDom { domIp = Just [T.unpack s] } parseJSON (Object o) = NmcDom <$> o .:? "service" <*> o .:? "ip"