summaryrefslogtreecommitdiff
path: root/OnionRouter.hs
diff options
context:
space:
mode:
Diffstat (limited to 'OnionRouter.hs')
-rw-r--r--OnionRouter.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/OnionRouter.hs b/OnionRouter.hs
index 55a08d48..57c8ba35 100644
--- a/OnionRouter.hs
+++ b/OnionRouter.hs
@@ -155,8 +155,8 @@ newOnionRouter :: TransportCrypto
155 -> (String -> IO ()) 155 -> (String -> IO ())
156 -> IO ( OnionRouter 156 -> IO ( OnionRouter
157 , TVar ( ChaChaDRG 157 , TVar ( ChaChaDRG
158 , Word64Map (Either (MVar (Bool,TCP.RelayPacket)) 158 , Word64Map (Either (Maybe (Bool,TCP.RelayPacket) -> IO ())
159 (MVar (OnionMessage Identity))))) 159 (Maybe (OnionMessage Identity) -> IO ()))))
160newOnionRouter crypto perror = do 160newOnionRouter crypto perror = do
161 drg0 <- drgNew 161 drg0 <- drgNew
162 (rlog,pq,rm) <- atomically $ do 162 (rlog,pq,rm) <- atomically $ do
@@ -166,7 +166,7 @@ newOnionRouter crypto perror = do
166 return (rlog,pq,rm) 166 return (rlog,pq,rm)
167 ((tbl,(tcptbl,tcpcons)),tcp) <- do 167 ((tbl,(tcptbl,tcpcons)),tcp) <- do
168 (tcptbl, client) <- TCP.newClient crypto Left $ \case 168 (tcptbl, client) <- TCP.newClient crypto Left $ \case
169 Left v -> void . tryPutMVar v . (,) False 169 Left v -> void . v . Just . (,) False
170 Right v -> \case 170 Right v -> \case
171 TCP.OnionPacketResponse x@(OnionAnnounceResponse n8 n24 _) -> do 171 TCP.OnionPacketResponse x@(OnionAnnounceResponse n8 n24 _) -> do
172 mod <- lookupSender' pq rlog localhost4 n8 172 mod <- lookupSender' pq rlog localhost4 n8
@@ -181,7 +181,7 @@ newOnionRouter crypto perror = do
181 atomically $ do 181 atomically $ do
182 modifyTVar' pq (W64.delete w8) 182 modifyTVar' pq (W64.delete w8)
183 modifyArray rm (fmap gotResponse) rid 183 modifyArray rm (fmap gotResponse) rid
184 void $ tryPutMVar v y 184 void $ v $ Just y
185 _ -> return () 185 _ -> return ()
186 x -> perror $ "Unexpected TCP query result: " ++ show x 186 x -> perror $ "Unexpected TCP query result: " ++ show x
187 187
@@ -578,7 +578,7 @@ hookQueries :: OnionRouter -> (tid -> Nonce8)
578 -> TransactionMethods d tid (OnionDestination RouteId) x 578 -> TransactionMethods d tid (OnionDestination RouteId) x
579 -> TransactionMethods d tid (OnionDestination RouteId) x 579 -> TransactionMethods d tid (OnionDestination RouteId) x
580hookQueries or t8 tmethods = TransactionMethods 580hookQueries or t8 tmethods = TransactionMethods
581 { dispatchRegister = \mvar od d -> {-# SCC "hookQ.dispatchRegister" #-} do -- :: MVar x -> d -> STM (tid, d) 581 { dispatchRegister = \getTimeout now mvar od d -> {-# SCC "hookQ.dispatchRegister" #-} do -- :: MVar x -> d -> STM (tid, d)
582 let ni = onionNodeInfo od 582 let ni = onionNodeInfo od
583 rid@(RouteId ridn) = fromMaybe (routeId (nodeId ni)) $ onionRouteSpec od 583 rid@(RouteId ridn) = fromMaybe (routeId (nodeId ni)) $ onionRouteSpec od
584 wanted <- {-# SCC "hookQ.wanted" #-} (readArray (pendingRoutes or) ridn) 584 wanted <- {-# SCC "hookQ.wanted" #-} (readArray (pendingRoutes or) ridn)
@@ -587,7 +587,7 @@ hookQueries or t8 tmethods = TransactionMethods
587 check $ fromMaybe False $ do 587 check $ fromMaybe False $ do
588 RouteRecord{routeVersion=rv} <- {-# SCC "hookQ.mr" #-} mr 588 RouteRecord{routeVersion=rv} <- {-# SCC "hookQ.mr" #-} mr
589 return $ wanted <= rv 589 return $ wanted <= rv
590 (tid,d') <- dispatchRegister tmethods mvar od d 590 ((tid,a,expiry),d') <- dispatchRegister tmethods getTimeout now mvar od d
591 let Nonce8 w8 = t8 tid 591 let Nonce8 w8 = t8 tid
592 od' = case od of 592 od' = case od of
593 OnionDestination {} -> od { onionRouteSpec = Just rid } 593 OnionDestination {} -> od { onionRouteSpec = Just rid }
@@ -599,7 +599,7 @@ hookQueries or t8 tmethods = TransactionMethods
599 -- check $ W64.size pqs < 20 599 -- check $ W64.size pqs < 20
600 modifyTVar' (pendingQueries or) (W64.insert w8 pq) 600 modifyTVar' (pendingQueries or) (W64.insert w8 pq)
601 writeTChan (routeLog or) $ "ONION query add " ++ unwords [ show (Just $ pendingVersion pq,w8), ":=", show ni ] 601 writeTChan (routeLog or) $ "ONION query add " ++ unwords [ show (Just $ pendingVersion pq,w8), ":=", show ni ]
602 return (tid,d') 602 return ((tid,a,expiry),d')
603 , dispatchResponse = \tid x d -> {-# SCC "hookQ.dispatchResponse" #-} do -- :: tid -> x -> d -> STM (d, IO ()) 603 , dispatchResponse = \tid x d -> {-# SCC "hookQ.dispatchResponse" #-} do -- :: tid -> x -> d -> STM (d, IO ())
604 let Nonce8 w8 = t8 tid 604 let Nonce8 w8 = t8 tid
605 mb <- W64.lookup w8 <$> readTVar (pendingQueries or) 605 mb <- W64.lookup w8 <$> readTVar (pendingQueries or)