summaryrefslogtreecommitdiff
path: root/OnionRouter.hs
diff options
context:
space:
mode:
Diffstat (limited to 'OnionRouter.hs')
-rw-r--r--OnionRouter.hs24
1 files changed, 14 insertions, 10 deletions
diff --git a/OnionRouter.hs b/OnionRouter.hs
index 7a48aaab..40112e6a 100644
--- a/OnionRouter.hs
+++ b/OnionRouter.hs
@@ -33,21 +33,21 @@ newtype RouteId = RouteId Int
33 deriving Show 33 deriving Show
34 34
35data OnionRouter = OnionRouter 35data OnionRouter = OnionRouter
36 { pendingQueries :: TVar (Word64Map NodeId) 36 { pendingQueries :: TVar (Word64Map NodeId) -- TODO: routeNonce belongs here instead of in routeMap, or just remove routeNonce and use transaction nonce.
37 , routeMap :: TVar (IntMap RouteRecord) 37 , routeMap :: TVar (IntMap RouteRecord)
38 , trampolineNodes :: TVar (IntMap NodeInfo) 38 , trampolineNodes :: TVar (IntMap NodeInfo)
39 , trampolineIds :: TVar (HashMap NodeId Int) 39 , trampolineIds :: TVar (HashMap NodeId Int)
40 , trampolineCount :: TVar Int 40 , trampolineCount :: TVar Int
41 , onionDRG :: TVar ChaChaDRG 41 , onionDRG :: TVar ChaChaDRG
42 , routeThread :: ThreadId 42 , routeThread :: ThreadId
43 , pendingRoutes :: IntMap (TVar Bool) 43 , pendingRoutes :: IntMap (TVar Bool)
44 , routeLog :: TChan String 44 , routeLog :: TChan String
45 } 45 }
46 46
47data RouteRecord = RouteRecord 47data RouteRecord = RouteRecord
48 { storedRoute :: OnionRoute 48 { storedRoute :: OnionRoute
49 , responseCount :: Int 49 , responseCount :: !Int
50 , timeoutCount :: Int 50 , timeoutCount :: !Int
51 } 51 }
52 52
53-- Onion paths have different timeouts depending on whether the path is 53-- Onion paths have different timeouts depending on whether the path is
@@ -230,7 +230,8 @@ handleEvent getnodes or e@(BuildRoute (RouteId rid)) = do
230 [ "ONION trampolines: " ++ show ts 230 [ "ONION trampolines: " ++ show ts
231 , "ONION query results: " ++ show nodes ] 231 , "ONION query results: " ++ show nodes ]
232 case nodes of 232 case nodes of
233 [a,b,c] -> do -- | distinct3by nodeClass a b c -> do 233 [a,b,c] | distinct3by nodeClass a b c -> do
234 atomically $ writeTChan (routeLog or) $ unwords [ "ONION using route:", show $ nodeAddr a, show $ nodeAddr b, show $ nodeAddr c]
234 return $ Just OnionRoute 235 return $ Just OnionRoute
235 { routeNonce = n24 236 { routeNonce = n24
236 , routeAliasA = asec 237 , routeAliasA = asec
@@ -240,6 +241,9 @@ handleEvent getnodes or e@(BuildRoute (RouteId rid)) = do
240 , routeNodeB = b 241 , routeNodeB = b
241 , routeNodeC = c 242 , routeNodeC = c
242 } 243 }
244 [a,b,c] -> do
245 atomically $ writeTChan (routeLog or) $ unwords [ "ONION Discarding insecure route:", show $ nodeAddr a, show $ nodeAddr b, show $ nodeAddr c]
246 return Nothing
243 _ -> return Nothing 247 _ -> return Nothing
244 writeTVar (onionDRG or) drg' 248 writeTVar (onionDRG or) drg'
245 return $ getr 249 return $ getr