summaryrefslogtreecommitdiff
path: root/src/Network
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-07-03 20:35:07 -0400
committerjoe <joe@jerkface.net>2017-07-03 20:35:07 -0400
commit78b05bf38b83b5d46468e1f938bb8c2d9dd0804f (patch)
treee82e4769ed2c00069799a3d7d26f17398ba724d5 /src/Network
parent81bcffd68c9997b8e4b5f8c2d4cb1e4db4c62153 (diff)
Fleshed out Tox TODO stubs.
Diffstat (limited to 'src/Network')
-rw-r--r--src/Network/BitTorrent/DHT/Query.hs1
-rw-r--r--src/Network/DatagramServer/Tox.hs8
2 files changed, 5 insertions, 4 deletions
diff --git a/src/Network/BitTorrent/DHT/Query.hs b/src/Network/BitTorrent/DHT/Query.hs
index 330b5478..ad29adb6 100644
--- a/src/Network/BitTorrent/DHT/Query.hs
+++ b/src/Network/BitTorrent/DHT/Query.hs
@@ -232,6 +232,7 @@ class DataHandlers raw dht where
232 (NodeId dht -> IO [NodeInfo dht ip ()]) 232 (NodeId dht -> IO [NodeInfo dht ip ()])
233 -> DHTData dht ip 233 -> DHTData dht ip
234 -> [MethodHandler raw dht ip] 234 -> [MethodHandler raw dht ip]
235 dataHandlers _ _ = []
235 236
236instance DataHandlers BValue KMessageOf where 237instance DataHandlers BValue KMessageOf where
237 dataHandlers = bthandlers 238 dataHandlers = bthandlers
diff --git a/src/Network/DatagramServer/Tox.hs b/src/Network/DatagramServer/Tox.hs
index 83701b6b..3a6135cc 100644
--- a/src/Network/DatagramServer/Tox.hs
+++ b/src/Network/DatagramServer/Tox.hs
@@ -37,7 +37,7 @@ type Nonce24 = Word192 -- 24 bytes
37 37
38 38
39data NodeFormat = NodeFormat 39data NodeFormat = NodeFormat
40 { nodePublicKey :: Key32 -- 32 byte public key 40 { nodePublicKey :: NodeId Message -- 32 byte public key
41 , nodeIsTCP :: Bool -- This has no analog in mainline NodeInfo structure 41 , nodeIsTCP :: Bool -- This has no analog in mainline NodeInfo structure
42 , nodeIP :: IP -- IPv4 or IPv6 address 42 , nodeIP :: IP -- IPv4 or IPv6 address
43 , nodePort :: PortNumber 43 , nodePort :: PortNumber
@@ -149,10 +149,10 @@ instance Serialize NodeFormat where
149 return $ NodeFormat { nodeIsTCP = istcp 149 return $ NodeFormat { nodeIsTCP = istcp
150 , nodeIP = ip 150 , nodeIP = ip
151 , nodePort = port 151 , nodePort = port
152 , nodePublicKey = pubkey 152 , nodePublicKey = NodeId pubkey
153 } 153 }
154 154
155 put (NodeFormat{..}) = do 155 put (NodeFormat{ nodePublicKey = NodeId pubkey, ..}) = do
156 put $ case (# nodeIP, nodeIsTCP #) of 156 put $ case (# nodeIP, nodeIsTCP #) of
157 (# IPv4 _, False #) -> 2 157 (# IPv4 _, False #) -> 2
158 (# IPv4 _, True #) -> 130 158 (# IPv4 _, True #) -> 130
@@ -160,7 +160,7 @@ instance Serialize NodeFormat where
160 (# IPv6 _, True #) -> 138 :: Word8 160 (# IPv6 _, True #) -> 138 :: Word8
161 put nodeIP 161 put nodeIP
162 put nodePort 162 put nodePort
163 put nodePublicKey 163 put pubkey
164 164
165-- Note: the char array is a public key, the 32-bytes is provided by libsodium-dev 165-- Note: the char array is a public key, the 32-bytes is provided by libsodium-dev
166-- in /usr/include/sodium/crypto_box.h as the symbol crypto_box_PUBLICKEYBYTES 166-- in /usr/include/sodium/crypto_box.h as the symbol crypto_box_PUBLICKEYBYTES