aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfx <[email protected]>2023-10-08 23:28:10 +0200
committerfx <[email protected]>2023-10-08 23:28:10 +0200
commit920496c85bdf0d017eaf837cbacd136d7d828669 (patch)
tree78e0cd32933d214fd16ad18a333cf7f1ade5a754
parent88bedad2d7c061b707e83d80aa6f0e51817586df (diff)
downloadwebol-920496c85bdf0d017eaf837cbacd136d7d828669.tar
webol-920496c85bdf0d017eaf837cbacd136d7d828669.tar.gz
webol-920496c85bdf0d017eaf837cbacd136d7d828669.zip
base web server
-rw-r--r--.gitignore6
-rw-r--r--Cargo.lock993
-rw-r--r--Cargo.toml15
-rw-r--r--src/auth.rs3
-rw-r--r--src/config.rs0
-rw-r--r--src/main.rs43
-rw-r--r--src/routes/mod.rs1
-rw-r--r--src/routes/start.rs29
8 files changed, 1086 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 6985cf1..af9826a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,12 +3,10 @@
3debug/ 3debug/
4target/ 4target/
5 5
6# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
7# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
8Cargo.lock
9
10# These are backup files generated by rustfmt 6# These are backup files generated by rustfmt
11**/*.rs.bk 7**/*.rs.bk
12 8
13# MSVC Windows builds of rustc generate these, which store debugging information 9# MSVC Windows builds of rustc generate these, which store debugging information
14*.pdb 10*.pdb
11
12.idea \ No newline at end of file
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 0000000..47552e5
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,993 @@
1# This file is automatically @generated by Cargo.
2# It is not intended for manual editing.
3version = 3
4
5[[package]]
6name = "addr2line"
7version = "0.21.0"
8source = "registry+https://github.com/rust-lang/crates.io-index"
9checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
10dependencies = [
11 "gimli",
12]
13
14[[package]]
15name = "adler"
16version = "1.0.2"
17source = "registry+https://github.com/rust-lang/crates.io-index"
18checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
19
20[[package]]
21name = "aho-corasick"
22version = "1.1.1"
23source = "registry+https://github.com/rust-lang/crates.io-index"
24checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab"
25dependencies = [
26 "memchr",
27]
28
29[[package]]
30name = "async-trait"
31version = "0.1.73"
32source = "registry+https://github.com/rust-lang/crates.io-index"
33checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0"
34dependencies = [
35 "proc-macro2",
36 "quote",
37 "syn",
38]
39
40[[package]]
41name = "axum"
42version = "0.6.20"
43source = "registry+https://github.com/rust-lang/crates.io-index"
44checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf"
45dependencies = [
46 "async-trait",
47 "axum-core",
48 "bitflags",
49 "bytes",
50 "futures-util",
51 "headers",
52 "http",
53 "http-body",
54 "hyper",
55 "itoa",
56 "matchit",
57 "memchr",
58 "mime",
59 "percent-encoding",
60 "pin-project-lite",
61 "rustversion",
62 "serde",
63 "serde_json",
64 "serde_path_to_error",
65 "serde_urlencoded",
66 "sync_wrapper",
67 "tokio",
68 "tower",
69 "tower-layer",
70 "tower-service",
71 "tracing",
72]
73
74[[package]]
75name = "axum-core"
76version = "0.3.4"
77source = "registry+https://github.com/rust-lang/crates.io-index"
78checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c"
79dependencies = [
80 "async-trait",
81 "bytes",
82 "futures-util",
83 "http",
84 "http-body",
85 "mime",
86 "rustversion",
87 "tower-layer",
88 "tower-service",
89 "tracing",
90]
91
92[[package]]
93name = "backtrace"
94version = "0.3.69"
95source = "registry+https://github.com/rust-lang/crates.io-index"
96checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
97dependencies = [
98 "addr2line",
99 "cc",
100 "cfg-if",
101 "libc",
102 "miniz_oxide",
103 "object",
104 "rustc-demangle",
105]
106
107[[package]]
108name = "base64"
109version = "0.21.4"
110source = "registry+https://github.com/rust-lang/crates.io-index"
111checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2"
112
113[[package]]
114name = "bitflags"
115version = "1.3.2"
116source = "registry+https://github.com/rust-lang/crates.io-index"
117checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
118
119[[package]]
120name = "block-buffer"
121version = "0.10.4"
122source = "registry+https://github.com/rust-lang/crates.io-index"
123checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
124dependencies = [
125 "generic-array",
126]
127
128[[package]]
129name = "bytes"
130version = "1.5.0"
131source = "registry+https://github.com/rust-lang/crates.io-index"
132checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
133
134[[package]]
135name = "cc"
136version = "1.0.83"
137source = "registry+https://github.com/rust-lang/crates.io-index"
138checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
139dependencies = [
140 "libc",
141]
142
143[[package]]
144name = "cfg-if"
145version = "1.0.0"
146source = "registry+https://github.com/rust-lang/crates.io-index"
147checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
148
149[[package]]
150name = "cpufeatures"
151version = "0.2.9"
152source = "registry+https://github.com/rust-lang/crates.io-index"
153checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1"
154dependencies = [
155 "libc",
156]
157
158[[package]]
159name = "crypto-common"
160version = "0.1.6"
161source = "registry+https://github.com/rust-lang/crates.io-index"
162checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
163dependencies = [
164 "generic-array",
165 "typenum",
166]
167
168[[package]]
169name = "deranged"
170version = "0.3.8"
171source = "registry+https://github.com/rust-lang/crates.io-index"
172checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946"
173
174[[package]]
175name = "digest"
176version = "0.10.7"
177source = "registry+https://github.com/rust-lang/crates.io-index"
178checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
179dependencies = [
180 "block-buffer",
181 "crypto-common",
182]
183
184[[package]]
185name = "fnv"
186version = "1.0.7"
187source = "registry+https://github.com/rust-lang/crates.io-index"
188checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
189
190[[package]]
191name = "form_urlencoded"
192version = "1.2.0"
193source = "registry+https://github.com/rust-lang/crates.io-index"
194checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652"
195dependencies = [
196 "percent-encoding",
197]
198
199[[package]]
200name = "futures-channel"
201version = "0.3.28"
202source = "registry+https://github.com/rust-lang/crates.io-index"
203checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2"
204dependencies = [
205 "futures-core",
206]
207
208[[package]]
209name = "futures-core"
210version = "0.3.28"
211source = "registry+https://github.com/rust-lang/crates.io-index"
212checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c"
213
214[[package]]
215name = "futures-task"
216version = "0.3.28"
217source = "registry+https://github.com/rust-lang/crates.io-index"
218checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65"
219
220[[package]]
221name = "futures-util"
222version = "0.3.28"
223source = "registry+https://github.com/rust-lang/crates.io-index"
224checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533"
225dependencies = [
226 "futures-core",
227 "futures-task",
228 "pin-project-lite",
229 "pin-utils",
230]
231
232[[package]]
233name = "generic-array"
234version = "0.14.7"
235source = "registry+https://github.com/rust-lang/crates.io-index"
236checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
237dependencies = [
238 "typenum",
239 "version_check",
240]
241
242[[package]]
243name = "gimli"
244version = "0.28.0"
245source = "registry+https://github.com/rust-lang/crates.io-index"
246checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
247
248[[package]]
249name = "headers"
250version = "0.3.9"
251source = "registry+https://github.com/rust-lang/crates.io-index"
252checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270"
253dependencies = [
254 "base64",
255 "bytes",
256 "headers-core",
257 "http",
258 "httpdate",
259 "mime",
260 "sha1",
261]
262
263[[package]]
264name = "headers-core"
265version = "0.2.0"
266source = "registry+https://github.com/rust-lang/crates.io-index"
267checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429"
268dependencies = [
269 "http",
270]
271
272[[package]]
273name = "hermit-abi"
274version = "0.3.3"
275source = "registry+https://github.com/rust-lang/crates.io-index"
276checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
277
278[[package]]
279name = "http"
280version = "0.2.9"
281source = "registry+https://github.com/rust-lang/crates.io-index"
282checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482"
283dependencies = [
284 "bytes",
285 "fnv",
286 "itoa",
287]
288
289[[package]]
290name = "http-body"
291version = "0.4.5"
292source = "registry+https://github.com/rust-lang/crates.io-index"
293checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1"
294dependencies = [
295 "bytes",
296 "http",
297 "pin-project-lite",
298]
299
300[[package]]
301name = "httparse"
302version = "1.8.0"
303source = "registry+https://github.com/rust-lang/crates.io-index"
304checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904"
305
306[[package]]
307name = "httpdate"
308version = "1.0.3"
309source = "registry+https://github.com/rust-lang/crates.io-index"
310checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
311
312[[package]]
313name = "hyper"
314version = "0.14.27"
315source = "registry+https://github.com/rust-lang/crates.io-index"
316checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468"
317dependencies = [
318 "bytes",
319 "futures-channel",
320 "futures-core",
321 "futures-util",
322 "http",
323 "http-body",
324 "httparse",
325 "httpdate",
326 "itoa",
327 "pin-project-lite",
328 "socket2 0.4.9",
329 "tokio",
330 "tower-service",
331 "tracing",
332 "want",
333]
334
335[[package]]
336name = "itoa"
337version = "1.0.9"
338source = "registry+https://github.com/rust-lang/crates.io-index"
339checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
340
341[[package]]
342name = "lazy_static"
343version = "1.4.0"
344source = "registry+https://github.com/rust-lang/crates.io-index"
345checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
346
347[[package]]
348name = "libc"
349version = "0.2.149"
350source = "registry+https://github.com/rust-lang/crates.io-index"
351checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b"
352
353[[package]]
354name = "log"
355version = "0.4.20"
356source = "registry+https://github.com/rust-lang/crates.io-index"
357checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
358
359[[package]]
360name = "matchers"
361version = "0.1.0"
362source = "registry+https://github.com/rust-lang/crates.io-index"
363checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
364dependencies = [
365 "regex-automata 0.1.10",
366]
367
368[[package]]
369name = "matchit"
370version = "0.7.3"
371source = "registry+https://github.com/rust-lang/crates.io-index"
372checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
373
374[[package]]
375name = "memchr"
376version = "2.6.4"
377source = "registry+https://github.com/rust-lang/crates.io-index"
378checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
379
380[[package]]
381name = "mime"
382version = "0.3.17"
383source = "registry+https://github.com/rust-lang/crates.io-index"
384checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
385
386[[package]]
387name = "miniz_oxide"
388version = "0.7.1"
389source = "registry+https://github.com/rust-lang/crates.io-index"
390checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
391dependencies = [
392 "adler",
393]
394
395[[package]]
396name = "mio"
397version = "0.8.8"
398source = "registry+https://github.com/rust-lang/crates.io-index"
399checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2"
400dependencies = [
401 "libc",
402 "wasi",
403 "windows-sys",
404]
405
406[[package]]
407name = "nu-ansi-term"
408version = "0.46.0"
409source = "registry+https://github.com/rust-lang/crates.io-index"
410checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
411dependencies = [
412 "overload",
413 "winapi",
414]
415
416[[package]]
417name = "num_cpus"
418version = "1.16.0"
419source = "registry+https://github.com/rust-lang/crates.io-index"
420checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
421dependencies = [
422 "hermit-abi",
423 "libc",
424]
425
426[[package]]
427name = "num_threads"
428version = "0.1.6"
429source = "registry+https://github.com/rust-lang/crates.io-index"
430checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44"
431dependencies = [
432 "libc",
433]
434
435[[package]]
436name = "object"
437version = "0.32.1"
438source = "registry+https://github.com/rust-lang/crates.io-index"
439checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
440dependencies = [
441 "memchr",
442]
443
444[[package]]
445name = "once_cell"
446version = "1.18.0"
447source = "registry+https://github.com/rust-lang/crates.io-index"
448checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
449
450[[package]]
451name = "overload"
452version = "0.1.1"
453source = "registry+https://github.com/rust-lang/crates.io-index"
454checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
455
456[[package]]
457name = "percent-encoding"
458version = "2.3.0"
459source = "registry+https://github.com/rust-lang/crates.io-index"
460checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94"
461
462[[package]]
463name = "pin-project"
464version = "1.1.3"
465source = "registry+https://github.com/rust-lang/crates.io-index"
466checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422"
467dependencies = [
468 "pin-project-internal",
469]
470
471[[package]]
472name = "pin-project-internal"
473version = "1.1.3"
474source = "registry+https://github.com/rust-lang/crates.io-index"
475checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405"
476dependencies = [
477 "proc-macro2",
478 "quote",
479 "syn",
480]
481
482[[package]]
483name = "pin-project-lite"
484version = "0.2.13"
485source = "registry+https://github.com/rust-lang/crates.io-index"
486checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
487
488[[package]]
489name = "pin-utils"
490version = "0.1.0"
491source = "registry+https://github.com/rust-lang/crates.io-index"
492checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
493
494[[package]]
495name = "proc-macro2"
496version = "1.0.68"
497source = "registry+https://github.com/rust-lang/crates.io-index"
498checksum = "5b1106fec09662ec6dd98ccac0f81cef56984d0b49f75c92d8cbad76e20c005c"
499dependencies = [
500 "unicode-ident",
501]
502
503[[package]]
504name = "quote"
505version = "1.0.33"
506source = "registry+https://github.com/rust-lang/crates.io-index"
507checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
508dependencies = [
509 "proc-macro2",
510]
511
512[[package]]
513name = "regex"
514version = "1.9.6"
515source = "registry+https://github.com/rust-lang/crates.io-index"
516checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff"
517dependencies = [
518 "aho-corasick",
519 "memchr",
520 "regex-automata 0.3.9",
521 "regex-syntax 0.7.5",
522]
523
524[[package]]
525name = "regex-automata"
526version = "0.1.10"
527source = "registry+https://github.com/rust-lang/crates.io-index"
528checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
529dependencies = [
530 "regex-syntax 0.6.29",
531]
532
533[[package]]
534name = "regex-automata"
535version = "0.3.9"
536source = "registry+https://github.com/rust-lang/crates.io-index"
537checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9"
538dependencies = [
539 "aho-corasick",
540 "memchr",
541 "regex-syntax 0.7.5",
542]
543
544[[package]]
545name = "regex-syntax"
546version = "0.6.29"
547source = "registry+https://github.com/rust-lang/crates.io-index"
548checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
549
550[[package]]
551name = "regex-syntax"
552version = "0.7.5"
553source = "registry+https://github.com/rust-lang/crates.io-index"
554checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
555
556[[package]]
557name = "rustc-demangle"
558version = "0.1.23"
559source = "registry+https://github.com/rust-lang/crates.io-index"
560checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
561
562[[package]]
563name = "rustversion"
564version = "1.0.14"
565source = "registry+https://github.com/rust-lang/crates.io-index"
566checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
567
568[[package]]
569name = "ryu"
570version = "1.0.15"
571source = "registry+https://github.com/rust-lang/crates.io-index"
572checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
573
574[[package]]
575name = "serde"
576version = "1.0.188"
577source = "registry+https://github.com/rust-lang/crates.io-index"
578checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
579dependencies = [
580 "serde_derive",
581]
582
583[[package]]
584name = "serde_derive"
585version = "1.0.188"
586source = "registry+https://github.com/rust-lang/crates.io-index"
587checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
588dependencies = [
589 "proc-macro2",
590 "quote",
591 "syn",
592]
593
594[[package]]
595name = "serde_json"
596version = "1.0.107"
597source = "registry+https://github.com/rust-lang/crates.io-index"
598checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65"
599dependencies = [
600 "itoa",
601 "ryu",
602 "serde",
603]
604
605[[package]]
606name = "serde_path_to_error"
607version = "0.1.14"
608source = "registry+https://github.com/rust-lang/crates.io-index"
609checksum = "4beec8bce849d58d06238cb50db2e1c417cfeafa4c63f692b15c82b7c80f8335"
610dependencies = [
611 "itoa",
612 "serde",
613]
614
615[[package]]
616name = "serde_urlencoded"
617version = "0.7.1"
618source = "registry+https://github.com/rust-lang/crates.io-index"
619checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
620dependencies = [
621 "form_urlencoded",
622 "itoa",
623 "ryu",
624 "serde",
625]
626
627[[package]]
628name = "sha1"
629version = "0.10.5"
630source = "registry+https://github.com/rust-lang/crates.io-index"
631checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3"
632dependencies = [
633 "cfg-if",
634 "cpufeatures",
635 "digest",
636]
637
638[[package]]
639name = "sharded-slab"
640version = "0.1.7"
641source = "registry+https://github.com/rust-lang/crates.io-index"
642checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
643dependencies = [
644 "lazy_static",
645]
646
647[[package]]
648name = "smallvec"
649version = "1.11.1"
650source = "registry+https://github.com/rust-lang/crates.io-index"
651checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
652
653[[package]]
654name = "socket2"
655version = "0.4.9"
656source = "registry+https://github.com/rust-lang/crates.io-index"
657checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662"
658dependencies = [
659 "libc",
660 "winapi",
661]
662
663[[package]]
664name = "socket2"
665version = "0.5.4"
666source = "registry+https://github.com/rust-lang/crates.io-index"
667checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e"
668dependencies = [
669 "libc",
670 "windows-sys",
671]
672
673[[package]]
674name = "syn"
675version = "2.0.38"
676source = "registry+https://github.com/rust-lang/crates.io-index"
677checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b"
678dependencies = [
679 "proc-macro2",
680 "quote",
681 "unicode-ident",
682]
683
684[[package]]
685name = "sync_wrapper"
686version = "0.1.2"
687source = "registry+https://github.com/rust-lang/crates.io-index"
688checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
689
690[[package]]
691name = "thread_local"
692version = "1.1.7"
693source = "registry+https://github.com/rust-lang/crates.io-index"
694checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152"
695dependencies = [
696 "cfg-if",
697 "once_cell",
698]
699
700[[package]]
701name = "time"
702version = "0.3.29"
703source = "registry+https://github.com/rust-lang/crates.io-index"
704checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe"
705dependencies = [
706 "deranged",
707 "itoa",
708 "libc",
709 "num_threads",
710 "serde",
711 "time-core",
712 "time-macros",
713]
714
715[[package]]
716name = "time-core"
717version = "0.1.2"
718source = "registry+https://github.com/rust-lang/crates.io-index"
719checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
720
721[[package]]
722name = "time-macros"
723version = "0.2.15"
724source = "registry+https://github.com/rust-lang/crates.io-index"
725checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20"
726dependencies = [
727 "time-core",
728]
729
730[[package]]
731name = "tokio"
732version = "1.32.0"
733source = "registry+https://github.com/rust-lang/crates.io-index"
734checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9"
735dependencies = [
736 "backtrace",
737 "libc",
738 "mio",
739 "num_cpus",
740 "pin-project-lite",
741 "socket2 0.5.4",
742 "tokio-macros",
743 "windows-sys",
744]
745
746[[package]]
747name = "tokio-macros"
748version = "2.1.0"
749source = "registry+https://github.com/rust-lang/crates.io-index"
750checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
751dependencies = [
752 "proc-macro2",
753 "quote",
754 "syn",
755]
756
757[[package]]
758name = "tower"
759version = "0.4.13"
760source = "registry+https://github.com/rust-lang/crates.io-index"
761checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
762dependencies = [
763 "futures-core",
764 "futures-util",
765 "pin-project",
766 "pin-project-lite",
767 "tokio",
768 "tower-layer",
769 "tower-service",
770 "tracing",
771]
772
773[[package]]
774name = "tower-layer"
775version = "0.3.2"
776source = "registry+https://github.com/rust-lang/crates.io-index"
777checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"
778
779[[package]]
780name = "tower-service"
781version = "0.3.2"
782source = "registry+https://github.com/rust-lang/crates.io-index"
783checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52"
784
785[[package]]
786name = "tracing"
787version = "0.1.37"
788source = "registry+https://github.com/rust-lang/crates.io-index"
789checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
790dependencies = [
791 "cfg-if",
792 "log",
793 "pin-project-lite",
794 "tracing-attributes",
795 "tracing-core",
796]
797
798[[package]]
799name = "tracing-attributes"
800version = "0.1.26"
801source = "registry+https://github.com/rust-lang/crates.io-index"
802checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab"
803dependencies = [
804 "proc-macro2",
805 "quote",
806 "syn",
807]
808
809[[package]]
810name = "tracing-core"
811version = "0.1.31"
812source = "registry+https://github.com/rust-lang/crates.io-index"
813checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a"
814dependencies = [
815 "once_cell",
816 "valuable",
817]
818
819[[package]]
820name = "tracing-log"
821version = "0.1.3"
822source = "registry+https://github.com/rust-lang/crates.io-index"
823checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
824dependencies = [
825 "lazy_static",
826 "log",
827 "tracing-core",
828]
829
830[[package]]
831name = "tracing-subscriber"
832version = "0.3.17"
833source = "registry+https://github.com/rust-lang/crates.io-index"
834checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77"
835dependencies = [
836 "matchers",
837 "nu-ansi-term",
838 "once_cell",
839 "regex",
840 "sharded-slab",
841 "smallvec",
842 "thread_local",
843 "time",
844 "tracing",
845 "tracing-core",
846 "tracing-log",
847]
848
849[[package]]
850name = "try-lock"
851version = "0.2.4"
852source = "registry+https://github.com/rust-lang/crates.io-index"
853checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
854
855[[package]]
856name = "typenum"
857version = "1.17.0"
858source = "registry+https://github.com/rust-lang/crates.io-index"
859checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
860
861[[package]]
862name = "unicode-ident"
863version = "1.0.12"
864source = "registry+https://github.com/rust-lang/crates.io-index"
865checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
866
867[[package]]
868name = "valuable"
869version = "0.1.0"
870source = "registry+https://github.com/rust-lang/crates.io-index"
871checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
872
873[[package]]
874name = "version_check"
875version = "0.9.4"
876source = "registry+https://github.com/rust-lang/crates.io-index"
877checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
878
879[[package]]
880name = "want"
881version = "0.3.1"
882source = "registry+https://github.com/rust-lang/crates.io-index"
883checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e"
884dependencies = [
885 "try-lock",
886]
887
888[[package]]
889name = "wasi"
890version = "0.11.0+wasi-snapshot-preview1"
891source = "registry+https://github.com/rust-lang/crates.io-index"
892checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
893
894[[package]]
895name = "webol"
896version = "0.1.0"
897dependencies = [
898 "axum",
899 "serde",
900 "serde_json",
901 "time",
902 "tokio",
903 "tracing",
904 "tracing-subscriber",
905]
906
907[[package]]
908name = "winapi"
909version = "0.3.9"
910source = "registry+https://github.com/rust-lang/crates.io-index"
911checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
912dependencies = [
913 "winapi-i686-pc-windows-gnu",
914 "winapi-x86_64-pc-windows-gnu",
915]
916
917[[package]]
918name = "winapi-i686-pc-windows-gnu"
919version = "0.4.0"
920source = "registry+https://github.com/rust-lang/crates.io-index"
921checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
922
923[[package]]
924name = "winapi-x86_64-pc-windows-gnu"
925version = "0.4.0"
926source = "registry+https://github.com/rust-lang/crates.io-index"
927checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
928
929[[package]]
930name = "windows-sys"
931version = "0.48.0"
932source = "registry+https://github.com/rust-lang/crates.io-index"
933checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
934dependencies = [
935 "windows-targets",
936]
937
938[[package]]
939name = "windows-targets"
940version = "0.48.5"
941source = "registry+https://github.com/rust-lang/crates.io-index"
942checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
943dependencies = [
944 "windows_aarch64_gnullvm",
945 "windows_aarch64_msvc",
946 "windows_i686_gnu",
947 "windows_i686_msvc",
948 "windows_x86_64_gnu",
949 "windows_x86_64_gnullvm",
950 "windows_x86_64_msvc",
951]
952
953[[package]]
954name = "windows_aarch64_gnullvm"
955version = "0.48.5"
956source = "registry+https://github.com/rust-lang/crates.io-index"
957checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
958
959[[package]]
960name = "windows_aarch64_msvc"
961version = "0.48.5"
962source = "registry+https://github.com/rust-lang/crates.io-index"
963checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
964
965[[package]]
966name = "windows_i686_gnu"
967version = "0.48.5"
968source = "registry+https://github.com/rust-lang/crates.io-index"
969checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
970
971[[package]]
972name = "windows_i686_msvc"
973version = "0.48.5"
974source = "registry+https://github.com/rust-lang/crates.io-index"
975checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
976
977[[package]]
978name = "windows_x86_64_gnu"
979version = "0.48.5"
980source = "registry+https://github.com/rust-lang/crates.io-index"
981checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
982
983[[package]]
984name = "windows_x86_64_gnullvm"
985version = "0.48.5"
986source = "registry+https://github.com/rust-lang/crates.io-index"
987checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
988
989[[package]]
990name = "windows_x86_64_msvc"
991version = "0.48.5"
992source = "registry+https://github.com/rust-lang/crates.io-index"
993checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..d0ba7b1
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,15 @@
1[package]
2name = "webol"
3version = "0.1.0"
4edition = "2021"
5
6# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
8[dependencies]
9axum = { version = "0.6.20", features = ["tracing", "headers"] }
10tokio = { version = "1.32.0", features = ["macros", "rt-multi-thread"] }
11tracing = "0.1.37"
12tracing-subscriber = { version = "0.3.17", features = ["env-filter", "local-time", "time"] }
13time = { version = "0.3.29", features = ["macros"] }
14serde = { version = "1.0.188", features = ["derive"] }
15serde_json = "1.0.107"
diff --git a/src/auth.rs b/src/auth.rs
new file mode 100644
index 0000000..b1ad76d
--- /dev/null
+++ b/src/auth.rs
@@ -0,0 +1,3 @@
1pub fn auth(secret: &str) -> bool {
2 secret == "aaa"
3}
diff --git a/src/config.rs b/src/config.rs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/config.rs
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..60f2214
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,43 @@
1use axum::{Router, routing::post};
2use time::util::local_offset;
3use tracing::{info, level_filters::LevelFilter};
4use tracing_subscriber::{EnvFilter, fmt::{self, time::LocalTime}, prelude::*};
5use crate::routes::start::start;
6
7mod auth;
8mod routes;
9
10#[tokio::main]
11async fn main() {
12
13 unsafe { local_offset::set_soundness(local_offset::Soundness::Unsound); }
14 let time_format =
15 time::macros::format_description!("[year]-[month]-[day] [hour]:[minute]:[second]");
16 let loc = LocalTime::new(time_format);
17
18 tracing_subscriber::registry()
19 .with(fmt::layer()
20 .with_timer(loc)
21 )
22 .with(
23 EnvFilter::builder()
24 .with_default_directive(LevelFilter::INFO.into())
25 .from_env_lossy(),
26 )
27 .init();
28
29 let version = env!("CARGO_PKG_VERSION");
30
31 info!("Starting webol v{}", version);
32
33 // build our application with a single route
34 let app = Router::new()
35 .route("/start", post(start));
36
37 // run it with hyper on localhost:3000
38 axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
39 .serve(app.into_make_service())
40 .await
41 .unwrap();
42}
43
diff --git a/src/routes/mod.rs b/src/routes/mod.rs
new file mode 100644
index 0000000..78d4375
--- /dev/null
+++ b/src/routes/mod.rs
@@ -0,0 +1 @@
pub mod start; \ No newline at end of file
diff --git a/src/routes/start.rs b/src/routes/start.rs
new file mode 100644
index 0000000..cda6352
--- /dev/null
+++ b/src/routes/start.rs
@@ -0,0 +1,29 @@
1use axum::headers::HeaderMap;
2use axum::Json;
3use serde::{Deserialize, Serialize};
4use serde_json::{json, Value};
5use crate::auth::auth;
6
7pub async fn start(headers: HeaderMap, Json(payload): Json<StartPayload>) -> Json<Value> {
8 let mut res = StartResponse { id: payload.id, boot: false };
9 if let Some(secret) = headers.get("authorization") {
10 if !auth(secret.to_str().unwrap()) { Json(json!(res)) } else {
11 res.boot = true;
12 Json(json!(res))
13 }
14 } else {
15 Json(json!(res))
16 }
17}
18
19#[derive(Deserialize)]
20pub struct StartPayload {
21 id: String,
22 _test: Option<bool>,
23}
24
25#[derive(Serialize)]
26struct StartResponse {
27 id: String,
28 boot: bool,
29}