Add token extension
parent: tbd commit: 86d028f
1 | use ; |
2 | |
3 | use ; |
4 | use |
5 | , | AuthenticationTokenGranter
6 | , |
7 | connection, listener, |
8 | ; |
9 | use Listeners; |
10 | use ; |
11 | use |
12 | , | File
13 | , |
14 | , |
15 | , | Mutex
16 | ; |
17 | use ; |
18 | use Table; |
19 | |
20 | |
21 | extern crate tracing; |
22 | |
23 | |
24 | async |
25 | ; | init
26 | let mut listener = bind .await?; |
27 | let connections: = default; |
28 | let listeners: = default; |
29 | let config: Table = |
30 | let mut file = open .await?; |
31 | let mut text = String new; |
32 | file.read_to_string .await?; |
33 | text.parse? |
34 | ; |
35 | let db_conn_options = new |
36 | .host |
37 | .port |
38 | .database |
39 | .username |
40 | .password |
41 | .log_statements; |
42 | let db_pool = connect_with .await?; |
43 | |
44 | debug!; |
45 | ! .run .await?; | migrate
46 | info!; |
47 | |
48 | let repository_backend: = new |
49 | let foo: GitBackend = GitBackend |
50 | pg_pool: db_pool, |
51 | repository_folder: String from, |
52 | ; |
53 | foo |
54 | ; |
55 | |
56 | let token_granter = new |
57 | config: config.clone, |
58 | ; |
59 | |
60 | info!; |
61 | |
62 | loop |
63 | let stream = accept_stream .await; |
64 | info!; |
65 | |
66 | let = match stream |
67 | Ok => stream, |
68 | Err => |
69 | error!; |
70 | continue; |
71 | |
72 | ; |
73 | |
74 | info!; |
75 | |
76 | let connection = accept_websocket_connection .await; |
77 | |
78 | let connection = match connection |
79 | Ok => connection, |
80 | Err => |
81 | error! |
82 | "Failed to initiate Websocket connection from {}. {:?}", |
83 | address, err |
84 | ; |
85 | continue; |
86 | |
87 | ; |
88 | |
89 | info!; |
90 | |
91 | let connection = RawConnection |
92 | task: spawn |
93 | connection, |
94 | listeners.clone, |
95 | connections.clone, |
96 | repository_backend.clone, |
97 | token_granter.clone, |
98 | address, |
99 | , |
100 | ; |
101 | |
102 | connections.lock .await.connections.push; |
103 | |
104 | |
105 | |
106 | async |
107 | listener: &mut TcpListener, |
108 | |
109 | let stream = listener.accept .await?; |
110 | |
111 | Ok |
112 | |
113 | |
114 | async |
115 | stream: S, |
116 | |
117 | let connection = accept_async .await?; |
118 | |
119 | Ok |
120 | |
121 |