summaryrefslogtreecommitdiff
path: root/src/Network/Tox/Onion/Handlers.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-10-14 16:34:24 -0400
committerjoe <joe@jerkface.net>2017-10-14 16:34:24 -0400
commit4b7f8e625d6cab8ae25074fc3339a5403ec5fb36 (patch)
tree9da87ee15ce14f6347e40b8a9491547edc281c9f /src/Network/Tox/Onion/Handlers.hs
parentf1a79aef9799176b52efb6197aaf7c2b5a8f14ad (diff)
Partitioned friend-request transport from the onion transport.
Diffstat (limited to 'src/Network/Tox/Onion/Handlers.hs')
-rw-r--r--src/Network/Tox/Onion/Handlers.hs30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/Network/Tox/Onion/Handlers.hs b/src/Network/Tox/Onion/Handlers.hs
index 167df336..439de709 100644
--- a/src/Network/Tox/Onion/Handlers.hs
+++ b/src/Network/Tox/Onion/Handlers.hs
@@ -130,7 +130,7 @@ toOnionDestination :: AnnouncedRoute -> OnionDestination r
130toOnionDestination (AnnouncedRoute ni rpath) = OnionToOwner ni rpath 130toOnionDestination (AnnouncedRoute ni rpath) = OnionToOwner ni rpath
131 131
132data AnnouncedKeys = AnnouncedKeys 132data AnnouncedKeys = AnnouncedKeys
133 { keyByAge :: !(PSQ NodeId (Down POSIXTime)) -- timeout of 300 seconds 133 { keyByAge :: !(PSQ NodeId (Down POSIXTime)) -- TODO: timeout of 300 seconds
134 , keyAssoc :: !(MinMaxPSQ' NodeId NodeDistance (Int,AnnouncedRoute)) 134 , keyAssoc :: !(MinMaxPSQ' NodeId NodeDistance (Int,AnnouncedRoute))
135 } 135 }
136 136
@@ -160,15 +160,6 @@ handlers net routing toks keydb AnnounceType
160handlers net _ _ keydb _ = Just $ NoReply Right $ dataToRouteH keydb net 160handlers net _ _ keydb _ = Just $ NoReply Right $ dataToRouteH keydb net
161 161
162 162
163data Rendezvous = Rendezvous
164 { rendezvousKey :: PublicKey
165 , rendezvousNode :: NodeInfo
166 }
167 deriving Eq
168
169instance Show Rendezvous where
170 show (Rendezvous k ni) = concat [show $ key2id k, ":", show ni]
171
172toxidSearch :: (TransactionId -> OnionDestination r -> STM (OnionDestination r, Int)) 163toxidSearch :: (TransactionId -> OnionDestination r -> STM (OnionDestination r, Int))
173 -> Client r 164 -> Client r
174 -> Search NodeId (IP, PortNumber) (Maybe Nonce32) NodeInfo Rendezvous 165 -> Search NodeId (IP, PortNumber) (Maybe Nonce32) NodeInfo Rendezvous
@@ -211,6 +202,25 @@ unwrapAnnounceResponse ni (AnnounceResponse is_stored (SendNodes ns))
211 SendBackKey k -> (ns, [Rendezvous k ni], Nothing) 202 SendBackKey k -> (ns, [Rendezvous k ni], Nothing)
212 Acknowledged n32 -> (ns, [], Just n32) 203 Acknowledged n32 -> (ns, [], Just n32)
213 204
205-- TODO Announce key to announce peers.
206--
207-- Announce Peers are only put in the 8 closest peers array if they respond
208-- to an announce request. If the peers fail to respond to 3 announce
209-- requests they are deemed timed out and removed.
210--
211-- ...
212--
213-- For this reason, after the peer is announced successfully for 17 seconds,
214-- announce packets are sent aggressively every 3 seconds to each known close
215-- peer (in the list of 8 peers) to search aggressively for peers that know
216-- the peer we are searching for.
217
218-- TODO
219-- If toxcore goes offline (no onion traffic for 20 seconds) toxcore will
220-- aggressively reannounce itself and search for friends as if it was just
221-- started.
222
223
214announce :: (TransactionId -> OnionDestination r -> STM (OnionDestination r, Int)) 224announce :: (TransactionId -> OnionDestination r -> STM (OnionDestination r, Int))
215 -> Client r 225 -> Client r
216 -> NodeId 226 -> NodeId