Major post-refactor cleanup
parent: tbd commit: f90d7fb
1 | use |
2 | , | SocketAddr
3 | |
4 | , |
5 | Arc, |
6 | , |
7 | ; |
8 | |
9 | use Error; |
10 | use ; |
11 | use Serialize; |
12 | use ; |
13 | use ; |
14 | |
15 | use crate:: |
16 | , | AuthenticationTokenGranter
17 | , |
18 | , |
19 | ; |
20 | |
21 | use |
22 | , handshake_handle, | authentication_handle
23 | , user_handle, Connections, | repository_handle
24 | ; |
25 | |
26 | pub async |
27 | socket: , |
28 | connections: , |
29 | repository_backend: , |
30 | user_backend: , |
31 | auth_granter: , |
32 | addr: SocketAddr, |
33 | instance: impl , |
34 | |
35 | let connection_state = ConnectionState |
36 | socket: new, |
37 | connections, |
38 | repository_backend, |
39 | user_backend, |
40 | auth_granter, |
41 | addr, |
42 | instance: instance.to_owned, |
43 | handshaked: new, |
44 | ; |
45 | |
46 | let mut handshaked = false; |
47 | |
48 | loop |
49 | let mut socket = connection_state.socket.lock .await; |
50 | let message = socket.next .await; |
51 | drop; |
52 | |
53 | match message |
54 | Some => |
55 | let payload = match message |
56 | => payload, | Binary
57 | => | Ping
58 | let mut socket = connection_state.socket.lock .await; |
59 | let _ = socket.send .await; |
60 | drop; |
61 | continue; |
62 | |
63 | => return, | Close
64 | _ => continue, |
65 | ; |
66 | |
67 | let message = NetworkMessage; |
68 | |
69 | if !handshaked |
70 | if handshake_handle .await.is_ok |
71 | if connection_state.handshaked.load |
72 | handshaked = true; |
73 | |
74 | |
75 | else |
76 | if authentication_handle |
77 | .await |
78 | .is_ok |
79 | |
80 | continue; |
81 | else if repository_handle .await.is_ok |
82 | continue; |
83 | else if user_handle .await.is_ok |
84 | continue; |
85 | else |
86 | error!; |
87 | continue; |
88 | |
89 | |
90 | |
91 | _ => |
92 | error!; |
93 | return; |
94 | |
95 | |
96 | |
97 | |
98 | |
99 | |
100 | |
101 | socket: , |
102 | pub connections: , |
103 | pub repository_backend: , |
104 | pub user_backend: , |
105 | pub auth_granter: , |
106 | pub addr: SocketAddr, |
107 | pub instance: Instance, |
108 | pub handshaked: , |
109 | |
110 | |
111 | |
112 | pub async |
113 | self.socket |
114 | .lock |
115 | .await |
116 | .send |
117 | .await?; |
118 | |
119 | Ok |
120 | |
121 | |
122 |