Fixes
parent: tbd commit: 25c3410
1 | use ; |
2 | |
3 | use Error; |
4 | use |
5 | HandshakeFinalize, HandshakeResponse, InitiateHandshake, |
6 | ; |
7 | use Version; |
8 | |
9 | use crate:: |
10 | , | ConnectionError
11 | , |
12 | validate_version, version, |
13 | ; |
14 | |
15 | use ; |
16 | |
17 | pub async |
18 | message: &NetworkMessage, |
19 | state: &ConnectionState, |
20 | |
21 | if initiate_handshake |
22 | .handle_message |
23 | .await |
24 | .is_ok |
25 | |
26 | Ok |
27 | else if handshake_response |
28 | .handle_message |
29 | .await |
30 | .is_ok |
31 | |
32 | Ok |
33 | else if handshake_finalize |
34 | .handle_message |
35 | .await |
36 | .is_ok |
37 | |
38 | Ok |
39 | else |
40 | Err |
41 | |
42 | |
43 | |
44 | async |
45 | Message | : ,
46 | State | : ,
47 | |
48 | connection_state |
49 | .send |
50 | identity: connection_state.instance.clone, |
51 | version: version, |
52 | |
53 | .await |
54 | .map_err?; |
55 | |
56 | Ok |
57 | // if !validate_version(&initiation.version) { |
58 | // error!( |
59 | // "Version compatibility failure! Our Version: {}, Their Version: {}", |
60 | // Version::from_str(&std::env::var("CARGO_PKG_VERSION").unwrap()).unwrap(), |
61 | // initiation.version |
62 | // ); |
63 | |
64 | // connection_state |
65 | // .send(HandshakeFinalize { success: false }) |
66 | // .await |
67 | // .map_err(|e| HandshakeError::SendError(e))?; |
68 | |
69 | // Ok(()) |
70 | // } else { |
71 | // connection_state |
72 | // .send(HandshakeResponse { |
73 | // identity: connection_state.instance.clone(), |
74 | // version: version(), |
75 | // }) |
76 | // .await |
77 | // .map_err(|e| HandshakeError::SendError(e))?; |
78 | |
79 | // Ok(()) |
80 | // } |
81 | |
82 | |
83 | async |
84 | Message | : ,
85 | State | : ,
86 | |
87 | connection_state |
88 | .send |
89 | .await |
90 | .map_err?; |
91 | |
92 | Ok |
93 | // if !validate_version(&response.version) { |
94 | // error!( |
95 | // "Version compatibility failure! Our Version: {}, Their Version: {}", |
96 | // Version::from_str(&std::env::var("CARGO_PKG_VERSION").unwrap()).unwrap(), |
97 | // response.version |
98 | // ); |
99 | |
100 | // connection_state |
101 | // .send(HandshakeFinalize { success: false }) |
102 | // .await |
103 | // .map_err(|e| HandshakeError::SendError(e))?; |
104 | |
105 | // Ok(()) |
106 | // } else { |
107 | // connection_state |
108 | // .send(HandshakeFinalize { success: true }) |
109 | // .await |
110 | // .map_err(|e| HandshakeError::SendError(e))?; |
111 | |
112 | // Ok(()) |
113 | // } |
114 | |
115 | |
116 | async |
117 | Message | : ,
118 | State | : ,
119 | |
120 | connection_state.handshaked.store; |
121 | |
122 | connection_state |
123 | .send |
124 | .await |
125 | .map_err?; |
126 | |
127 | Ok |
128 | // if !finalize.success { |
129 | // error!("Error during handshake, aborting connection"); |
130 | // return Err(Error::from(ConnectionError::Shutdown).into()); |
131 | // } else { |
132 | // connection_state.handshaked.store(true, Ordering::SeqCst); |
133 | |
134 | // connection_state |
135 | // .send(HandshakeFinalize { success: true }) |
136 | // .await |
137 | // .map_err(|e| HandshakeError::SendError(e))?; |
138 | |
139 | // Ok(()) |
140 | // } |
141 | |
142 | |
143 | |
144 | |
145 | |
146 | VersionMismatch, |
147 | |
148 | SendError, |
149 | |
150 | Other, |
151 | |
152 |