diff options
Diffstat (limited to 'src/Network/Tox/Transport.hs')
-rw-r--r-- | src/Network/Tox/Transport.hs | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/src/Network/Tox/Transport.hs b/src/Network/Tox/Transport.hs deleted file mode 100644 index 217d5b1d..00000000 --- a/src/Network/Tox/Transport.hs +++ /dev/null | |||
@@ -1,86 +0,0 @@ | |||
1 | {-# LANGUAGE DataKinds #-} | ||
2 | {-# LANGUAGE GADTs #-} | ||
3 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
4 | {-# LANGUAGE KindSignatures #-} | ||
5 | {-# LANGUAGE LambdaCase #-} | ||
6 | {-# LANGUAGE ScopedTypeVariables #-} | ||
7 | {-# LANGUAGE TupleSections #-} | ||
8 | {-# LANGUAGE TypeOperators #-} | ||
9 | module Network.Tox.Transport (toxTransport, RouteId) where | ||
10 | |||
11 | import Network.QueryResponse | ||
12 | import Crypto.Tox | ||
13 | import Data.Tox.Relay as TCP | ||
14 | import Network.Tox.DHT.Transport as UDP | ||
15 | import Network.Tox.Onion.Transport | ||
16 | import Network.Tox.Crypto.Transport | ||
17 | import OnionRouter | ||
18 | |||
19 | import Network.Socket | ||
20 | |||
21 | toxTransport :: | ||
22 | TransportCrypto | ||
23 | -> OnionRouter | ||
24 | -> (PublicKey -> IO (Maybe UDP.NodeInfo)) | ||
25 | -> UDPTransport | ||
26 | -> (TCP.NodeInfo -> RelayPacket -> IO ()) -- ^ TCP server-bound callback. | ||
27 | -> (Int -> OnionMessage Encrypted -> IO ()) -- ^ TCP client-bound callback. | ||
28 | -> IO ( Transport String SockAddr (CryptoPacket Encrypted) | ||
29 | , Transport String UDP.NodeInfo (DHTMessage Encrypted8) | ||
30 | , Transport String (OnionDestination RouteId) (OnionMessage Encrypted) | ||
31 | , Transport String AnnouncedRendezvous (PublicKey,OnionData) | ||
32 | , Transport String SockAddr (Handshake Encrypted)) | ||
33 | toxTransport crypto orouter closeLookup udp tcp2server tcp2client = do | ||
34 | (netcrypto, udp0) <- partitionTransport parseCrypto encodeCrypto udp | ||
35 | (dht,udp1) <- partitionTransportM (parseDHTAddr crypto) (fmap Just . encodeDHTAddr) | ||
36 | $ forwardOnions crypto udp0 tcp2client | ||
37 | (onion1,udp2) <- partitionAndForkTransport tcp2server | ||
38 | (parseOnionAddr $ lookupSender orouter) | ||
39 | (encodeOnionAddr crypto $ lookupRoute orouter) | ||
40 | udp1 | ||
41 | (dta,onion) <- partitionTransportM (parseDataToRoute crypto) (encodeDataToRoute crypto) onion1 | ||
42 | let handshakes = layerTransport parseHandshakes encodeHandshakes udp2 | ||
43 | return ( netcrypto | ||
44 | , forwardDHTRequests crypto closeLookup dht | ||
45 | , onion | ||
46 | , dta | ||
47 | , handshakes | ||
48 | ) | ||
49 | |||
50 | |||
51 | -- instance (Sized a, Sized b) => Sized (a,b) where size = _todo | ||
52 | |||
53 | |||
54 | -- Byte value Packet Kind Return address | ||
55 | -- :----------- :-------------------- | ||
56 | -- `0x00` Ping Request DHTNode | ||
57 | -- `0x01` Ping Response - | ||
58 | -- `0x02` Nodes Request DHTNode | ||
59 | -- `0x04` Nodes Response - | ||
60 | -- `0x18` Cookie Request DHTNode, but without sending pubkey in response | ||
61 | -- `0x19` Cookie Response - (no pubkey) | ||
62 | -- | ||
63 | -- `0x21` LAN Discovery DHTNode (No reply, port 33445, trigger Nodes Request/Response) | ||
64 | -- | ||
65 | -- `0x20` DHT Request DHTNode/-forward | ||
66 | -- | ||
67 | -- `0x1a` Crypto Handshake CookieAddress | ||
68 | -- | ||
69 | -- `0x1b` Crypto Data SessionAddress | ||
70 | -- | ||
71 | -- `0x83` Announce Request OnionToOwner | ||
72 | -- `0x84` Announce Response - | ||
73 | -- `0x85` Onion Data Request OnionToOwner | ||
74 | -- `0x86` Onion Data Response - | ||
75 | -- | ||
76 | -- `0xf0` Bootstrap Info SockAddr? | ||
77 | -- | ||
78 | -- `0x80` Onion Request 0 -forward | ||
79 | -- `0x81` Onion Request 1 -forward | ||
80 | -- `0x82` Onion Request 2 -forward | ||
81 | -- `0x8c` Onion Response 3 -return | ||
82 | -- `0x8d` Onion Response 2 -return | ||
83 | -- `0x8e` Onion Response 1 -return | ||
84 | |||
85 | |||
86 | |||