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