summaryrefslogtreecommitdiff
path: root/src/Data/Tox/Relay.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/Tox/Relay.hs')
-rw-r--r--src/Data/Tox/Relay.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Data/Tox/Relay.hs b/src/Data/Tox/Relay.hs
index 1437c9cd..1fe6d256 100644
--- a/src/Data/Tox/Relay.hs
+++ b/src/Data/Tox/Relay.hs
@@ -45,8 +45,8 @@ data RelayPacket
45 | RelayPong Nonce8 45 | RelayPong Nonce8
46 | OOBSend PublicKey ByteString 46 | OOBSend PublicKey ByteString
47 | OOBRecv PublicKey ByteString 47 | OOBRecv PublicKey ByteString
48 | OnionPacket (OnionRequest N0) 48 | OnionPacket Nonce24 (Addressed (Forwarding N2 (OnionMessage Encrypted))) -- (OnionRequest N0)
49 | OnionPacketResponse (OnionResponse N1) 49 | OnionPacketResponse (OnionMessage Encrypted)
50 -- 0x0A through 0x0F reserved for future use. 50 -- 0x0A through 0x0F reserved for future use.
51 | RelayData ByteString ConId 51 | RelayData ByteString ConId
52 deriving (Eq,Ord,Show,Data) 52 deriving (Eq,Ord,Show,Data)
@@ -65,9 +65,9 @@ instance Sized RelayPacket where
65 RelayPong pingid -> 8 65 RelayPong pingid -> 8
66 OOBSend k bs -> 32 + B.length bs 66 OOBSend k bs -> 32 + B.length bs
67 OOBRecv k bs -> 32 + B.length bs 67 OOBRecv k bs -> 32 + B.length bs
68 OnionPacket query -> case contramap (`asTypeOf` query) size of 68 OnionPacket n24 query -> 24 + case contramap (`asTypeOf` query) size of
69 ConstSize n -> n 69 ConstSize n -> n
70 VarSize f -> f query 70 VarSize f -> f query
71 OnionPacketResponse answer -> case contramap (`asTypeOf` answer) size of 71 OnionPacketResponse answer -> case contramap (`asTypeOf` answer) size of
72 ConstSize n -> n 72 ConstSize n -> n
73 VarSize f -> f answer 73 VarSize f -> f answer
@@ -86,7 +86,7 @@ instance Serialize RelayPacket where
86 5 -> RelayPong <$> get 86 5 -> RelayPong <$> get
87 6 -> OOBSend <$> getPublicKey <*> (remaining >>= getBytes) 87 6 -> OOBSend <$> getPublicKey <*> (remaining >>= getBytes)
88 7 -> OOBRecv <$> getPublicKey <*> (remaining >>= getBytes) 88 7 -> OOBRecv <$> getPublicKey <*> (remaining >>= getBytes)
89 8 -> OnionPacket <$> get 89 8 -> OnionPacket <$> get <*> get
90 9 -> OnionPacketResponse <$> get 90 9 -> OnionPacketResponse <$> get
91 conid -> (`RelayData` ConId conid) <$> (remaining >>= getBytes) 91 conid -> (`RelayData` ConId conid) <$> (remaining >>= getBytes)
92 92
@@ -101,7 +101,7 @@ instance Serialize RelayPacket where
101 RelayPong pingid -> put pingid 101 RelayPong pingid -> put pingid
102 OOBSend k bs -> putPublicKey k >> putByteString bs 102 OOBSend k bs -> putPublicKey k >> putByteString bs
103 OOBRecv k bs -> putPublicKey k >> putByteString bs 103 OOBRecv k bs -> putPublicKey k >> putByteString bs
104 OnionPacket query -> put query 104 OnionPacket n24 query -> put n24 >> put query
105 OnionPacketResponse answer -> put answer 105 OnionPacketResponse answer -> put answer
106 RelayData bs _ -> putByteString bs 106 RelayData bs _ -> putByteString bs
107 107