summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2018-12-01 15:43:15 -0500
committerJoe Crayne <joe@jerkface.net>2018-12-16 14:08:26 -0500
commite9262f232d5acdd5ad2eda29cf805618dccbac28 (patch)
tree3f1a18b2c78ef8a204db2b665810fb169f70a920 /examples
parent86e1e877396297d85bc6c3cdcd6df870074940ed (diff)
Fallback bind-addresses for Tox UDP.
Diffstat (limited to 'examples')
-rw-r--r--examples/dhtd.hs17
1 files changed, 10 insertions, 7 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index 6756b14b..04b8c064 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -1055,7 +1055,7 @@ readExternals nodeAddr vars = do
1055 1055
1056data Options = Options 1056data Options = Options
1057 { portbt :: String 1057 { portbt :: String
1058 , porttox :: String 1058 , porttox :: [String]
1059 , portxmpp :: String -- client-to-server 1059 , portxmpp :: String -- client-to-server
1060 , portxmppS :: String -- server-to-server 1060 , portxmppS :: String -- server-to-server
1061 , ip6bt :: Bool 1061 , ip6bt :: Bool
@@ -1076,7 +1076,7 @@ data Options = Options
1076sensibleDefaults :: Options 1076sensibleDefaults :: Options
1077sensibleDefaults = Options 1077sensibleDefaults = Options
1078 { portbt = "6881" 1078 { portbt = "6881"
1079 , porttox = "33445" 1079 , porttox = ["33445"]
1080 , portxmpp = "5222" 1080 , portxmpp = "5222"
1081 , portxmppS = "5269" 1081 , portxmppS = "5269"
1082 , ip6bt = True 1082 , ip6bt = True
@@ -1107,10 +1107,13 @@ parseArgs ("-v":tags:args) opts = parseArgs args opts
1107 } 1107 }
1108parseArgs (arg:args) opts = parseArgs args opts 1108parseArgs (arg:args) opts = parseArgs args opts
1109 { portbt = fromMaybe (portbt opts) $ Prelude.lookup "bt" ports 1109 { portbt = fromMaybe (portbt opts) $ Prelude.lookup "bt" ports
1110 , porttox = fromMaybe (porttox opts) $ Prelude.lookup "tox" ports 1110 , porttox = fromMaybe (porttox opts) $ lookupAll "tox" ports
1111 , portxmpp = fromMaybe (portxmpp opts) $ Prelude.lookup "xmpp" ports 1111 , portxmpp = fromMaybe (portxmpp opts) $ Prelude.lookup "xmpp" ports
1112 , portxmppS = fromMaybe (portxmppS opts) $ Prelude.lookup "xmpp.s2s" ports } 1112 , portxmppS = fromMaybe (portxmppS opts) $ Prelude.lookup "xmpp.s2s" ports }
1113 where 1113 where
1114 lookupAll seeking kvs = case filter (\(k,v) -> k == seeking) kvs of
1115 [] -> Nothing
1116 xs -> Just $ map snd xs
1114 ports = map ( (dropWhile (==',') *** dropWhile (=='=')) 1117 ports = map ( (dropWhile (==',') *** dropWhile (=='='))
1115 . break (=='=') ) 1118 . break (=='=') )
1116 $ groupBy (const (/= ',')) arg 1119 $ groupBy (const (/= ',')) arg
@@ -1298,17 +1301,17 @@ initTox :: Options
1298 , IO [SockAddr] 1301 , IO [SockAddr]
1299 , [SockAddr]) 1302 , [SockAddr])
1300initTox opts ssvar keysdb mbxmpp invc = case porttox opts of 1303initTox opts ssvar keysdb mbxmpp invc = case porttox opts of
1301 "" -> return (Nothing,return (), Map.empty, return [],[]) 1304 [""] -> return (Nothing,return (), Map.empty, return [],[])
1302 toxport -> do 1305 toxport -> do
1303 addrTox <- getBindAddress toxport (ip6tox opts)
1304 dput XMisc $ "Supplied key: " ++ show (fmap (Tox.key2id . toPublic) (dhtkey opts)) 1306 dput XMisc $ "Supplied key: " ++ show (fmap (Tox.key2id . toPublic) (dhtkey opts))
1305 tox <- Tox.newTox keysdb 1307 tox <- Tox.newTox keysdb
1306 addrTox 1308 toxport
1307 (case mbxmpp of 1309 (case mbxmpp of
1308 Nothing -> \_ _ _ -> return () 1310 Nothing -> \_ _ _ -> return ()
1309 Just xmpp -> onNewToxSession xmpp ssvar invc) 1311 Just xmpp -> onNewToxSession xmpp ssvar invc)
1310 (dhtkey opts) 1312 (dhtkey opts)
1311 (\_ _ -> return ()) -- TODO: TCP relay send 1313 (\_ _ -> return ()) -- TODO: TCP relay send
1314 -- addrTox <- getBindAddress toxport (ip6tox opts)
1312 (quitTox, toxStrap4, toxStrap6) <- Tox.forkTox tox True 1315 (quitTox, toxStrap4, toxStrap6) <- Tox.forkTox tox True
1313 1316
1314 toxSearches <- atomically $ newTVar Map.empty 1317 toxSearches <- atomically $ newTVar Map.empty
@@ -1491,7 +1494,7 @@ initTox opts ssvar keysdb mbxmpp invc = case porttox opts of
1491 ips :: IO [SockAddr] 1494 ips :: IO [SockAddr]
1492 ips = readExternals Tox.nodeAddr [ Tox.routing4 $ Tox.toxRouting tox 1495 ips = readExternals Tox.nodeAddr [ Tox.routing4 $ Tox.toxRouting tox
1493 , Tox.routing6 $ Tox.toxRouting tox ] 1496 , Tox.routing6 $ Tox.toxRouting tox ]
1494 return (Just tox, quitTox, dhts, ips, [addrTox]) 1497 return (Just tox, quitTox, dhts, ips, [Tox.toxBindAddress tox])
1495 1498
1496initJabber :: Options 1499initJabber :: Options
1497 -> TVar (Map.Map Uniq24 AggregateSession) 1500 -> TVar (Map.Map Uniq24 AggregateSession)