diff options
Diffstat (limited to 'src/Network')
-rw-r--r-- | src/Network/Tox/Onion/Transport.hs | 7 |
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 | ||
350 | instance 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 | |||
350 | instance ( Serialize (Forwarding (ThreeMinus n) (OnionMessage Encrypted)) | 355 | instance ( 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 | ||
391 | instance (Sized (ReturnPath n)) => Sized (OnionResponse (S n)) where | ||
392 | size = contramap pathToOwner size <> contramap msgToOwner size | ||
386 | 393 | ||
387 | data Addressed a = Addressed { sockAddr :: SockAddr, unaddressed :: a } | 394 | data Addressed a = Addressed { sockAddr :: SockAddr, unaddressed :: a } |
388 | deriving (Eq,Show) | 395 | deriving (Eq,Show) |