summaryrefslogtreecommitdiff
path: root/src/Network/Tox/DHT/Transport.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/Tox/DHT/Transport.hs')
-rw-r--r--src/Network/Tox/DHT/Transport.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Network/Tox/DHT/Transport.hs b/src/Network/Tox/DHT/Transport.hs
index 0c69ea8b..e784ec90 100644
--- a/src/Network/Tox/DHT/Transport.hs
+++ b/src/Network/Tox/DHT/Transport.hs
@@ -1,3 +1,4 @@
1{-# LANGUAGE DeriveGeneric #-}
1{-# LANGUAGE FlexibleContexts #-} 2{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE FlexibleInstances #-} 3{-# LANGUAGE FlexibleInstances #-}
3{-# LANGUAGE GeneralizedNewtypeDeriving #-} 4{-# LANGUAGE GeneralizedNewtypeDeriving #-}
@@ -47,11 +48,13 @@ import Data.Bool
47import qualified Data.ByteString as B 48import qualified Data.ByteString as B
48 ;import Data.ByteString (ByteString) 49 ;import Data.ByteString (ByteString)
49import Data.Functor.Contravariant 50import Data.Functor.Contravariant
51import Data.Hashable
50import Data.Maybe 52import Data.Maybe
51import Data.Monoid 53import Data.Monoid
52import Data.Serialize as S 54import Data.Serialize as S
53import Data.Tuple 55import Data.Tuple
54import Data.Word 56import Data.Word
57import GHC.Generics
55import Network.Socket 58import Network.Socket
56 59
57type DHTTransport = Transport String NodeInfo (DHTMessage Encrypted8) 60type DHTTransport = Transport String NodeInfo (DHTMessage Encrypted8)
@@ -358,6 +361,9 @@ data Cookie (f :: * -> *) = Cookie Nonce24 (f CookieData)
358deriving instance Eq (f CookieData) => Eq (Cookie f) 361deriving instance Eq (f CookieData) => Eq (Cookie f)
359deriving instance Ord (f CookieData) => Ord (Cookie f) 362deriving instance Ord (f CookieData) => Ord (Cookie f)
360deriving instance Show (f CookieData) => Show (Cookie f) 363deriving instance Show (f CookieData) => Show (Cookie f)
364deriving instance Generic (f CookieData) => Generic (Cookie f)
365
366instance Hashable (Cookie Encrypted)
361 367
362instance Sized (Cookie Encrypted) where size = ConstSize 112 -- 24 byte nonce + 88 byte cookie data 368instance Sized (Cookie Encrypted) where size = ConstSize 112 -- 24 byte nonce + 88 byte cookie data
363 369
@@ -370,7 +376,7 @@ data CookieData = CookieData -- 16 (mac)
370 , longTermKey :: PublicKey -- 32 376 , longTermKey :: PublicKey -- 32
371 , dhtKey :: PublicKey -- + 32 377 , dhtKey :: PublicKey -- + 32
372 } -- = 88 bytes when encrypted. 378 } -- = 88 bytes when encrypted.
373 deriving Show 379 deriving (Show, Generic)
374 380
375instance Sized CookieData where 381instance Sized CookieData where
376 size = ConstSize 72 382 size = ConstSize 72