diff options
Diffstat (limited to 'src/Network/Tox/Transport.hs')
-rw-r--r-- | src/Network/Tox/Transport.hs | 22 |
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 | ||
11 | import Network.QueryResponse | 11 | import Network.QueryResponse |
12 | import Crypto.Tox | 12 | import Crypto.Tox |
13 | import Network.Tox.DHT.Transport | 13 | import Data.Tox.Relay as TCP |
14 | import Network.Tox.DHT.Transport as UDP | ||
14 | import Network.Tox.Onion.Transport | 15 | import Network.Tox.Onion.Transport |
15 | import Network.Tox.Crypto.Transport | 16 | import Network.Tox.Crypto.Transport |
16 | import OnionRouter | 17 | import OnionRouter |
@@ -20,20 +21,23 @@ import Network.Socket | |||
20 | toxTransport :: | 21 | toxTransport :: |
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)) |
31 | toxTransport crypto orouter closeLookup udp tcp = do | 33 | toxTransport 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 |