X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fharbl.git;a=blobdiff_plain;f=harbl-cli%2Fsrc%2FConfiguration.hs;h=c3c55f0489189ab9ef2c2d201c0b7a9d556aa8eb;hp=64adc7e6a7bb330b396cf0603b3381f61e49edca;hb=98b9d8768fe78d9948151e499ec52f7f616bd6e9;hpb=b55e5db2a68be5d69b970bbe4b5ad447881abd3d diff --git a/harbl-cli/src/Configuration.hs b/harbl-cli/src/Configuration.hs index 64adc7e..c3c55f0 100644 --- a/harbl-cli/src/Configuration.hs +++ b/harbl-cli/src/Configuration.hs @@ -7,10 +7,17 @@ module Configuration ( merge_optional ) where +-- System imports. import System.Console.CmdArgs.Default ( Default(..) ) +-- Harbl library imports. +import Network.DNS.RBL.Weight ( Weight ) + +-- Local imports. import qualified OptionalConfiguration as OC ( - OptionalConfiguration(..) ) + OptionalConfiguration(..), + merge_maybe, + merge_monoid ) import Hosts ( Hosts(..) ) import Lists ( Lists(..) ) @@ -21,7 +28,8 @@ import Lists ( Lists(..) ) data Configuration = Configuration { hosts :: Hosts, - lists :: Lists } + lists :: Lists, + threshold :: Weight } deriving (Show) @@ -29,7 +37,9 @@ data Configuration = -- values. -- instance Default Configuration where - def = Configuration { hosts = def, lists = def } + def = Configuration { hosts = def, + lists = def, + threshold = def } -- | Merge a 'Configuration' with an 'OptionalConfiguration'. This is @@ -39,10 +49,8 @@ instance Default Configuration where merge_optional :: Configuration -> OC.OptionalConfiguration -> Configuration -merge_optional cfg opt_cfg = - Configuration all_hosts all_lists +merge_optional cfg opt_cfg = Configuration hs ls t where - all_hosts = - Hosts $ (get_hosts $ hosts cfg) ++ (get_hosts $ OC.hosts opt_cfg) - all_lists = - Lists $ (get_lists $ lists cfg) ++ (get_lists $ OC.lists opt_cfg) + hs = OC.merge_monoid (hosts cfg) (OC.hosts opt_cfg) + ls = OC.merge_monoid (lists cfg) (OC.lists opt_cfg) + t = OC.merge_maybe (threshold cfg) (OC.threshold opt_cfg)