summaryrefslogtreecommitdiff
path: root/src/Network/Tox/Onion
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2018-11-28 21:41:56 -0500
committerJoe Crayne <joe@jerkface.net>2018-12-16 14:08:26 -0500
commitc381679d47959861d1e94d0e9cd6f809e8de3a8c (patch)
treed42477e9673c8614a07c982cf76b6878f07dc5b3 /src/Network/Tox/Onion
parent006093d2ec381739d0fffb5e3c4534daaea774d2 (diff)
More TCP relay packet serialization.
Diffstat (limited to 'src/Network/Tox/Onion')
-rw-r--r--src/Network/Tox/Onion/Transport.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Network/Tox/Onion/Transport.hs b/src/Network/Tox/Onion/Transport.hs
index ef9121f2..160b99f7 100644
--- a/src/Network/Tox/Onion/Transport.hs
+++ b/src/Network/Tox/Onion/Transport.hs
@@ -347,6 +347,11 @@ deriving instance ( Show (Forwarding (ThreeMinus n) (OnionMessage Encrypted))
347 , KnownNat (PeanoNat n) 347 , KnownNat (PeanoNat n)
348 ) => Show (OnionRequest n) 348 ) => Show (OnionRequest n)
349 349
350instance Sized (OnionRequest N0) where -- N1 and N2 are the same, N3 does not encode the nonce.
351 size = contramap onionNonce size
352 <> contramap onionForward size
353 <> contramap pathFromOwner size
354
350instance ( Serialize (Forwarding (ThreeMinus n) (OnionMessage Encrypted)) 355instance ( Serialize (Forwarding (ThreeMinus n) (OnionMessage Encrypted))
351 , Sized (ReturnPath n) 356 , Sized (ReturnPath n)
352 , Serialize (ReturnPath n) 357 , Serialize (ReturnPath n)
@@ -383,6 +388,8 @@ instance ( Serialize (ReturnPath n) ) => Serialize (OnionResponse n) where
383 . getOnionReply) 388 . getOnionReply)
384 put (OnionResponse p m) = put p >> putOnionMsg m 389 put (OnionResponse p m) = put p >> putOnionMsg m
385 390
391instance (Sized (ReturnPath n)) => Sized (OnionResponse (S n)) where
392 size = contramap pathToOwner size <> contramap msgToOwner size
386 393
387data Addressed a = Addressed { sockAddr :: SockAddr, unaddressed :: a } 394data Addressed a = Addressed { sockAddr :: SockAddr, unaddressed :: a }
388 deriving (Eq,Show) 395 deriving (Eq,Show)