summaryrefslogtreecommitdiff
path: root/examples/dhtd.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-09-16 20:35:32 -0400
committerjoe <joe@jerkface.net>2017-09-16 20:35:32 -0400
commitd034fd6bee01a1bf1e9080d16f4fd230887a792b (patch)
tree691bf843b8b9dc58cc9b2b626aaf0a47a552a568 /examples/dhtd.hs
parentbc0b119f7ec7ef7aa2d4faa9879633a7926bd2a6 (diff)
UPNP port requests (requires miniupnpc).
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r--examples/dhtd.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index 6c655458..32fb8060 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -45,6 +45,7 @@ import Control.Concurrent.Lifted
45import GHC.Conc (labelThread) 45import GHC.Conc (labelThread)
46#endif 46#endif
47 47
48import Network.UPNP as UPNP
48import Network.Address hiding (NodeId, NodeInfo(..)) 49import Network.Address hiding (NodeId, NodeInfo(..))
49import Network.Kademlia.Search 50import Network.Kademlia.Search
50import Network.QueryResponse 51import Network.QueryResponse
@@ -524,8 +525,8 @@ main = do
524 (atomically . writeTVar (Mainline.contactInfo swarms)) 525 (atomically . writeTVar (Mainline.contactInfo swarms))
525 (peerdb >>= S.decodeLazy) 526 (peerdb >>= S.decodeLazy)
526 527
527 (quitBt,btdhts,btips) <- case portbt opts of 528 (quitBt,btdhts,btips,baddrs) <- case portbt opts of
528 "" -> return (return (), Map.empty,return []) 529 "" -> return (return (), Map.empty,return [],[])
529 p -> do 530 p -> do
530 addr <- getBindAddress p (ip6bt opts) 531 addr <- getBindAddress p (ip6bt opts)
531 (bt,btR) <- Mainline.newClient swarms addr 532 (bt,btR) <- Mainline.newClient swarms addr
@@ -563,12 +564,12 @@ main = do
563 [ Mainline.routing4 btR 564 [ Mainline.routing4 btR
564 , Mainline.routing6 btR 565 , Mainline.routing6 btR
565 ] 566 ]
566 return (quitBt,dhts,ips) 567 return (quitBt,dhts,ips, [addr])
567 568
568 keysdb <- Tox.newKeysDatabase 569 keysdb <- Tox.newKeysDatabase
569 570
570 (quitTox,toxdhts,toxips) <- case porttox opts of 571 (quitTox,toxdhts,toxips,taddrs) <- case porttox opts of
571 "" -> return (return (), Map.empty, return []) 572 "" -> return (return (), Map.empty, return [],[])
572 toxport -> do 573 toxport -> do
573 addrTox <- getBindAddress toxport (ip6tox opts) 574 addrTox <- getBindAddress toxport (ip6tox opts)
574 tox <- Tox.newTox keysdb addrTox 575 tox <- Tox.newTox keysdb addrTox
@@ -599,7 +600,9 @@ main = do
599 ips :: IO [SockAddr] 600 ips :: IO [SockAddr]
600 ips = readExternals Tox.nodeAddr [ Tox.routing4 $ Tox.toxRouting tox 601 ips = readExternals Tox.nodeAddr [ Tox.routing4 $ Tox.toxRouting tox
601 , Tox.routing6 $ Tox.toxRouting tox ] 602 , Tox.routing6 $ Tox.toxRouting tox ]
602 return (quitTox, dhts, ips) 603 return (quitTox, dhts, ips, [addrTox])
604
605 _ <- UPNP.requestPorts "dht-client" $ map (Datagram,) $ baddrs ++ taddrs
603 606
604 let dhts = Map.union btdhts toxdhts 607 let dhts = Map.union btdhts toxdhts
605 608