summaryrefslogtreecommitdiff
path: root/Connection
diff options
context:
space:
mode:
Diffstat (limited to 'Connection')
-rw-r--r--Connection/Tcp.hs13
-rw-r--r--Connection/Tox.hs9
-rw-r--r--Connection/Tox/Threads.hs7
3 files changed, 16 insertions, 13 deletions
diff --git a/Connection/Tcp.hs b/Connection/Tcp.hs
index 2c2c8d76..9a44f34f 100644
--- a/Connection/Tcp.hs
+++ b/Connection/Tcp.hs
@@ -80,6 +80,7 @@ import Network.StreamServer
80import Network.SocketLike hiding (sClose) 80import Network.SocketLike hiding (sClose)
81import qualified Connection as G 81import qualified Connection as G
82 ;import Connection (Manager (..), Policy(..)) 82 ;import Connection (Manager (..), Policy(..))
83import DPut
83 84
84 85
85type Microseconds = Int 86type Microseconds = Int
@@ -298,10 +299,10 @@ server allocate sessionConduits = do
298 `fmap` atomically (readTVar $ listenmap server) 299 `fmap` atomically (readTVar $ listenmap server)
299 when (not listening) $ do 300 when (not listening) $ do
300 301
301 hPutStrLn stderr $ "Started listening on "++show port 302 dput XMisc $ "Started listening on "++show port
302 303
303 sserv <- flip streamServer port ServerConfig 304 sserv <- flip streamServer port ServerConfig
304 { serverWarn = hPutStrLn stderr 305 { serverWarn = dput XMisc
305 , serverSession = \sock _ h -> do 306 , serverSession = \sock _ h -> do
306 (conkey,u) <- makeConnKey params sock 307 (conkey,u) <- makeConnKey params sock
307 _ <- newConnection server sessionConduits params conkey u h In 308 _ <- newConnection server sessionConduits params conkey u h In
@@ -311,7 +312,7 @@ server allocate sessionConduits = do
311 atomically $ listenmap server `modifyTVar'` Map.insert port sserv 312 atomically $ listenmap server `modifyTVar'` Map.insert port sserv
312 313
313 doit server (Ignore port) = do 314 doit server (Ignore port) = do
314 hPutStrLn stderr $ "Stopping listen on "++show port 315 dput XMisc $ "Stopping listen on "++show port
315 mb <- atomically $ do 316 mb <- atomically $ do
316 map <- readTVar $ listenmap server 317 map <- readTVar $ listenmap server
317 modifyTVar' (listenmap server) $ Map.delete port 318 modifyTVar' (listenmap server) $ Map.delete port
@@ -758,7 +759,7 @@ bshow :: Show a => a -> ByteString
758bshow e = S.pack . show $ e 759bshow e = S.pack . show $ e
759 760
760warn :: ByteString -> IO () 761warn :: ByteString -> IO ()
761warn str = S.hPutStrLn stderr str >> hFlush stderr 762warn str =dputB XMisc str >> hFlush stderr
762 763
763debugNoise :: Monad m => t -> m () 764debugNoise :: Monad m => t -> m ()
764debugNoise str = return () 765debugNoise str = return ()
@@ -790,8 +791,8 @@ tcpManager grokKey s2k resolvKey sv = do
790 Just conkey -> do 791 Just conkey -> do
791 control sv $ case grokKey conkey of 792 control sv $ case grokKey conkey of
792 (saddr,params,ms) -> ConnectWithEndlessRetry saddr params ms 793 (saddr,params,ms) -> ConnectWithEndlessRetry saddr params ms
793 OpenToConnect -> hPutStrLn stderr "TODO: TCP OpenToConnect" 794 OpenToConnect -> dput XMisc "TODO: TCP OpenToConnect"
794 RefusingToConnect -> hPutStrLn stderr "TODO: TCP RefusingToConnect" 795 RefusingToConnect -> dput XMisc "TODO: TCP RefusingToConnect"
795 , connections = do 796 , connections = do
796 c <- readTVar $ conmap sv 797 c <- readTVar $ conmap sv
797 fmap (exportConnection nullping c) <$> readTVar rmap 798 fmap (exportConnection nullping c) <$> readTVar rmap
diff --git a/Connection/Tox.hs b/Connection/Tox.hs
index 03ffbc25..1cbbdaee 100644
--- a/Connection/Tox.hs
+++ b/Connection/Tox.hs
@@ -31,6 +31,7 @@ import GHC.Conc (labelThread)
31#endif 31#endif
32import GHC.Conc (ThreadStatus (..), threadStatus) 32import GHC.Conc (ThreadStatus (..), threadStatus)
33import System.IO 33import System.IO
34import DPut
34 35
35 36
36 37
@@ -81,7 +82,7 @@ launch lbl st f = do
81 tid <- forkIO (f stvar) 82 tid <- forkIO (f stvar)
82 labelThread tid lbl 83 labelThread tid lbl
83 stat <- threadStatus tid 84 stat <- threadStatus tid
84 hPutStrLn stderr $ "launch "++lbl++" "++show stat 85 dput XMan $ "launch "++lbl++" "++show stat
85 return $ StatefulTask tid stvar 86 return $ StatefulTask tid stvar
86 87
87 88
@@ -142,12 +143,12 @@ setToxPolicy :: Parameters extra
142 -> Policy 143 -> Policy
143 -> IO () 144 -> IO ()
144setToxPolicy params conmap k@(Key me them) policy = do 145setToxPolicy params conmap k@(Key me them) policy = do
145 hPutStrLn stderr $ "C.setToxPolicy "++show (them,policy) 146 dput XMan $ "C.setToxPolicy "++show (them,policy)
146 case policy of 147 case policy of
147 TryingToConnect -> do 148 TryingToConnect -> do
148 mst <- lookupForPolicyChange conmap k policy 149 mst <- lookupForPolicyChange conmap k policy
149 r <- atomically $ lookupContact k (roster params) 150 r <- atomically $ lookupContact k (roster params)
150 hPutStrLn stderr $ "C.r="++show (fmap (const ()) r) 151 dput XMan $ "C.r="++show (fmap (const ()) r)
151 forM_ r $ \(sec,c) -> do 152 forM_ r $ \(sec,c) -> do
152 let persue_methods = PersueContactMethods 153 let persue_methods = PersueContactMethods
153 { allsessions = sessions params 154 { allsessions = sessions params
@@ -178,7 +179,7 @@ setToxPolicy params conmap k@(Key me them) policy = do
178 fmap (fromMaybe G.Dormant) $ forM (Map.lookup (id2key them) sbk) $ \ss -> do 179 fmap (fromMaybe G.Dormant) $ forM (Map.lookup (id2key them) sbk) $ \ss -> do
179 stats <- mapM (readTVar . ncState) ss 180 stats <- mapM (readTVar . ncState) ss
180 return $ maximum stats 181 return $ maximum stats
181 hPutStrLn stderr $ "C.mst="++show (fmap (const ()) mst) 182 dput XMan $ "C.mst="++show (fmap (const ()) mst)
182 forM_ mst $ \st -> do 183 forM_ mst $ \st -> do
183 let getPolicy = readTVar $ connPolicy st 184 let getPolicy = readTVar $ connPolicy st
184 tasks <- atomically $ readTVar (handshakeTask st) 185 tasks <- atomically $ readTVar (handshakeTask st)
diff --git a/Connection/Tox/Threads.hs b/Connection/Tox/Threads.hs
index aeeab0e1..6a7edeb4 100644
--- a/Connection/Tox/Threads.hs
+++ b/Connection/Tox/Threads.hs
@@ -41,6 +41,7 @@ import Data.Functor.Identity
41import Data.Time.Clock.POSIX 41import Data.Time.Clock.POSIX
42import System.IO 42import System.IO
43import System.Timeout 43import System.Timeout
44import DPut
44 45
45 46
46 47
@@ -146,11 +147,11 @@ persueContact getPolicy getStatus PersueContactMethods{..} statusVar = do
146 DHT.cookieRequest crypto client (toPublic myseckey) ni 147 DHT.cookieRequest crypto client (toPublic myseckey) ni
147 interval <- case mbCookie of 148 interval <- case mbCookie of
148 Nothing -> do 149 Nothing -> do
149 hPutStrLn stderr ("persueContact: (" ++ show mykeyAsId ++") <--> (" ++ show theirkeyAsId ++ ").") 150 dput XMan ("persueContact: (" ++ show mykeyAsId ++") <--> (" ++ show theirkeyAsId ++ ").")
150 hPutStrLn stderr ("persueContact: CookieRequest failed. TODO: dhtpkNodes thingy") 151 dput XMan ("persueContact: CookieRequest failed. TODO: dhtpkNodes thingy")
151 return longRetryInterval 152 return longRetryInterval
152 Just cookie -> do 153 Just cookie -> do
153 hPutStrLn stderr "Have cookie, creating handshake packet..." 154 dput XMan "Have cookie, creating handshake packet..."
154 let hp = HParam { hpOtherCookie = cookie 155 let hp = HParam { hpOtherCookie = cookie
155 , hpMySecretKey = myseckey 156 , hpMySecretKey = myseckey
156 , hpCookieRemotePubkey = theirpubkey 157 , hpCookieRemotePubkey = theirpubkey