summaryrefslogtreecommitdiff
path: root/Connection/Tox/Threads.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Connection/Tox/Threads.hs')
-rw-r--r--Connection/Tox/Threads.hs66
1 files changed, 65 insertions, 1 deletions
diff --git a/Connection/Tox/Threads.hs b/Connection/Tox/Threads.hs
index 8b19c7cf..dcee37d1 100644
--- a/Connection/Tox/Threads.hs
+++ b/Connection/Tox/Threads.hs
@@ -12,7 +12,7 @@
12module Connection.Tox.Threads where 12module Connection.Tox.Threads where
13 13
14import Connection 14import Connection
15import Connection.Tox 15-- import Connection.Tox
16import Data.IP (IP) 16import Data.IP (IP)
17import Network.Tox.Crypto.Transport 17import Network.Tox.Crypto.Transport
18import Network.Tox.NodeId 18import Network.Tox.NodeId
@@ -27,6 +27,70 @@ import Data.Function
27import Data.Functor.Identity 27import Data.Functor.Identity
28import System.Timeout 28import System.Timeout
29 29
30
31-- | This type indicates the progress of a tox encrypted friend link
32-- connection. Two scenarios are illustrated below. The parenthesis show the
33-- current 'G.Status' 'ToxProgress' of the session.
34--
35--
36-- Perfect handshake scenario:
37--
38-- Peer 1 Peer 2
39-- (InProgress AcquiringCookie) (Dormant/InProgress AcquiringCookie)
40-- Cookie request ->
41-- <- Cookie response
42-- (InProgress AwaitingHandshake) (Dormant/InProgress AcquiringCookie)
43-- Handshake packet ->
44-- * accepts connection
45-- (InProgress AwaitingSessionPacket)
46-- <- Handshake packet
47-- *accepts connection
48-- (InProgress AwaitingSessionPacket)
49-- Encrypted packet -> <- Encrypted packet
50-- *confirms connection *confirms connection
51-- (Established) (Established)
52--
53-- Connection successful.
54--
55-- Encrypted packets -> <- Encrypted packets
56--
57--
58--
59--
60-- More realistic handshake scenario:
61-- Peer 1 Peer 2
62-- (InProgress AcquiringCookie) (Dormant/InProgress AcquiringCookie)
63-- Cookie request -> *packet lost*
64-- Cookie request ->
65-- <- Cookie response
66-- (InProgress AwaitingHandshake) (Dormant/InProgress AcquiringCookie)
67--
68-- *Peer 2 randomly starts new connection to peer 1
69-- (InProgress AcquiringCookie)
70-- <- Cookie request
71-- Cookie response ->
72-- (InProgress AwaitingHandshake)
73--
74-- Handshake packet -> <- Handshake packet
75-- *accepts connection * accepts connection
76-- (InProgress AwaitingSessionPacket) (InProgress AwaitingSessionPacket)
77--
78-- Encrypted packet -> <- Encrypted packet
79-- *confirms connection *confirms connection
80-- (Established) (Established)
81--
82-- Connection successful.
83--
84-- Encrypted packets -> <- Encrypted packets
85data ToxProgress
86 = AwaitingDHTKey -- ^ Waiting to receive their DHT key.
87 | AcquiringIPAddress -- ^ Searching DHT to obtain their node's IP & port.
88 | AcquiringCookie -- ^ Attempting to obtain a cookie.
89 | AwaitingHandshake -- ^ Waiting to receive a handshake.
90 | AwaitingSessionPacket -- ^ Connection is "accepted" but not yet "confirmed".
91 deriving (Eq,Ord,Enum,Show)
92
93
30type NodeSearch = Search NodeId (IP,PortNumber) () NodeInfo NodeInfo 94type NodeSearch = Search NodeId (IP,PortNumber) () NodeInfo NodeInfo
31 95
32data AcceptContactMethods = AcceptContactMethods 96data AcceptContactMethods = AcceptContactMethods