diff options
Diffstat (limited to 'src/Network/Tox/DHT/Transport.hs')
-rw-r--r-- | src/Network/Tox/DHT/Transport.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Network/Tox/DHT/Transport.hs b/src/Network/Tox/DHT/Transport.hs index b7982a1a..6009afa2 100644 --- a/src/Network/Tox/DHT/Transport.hs +++ b/src/Network/Tox/DHT/Transport.hs | |||
@@ -174,6 +174,16 @@ data DHTRequest | |||
174 | -- `8` `uint64_t` random number (the same that was received in request) | 174 | -- `8` `uint64_t` random number (the same that was received in request) |
175 | | NATPong Nonce8 | 175 | | NATPong Nonce8 |
176 | | DHTPK LongTermKeyWrap | 176 | | DHTPK LongTermKeyWrap |
177 | -- From docs/Hardening_docs.txt | ||
178 | -- | ||
179 | -- All hardening requests must contain exactly 384 bytes of data. (The data sent | ||
180 | -- must be padded with zeros if it is smaller than that.) | ||
181 | -- | ||
182 | -- [byte with value: 02 (get nodes test request)][struct Node_format (the node to | ||
183 | -- test.)][client_id(32 bytes) the id to query the node with.][padding] | ||
184 | -- | ||
185 | -- packet id: CRYPTO_PACKET_HARDENING (48) | ||
186 | | Hardening -- TODO | ||
177 | deriving Show | 187 | deriving Show |
178 | 188 | ||
179 | instance Sized DHTRequest where | 189 | instance Sized DHTRequest where |
@@ -193,10 +203,12 @@ instance Serialize DHTRequest where | |||
193 | direction <- get | 203 | direction <- get |
194 | bool NATPong NATPing (direction==(0::Word8)) <$> get | 204 | bool NATPong NATPing (direction==(0::Word8)) <$> get |
195 | 0x9c -> DHTPK <$> get | 205 | 0x9c -> DHTPK <$> get |
206 | 0x30 -> pure Hardening -- TODO: CRYPTO_PACKET_HARDENING | ||
196 | _ -> fail ("unrecognized DHT request: "++show tag) | 207 | _ -> fail ("unrecognized DHT request: "++show tag) |
197 | put (NATPing n) = put (0xfe00 :: Word16) >> put n | 208 | put (NATPing n) = put (0xfe00 :: Word16) >> put n |
198 | put (NATPong n) = put (0xfe01 :: Word16) >> put n | 209 | put (NATPong n) = put (0xfe01 :: Word16) >> put n |
199 | put (DHTPK pk) = put (0x9c :: Word8) >> put pk | 210 | put (DHTPK pk) = put (0x9c :: Word8) >> put pk |
211 | put (Hardening) = put (0x30 :: Word8) >> putByteString (B.replicate 384 0) -- TODO | ||
200 | 212 | ||
201 | -- DHT public key packet: | 213 | -- DHT public key packet: |
202 | -- (As Onion data packet?) | 214 | -- (As Onion data packet?) |