diff options
author | joe <joe@jerkface.net> | 2017-10-01 05:26:36 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-10-01 05:26:36 -0400 |
commit | d408e6c3148106c6dbc8afe24a1488619adf34e1 (patch) | |
tree | ca2d7a66b07dba82b6bf236fb234cac75bf87da6 /src/Network/Tox/Transport.hs | |
parent | f6f70dcfa25ddf10e3cf16745bdd082cc26b2fd6 (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.hs | 18 |
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 #-} |
9 | module Network.Tox.Transport (toxTransport) where | 9 | 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 |
@@ -16,16 +16,26 @@ import Network.Tox.Crypto.Transport | |||
16 | 16 | ||
17 | import Network.Socket | 17 | import Network.Socket |
18 | 18 | ||
19 | type RouteId = () -- todo | ||
20 | |||
21 | lookupSender :: SockAddr -> Nonce8 -> IO (Maybe (NodeInfo, RouteId)) | ||
22 | lookupSender _ _ = return Nothing -- todo | ||
23 | |||
24 | lookupRoute :: NodeInfo -> RouteId -> IO (Maybe OnionRoute) | ||
25 | lookupRoute _ _ = return Nothing -- todo | ||
26 | |||
19 | toxTransport :: | 27 | toxTransport :: |
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 ) |
26 | toxTransport crypto closeLookup udp = do | 34 | toxTransport 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 |