summaryrefslogtreecommitdiff
path: root/src/Network/Tox/Transport.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-10-01 05:26:36 -0400
committerjoe <joe@jerkface.net>2017-10-01 05:26:36 -0400
commitd408e6c3148106c6dbc8afe24a1488619adf34e1 (patch)
treeca2d7a66b07dba82b6bf236fb234cac75bf87da6 /src/Network/Tox/Transport.hs
parentf6f70dcfa25ddf10e3cf16745bdd082cc26b2fd6 (diff)
Ability to send onion messages when given a path.
Diffstat (limited to 'src/Network/Tox/Transport.hs')
-rw-r--r--src/Network/Tox/Transport.hs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/Network/Tox/Transport.hs b/src/Network/Tox/Transport.hs
index d99b6713..d441dc0a 100644
--- a/src/Network/Tox/Transport.hs
+++ b/src/Network/Tox/Transport.hs
@@ -6,7 +6,7 @@
6{-# LANGUAGE ScopedTypeVariables #-} 6{-# LANGUAGE ScopedTypeVariables #-}
7{-# LANGUAGE TupleSections #-} 7{-# LANGUAGE TupleSections #-}
8{-# LANGUAGE TypeOperators #-} 8{-# LANGUAGE TypeOperators #-}
9module Network.Tox.Transport (toxTransport) where 9module Network.Tox.Transport (toxTransport, RouteId) where
10 10
11import Network.QueryResponse 11import Network.QueryResponse
12import Crypto.Tox 12import Crypto.Tox
@@ -16,16 +16,26 @@ import Network.Tox.Crypto.Transport
16 16
17import Network.Socket 17import Network.Socket
18 18
19type RouteId = () -- todo
20
21lookupSender :: SockAddr -> Nonce8 -> IO (Maybe (NodeInfo, RouteId))
22lookupSender _ _ = return Nothing -- todo
23
24lookupRoute :: NodeInfo -> RouteId -> IO (Maybe OnionRoute)
25lookupRoute _ _ = return Nothing -- todo
26
19toxTransport :: 27toxTransport ::
20 TransportCrypto 28 TransportCrypto
21 -> (PublicKey -> IO (Maybe NodeInfo)) 29 -> (PublicKey -> IO (Maybe NodeInfo))
22 -> UDPTransport 30 -> UDPTransport
23 -> IO ( Transport String NodeInfo (DHTMessage Encrypted8) 31 -> IO ( Transport String NodeInfo (DHTMessage Encrypted8)
24 , Transport String OnionDestination (OnionMessage Encrypted) 32 , Transport String (OnionDestination RouteId) (OnionMessage Encrypted)
25 , Transport String SockAddr NetCrypto ) 33 , Transport String SockAddr NetCrypto )
26toxTransport crypto closeLookup udp = do 34toxTransport crypto closeLookup udp = do
27 (dht,udp1) <- partitionTransport parseDHTAddr encodeDHTAddr id $ forwardOnions crypto udp 35 (dht,udp1) <- partitionTransport parseDHTAddr (Just . encodeDHTAddr) $ forwardOnions crypto udp
28 (onion,udp2) <- partitionTransport parseOnionAddr encodeOnionAddr id udp1 36 (onion,udp2) <- partitionTransportM (parseOnionAddr lookupSender)
37 (encodeOnionAddr lookupRoute)
38 udp1
29 let netcrypto = layerTransport parseNetCrypto encodeNetCrypto udp2 39 let netcrypto = layerTransport parseNetCrypto encodeNetCrypto udp2
30 return ( forwardDHTRequests crypto closeLookup dht 40 return ( forwardDHTRequests crypto closeLookup dht
31 , onion 41 , onion