From e2e69ffc55abdd6df9e6f328ee867d8ed6639322 Mon Sep 17 00:00:00 2001 From: joe Date: Fri, 27 Oct 2017 17:39:30 -0400 Subject: Added TODO regarding Tox "Hardening" message. --- examples/dhtd.hs | 1 + src/Network/Tox/DHT/Transport.hs | 12 ++++++++++++ todo.txt | 2 ++ 3 files changed, 15 insertions(+) diff --git a/examples/dhtd.hs b/examples/dhtd.hs index ea2b3459..9966fb32 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs @@ -164,6 +164,7 @@ loadNodes netname = do >>= maybe (ioError $ userError "Nothing") return either (const $ fallbackLoad fname) return attempt +fallbackLoad :: FromJSON t => FilePath -> IO [t] fallbackLoad fname = do attempt <- tryIOError $ do J.decode <$> L.readFile fname 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 -- `8` `uint64_t` random number (the same that was received in request) | NATPong Nonce8 | DHTPK LongTermKeyWrap + -- From docs/Hardening_docs.txt + -- + -- All hardening requests must contain exactly 384 bytes of data. (The data sent + -- must be padded with zeros if it is smaller than that.) + -- + -- [byte with value: 02 (get nodes test request)][struct Node_format (the node to + -- test.)][client_id(32 bytes) the id to query the node with.][padding] + -- + -- packet id: CRYPTO_PACKET_HARDENING (48) + | Hardening -- TODO deriving Show instance Sized DHTRequest where @@ -193,10 +203,12 @@ instance Serialize DHTRequest where direction <- get bool NATPong NATPing (direction==(0::Word8)) <$> get 0x9c -> DHTPK <$> get + 0x30 -> pure Hardening -- TODO: CRYPTO_PACKET_HARDENING _ -> fail ("unrecognized DHT request: "++show tag) put (NATPing n) = put (0xfe00 :: Word16) >> put n put (NATPong n) = put (0xfe01 :: Word16) >> put n put (DHTPK pk) = put (0x9c :: Word8) >> put pk + put (Hardening) = put (0x30 :: Word8) >> putByteString (B.replicate 384 0) -- TODO -- DHT public key packet: -- (As Onion data packet?) diff --git a/todo.txt b/todo.txt index ecb9a46e..b5e7ed04 100644 --- a/todo.txt +++ b/todo.txt @@ -15,6 +15,8 @@ tox: fallback to https://nodes.tox.chat/json tox: bootstrap motd query +tox: hardening get-nodes test request. + tox: nat ping tox: base64 read/show -- cgit v1.2.3