summaryrefslogtreecommitdiff
path: root/src/Network/Tox
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/Tox')
-rw-r--r--src/Network/Tox/ContactInfo.hs9
-rw-r--r--src/Network/Tox/Crypto/Handlers.hs2
-rw-r--r--src/Network/Tox/Onion/Transport.hs4
3 files changed, 11 insertions, 4 deletions
diff --git a/src/Network/Tox/ContactInfo.hs b/src/Network/Tox/ContactInfo.hs
index d9d9a510..df3365a2 100644
--- a/src/Network/Tox/ContactInfo.hs
+++ b/src/Network/Tox/ContactInfo.hs
@@ -12,10 +12,11 @@ import qualified Data.HashMap.Strict as HashMap
12import Data.Maybe 12import Data.Maybe
13import qualified Data.Set as Set 13import qualified Data.Set as Set
14 ;import Data.Set (Set) 14 ;import Data.Set (Set)
15import Network.Socket
15import Network.Tox.DHT.Transport as DHT 16import Network.Tox.DHT.Transport as DHT
17import Network.Tox.NodeId (id2key)
16import Network.Tox.Onion.Transport as Onion 18import Network.Tox.Onion.Transport as Onion
17import System.IO 19import System.IO
18import Network.Socket
19 20
20newtype ContactInfo = ContactInfo 21newtype ContactInfo = ContactInfo
21 -- | Map our toxid public key to an Account record. 22 -- | Map our toxid public key to an Account record.
@@ -150,3 +151,9 @@ friendRequests (ContactInfo roster) = do
150 $ HashMap.toList cs 151 $ HashMap.toList cs
151 return remotes 152 return remotes
152 153
154myKeyPairs :: ContactInfo -> STM [(SecretKey,PublicKey)]
155myKeyPairs (ContactInfo accounts) = do
156 acnts <- readTVar accounts
157 forM (HashMap.toList acnts) $ \(nid, Account{userSecret}) -> do
158 return (userSecret,id2key nid)
159
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs
index 95cb1bc8..9e5bd94e 100644
--- a/src/Network/Tox/Crypto/Handlers.hs
+++ b/src/Network/Tox/Crypto/Handlers.hs
@@ -543,7 +543,7 @@ cryptoNetHandler sessions addr (NetHandshake (Handshake (Cookie n24 ecookie) non
543 allsessions = netCryptoSessions sessions 543 allsessions = netCryptoSessions sessions
544 anyRight [] f = return $ Left "missing key" 544 anyRight [] f = return $ Left "missing key"
545 anyRight (x:xs) f = f x >>= either (const $ anyRight xs f) (return . Right) 545 anyRight (x:xs) f = f x >>= either (const $ anyRight xs f) (return . Right)
546 seckeys <- map fst <$> atomically (readTVar (userKeys crypto)) 546 seckeys <- map fst <$> atomically (userKeys crypto)
547 symkey <- atomically $ transportSymmetric crypto 547 symkey <- atomically $ transportSymmetric crypto
548 now <- getPOSIXTime 548 now <- getPOSIXTime
549 dput XNetCrypto ("Decrypt cookie with n24=" ++ show n24 ++ "\n symkey= " ++ show symkey) 549 dput XNetCrypto ("Decrypt cookie with n24=" ++ show n24 ++ "\n symkey= " ++ show symkey)
diff --git a/src/Network/Tox/Onion/Transport.hs b/src/Network/Tox/Onion/Transport.hs
index 550a7730..d604a5c8 100644
--- a/src/Network/Tox/Onion/Transport.hs
+++ b/src/Network/Tox/Onion/Transport.hs
@@ -848,7 +848,7 @@ instance Read AnnouncedRendezvous where
848selectAlias :: TransportCrypto -> NodeId -> STM AliasSelector 848selectAlias :: TransportCrypto -> NodeId -> STM AliasSelector
849selectAlias crypto pkey = do 849selectAlias crypto pkey = do
850 ks <- filter (\(sk,pk) -> pk == id2key pkey) 850 ks <- filter (\(sk,pk) -> pk == id2key pkey)
851 <$> readTVar (userKeys crypto) 851 <$> userKeys crypto
852 maybe (return SearchingAlias) 852 maybe (return SearchingAlias)
853 (return . uncurry AnnouncingAlias) 853 (return . uncurry AnnouncingAlias)
854 (listToMaybe ks) 854 (listToMaybe ks)
@@ -859,7 +859,7 @@ parseDataToRoute
859 -> (OnionMessage Encrypted,OnionDestination r) 859 -> (OnionMessage Encrypted,OnionDestination r)
860 -> IO (Either ((PublicKey,OnionData),AnnouncedRendezvous) (OnionMessage Encrypted, OnionDestination r)) 860 -> IO (Either ((PublicKey,OnionData),AnnouncedRendezvous) (OnionMessage Encrypted, OnionDestination r))
861parseDataToRoute crypto (OnionToRouteResponse dta, od) = do 861parseDataToRoute crypto (OnionToRouteResponse dta, od) = do
862 ks <- atomically $ readTVar $ userKeys crypto 862 ks <- atomically $ userKeys crypto
863 863
864 omsg0 <- decryptMessage crypto (rendezvousSecret crypto,rendezvousPublic crypto) 864 omsg0 <- decryptMessage crypto (rendezvousSecret crypto,rendezvousPublic crypto)
865 (asymmNonce dta) 865 (asymmNonce dta)