summaryrefslogtreecommitdiff
path: root/src/Network/Tox/Transport.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/Tox/Transport.hs')
-rw-r--r--src/Network/Tox/Transport.hs22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/Network/Tox/Transport.hs b/src/Network/Tox/Transport.hs
index e79e4d8b..217d5b1d 100644
--- a/src/Network/Tox/Transport.hs
+++ b/src/Network/Tox/Transport.hs
@@ -10,7 +10,8 @@ module Network.Tox.Transport (toxTransport, RouteId) where
10 10
11import Network.QueryResponse 11import Network.QueryResponse
12import Crypto.Tox 12import Crypto.Tox
13import Network.Tox.DHT.Transport 13import Data.Tox.Relay as TCP
14import Network.Tox.DHT.Transport as UDP
14import Network.Tox.Onion.Transport 15import Network.Tox.Onion.Transport
15import Network.Tox.Crypto.Transport 16import Network.Tox.Crypto.Transport
16import OnionRouter 17import OnionRouter
@@ -20,20 +21,23 @@ import Network.Socket
20toxTransport :: 21toxTransport ::
21 TransportCrypto 22 TransportCrypto
22 -> OnionRouter 23 -> OnionRouter
23 -> (PublicKey -> IO (Maybe NodeInfo)) 24 -> (PublicKey -> IO (Maybe UDP.NodeInfo))
24 -> UDPTransport 25 -> UDPTransport
25 -> (Int -> OnionMessage Encrypted -> IO ()) -- ^ TCP-bound callback. 26 -> (TCP.NodeInfo -> RelayPacket -> IO ()) -- ^ TCP server-bound callback.
27 -> (Int -> OnionMessage Encrypted -> IO ()) -- ^ TCP client-bound callback.
26 -> IO ( Transport String SockAddr (CryptoPacket Encrypted) 28 -> IO ( Transport String SockAddr (CryptoPacket Encrypted)
27 , Transport String NodeInfo (DHTMessage Encrypted8) 29 , Transport String UDP.NodeInfo (DHTMessage Encrypted8)
28 , Transport String (OnionDestination RouteId) (OnionMessage Encrypted) 30 , Transport String (OnionDestination RouteId) (OnionMessage Encrypted)
29 , Transport String AnnouncedRendezvous (PublicKey,OnionData) 31 , Transport String AnnouncedRendezvous (PublicKey,OnionData)
30 , Transport String SockAddr (Handshake Encrypted)) 32 , Transport String SockAddr (Handshake Encrypted))
31toxTransport crypto orouter closeLookup udp tcp = do 33toxTransport crypto orouter closeLookup udp tcp2server tcp2client = do
32 (netcrypto, udp0) <- partitionTransport parseCrypto encodeCrypto udp 34 (netcrypto, udp0) <- partitionTransport parseCrypto encodeCrypto udp
33 (dht,udp1) <- partitionTransportM (parseDHTAddr crypto) (fmap Just . encodeDHTAddr) $ forwardOnions crypto udp0 tcp 35 (dht,udp1) <- partitionTransportM (parseDHTAddr crypto) (fmap Just . encodeDHTAddr)
34 (onion1,udp2) <- partitionTransportM (parseOnionAddr $ lookupSender orouter) 36 $ forwardOnions crypto udp0 tcp2client
35 (encodeOnionAddr crypto $ lookupRoute orouter) 37 (onion1,udp2) <- partitionAndForkTransport tcp2server
36 udp1 38 (parseOnionAddr $ lookupSender orouter)
39 (encodeOnionAddr crypto $ lookupRoute orouter)
40 udp1
37 (dta,onion) <- partitionTransportM (parseDataToRoute crypto) (encodeDataToRoute crypto) onion1 41 (dta,onion) <- partitionTransportM (parseDataToRoute crypto) (encodeDataToRoute crypto) onion1
38 let handshakes = layerTransport parseHandshakes encodeHandshakes udp2 42 let handshakes = layerTransport parseHandshakes encodeHandshakes udp2
39 return ( netcrypto 43 return ( netcrypto