diff options
author | Joe Crayne <joe@jerkface.net> | 2019-12-18 18:06:12 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-01 23:27:11 -0500 |
commit | b6676d7c3339e46752cadfc1198886062f5c666d (patch) | |
tree | 25d8630d8d2fa6b2f5d3234a07445d61c02194df /dht/src/Data/Tox/Onion.hs | |
parent | 4e8aa82d56129aae9e5ef22e5e0aa9287b993a92 (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.hs | 19 |
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 @@ | |||
19 | module Data.Tox.Onion where | 19 | module Data.Tox.Onion where |
20 | 20 | ||
21 | 21 | ||
22 | import Network.Address (fromSockAddr,toSockAddr,setPort,either4or6,sockAddrPort,localhost4,localhost6) | 22 | import Network.Address (fromSockAddr,toSockAddr,setPort,either4or6,sockAddrPort,localhost4,localhost6,nullAddress4) |
23 | import Network.QueryResponse | 23 | import Network.QueryResponse |
24 | import Crypto.Tox hiding (encrypt,decrypt) | 24 | import Crypto.Tox hiding (encrypt,decrypt) |
25 | import Network.Tox.NodeId | 25 | import Network.Tox.NodeId |
@@ -873,6 +873,19 @@ data OnionRoute = OnionRoute | |||
873 | } | 873 | } |
874 | deriving Show | 874 | deriving Show |
875 | 875 | ||
876 | dummySecret :: SecretKey | ||
877 | dummySecret = fromJust $ decodeSecret "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" | ||
878 | |||
879 | dummyNodeId :: NodeId | ||
880 | dummyNodeId = read "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" | ||
881 | |||
882 | dummyNode :: NodeInfo | ||
883 | dummyNode = k where Right k = nodeInfo dummyNodeId nullAddress4 | ||
884 | |||
885 | dummyRoute :: OnionRoute | ||
886 | dummyRoute = OnionRoute dummySecret dummySecret dummySecret | ||
887 | dummyNode dummyNode dummyNode | ||
888 | Nothing | ||
876 | 889 | ||
877 | wrapOnion :: Serialize (Forwarding n msg) => | 890 | wrapOnion :: 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. | ||
959 | selectAlias :: TransportCrypto -> NodeId -> STM AliasSelector | 976 | selectAlias :: TransportCrypto -> NodeId -> STM AliasSelector |
960 | selectAlias crypto pkey = do | 977 | selectAlias crypto pkey = do |
961 | ks <- filter (\(sk,pk) -> pk == id2key pkey) | 978 | ks <- filter (\(sk,pk) -> pk == id2key pkey) |