summaryrefslogtreecommitdiff
path: root/dht/conn-notes.txt
diff options
context:
space:
mode:
authorJames Crayne <jim.crayne@gmail.com>2019-09-28 13:43:29 -0400
committerJoe Crayne <joe@jerkface.net>2020-01-01 19:27:53 -0500
commit11987749fc6e6d3e53ea737d46d5ab13a16faeb8 (patch)
tree5716463275c2d3e902889db619908ded2a73971c /dht/conn-notes.txt
parentadd2c76bced51fde5e9917e7449ef52be70faf87 (diff)
Factor out some new libraries
word64-map: Data.Word64Map network-addr: Network.Address tox-crypto: Crypto.Tox lifted-concurrent: Control.Concurrent.Lifted.Instrument Control.Concurrent.Async.Lifted.Instrument psq-wrap: Data.Wrapper.PSQInt Data.Wrapper.PSQ minmax-psq: Data.MinMaxPSQ tasks: Control.Concurrent.Tasks kad: Network.Kademlia Network.Kademlia.Bootstrap Network.Kademlia.Routing Network.Kademlia.CommonAPI Network.Kademlia.Persistence Network.Kademlia.Search
Diffstat (limited to 'dht/conn-notes.txt')
-rw-r--r--dht/conn-notes.txt88
1 files changed, 88 insertions, 0 deletions
diff --git a/dht/conn-notes.txt b/dht/conn-notes.txt
new file mode 100644
index 00000000..257987d1
--- /dev/null
+++ b/dht/conn-notes.txt
@@ -0,0 +1,88 @@
1Status of a tox friend netcrypto session.
2-----------------------------------------
3data ToxProgress
4 = AwaitingDHTKey -- ^ Waiting to receive their DHT key.
5 | AcquiringIPAddress -- ^ Searching DHT to obtain their node's IP & port.
6 | AcquiringCookie -- ^ Attempting to obtain a cookie.
7 | AwaitingHandshake -- ^ Waiting to receive a handshake.
8 | AwaitingSessionPacket -- ^ Connection is "accepted" but not yet "confirmed".
9 deriving (Eq,Ord,Enum,Show)
10
11
12Information about contact toxid and events that provide it.
13----------------------------------------------------------
14 SockAddr
15 receive packet with dhtkey associated with toxid
16 receive query result with dhtkey associated with toxid
17 receive netcrypto session packet from toxid
18 DHTKey
19 receive dhtpk over DataToRoute transport.
20 receive dht message from SockAddr
21 receive dhtpk via dht-request
22
23
24
25Recurring tasks associated with obtaining a connection.
26-------------------------------------------------------
27while (account is active):
28 tox4id:announce{toxid}
29 tox6id:
30
31 while (policy=TryingToConnect and friend session is not established)
32 search{toxid} contact, send my dhtkey to results
33 (AwaitingDHTKey .. AwaitingSessionPacket)
34
35 while (dhtkey is fresh but sockaddr is stale)
36 search{node} dhtkey
37 (AcquiringIPAddress..)
38
39 while (dhtkey and sockaddr are fresh)
40 (AcquiringCookie)
41 getCookie { on timeout, consider sockaddr stale, set sockaddr to Nothing)
42 (AwaitingHandshake)
43 send handshake
44
45Plan: Suppose our user key is OrjBG.GyWuQhGc1pb0KssgmYAocohFh35Vx8mREC9Nu and we have
46a contact with user key DdhbLjiwaV0GAiGKgesNPbvj2TbhrBHEWEEc5icfvQN. The following AnnounceKeys
47will be scheduled:
48
49 toxid:OrjBG.GyWuQhGc1pb0KssgmYAocohFh35Vx8mREC9Nu
50
51 This task searches for our own user key, and publishes itself
52 at rendezvous nodes.
53
54 dhtkey:OrjBG.Gy:DdhbLjiwaV0GAiGKgesNPbvj2TbhrBHEWEEc5icfvQN
55
56 This task searches for our contact's user key and uses the
57 rendezvous nodes that it finds in order to share our dhtkey
58 with our contact.
59
60
61 connect:OrjBG.Gy:DdhbLjiwaV0GAiGKgesNPbvj2TbhrBHEWEEc5icfvQN
62
63 Depending on whether or not the ip/port is "fresh", this task
64 has two modes only one of which is active at a time:
65
66 (1) (stale) Search for our contact's dhtkey (nodeid) in order
67 to discover his ip address and port.
68
69 (2) (fresh) Send handshakes to our friend every 5 seconds.
70
71The toxid:* task will be scheduled as long as you are online. The dhtkey:* and
72connect:* will only be scheduled when there is no active "netcrypto" session
73link with your contact.
74
75On inbound
76----------
77 Handshake recieved!
78 (AwaitingSessionPacket)
79
80
81Interesting tox repositories
82--------------------------------------------
83 https://github.com/TokTok/spec
84
85 https://github.com/TokTok/hs-toxcore
86 https://github.com/iphydf/hstox
87
88 https://github.com/TokTok/c-toxcore