summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-11-27 22:20:39 -0500
committerJoe Crayne <joe@jerkface.net>2020-01-01 22:50:28 -0500
commit978eecfe2854ce093a5e93e1cb7fbde3677173aa (patch)
treede26802bfa0ce2d126494b88e316fa8060651e14
parenta39e744dd2c6895cc287cf43ed4704252dcf8293 (diff)
Show instance for RouteRecord and OnionRoute.
-rw-r--r--dht/OnionRouter.hs7
-rw-r--r--dht/src/Data/Tox/Onion.hs1
-rw-r--r--dht/src/Network/QueryResponse/TCP.hs5
3 files changed, 10 insertions, 3 deletions
diff --git a/dht/OnionRouter.hs b/dht/OnionRouter.hs
index cb74f6db..1c16db6d 100644
--- a/dht/OnionRouter.hs
+++ b/dht/OnionRouter.hs
@@ -108,6 +108,7 @@ data RouteRecord = RouteRecord
108 , routeVersion :: !Int 108 , routeVersion :: !Int
109 , routeBirthTime :: !POSIXTime 109 , routeBirthTime :: !POSIXTime
110 } 110 }
111 deriving Show
111 112
112-- Onion paths have different timeouts depending on whether the path is 113-- Onion paths have different timeouts depending on whether the path is
113-- confirmed or unconfirmed. Unconfirmed paths (paths that core has never 114-- confirmed or unconfirmed. Unconfirmed paths (paths that core has never
@@ -371,7 +372,7 @@ selectTrampolines or = do
371 tset f = bool (left Right . right Right <$> f (trampolinesUDP or)) 372 tset f = bool (left Right . right Right <$> f (trampolinesUDP or))
372 (left Left . right Left <$> f (trampolinesTCP or)) 373 (left Left . right Left <$> f (trampolinesTCP or))
373 =<< readTVar (tcpMode or) 374 =<< readTVar (tcpMode or)
374 atomically (tset $ selectTrampolines' (onionDRG or)) >>= \case 375 atomically (tset $ internalSelectTrampolines (onionDRG or)) >>= \case
375 Left ns -> do 376 Left ns -> do
376 -- atomically $ writeTChan (routeLog or) 377 -- atomically $ writeTChan (routeLog or)
377 routeLogger or $ unwords 378 routeLogger or $ unwords
@@ -426,8 +427,8 @@ choose3 drg0 cnt = ([a,b,c], drg)
426-- 427--
427-- The only write this function does to STM state is that the onionDRG random 428-- The only write this function does to STM state is that the onionDRG random
428-- seed will be updated. 429-- seed will be updated.
429selectTrampolines' :: TVar ChaChaDRG -> TrampolineSet ni -> STM (Either [ni] [ni]) 430internalSelectTrampolines :: TVar ChaChaDRG -> TrampolineSet ni -> STM (Either [ni] [ni])
430selectTrampolines' setDRG TrampolineSet{..} = do 431internalSelectTrampolines setDRG TrampolineSet{..} = do
431 cnt <- readTVar setCount 432 cnt <- readTVar setCount
432 ts <- readTVar setNodes 433 ts <- readTVar setNodes
433 drg0 <- readTVar setDRG 434 drg0 <- readTVar setDRG
diff --git a/dht/src/Data/Tox/Onion.hs b/dht/src/Data/Tox/Onion.hs
index bd802c75..0338111b 100644
--- a/dht/src/Data/Tox/Onion.hs
+++ b/dht/src/Data/Tox/Onion.hs
@@ -848,6 +848,7 @@ data OnionRoute = OnionRoute
848 , routeNodeC :: NodeInfo 848 , routeNodeC :: NodeInfo
849 , routeRelayPort :: Maybe PortNumber 849 , routeRelayPort :: Maybe PortNumber
850 } 850 }
851 deriving Show
851 852
852 853
853wrapOnion :: Serialize (Forwarding n msg) => 854wrapOnion :: Serialize (Forwarding n msg) =>
diff --git a/dht/src/Network/QueryResponse/TCP.hs b/dht/src/Network/QueryResponse/TCP.hs
index e4831fb2..fdca86b4 100644
--- a/dht/src/Network/QueryResponse/TCP.hs
+++ b/dht/src/Network/QueryResponse/TCP.hs
@@ -175,6 +175,11 @@ closeAll tcpcache stream = do
175 case r of TCPSession{tcpState=st,tcpHandle=h} -> streamGoodbye st >> hClose h 175 case r of TCPSession{tcpState=st,tcpHandle=h} -> streamGoodbye st >> hClose h
176 _ -> return () 176 _ -> return ()
177 177
178-- Use a cache of TCP client connections for sending (and receiving) packets.
179-- The boolean value prepended to the message allows the sender to specify
180-- whether or not a new connection will be initiated if neccessary. If 'False'
181-- is passed, then the packet will be sent only if there already exists a
182-- connection.
178tcpTransport :: Int -- ^ maximum number of TCP links to maintain. 183tcpTransport :: Int -- ^ maximum number of TCP links to maintain.
179 -> StreamHandshake addr x y 184 -> StreamHandshake addr x y
180 -> IO (TCPCache (SessionProtocol x y), TransportA err addr x (Bool,y)) 185 -> IO (TCPCache (SessionProtocol x y), TransportA err addr x (Bool,y))