summaryrefslogtreecommitdiff
path: root/dht/src/Data/Tox/Onion.hs
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-12-18 18:06:12 -0500
committerJoe Crayne <joe@jerkface.net>2020-01-01 23:27:11 -0500
commitb6676d7c3339e46752cadfc1198886062f5c666d (patch)
tree25d8630d8d2fa6b2f5d3234a07445d61c02194df /dht/src/Data/Tox/Onion.hs
parent4e8aa82d56129aae9e5ef22e5e0aa9287b993a92 (diff)
Used partitionTransform to simplify the onion client.
Diffstat (limited to 'dht/src/Data/Tox/Onion.hs')
-rw-r--r--dht/src/Data/Tox/Onion.hs19
1 files changed, 18 insertions, 1 deletions
diff --git a/dht/src/Data/Tox/Onion.hs b/dht/src/Data/Tox/Onion.hs
index a9bc4e1d..55e81069 100644
--- a/dht/src/Data/Tox/Onion.hs
+++ b/dht/src/Data/Tox/Onion.hs
@@ -19,7 +19,7 @@
19module Data.Tox.Onion where 19module Data.Tox.Onion where
20 20
21 21
22import Network.Address (fromSockAddr,toSockAddr,setPort,either4or6,sockAddrPort,localhost4,localhost6) 22import Network.Address (fromSockAddr,toSockAddr,setPort,either4or6,sockAddrPort,localhost4,localhost6,nullAddress4)
23import Network.QueryResponse 23import Network.QueryResponse
24import Crypto.Tox hiding (encrypt,decrypt) 24import Crypto.Tox hiding (encrypt,decrypt)
25import Network.Tox.NodeId 25import Network.Tox.NodeId
@@ -873,6 +873,19 @@ data OnionRoute = OnionRoute
873 } 873 }
874 deriving Show 874 deriving Show
875 875
876dummySecret :: SecretKey
877dummySecret = fromJust $ decodeSecret "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
878
879dummyNodeId :: NodeId
880dummyNodeId = read "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
881
882dummyNode :: NodeInfo
883dummyNode = k where Right k = nodeInfo dummyNodeId nullAddress4
884
885dummyRoute :: OnionRoute
886dummyRoute = OnionRoute dummySecret dummySecret dummySecret
887 dummyNode dummyNode dummyNode
888 Nothing
876 889
877wrapOnion :: Serialize (Forwarding n msg) => 890wrapOnion :: Serialize (Forwarding n msg) =>
878 TransportCrypto 891 TransportCrypto
@@ -956,6 +969,10 @@ instance Read AnnouncedRendezvous where
956 } 969 }
957 970
958 971
972-- | Lookup the secret key for the given toxid public key. If it is not found,
973-- then the SearchingAlias symbol will be used to indicate that a new temporary
974-- key pair should be generated or that all known keys should be tried until one
975-- succeeds to decrypt the message.
959selectAlias :: TransportCrypto -> NodeId -> STM AliasSelector 976selectAlias :: TransportCrypto -> NodeId -> STM AliasSelector
960selectAlias crypto pkey = do 977selectAlias crypto pkey = do
961 ks <- filter (\(sk,pk) -> pk == id2key pkey) 978 ks <- filter (\(sk,pk) -> pk == id2key pkey)