summaryrefslogtreecommitdiff
path: root/examples/dhtd.hs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r--examples/dhtd.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index 3f7a7261..c06b69d1 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -801,7 +801,7 @@ clientSession s@Session{..} sock cnum h = do
801 (qresultAddr dta) 801 (qresultAddr dta)
802 announceInterval) 802 announceInterval)
803 dta 803 dta
804 hPutClient h "ok." 804 hPutClient h $ "Announcing at " ++ show (qresultAddr dta) ++ "."
805 let aerror = unlines 805 let aerror = unlines
806 [ "announce error." 806 [ "announce error."
807 , "method = " ++ method 807 , "method = " ++ method
@@ -955,6 +955,7 @@ data Options = Options
955 , porttox :: String 955 , porttox :: String
956 , ip6bt :: Bool 956 , ip6bt :: Bool
957 , ip6tox :: Bool 957 , ip6tox :: Bool
958 , dhtkey :: Maybe SecretKey
958 } 959 }
959 deriving (Eq,Show) 960 deriving (Eq,Show)
960 961
@@ -964,16 +965,18 @@ sensibleDefaults = Options
964 , porttox = "33445" 965 , porttox = "33445"
965 , ip6bt = True 966 , ip6bt = True
966 , ip6tox = True 967 , ip6tox = True
968 , dhtkey = Nothing
967 } 969 }
968 970
969-- bt=<port>,tox=<port> 971-- bt=<port>,tox=<port>
970-- -4 972-- -4
971parseArgs :: [String] -> Options -> Options 973parseArgs :: [String] -> Options -> Options
972parseArgs [] opts = opts 974parseArgs [] opts = opts
973parseArgs ("-4":args) opts = parseArgs args opts 975parseArgs ("--dhtkey":k:args) opts = opts { dhtkey = decodeSecret $ B.pack k }
976parseArgs ("-4":args) opts = parseArgs args opts
974 { ip6bt = False 977 { ip6bt = False
975 , ip6tox = False } 978 , ip6tox = False }
976parseArgs (arg:args) opts = parseArgs args opts 979parseArgs (arg:args) opts = parseArgs args opts
977 { portbt = fromMaybe (portbt opts) $ Prelude.lookup "bt" ports 980 { portbt = fromMaybe (portbt opts) $ Prelude.lookup "bt" ports
978 , porttox = fromMaybe (porttox opts) $ Prelude.lookup "tox" ports } 981 , porttox = fromMaybe (porttox opts) $ Prelude.lookup "tox" ports }
979 where 982 where
@@ -1096,7 +1099,7 @@ main = do
1096 "" -> return (Nothing,return (), Map.empty, return [],[]) 1099 "" -> return (Nothing,return (), Map.empty, return [],[])
1097 toxport -> do 1100 toxport -> do
1098 addrTox <- getBindAddress toxport (ip6tox opts) 1101 addrTox <- getBindAddress toxport (ip6tox opts)
1099 tox <- Tox.newTox keysdb addrTox (Just netCryptoSessionsState) 1102 tox <- Tox.newTox keysdb addrTox (Just netCryptoSessionsState) (dhtkey opts)
1100 quitTox <- Tox.forkTox tox 1103 quitTox <- Tox.forkTox tox
1101 1104
1102 toxSearches <- atomically $ newTVar Map.empty 1105 toxSearches <- atomically $ newTVar Map.empty