+5
.github/ISSUE_TEMPLATE/config.yml
+5
.github/ISSUE_TEMPLATE/config.yml
+2
.github/workflows/rust.yml
+2
.github/workflows/rust.yml
+26
-3
CHANGELOG.md
+26
-3
CHANGELOG.md
···
2
2
3
3
## [Unreleased] - _TBD_
4
4
5
+
## [v0.4.0] - 2024-03-19
6
+
7
+
### Added
8
+
9
+
- Implemented the function histories command.
10
+
- Configurable time limits.
11
+
12
+
### Fixed
13
+
14
+
- RPC HelloResult will now report if deletes are enabled.
15
+
16
+
### Changes
17
+
18
+
- Applied code formatting using `cargo fmt`
19
+
5
20
## [v0.3.0] - 2023-08-22
21
+
6
22
### Added
23
+
7
24
- This changelog.
8
25
- Support for IDA 8.1+ delete command.
9
26
- Pooling for connections to database.
···
13
30
- Add Metrics for prometheus.
14
31
15
32
### Fixed
33
+
16
34
- 8K stack size is too small for debug builds.
17
35
18
36
## [v0.2.0] - 2022-10-12
37
+
19
38
### Added
39
+
20
40
- Protocol: support for IDA 8.1+ user authentication.
21
41
- Client connection duration limitations.
42
+
22
43
### Changed
44
+
23
45
- Tokio's thread size is reduced from 4M to 8K.
24
46
25
-
## [v0.1.0] - 2021-01-21
47
+
## [v0.1.0] - 2021-01-21
48
+
26
49
This is Lumen's first tagged release. It contains a few fixes and dependency updates since the initial commit (2020-12-17).
27
50
28
-
29
-
[Unreleased]: https://github.com/naim94a/lumen/compare/v0.3.0...HEAD
51
+
[Unreleased]: https://github.com/naim94a/lumen/compare/v0.4.0...HEAD
52
+
[v0.4.0]: https://github.com/naim94a/lumen/compare/v0.3.0...v0.4.0
30
53
[v0.3.0]: https://github.com/naim94a/lumen/compare/v0.2.0...v0.3.0
31
54
[v0.2.0]: https://github.com/naim94a/lumen/compare/v0.1.0...v0.2.0
32
55
[v0.1.0]: https://github.com/naim94a/lumen/releases/tag/v0.1.0
+587
-425
Cargo.lock
+587
-425
Cargo.lock
···
4
4
5
5
[[package]]
6
6
name = "addr2line"
7
-
version = "0.20.0"
7
+
version = "0.22.0"
8
8
source = "registry+https://github.com/rust-lang/crates.io-index"
9
-
checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3"
9
+
checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678"
10
10
dependencies = [
11
11
"gimli",
12
12
]
···
19
19
20
20
[[package]]
21
21
name = "aho-corasick"
22
-
version = "1.0.4"
22
+
version = "1.1.3"
23
23
source = "registry+https://github.com/rust-lang/crates.io-index"
24
-
checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a"
24
+
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
25
25
dependencies = [
26
26
"memchr",
27
27
]
28
28
29
29
[[package]]
30
30
name = "anstream"
31
-
version = "0.3.2"
31
+
version = "0.6.15"
32
32
source = "registry+https://github.com/rust-lang/crates.io-index"
33
-
checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163"
33
+
checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"
34
34
dependencies = [
35
35
"anstyle",
36
36
"anstyle-parse",
37
37
"anstyle-query",
38
38
"anstyle-wincon",
39
39
"colorchoice",
40
-
"is-terminal",
40
+
"is_terminal_polyfill",
41
41
"utf8parse",
42
42
]
43
43
44
44
[[package]]
45
45
name = "anstyle"
46
-
version = "1.0.1"
46
+
version = "1.0.8"
47
47
source = "registry+https://github.com/rust-lang/crates.io-index"
48
-
checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd"
48
+
checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
49
49
50
50
[[package]]
51
51
name = "anstyle-parse"
52
-
version = "0.2.1"
52
+
version = "0.2.5"
53
53
source = "registry+https://github.com/rust-lang/crates.io-index"
54
-
checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333"
54
+
checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb"
55
55
dependencies = [
56
56
"utf8parse",
57
57
]
58
58
59
59
[[package]]
60
60
name = "anstyle-query"
61
-
version = "1.0.0"
61
+
version = "1.1.1"
62
62
source = "registry+https://github.com/rust-lang/crates.io-index"
63
-
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
63
+
checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
64
64
dependencies = [
65
-
"windows-sys",
65
+
"windows-sys 0.52.0",
66
66
]
67
67
68
68
[[package]]
69
69
name = "anstyle-wincon"
70
-
version = "1.0.2"
70
+
version = "3.0.4"
71
71
source = "registry+https://github.com/rust-lang/crates.io-index"
72
-
checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c"
72
+
checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
73
73
dependencies = [
74
74
"anstyle",
75
-
"windows-sys",
75
+
"windows-sys 0.52.0",
76
76
]
77
77
78
78
[[package]]
79
79
name = "anyhow"
80
-
version = "1.0.75"
80
+
version = "1.0.86"
81
81
source = "registry+https://github.com/rust-lang/crates.io-index"
82
-
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
82
+
checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
83
83
84
84
[[package]]
85
85
name = "async-trait"
86
-
version = "0.1.73"
86
+
version = "0.1.81"
87
87
source = "registry+https://github.com/rust-lang/crates.io-index"
88
-
checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0"
88
+
checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107"
89
89
dependencies = [
90
90
"proc-macro2",
91
91
"quote",
···
94
94
95
95
[[package]]
96
96
name = "autocfg"
97
-
version = "1.1.0"
97
+
version = "1.3.0"
98
98
source = "registry+https://github.com/rust-lang/crates.io-index"
99
-
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
99
+
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
100
100
101
101
[[package]]
102
102
name = "backtrace"
103
-
version = "0.3.68"
103
+
version = "0.3.73"
104
104
source = "registry+https://github.com/rust-lang/crates.io-index"
105
-
checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12"
105
+
checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a"
106
106
dependencies = [
107
107
"addr2line",
108
108
"cc",
···
115
115
116
116
[[package]]
117
117
name = "base64"
118
-
version = "0.13.1"
118
+
version = "0.21.7"
119
119
source = "registry+https://github.com/rust-lang/crates.io-index"
120
-
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
120
+
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
121
121
122
122
[[package]]
123
123
name = "base64"
124
-
version = "0.21.2"
124
+
version = "0.22.1"
125
125
source = "registry+https://github.com/rust-lang/crates.io-index"
126
-
checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d"
126
+
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
127
127
128
128
[[package]]
129
129
name = "bb8"
130
-
version = "0.8.1"
130
+
version = "0.8.5"
131
131
source = "registry+https://github.com/rust-lang/crates.io-index"
132
-
checksum = "98b4b0f25f18bcdc3ac72bdb486ed0acf7e185221fd4dc985bc15db5800b0ba2"
132
+
checksum = "b10cf871f3ff2ce56432fddc2615ac7acc3aa22ca321f8fea800846fbb32f188"
133
133
dependencies = [
134
134
"async-trait",
135
-
"futures-channel",
136
135
"futures-util",
137
136
"parking_lot",
138
137
"tokio",
···
152
151
153
152
[[package]]
154
153
name = "bitflags"
155
-
version = "2.4.0"
154
+
version = "2.6.0"
156
155
source = "registry+https://github.com/rust-lang/crates.io-index"
157
-
checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
156
+
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
158
157
159
158
[[package]]
160
159
name = "block-buffer"
···
166
165
]
167
166
168
167
[[package]]
168
+
name = "bumpalo"
169
+
version = "3.16.0"
170
+
source = "registry+https://github.com/rust-lang/crates.io-index"
171
+
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
172
+
173
+
[[package]]
169
174
name = "byteorder"
170
-
version = "1.4.3"
175
+
version = "1.5.0"
171
176
source = "registry+https://github.com/rust-lang/crates.io-index"
172
-
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
177
+
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
173
178
174
179
[[package]]
175
180
name = "bytes"
176
-
version = "1.4.0"
181
+
version = "1.7.1"
177
182
source = "registry+https://github.com/rust-lang/crates.io-index"
178
-
checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
183
+
checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50"
179
184
180
185
[[package]]
181
186
name = "cc"
182
-
version = "1.0.82"
187
+
version = "1.1.10"
183
188
source = "registry+https://github.com/rust-lang/crates.io-index"
184
-
checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01"
185
-
dependencies = [
186
-
"libc",
187
-
]
189
+
checksum = "e9e8aabfac534be767c909e0690571677d49f41bd8465ae876fe043d52ba5292"
188
190
189
191
[[package]]
190
192
name = "cfg-if"
···
194
196
195
197
[[package]]
196
198
name = "clap"
197
-
version = "4.3.22"
199
+
version = "4.5.15"
198
200
source = "registry+https://github.com/rust-lang/crates.io-index"
199
-
checksum = "b417ae4361bca3f5de378294fc7472d3c4ed86a5ef9f49e93ae722f432aae8d2"
201
+
checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc"
200
202
dependencies = [
201
203
"clap_builder",
202
204
]
203
205
204
206
[[package]]
205
207
name = "clap_builder"
206
-
version = "4.3.22"
208
+
version = "4.5.15"
207
209
source = "registry+https://github.com/rust-lang/crates.io-index"
208
-
checksum = "9c90dc0f0e42c64bff177ca9d7be6fcc9ddb0f26a6e062174a61c84dd6c644d4"
210
+
checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6"
209
211
dependencies = [
210
212
"anstream",
211
213
"anstyle",
···
215
217
216
218
[[package]]
217
219
name = "clap_lex"
218
-
version = "0.5.0"
220
+
version = "0.7.2"
219
221
source = "registry+https://github.com/rust-lang/crates.io-index"
220
-
checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
222
+
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
221
223
222
224
[[package]]
223
225
name = "colorchoice"
224
-
version = "1.0.0"
226
+
version = "1.0.2"
225
227
source = "registry+https://github.com/rust-lang/crates.io-index"
226
-
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
228
+
checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
227
229
228
230
[[package]]
229
231
name = "common"
···
239
241
"postgres-native-tls",
240
242
"prometheus-client",
241
243
"serde",
244
+
"time",
242
245
"tokio",
243
246
"tokio-postgres",
244
247
"toml",
···
247
250
248
251
[[package]]
249
252
name = "core-foundation"
250
-
version = "0.9.3"
253
+
version = "0.9.4"
251
254
source = "registry+https://github.com/rust-lang/crates.io-index"
252
-
checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"
255
+
checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
253
256
dependencies = [
254
257
"core-foundation-sys",
255
258
"libc",
···
257
260
258
261
[[package]]
259
262
name = "core-foundation-sys"
260
-
version = "0.8.4"
263
+
version = "0.8.7"
261
264
source = "registry+https://github.com/rust-lang/crates.io-index"
262
-
checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
265
+
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
263
266
264
267
[[package]]
265
268
name = "cpufeatures"
266
-
version = "0.2.9"
269
+
version = "0.2.13"
267
270
source = "registry+https://github.com/rust-lang/crates.io-index"
268
-
checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1"
271
+
checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad"
269
272
dependencies = [
270
273
"libc",
271
274
]
···
281
284
]
282
285
283
286
[[package]]
287
+
name = "darling"
288
+
version = "0.20.10"
289
+
source = "registry+https://github.com/rust-lang/crates.io-index"
290
+
checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989"
291
+
dependencies = [
292
+
"darling_core",
293
+
"darling_macro",
294
+
]
295
+
296
+
[[package]]
297
+
name = "darling_core"
298
+
version = "0.20.10"
299
+
source = "registry+https://github.com/rust-lang/crates.io-index"
300
+
checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5"
301
+
dependencies = [
302
+
"fnv",
303
+
"ident_case",
304
+
"proc-macro2",
305
+
"quote",
306
+
"strsim",
307
+
"syn",
308
+
]
309
+
310
+
[[package]]
311
+
name = "darling_macro"
312
+
version = "0.20.10"
313
+
source = "registry+https://github.com/rust-lang/crates.io-index"
314
+
checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806"
315
+
dependencies = [
316
+
"darling_core",
317
+
"quote",
318
+
"syn",
319
+
]
320
+
321
+
[[package]]
322
+
name = "data-encoding"
323
+
version = "2.6.0"
324
+
source = "registry+https://github.com/rust-lang/crates.io-index"
325
+
checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2"
326
+
327
+
[[package]]
284
328
name = "deranged"
285
-
version = "0.3.7"
329
+
version = "0.3.11"
286
330
source = "registry+https://github.com/rust-lang/crates.io-index"
287
-
checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929"
331
+
checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4"
332
+
dependencies = [
333
+
"powerfmt",
334
+
]
288
335
289
336
[[package]]
290
337
name = "diesel"
291
-
version = "2.1.0"
338
+
version = "2.2.2"
292
339
source = "registry+https://github.com/rust-lang/crates.io-index"
293
-
checksum = "f7a532c1f99a0f596f6960a60d1e119e91582b24b39e2d83a190e61262c3ef0c"
340
+
checksum = "bf97ee7261bb708fa3402fa9c17a54b70e90e3cb98afb3dc8999d5512cb03f94"
294
341
dependencies = [
295
-
"bitflags 2.4.0",
342
+
"bitflags 2.6.0",
296
343
"byteorder",
297
344
"diesel_derives",
298
345
"itoa",
···
301
348
302
349
[[package]]
303
350
name = "diesel-async"
304
-
version = "0.3.2"
351
+
version = "0.5.0"
305
352
source = "registry+https://github.com/rust-lang/crates.io-index"
306
-
checksum = "c7e7974099f0d9bde0e010dd3a673555276a474f3362a7a52ab535a57b7c5056"
353
+
checksum = "fcb799bb6f8ca6a794462125d7b8983b0c86e6c93a33a9c55934a4a5de4409d3"
307
354
dependencies = [
308
355
"async-trait",
309
356
"bb8",
···
316
363
317
364
[[package]]
318
365
name = "diesel_derives"
319
-
version = "2.1.0"
366
+
version = "2.2.2"
320
367
source = "registry+https://github.com/rust-lang/crates.io-index"
321
-
checksum = "74398b79d81e52e130d991afeed9c86034bb1b7735f46d2f5bf7deb261d80303"
368
+
checksum = "d6ff2be1e7312c858b2ef974f5c7089833ae57b5311b334b30923af58e5718d8"
322
369
dependencies = [
323
370
"diesel_table_macro_syntax",
371
+
"dsl_auto_type",
324
372
"proc-macro2",
325
373
"quote",
326
374
"syn",
···
328
376
329
377
[[package]]
330
378
name = "diesel_table_macro_syntax"
331
-
version = "0.1.0"
379
+
version = "0.2.0"
332
380
source = "registry+https://github.com/rust-lang/crates.io-index"
333
-
checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5"
381
+
checksum = "209c735641a413bc68c4923a9d6ad4bcb3ca306b794edaa7eb0b3228a99ffb25"
334
382
dependencies = [
335
383
"syn",
336
384
]
···
347
395
]
348
396
349
397
[[package]]
398
+
name = "dsl_auto_type"
399
+
version = "0.1.2"
400
+
source = "registry+https://github.com/rust-lang/crates.io-index"
401
+
checksum = "c5d9abe6314103864cc2d8901b7ae224e0ab1a103a0a416661b4097b0779b607"
402
+
dependencies = [
403
+
"darling",
404
+
"either",
405
+
"heck",
406
+
"proc-macro2",
407
+
"quote",
408
+
"syn",
409
+
]
410
+
411
+
[[package]]
350
412
name = "dtoa"
351
413
version = "1.0.9"
352
414
source = "registry+https://github.com/rust-lang/crates.io-index"
353
415
checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653"
354
416
355
417
[[package]]
418
+
name = "either"
419
+
version = "1.13.0"
420
+
source = "registry+https://github.com/rust-lang/crates.io-index"
421
+
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
422
+
423
+
[[package]]
356
424
name = "encoding_rs"
357
-
version = "0.8.32"
425
+
version = "0.8.34"
358
426
source = "registry+https://github.com/rust-lang/crates.io-index"
359
-
checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394"
427
+
checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59"
360
428
dependencies = [
361
429
"cfg-if",
362
430
]
363
431
364
432
[[package]]
365
433
name = "env_logger"
366
-
version = "0.10.0"
434
+
version = "0.10.2"
367
435
source = "registry+https://github.com/rust-lang/crates.io-index"
368
-
checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0"
436
+
checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580"
369
437
dependencies = [
370
438
"humantime",
371
439
"is-terminal",
···
382
450
383
451
[[package]]
384
452
name = "errno"
385
-
version = "0.3.2"
453
+
version = "0.3.9"
386
454
source = "registry+https://github.com/rust-lang/crates.io-index"
387
-
checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f"
455
+
checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
388
456
dependencies = [
389
-
"errno-dragonfly",
390
457
"libc",
391
-
"windows-sys",
392
-
]
393
-
394
-
[[package]]
395
-
name = "errno-dragonfly"
396
-
version = "0.1.2"
397
-
source = "registry+https://github.com/rust-lang/crates.io-index"
398
-
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
399
-
dependencies = [
400
-
"cc",
401
-
"libc",
458
+
"windows-sys 0.52.0",
402
459
]
403
460
404
461
[[package]]
···
409
466
410
467
[[package]]
411
468
name = "fastrand"
412
-
version = "2.0.0"
469
+
version = "2.1.0"
413
470
source = "registry+https://github.com/rust-lang/crates.io-index"
414
-
checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764"
471
+
checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
415
472
416
473
[[package]]
417
474
name = "fnv"
···
436
493
437
494
[[package]]
438
495
name = "form_urlencoded"
439
-
version = "1.2.0"
496
+
version = "1.2.1"
440
497
source = "registry+https://github.com/rust-lang/crates.io-index"
441
-
checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652"
498
+
checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456"
442
499
dependencies = [
443
500
"percent-encoding",
444
501
]
445
502
446
503
[[package]]
447
504
name = "futures"
448
-
version = "0.3.28"
505
+
version = "0.3.30"
449
506
source = "registry+https://github.com/rust-lang/crates.io-index"
450
-
checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40"
507
+
checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"
451
508
dependencies = [
452
509
"futures-channel",
453
510
"futures-core",
···
460
517
461
518
[[package]]
462
519
name = "futures-channel"
463
-
version = "0.3.28"
520
+
version = "0.3.30"
464
521
source = "registry+https://github.com/rust-lang/crates.io-index"
465
-
checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2"
522
+
checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
466
523
dependencies = [
467
524
"futures-core",
468
525
"futures-sink",
···
470
527
471
528
[[package]]
472
529
name = "futures-core"
473
-
version = "0.3.28"
530
+
version = "0.3.30"
474
531
source = "registry+https://github.com/rust-lang/crates.io-index"
475
-
checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c"
532
+
checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
476
533
477
534
[[package]]
478
535
name = "futures-executor"
479
-
version = "0.3.28"
536
+
version = "0.3.30"
480
537
source = "registry+https://github.com/rust-lang/crates.io-index"
481
-
checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0"
538
+
checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d"
482
539
dependencies = [
483
540
"futures-core",
484
541
"futures-task",
···
487
544
488
545
[[package]]
489
546
name = "futures-io"
490
-
version = "0.3.28"
547
+
version = "0.3.30"
491
548
source = "registry+https://github.com/rust-lang/crates.io-index"
492
-
checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964"
549
+
checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
493
550
494
551
[[package]]
495
552
name = "futures-macro"
496
-
version = "0.3.28"
553
+
version = "0.3.30"
497
554
source = "registry+https://github.com/rust-lang/crates.io-index"
498
-
checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
555
+
checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
499
556
dependencies = [
500
557
"proc-macro2",
501
558
"quote",
···
504
561
505
562
[[package]]
506
563
name = "futures-sink"
507
-
version = "0.3.28"
564
+
version = "0.3.30"
508
565
source = "registry+https://github.com/rust-lang/crates.io-index"
509
-
checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e"
566
+
checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5"
510
567
511
568
[[package]]
512
569
name = "futures-task"
513
-
version = "0.3.28"
570
+
version = "0.3.30"
514
571
source = "registry+https://github.com/rust-lang/crates.io-index"
515
-
checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65"
572
+
checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
516
573
517
574
[[package]]
518
575
name = "futures-util"
519
-
version = "0.3.28"
576
+
version = "0.3.30"
520
577
source = "registry+https://github.com/rust-lang/crates.io-index"
521
-
checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533"
578
+
checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
522
579
dependencies = [
523
580
"futures-channel",
524
581
"futures-core",
···
544
601
545
602
[[package]]
546
603
name = "getrandom"
547
-
version = "0.2.10"
604
+
version = "0.2.15"
548
605
source = "registry+https://github.com/rust-lang/crates.io-index"
549
-
checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
606
+
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
550
607
dependencies = [
551
608
"cfg-if",
552
609
"libc",
···
555
612
556
613
[[package]]
557
614
name = "gimli"
558
-
version = "0.27.3"
615
+
version = "0.29.0"
559
616
source = "registry+https://github.com/rust-lang/crates.io-index"
560
-
checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e"
617
+
checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd"
561
618
562
619
[[package]]
563
620
name = "h2"
564
-
version = "0.3.20"
621
+
version = "0.3.26"
565
622
source = "registry+https://github.com/rust-lang/crates.io-index"
566
-
checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049"
623
+
checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8"
567
624
dependencies = [
568
625
"bytes",
569
626
"fnv",
570
627
"futures-core",
571
628
"futures-sink",
572
629
"futures-util",
573
-
"http",
574
-
"indexmap 1.9.3",
630
+
"http 0.2.12",
631
+
"indexmap",
575
632
"slab",
576
633
"tokio",
577
634
"tokio-util",
···
580
637
581
638
[[package]]
582
639
name = "hashbrown"
583
-
version = "0.12.3"
584
-
source = "registry+https://github.com/rust-lang/crates.io-index"
585
-
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
586
-
587
-
[[package]]
588
-
name = "hashbrown"
589
-
version = "0.14.0"
640
+
version = "0.14.5"
590
641
source = "registry+https://github.com/rust-lang/crates.io-index"
591
-
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
642
+
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
592
643
593
644
[[package]]
594
645
name = "headers"
595
-
version = "0.3.8"
646
+
version = "0.3.9"
596
647
source = "registry+https://github.com/rust-lang/crates.io-index"
597
-
checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584"
648
+
checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270"
598
649
dependencies = [
599
-
"base64 0.13.1",
600
-
"bitflags 1.3.2",
650
+
"base64 0.21.7",
601
651
"bytes",
602
652
"headers-core",
603
-
"http",
653
+
"http 0.2.12",
604
654
"httpdate",
605
655
"mime",
606
656
"sha1",
···
612
662
source = "registry+https://github.com/rust-lang/crates.io-index"
613
663
checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429"
614
664
dependencies = [
615
-
"http",
665
+
"http 0.2.12",
616
666
]
617
667
618
668
[[package]]
669
+
name = "heck"
670
+
version = "0.5.0"
671
+
source = "registry+https://github.com/rust-lang/crates.io-index"
672
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
673
+
674
+
[[package]]
619
675
name = "hermit-abi"
620
-
version = "0.3.2"
676
+
version = "0.3.9"
621
677
source = "registry+https://github.com/rust-lang/crates.io-index"
622
-
checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
678
+
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
623
679
624
680
[[package]]
625
681
name = "hmac"
···
632
688
633
689
[[package]]
634
690
name = "http"
635
-
version = "0.2.9"
691
+
version = "0.2.12"
636
692
source = "registry+https://github.com/rust-lang/crates.io-index"
637
-
checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482"
693
+
checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1"
694
+
dependencies = [
695
+
"bytes",
696
+
"fnv",
697
+
"itoa",
698
+
]
699
+
700
+
[[package]]
701
+
name = "http"
702
+
version = "1.1.0"
703
+
source = "registry+https://github.com/rust-lang/crates.io-index"
704
+
checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258"
638
705
dependencies = [
639
706
"bytes",
640
707
"fnv",
···
643
710
644
711
[[package]]
645
712
name = "http-body"
646
-
version = "0.4.5"
713
+
version = "0.4.6"
647
714
source = "registry+https://github.com/rust-lang/crates.io-index"
648
-
checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1"
715
+
checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
649
716
dependencies = [
650
717
"bytes",
651
-
"http",
718
+
"http 0.2.12",
652
719
"pin-project-lite",
653
720
]
654
721
655
722
[[package]]
656
723
name = "httparse"
657
-
version = "1.8.0"
724
+
version = "1.9.4"
658
725
source = "registry+https://github.com/rust-lang/crates.io-index"
659
-
checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904"
726
+
checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9"
660
727
661
728
[[package]]
662
729
name = "httpdate"
···
672
739
673
740
[[package]]
674
741
name = "hyper"
675
-
version = "0.14.27"
742
+
version = "0.14.30"
676
743
source = "registry+https://github.com/rust-lang/crates.io-index"
677
-
checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468"
744
+
checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9"
678
745
dependencies = [
679
746
"bytes",
680
747
"futures-channel",
681
748
"futures-core",
682
749
"futures-util",
683
750
"h2",
684
-
"http",
751
+
"http 0.2.12",
685
752
"http-body",
686
753
"httparse",
687
754
"httpdate",
688
755
"itoa",
689
756
"pin-project-lite",
690
-
"socket2 0.4.9",
757
+
"socket2",
691
758
"tokio",
692
759
"tower-service",
693
760
"tracing",
···
695
762
]
696
763
697
764
[[package]]
765
+
name = "ident_case"
766
+
version = "1.0.1"
767
+
source = "registry+https://github.com/rust-lang/crates.io-index"
768
+
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
769
+
770
+
[[package]]
698
771
name = "idna"
699
-
version = "0.4.0"
772
+
version = "0.5.0"
700
773
source = "registry+https://github.com/rust-lang/crates.io-index"
701
-
checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c"
774
+
checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6"
702
775
dependencies = [
703
776
"unicode-bidi",
704
777
"unicode-normalization",
···
706
779
707
780
[[package]]
708
781
name = "indexmap"
709
-
version = "1.9.3"
782
+
version = "2.3.0"
710
783
source = "registry+https://github.com/rust-lang/crates.io-index"
711
-
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
784
+
checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0"
712
785
dependencies = [
713
-
"autocfg",
714
-
"hashbrown 0.12.3",
786
+
"equivalent",
787
+
"hashbrown",
715
788
]
716
789
717
790
[[package]]
718
-
name = "indexmap"
719
-
version = "2.0.0"
791
+
name = "is-terminal"
792
+
version = "0.4.12"
720
793
source = "registry+https://github.com/rust-lang/crates.io-index"
721
-
checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
794
+
checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b"
722
795
dependencies = [
723
-
"equivalent",
724
-
"hashbrown 0.14.0",
796
+
"hermit-abi",
797
+
"libc",
798
+
"windows-sys 0.52.0",
725
799
]
726
800
727
801
[[package]]
728
-
name = "is-terminal"
729
-
version = "0.4.9"
802
+
name = "is_terminal_polyfill"
803
+
version = "1.70.1"
730
804
source = "registry+https://github.com/rust-lang/crates.io-index"
731
-
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
732
-
dependencies = [
733
-
"hermit-abi",
734
-
"rustix",
735
-
"windows-sys",
736
-
]
805
+
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
737
806
738
807
[[package]]
739
808
name = "itoa"
740
-
version = "1.0.9"
809
+
version = "1.0.11"
741
810
source = "registry+https://github.com/rust-lang/crates.io-index"
742
-
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
811
+
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
743
812
744
813
[[package]]
745
-
name = "lazy_static"
746
-
version = "1.4.0"
814
+
name = "js-sys"
815
+
version = "0.3.70"
747
816
source = "registry+https://github.com/rust-lang/crates.io-index"
748
-
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
817
+
checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a"
818
+
dependencies = [
819
+
"wasm-bindgen",
820
+
]
749
821
750
822
[[package]]
751
823
name = "libc"
752
-
version = "0.2.147"
824
+
version = "0.2.155"
753
825
source = "registry+https://github.com/rust-lang/crates.io-index"
754
-
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
826
+
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
755
827
756
828
[[package]]
757
829
name = "linux-raw-sys"
758
-
version = "0.4.5"
830
+
version = "0.4.14"
759
831
source = "registry+https://github.com/rust-lang/crates.io-index"
760
-
checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503"
832
+
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
761
833
762
834
[[package]]
763
835
name = "lock_api"
764
-
version = "0.4.10"
836
+
version = "0.4.12"
765
837
source = "registry+https://github.com/rust-lang/crates.io-index"
766
-
checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16"
838
+
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
767
839
dependencies = [
768
840
"autocfg",
769
841
"scopeguard",
···
771
843
772
844
[[package]]
773
845
name = "log"
774
-
version = "0.4.20"
846
+
version = "0.4.22"
775
847
source = "registry+https://github.com/rust-lang/crates.io-index"
776
-
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
848
+
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
777
849
778
850
[[package]]
779
851
name = "lumen"
···
792
864
793
865
[[package]]
794
866
name = "md-5"
795
-
version = "0.10.5"
867
+
version = "0.10.6"
796
868
source = "registry+https://github.com/rust-lang/crates.io-index"
797
-
checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca"
869
+
checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"
798
870
dependencies = [
871
+
"cfg-if",
799
872
"digest",
800
873
]
801
874
802
875
[[package]]
803
876
name = "memchr"
804
-
version = "2.5.0"
877
+
version = "2.7.4"
805
878
source = "registry+https://github.com/rust-lang/crates.io-index"
806
-
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
879
+
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
807
880
808
881
[[package]]
809
882
name = "mime"
···
813
886
814
887
[[package]]
815
888
name = "mime_guess"
816
-
version = "2.0.4"
889
+
version = "2.0.5"
817
890
source = "registry+https://github.com/rust-lang/crates.io-index"
818
-
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
891
+
checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e"
819
892
dependencies = [
820
893
"mime",
821
894
"unicase",
···
823
896
824
897
[[package]]
825
898
name = "miniz_oxide"
826
-
version = "0.7.1"
899
+
version = "0.7.4"
827
900
source = "registry+https://github.com/rust-lang/crates.io-index"
828
-
checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
901
+
checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08"
829
902
dependencies = [
830
903
"adler",
831
904
]
832
905
833
906
[[package]]
834
907
name = "mio"
835
-
version = "0.8.8"
908
+
version = "1.0.2"
836
909
source = "registry+https://github.com/rust-lang/crates.io-index"
837
-
checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2"
910
+
checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec"
838
911
dependencies = [
912
+
"hermit-abi",
839
913
"libc",
840
914
"wasi",
841
-
"windows-sys",
915
+
"windows-sys 0.52.0",
842
916
]
843
917
844
918
[[package]]
···
850
924
"bytes",
851
925
"encoding_rs",
852
926
"futures-util",
853
-
"http",
927
+
"http 0.2.12",
854
928
"httparse",
855
929
"log",
856
930
"memchr",
···
861
935
862
936
[[package]]
863
937
name = "native-tls"
864
-
version = "0.2.11"
938
+
version = "0.2.12"
865
939
source = "registry+https://github.com/rust-lang/crates.io-index"
866
-
checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e"
940
+
checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466"
867
941
dependencies = [
868
-
"lazy_static",
869
942
"libc",
870
943
"log",
871
944
"openssl",
···
878
951
]
879
952
880
953
[[package]]
881
-
name = "num_cpus"
882
-
version = "1.16.0"
954
+
name = "num-conv"
955
+
version = "0.1.0"
883
956
source = "registry+https://github.com/rust-lang/crates.io-index"
884
-
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
885
-
dependencies = [
886
-
"hermit-abi",
887
-
"libc",
888
-
]
957
+
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
889
958
890
959
[[package]]
891
960
name = "object"
892
-
version = "0.31.1"
961
+
version = "0.36.3"
893
962
source = "registry+https://github.com/rust-lang/crates.io-index"
894
-
checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1"
963
+
checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9"
895
964
dependencies = [
896
965
"memchr",
897
966
]
898
967
899
968
[[package]]
900
969
name = "once_cell"
901
-
version = "1.18.0"
970
+
version = "1.19.0"
902
971
source = "registry+https://github.com/rust-lang/crates.io-index"
903
-
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
972
+
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
904
973
905
974
[[package]]
906
975
name = "openssl"
907
-
version = "0.10.56"
976
+
version = "0.10.66"
908
977
source = "registry+https://github.com/rust-lang/crates.io-index"
909
-
checksum = "729b745ad4a5575dd06a3e1af1414bd330ee561c01b3899eb584baeaa8def17e"
978
+
checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1"
910
979
dependencies = [
911
-
"bitflags 1.3.2",
980
+
"bitflags 2.6.0",
912
981
"cfg-if",
913
982
"foreign-types",
914
983
"libc",
···
936
1005
937
1006
[[package]]
938
1007
name = "openssl-sys"
939
-
version = "0.9.91"
1008
+
version = "0.9.103"
940
1009
source = "registry+https://github.com/rust-lang/crates.io-index"
941
-
checksum = "866b5f16f90776b9bb8dc1e1802ac6f0513de3a7a7465867bfbc563dc737faac"
1010
+
checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6"
942
1011
dependencies = [
943
1012
"cc",
944
1013
"libc",
···
948
1017
949
1018
[[package]]
950
1019
name = "parking_lot"
951
-
version = "0.12.1"
1020
+
version = "0.12.3"
952
1021
source = "registry+https://github.com/rust-lang/crates.io-index"
953
-
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
1022
+
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
954
1023
dependencies = [
955
1024
"lock_api",
956
1025
"parking_lot_core",
···
958
1027
959
1028
[[package]]
960
1029
name = "parking_lot_core"
961
-
version = "0.9.8"
1030
+
version = "0.9.10"
962
1031
source = "registry+https://github.com/rust-lang/crates.io-index"
963
-
checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447"
1032
+
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
964
1033
dependencies = [
965
1034
"cfg-if",
966
1035
"libc",
967
-
"redox_syscall",
1036
+
"redox_syscall 0.5.3",
968
1037
"smallvec",
969
1038
"windows-targets",
970
1039
]
971
1040
972
1041
[[package]]
973
1042
name = "percent-encoding"
974
-
version = "2.3.0"
1043
+
version = "2.3.1"
975
1044
source = "registry+https://github.com/rust-lang/crates.io-index"
976
-
checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94"
1045
+
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
977
1046
978
1047
[[package]]
979
1048
name = "phf"
···
995
1064
996
1065
[[package]]
997
1066
name = "pin-project"
998
-
version = "1.1.3"
1067
+
version = "1.1.5"
999
1068
source = "registry+https://github.com/rust-lang/crates.io-index"
1000
-
checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422"
1069
+
checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3"
1001
1070
dependencies = [
1002
1071
"pin-project-internal",
1003
1072
]
1004
1073
1005
1074
[[package]]
1006
1075
name = "pin-project-internal"
1007
-
version = "1.1.3"
1076
+
version = "1.1.5"
1008
1077
source = "registry+https://github.com/rust-lang/crates.io-index"
1009
-
checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405"
1078
+
checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
1010
1079
dependencies = [
1011
1080
"proc-macro2",
1012
1081
"quote",
···
1015
1084
1016
1085
[[package]]
1017
1086
name = "pin-project-lite"
1018
-
version = "0.2.12"
1087
+
version = "0.2.14"
1019
1088
source = "registry+https://github.com/rust-lang/crates.io-index"
1020
-
checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05"
1089
+
checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02"
1021
1090
1022
1091
[[package]]
1023
1092
name = "pin-utils"
···
1027
1096
1028
1097
[[package]]
1029
1098
name = "pkg-config"
1030
-
version = "0.3.27"
1099
+
version = "0.3.30"
1031
1100
source = "registry+https://github.com/rust-lang/crates.io-index"
1032
-
checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
1101
+
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
1033
1102
1034
1103
[[package]]
1035
1104
name = "postgres-native-tls"
···
1046
1115
1047
1116
[[package]]
1048
1117
name = "postgres-protocol"
1049
-
version = "0.6.5"
1118
+
version = "0.6.7"
1050
1119
source = "registry+https://github.com/rust-lang/crates.io-index"
1051
-
checksum = "78b7fa9f396f51dffd61546fd8573ee20592287996568e6175ceb0f8699ad75d"
1120
+
checksum = "acda0ebdebc28befa84bee35e651e4c5f09073d668c7aed4cf7e23c3cda84b23"
1052
1121
dependencies = [
1053
-
"base64 0.21.2",
1122
+
"base64 0.22.1",
1054
1123
"byteorder",
1055
1124
"bytes",
1056
1125
"fallible-iterator",
···
1064
1133
1065
1134
[[package]]
1066
1135
name = "postgres-types"
1067
-
version = "0.2.5"
1136
+
version = "0.2.7"
1068
1137
source = "registry+https://github.com/rust-lang/crates.io-index"
1069
-
checksum = "f028f05971fe20f512bcc679e2c10227e57809a3af86a7606304435bc8896cd6"
1138
+
checksum = "02048d9e032fb3cc3413bbf7b83a15d84a5d419778e2628751896d856498eee9"
1070
1139
dependencies = [
1071
1140
"bytes",
1072
1141
"fallible-iterator",
···
1074
1143
]
1075
1144
1076
1145
[[package]]
1146
+
name = "powerfmt"
1147
+
version = "0.2.0"
1148
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1149
+
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
1150
+
1151
+
[[package]]
1077
1152
name = "ppv-lite86"
1078
-
version = "0.2.17"
1153
+
version = "0.2.20"
1079
1154
source = "registry+https://github.com/rust-lang/crates.io-index"
1080
-
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
1155
+
checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
1156
+
dependencies = [
1157
+
"zerocopy",
1158
+
]
1081
1159
1082
1160
[[package]]
1083
1161
name = "pretty_env_logger"
···
1091
1169
1092
1170
[[package]]
1093
1171
name = "proc-macro2"
1094
-
version = "1.0.66"
1172
+
version = "1.0.86"
1095
1173
source = "registry+https://github.com/rust-lang/crates.io-index"
1096
-
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
1174
+
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
1097
1175
dependencies = [
1098
1176
"unicode-ident",
1099
1177
]
1100
1178
1101
1179
[[package]]
1102
1180
name = "prometheus-client"
1103
-
version = "0.21.2"
1181
+
version = "0.22.3"
1104
1182
source = "registry+https://github.com/rust-lang/crates.io-index"
1105
-
checksum = "3c99afa9a01501019ac3a14d71d9f94050346f55ca471ce90c799a15c58f61e2"
1183
+
checksum = "504ee9ff529add891127c4827eb481bd69dc0ebc72e9a682e187db4caa60c3ca"
1106
1184
dependencies = [
1107
1185
"dtoa",
1108
1186
"itoa",
···
1123
1201
1124
1202
[[package]]
1125
1203
name = "quote"
1126
-
version = "1.0.33"
1204
+
version = "1.0.36"
1127
1205
source = "registry+https://github.com/rust-lang/crates.io-index"
1128
-
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
1206
+
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
1129
1207
dependencies = [
1130
1208
"proc-macro2",
1131
1209
]
···
1162
1240
1163
1241
[[package]]
1164
1242
name = "redox_syscall"
1165
-
version = "0.3.5"
1243
+
version = "0.4.1"
1166
1244
source = "registry+https://github.com/rust-lang/crates.io-index"
1167
-
checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
1245
+
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
1168
1246
dependencies = [
1169
1247
"bitflags 1.3.2",
1170
1248
]
1171
1249
1172
1250
[[package]]
1251
+
name = "redox_syscall"
1252
+
version = "0.5.3"
1253
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1254
+
checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4"
1255
+
dependencies = [
1256
+
"bitflags 2.6.0",
1257
+
]
1258
+
1259
+
[[package]]
1173
1260
name = "regex"
1174
-
version = "1.9.3"
1261
+
version = "1.10.6"
1175
1262
source = "registry+https://github.com/rust-lang/crates.io-index"
1176
-
checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a"
1263
+
checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
1177
1264
dependencies = [
1178
1265
"aho-corasick",
1179
1266
"memchr",
···
1183
1270
1184
1271
[[package]]
1185
1272
name = "regex-automata"
1186
-
version = "0.3.6"
1273
+
version = "0.4.7"
1187
1274
source = "registry+https://github.com/rust-lang/crates.io-index"
1188
-
checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69"
1275
+
checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
1189
1276
dependencies = [
1190
1277
"aho-corasick",
1191
1278
"memchr",
···
1194
1281
1195
1282
[[package]]
1196
1283
name = "regex-syntax"
1197
-
version = "0.7.4"
1284
+
version = "0.8.4"
1198
1285
source = "registry+https://github.com/rust-lang/crates.io-index"
1199
-
checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2"
1286
+
checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
1200
1287
1201
1288
[[package]]
1202
1289
name = "rustc-demangle"
1203
-
version = "0.1.23"
1290
+
version = "0.1.24"
1204
1291
source = "registry+https://github.com/rust-lang/crates.io-index"
1205
-
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
1292
+
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
1206
1293
1207
1294
[[package]]
1208
1295
name = "rustix"
1209
-
version = "0.38.8"
1296
+
version = "0.38.34"
1210
1297
source = "registry+https://github.com/rust-lang/crates.io-index"
1211
-
checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f"
1298
+
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
1212
1299
dependencies = [
1213
-
"bitflags 2.4.0",
1300
+
"bitflags 2.6.0",
1214
1301
"errno",
1215
1302
"libc",
1216
1303
"linux-raw-sys",
1217
-
"windows-sys",
1218
-
]
1219
-
1220
-
[[package]]
1221
-
name = "rustls-pemfile"
1222
-
version = "1.0.3"
1223
-
source = "registry+https://github.com/rust-lang/crates.io-index"
1224
-
checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2"
1225
-
dependencies = [
1226
-
"base64 0.21.2",
1304
+
"windows-sys 0.52.0",
1227
1305
]
1228
1306
1229
1307
[[package]]
1230
1308
name = "ryu"
1231
-
version = "1.0.15"
1309
+
version = "1.0.18"
1232
1310
source = "registry+https://github.com/rust-lang/crates.io-index"
1233
-
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
1311
+
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
1234
1312
1235
1313
[[package]]
1236
1314
name = "schannel"
1237
-
version = "0.1.22"
1315
+
version = "0.1.23"
1238
1316
source = "registry+https://github.com/rust-lang/crates.io-index"
1239
-
checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88"
1317
+
checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534"
1240
1318
dependencies = [
1241
-
"windows-sys",
1319
+
"windows-sys 0.52.0",
1242
1320
]
1243
1321
1244
1322
[[package]]
···
1265
1343
1266
1344
[[package]]
1267
1345
name = "security-framework"
1268
-
version = "2.9.2"
1346
+
version = "2.11.1"
1269
1347
source = "registry+https://github.com/rust-lang/crates.io-index"
1270
-
checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de"
1348
+
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
1271
1349
dependencies = [
1272
-
"bitflags 1.3.2",
1350
+
"bitflags 2.6.0",
1273
1351
"core-foundation",
1274
1352
"core-foundation-sys",
1275
1353
"libc",
···
1278
1356
1279
1357
[[package]]
1280
1358
name = "security-framework-sys"
1281
-
version = "2.9.1"
1359
+
version = "2.11.1"
1282
1360
source = "registry+https://github.com/rust-lang/crates.io-index"
1283
-
checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a"
1361
+
checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf"
1284
1362
dependencies = [
1285
1363
"core-foundation-sys",
1286
1364
"libc",
···
1288
1366
1289
1367
[[package]]
1290
1368
name = "serde"
1291
-
version = "1.0.183"
1369
+
version = "1.0.207"
1292
1370
source = "registry+https://github.com/rust-lang/crates.io-index"
1293
-
checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c"
1371
+
checksum = "5665e14a49a4ea1b91029ba7d3bca9f299e1f7cfa194388ccc20f14743e784f2"
1294
1372
dependencies = [
1295
1373
"serde_derive",
1296
1374
]
1297
1375
1298
1376
[[package]]
1299
1377
name = "serde_derive"
1300
-
version = "1.0.183"
1378
+
version = "1.0.207"
1301
1379
source = "registry+https://github.com/rust-lang/crates.io-index"
1302
-
checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816"
1380
+
checksum = "6aea2634c86b0e8ef2cfdc0c340baede54ec27b1e46febd7f80dffb2aa44a00e"
1303
1381
dependencies = [
1304
1382
"proc-macro2",
1305
1383
"quote",
···
1308
1386
1309
1387
[[package]]
1310
1388
name = "serde_json"
1311
-
version = "1.0.105"
1389
+
version = "1.0.124"
1312
1390
source = "registry+https://github.com/rust-lang/crates.io-index"
1313
-
checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360"
1391
+
checksum = "66ad62847a56b3dba58cc891acd13884b9c61138d330c0d7b6181713d4fce38d"
1314
1392
dependencies = [
1315
1393
"itoa",
1394
+
"memchr",
1316
1395
"ryu",
1317
1396
"serde",
1318
1397
]
1319
1398
1320
1399
[[package]]
1321
1400
name = "serde_spanned"
1322
-
version = "0.6.3"
1401
+
version = "0.6.7"
1323
1402
source = "registry+https://github.com/rust-lang/crates.io-index"
1324
-
checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186"
1403
+
checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d"
1325
1404
dependencies = [
1326
1405
"serde",
1327
1406
]
···
1340
1419
1341
1420
[[package]]
1342
1421
name = "sha1"
1343
-
version = "0.10.5"
1422
+
version = "0.10.6"
1344
1423
source = "registry+https://github.com/rust-lang/crates.io-index"
1345
-
checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3"
1424
+
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
1346
1425
dependencies = [
1347
1426
"cfg-if",
1348
1427
"cpufeatures",
···
1351
1430
1352
1431
[[package]]
1353
1432
name = "sha2"
1354
-
version = "0.10.7"
1433
+
version = "0.10.8"
1355
1434
source = "registry+https://github.com/rust-lang/crates.io-index"
1356
-
checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8"
1435
+
checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
1357
1436
dependencies = [
1358
1437
"cfg-if",
1359
1438
"cpufeatures",
···
1362
1441
1363
1442
[[package]]
1364
1443
name = "signal-hook-registry"
1365
-
version = "1.4.1"
1444
+
version = "1.4.2"
1366
1445
source = "registry+https://github.com/rust-lang/crates.io-index"
1367
-
checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1"
1446
+
checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
1368
1447
dependencies = [
1369
1448
"libc",
1370
1449
]
1371
1450
1372
1451
[[package]]
1373
1452
name = "siphasher"
1374
-
version = "0.3.10"
1453
+
version = "0.3.11"
1375
1454
source = "registry+https://github.com/rust-lang/crates.io-index"
1376
-
checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de"
1455
+
checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"
1377
1456
1378
1457
[[package]]
1379
1458
name = "slab"
1380
-
version = "0.4.8"
1459
+
version = "0.4.9"
1381
1460
source = "registry+https://github.com/rust-lang/crates.io-index"
1382
-
checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d"
1461
+
checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
1383
1462
dependencies = [
1384
1463
"autocfg",
1385
1464
]
1386
1465
1387
1466
[[package]]
1388
1467
name = "smallvec"
1389
-
version = "1.11.0"
1468
+
version = "1.13.2"
1390
1469
source = "registry+https://github.com/rust-lang/crates.io-index"
1391
-
checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9"
1470
+
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
1392
1471
1393
1472
[[package]]
1394
1473
name = "socket2"
1395
-
version = "0.4.9"
1474
+
version = "0.5.7"
1396
1475
source = "registry+https://github.com/rust-lang/crates.io-index"
1397
-
checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662"
1476
+
checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c"
1398
1477
dependencies = [
1399
1478
"libc",
1400
-
"winapi",
1401
-
]
1402
-
1403
-
[[package]]
1404
-
name = "socket2"
1405
-
version = "0.5.3"
1406
-
source = "registry+https://github.com/rust-lang/crates.io-index"
1407
-
checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877"
1408
-
dependencies = [
1409
-
"libc",
1410
-
"windows-sys",
1479
+
"windows-sys 0.52.0",
1411
1480
]
1412
1481
1413
1482
[[package]]
···
1418
1487
1419
1488
[[package]]
1420
1489
name = "stringprep"
1421
-
version = "0.1.3"
1490
+
version = "0.1.5"
1422
1491
source = "registry+https://github.com/rust-lang/crates.io-index"
1423
-
checksum = "db3737bde7edce97102e0e2b15365bf7a20bfdb5f60f4f9e8d7004258a51a8da"
1492
+
checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1"
1424
1493
dependencies = [
1425
1494
"unicode-bidi",
1426
1495
"unicode-normalization",
1496
+
"unicode-properties",
1427
1497
]
1428
1498
1429
1499
[[package]]
1430
1500
name = "strsim"
1431
-
version = "0.10.0"
1501
+
version = "0.11.1"
1432
1502
source = "registry+https://github.com/rust-lang/crates.io-index"
1433
-
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
1503
+
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
1434
1504
1435
1505
[[package]]
1436
1506
name = "subtle"
1437
-
version = "2.5.0"
1507
+
version = "2.6.1"
1438
1508
source = "registry+https://github.com/rust-lang/crates.io-index"
1439
-
checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
1509
+
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
1440
1510
1441
1511
[[package]]
1442
1512
name = "syn"
1443
-
version = "2.0.29"
1513
+
version = "2.0.74"
1444
1514
source = "registry+https://github.com/rust-lang/crates.io-index"
1445
-
checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a"
1515
+
checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7"
1446
1516
dependencies = [
1447
1517
"proc-macro2",
1448
1518
"quote",
···
1451
1521
1452
1522
[[package]]
1453
1523
name = "tempfile"
1454
-
version = "3.7.1"
1524
+
version = "3.12.0"
1455
1525
source = "registry+https://github.com/rust-lang/crates.io-index"
1456
-
checksum = "dc02fddf48964c42031a0b3fe0428320ecf3a73c401040fc0096f97794310651"
1526
+
checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64"
1457
1527
dependencies = [
1458
1528
"cfg-if",
1459
1529
"fastrand",
1460
-
"redox_syscall",
1530
+
"once_cell",
1461
1531
"rustix",
1462
-
"windows-sys",
1532
+
"windows-sys 0.59.0",
1463
1533
]
1464
1534
1465
1535
[[package]]
1466
1536
name = "termcolor"
1467
-
version = "1.2.0"
1537
+
version = "1.4.1"
1468
1538
source = "registry+https://github.com/rust-lang/crates.io-index"
1469
-
checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
1539
+
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
1470
1540
dependencies = [
1471
1541
"winapi-util",
1472
1542
]
1473
1543
1474
1544
[[package]]
1475
1545
name = "thiserror"
1476
-
version = "1.0.47"
1546
+
version = "1.0.63"
1477
1547
source = "registry+https://github.com/rust-lang/crates.io-index"
1478
-
checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f"
1548
+
checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
1479
1549
dependencies = [
1480
1550
"thiserror-impl",
1481
1551
]
1482
1552
1483
1553
[[package]]
1484
1554
name = "thiserror-impl"
1485
-
version = "1.0.47"
1555
+
version = "1.0.63"
1486
1556
source = "registry+https://github.com/rust-lang/crates.io-index"
1487
-
checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b"
1557
+
checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
1488
1558
dependencies = [
1489
1559
"proc-macro2",
1490
1560
"quote",
···
1493
1563
1494
1564
[[package]]
1495
1565
name = "time"
1496
-
version = "0.3.25"
1566
+
version = "0.3.36"
1497
1567
source = "registry+https://github.com/rust-lang/crates.io-index"
1498
-
checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea"
1568
+
checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885"
1499
1569
dependencies = [
1500
1570
"deranged",
1571
+
"num-conv",
1572
+
"powerfmt",
1501
1573
"serde",
1502
1574
"time-core",
1503
1575
"time-macros",
···
1505
1577
1506
1578
[[package]]
1507
1579
name = "time-core"
1508
-
version = "0.1.1"
1580
+
version = "0.1.2"
1509
1581
source = "registry+https://github.com/rust-lang/crates.io-index"
1510
-
checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
1582
+
checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
1511
1583
1512
1584
[[package]]
1513
1585
name = "time-macros"
1514
-
version = "0.2.11"
1586
+
version = "0.2.18"
1515
1587
source = "registry+https://github.com/rust-lang/crates.io-index"
1516
-
checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd"
1588
+
checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf"
1517
1589
dependencies = [
1590
+
"num-conv",
1518
1591
"time-core",
1519
1592
]
1520
1593
1521
1594
[[package]]
1522
1595
name = "tinyvec"
1523
-
version = "1.6.0"
1596
+
version = "1.8.0"
1524
1597
source = "registry+https://github.com/rust-lang/crates.io-index"
1525
-
checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
1598
+
checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938"
1526
1599
dependencies = [
1527
1600
"tinyvec_macros",
1528
1601
]
···
1535
1608
1536
1609
[[package]]
1537
1610
name = "tokio"
1538
-
version = "1.32.0"
1611
+
version = "1.39.2"
1539
1612
source = "registry+https://github.com/rust-lang/crates.io-index"
1540
-
checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9"
1613
+
checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1"
1541
1614
dependencies = [
1542
1615
"backtrace",
1543
1616
"bytes",
1544
1617
"libc",
1545
1618
"mio",
1546
-
"num_cpus",
1547
1619
"parking_lot",
1548
1620
"pin-project-lite",
1549
1621
"signal-hook-registry",
1550
-
"socket2 0.5.3",
1622
+
"socket2",
1551
1623
"tokio-macros",
1552
-
"windows-sys",
1624
+
"windows-sys 0.52.0",
1553
1625
]
1554
1626
1555
1627
[[package]]
1556
1628
name = "tokio-macros"
1557
-
version = "2.1.0"
1629
+
version = "2.4.0"
1558
1630
source = "registry+https://github.com/rust-lang/crates.io-index"
1559
-
checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
1631
+
checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
1560
1632
dependencies = [
1561
1633
"proc-macro2",
1562
1634
"quote",
···
1575
1647
1576
1648
[[package]]
1577
1649
name = "tokio-postgres"
1578
-
version = "0.7.8"
1650
+
version = "0.7.11"
1579
1651
source = "registry+https://github.com/rust-lang/crates.io-index"
1580
-
checksum = "6e89f6234aa8fd43779746012fcf53603cdb91fdd8399aa0de868c2d56b6dde1"
1652
+
checksum = "03adcf0147e203b6032c0b2d30be1415ba03bc348901f3ff1cc0df6a733e60c3"
1581
1653
dependencies = [
1582
1654
"async-trait",
1583
1655
"byteorder",
···
1592
1664
"pin-project-lite",
1593
1665
"postgres-protocol",
1594
1666
"postgres-types",
1595
-
"socket2 0.5.3",
1667
+
"rand",
1668
+
"socket2",
1596
1669
"tokio",
1597
1670
"tokio-util",
1598
-
]
1599
-
1600
-
[[package]]
1601
-
name = "tokio-stream"
1602
-
version = "0.1.14"
1603
-
source = "registry+https://github.com/rust-lang/crates.io-index"
1604
-
checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842"
1605
-
dependencies = [
1606
-
"futures-core",
1607
-
"pin-project-lite",
1608
-
"tokio",
1671
+
"whoami",
1609
1672
]
1610
1673
1611
1674
[[package]]
1612
1675
name = "tokio-tungstenite"
1613
-
version = "0.18.0"
1676
+
version = "0.21.0"
1614
1677
source = "registry+https://github.com/rust-lang/crates.io-index"
1615
-
checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd"
1678
+
checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38"
1616
1679
dependencies = [
1617
1680
"futures-util",
1618
1681
"log",
···
1622
1685
1623
1686
[[package]]
1624
1687
name = "tokio-util"
1625
-
version = "0.7.8"
1688
+
version = "0.7.11"
1626
1689
source = "registry+https://github.com/rust-lang/crates.io-index"
1627
-
checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d"
1690
+
checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1"
1628
1691
dependencies = [
1629
1692
"bytes",
1630
1693
"futures-core",
1631
1694
"futures-sink",
1632
1695
"pin-project-lite",
1633
1696
"tokio",
1634
-
"tracing",
1635
1697
]
1636
1698
1637
1699
[[package]]
1638
1700
name = "toml"
1639
-
version = "0.7.6"
1701
+
version = "0.8.19"
1640
1702
source = "registry+https://github.com/rust-lang/crates.io-index"
1641
-
checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542"
1703
+
checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e"
1642
1704
dependencies = [
1643
1705
"serde",
1644
1706
"serde_spanned",
···
1648
1710
1649
1711
[[package]]
1650
1712
name = "toml_datetime"
1651
-
version = "0.6.3"
1713
+
version = "0.6.8"
1652
1714
source = "registry+https://github.com/rust-lang/crates.io-index"
1653
-
checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b"
1715
+
checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
1654
1716
dependencies = [
1655
1717
"serde",
1656
1718
]
1657
1719
1658
1720
[[package]]
1659
1721
name = "toml_edit"
1660
-
version = "0.19.14"
1722
+
version = "0.22.20"
1661
1723
source = "registry+https://github.com/rust-lang/crates.io-index"
1662
-
checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a"
1724
+
checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d"
1663
1725
dependencies = [
1664
-
"indexmap 2.0.0",
1726
+
"indexmap",
1665
1727
"serde",
1666
1728
"serde_spanned",
1667
1729
"toml_datetime",
···
1676
1738
1677
1739
[[package]]
1678
1740
name = "tracing"
1679
-
version = "0.1.37"
1741
+
version = "0.1.40"
1680
1742
source = "registry+https://github.com/rust-lang/crates.io-index"
1681
-
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
1743
+
checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
1682
1744
dependencies = [
1683
-
"cfg-if",
1684
1745
"log",
1685
1746
"pin-project-lite",
1686
1747
"tracing-core",
···
1688
1749
1689
1750
[[package]]
1690
1751
name = "tracing-core"
1691
-
version = "0.1.31"
1752
+
version = "0.1.32"
1692
1753
source = "registry+https://github.com/rust-lang/crates.io-index"
1693
-
checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a"
1754
+
checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"
1694
1755
dependencies = [
1695
1756
"once_cell",
1696
1757
]
1697
1758
1698
1759
[[package]]
1699
1760
name = "try-lock"
1700
-
version = "0.2.4"
1761
+
version = "0.2.5"
1701
1762
source = "registry+https://github.com/rust-lang/crates.io-index"
1702
-
checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
1763
+
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
1703
1764
1704
1765
[[package]]
1705
1766
name = "tungstenite"
1706
-
version = "0.18.0"
1767
+
version = "0.21.0"
1707
1768
source = "registry+https://github.com/rust-lang/crates.io-index"
1708
-
checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788"
1769
+
checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1"
1709
1770
dependencies = [
1710
-
"base64 0.13.1",
1711
1771
"byteorder",
1712
1772
"bytes",
1713
-
"http",
1773
+
"data-encoding",
1774
+
"http 1.1.0",
1714
1775
"httparse",
1715
1776
"log",
1716
1777
"rand",
···
1722
1783
1723
1784
[[package]]
1724
1785
name = "typenum"
1725
-
version = "1.16.0"
1786
+
version = "1.17.0"
1726
1787
source = "registry+https://github.com/rust-lang/crates.io-index"
1727
-
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
1788
+
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
1728
1789
1729
1790
[[package]]
1730
1791
name = "unicase"
1731
-
version = "2.6.0"
1792
+
version = "2.7.0"
1732
1793
source = "registry+https://github.com/rust-lang/crates.io-index"
1733
-
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
1794
+
checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89"
1734
1795
dependencies = [
1735
1796
"version_check",
1736
1797
]
1737
1798
1738
1799
[[package]]
1739
1800
name = "unicode-bidi"
1740
-
version = "0.3.13"
1801
+
version = "0.3.15"
1741
1802
source = "registry+https://github.com/rust-lang/crates.io-index"
1742
-
checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460"
1803
+
checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75"
1743
1804
1744
1805
[[package]]
1745
1806
name = "unicode-ident"
1746
-
version = "1.0.11"
1807
+
version = "1.0.12"
1747
1808
source = "registry+https://github.com/rust-lang/crates.io-index"
1748
-
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
1809
+
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
1749
1810
1750
1811
[[package]]
1751
1812
name = "unicode-normalization"
1752
-
version = "0.1.22"
1813
+
version = "0.1.23"
1753
1814
source = "registry+https://github.com/rust-lang/crates.io-index"
1754
-
checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
1815
+
checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5"
1755
1816
dependencies = [
1756
1817
"tinyvec",
1757
1818
]
1758
1819
1759
1820
[[package]]
1821
+
name = "unicode-properties"
1822
+
version = "0.1.1"
1823
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1824
+
checksum = "e4259d9d4425d9f0661581b804cb85fe66a4c631cadd8f490d1c13a35d5d9291"
1825
+
1826
+
[[package]]
1760
1827
name = "url"
1761
-
version = "2.4.0"
1828
+
version = "2.5.2"
1762
1829
source = "registry+https://github.com/rust-lang/crates.io-index"
1763
-
checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb"
1830
+
checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c"
1764
1831
dependencies = [
1765
1832
"form_urlencoded",
1766
1833
"idna",
···
1775
1842
1776
1843
[[package]]
1777
1844
name = "utf8parse"
1778
-
version = "0.2.1"
1845
+
version = "0.2.2"
1779
1846
source = "registry+https://github.com/rust-lang/crates.io-index"
1780
-
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
1847
+
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
1781
1848
1782
1849
[[package]]
1783
1850
name = "vcpkg"
···
1787
1854
1788
1855
[[package]]
1789
1856
name = "version_check"
1790
-
version = "0.9.4"
1857
+
version = "0.9.5"
1791
1858
source = "registry+https://github.com/rust-lang/crates.io-index"
1792
-
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
1859
+
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
1793
1860
1794
1861
[[package]]
1795
1862
name = "want"
···
1802
1869
1803
1870
[[package]]
1804
1871
name = "warp"
1805
-
version = "0.3.5"
1872
+
version = "0.3.7"
1806
1873
source = "registry+https://github.com/rust-lang/crates.io-index"
1807
-
checksum = "ba431ef570df1287f7f8b07e376491ad54f84d26ac473489427231e1718e1f69"
1874
+
checksum = "4378d202ff965b011c64817db11d5829506d3404edeadb61f190d111da3f231c"
1808
1875
dependencies = [
1809
1876
"bytes",
1810
1877
"futures-channel",
1811
1878
"futures-util",
1812
1879
"headers",
1813
-
"http",
1880
+
"http 0.2.12",
1814
1881
"hyper",
1815
1882
"log",
1816
1883
"mime",
···
1818
1885
"multer",
1819
1886
"percent-encoding",
1820
1887
"pin-project",
1821
-
"rustls-pemfile",
1822
1888
"scoped-tls",
1823
1889
"serde",
1824
1890
"serde_json",
1825
1891
"serde_urlencoded",
1826
1892
"tokio",
1827
-
"tokio-stream",
1828
1893
"tokio-tungstenite",
1829
1894
"tokio-util",
1830
1895
"tower-service",
···
1838
1903
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
1839
1904
1840
1905
[[package]]
1841
-
name = "winapi"
1842
-
version = "0.3.9"
1906
+
name = "wasite"
1907
+
version = "0.1.0"
1908
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1909
+
checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b"
1910
+
1911
+
[[package]]
1912
+
name = "wasm-bindgen"
1913
+
version = "0.2.93"
1914
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1915
+
checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5"
1916
+
dependencies = [
1917
+
"cfg-if",
1918
+
"once_cell",
1919
+
"wasm-bindgen-macro",
1920
+
]
1921
+
1922
+
[[package]]
1923
+
name = "wasm-bindgen-backend"
1924
+
version = "0.2.93"
1925
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1926
+
checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b"
1927
+
dependencies = [
1928
+
"bumpalo",
1929
+
"log",
1930
+
"once_cell",
1931
+
"proc-macro2",
1932
+
"quote",
1933
+
"syn",
1934
+
"wasm-bindgen-shared",
1935
+
]
1936
+
1937
+
[[package]]
1938
+
name = "wasm-bindgen-macro"
1939
+
version = "0.2.93"
1940
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1941
+
checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf"
1942
+
dependencies = [
1943
+
"quote",
1944
+
"wasm-bindgen-macro-support",
1945
+
]
1946
+
1947
+
[[package]]
1948
+
name = "wasm-bindgen-macro-support"
1949
+
version = "0.2.93"
1843
1950
source = "registry+https://github.com/rust-lang/crates.io-index"
1844
-
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
1951
+
checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836"
1845
1952
dependencies = [
1846
-
"winapi-i686-pc-windows-gnu",
1847
-
"winapi-x86_64-pc-windows-gnu",
1953
+
"proc-macro2",
1954
+
"quote",
1955
+
"syn",
1956
+
"wasm-bindgen-backend",
1957
+
"wasm-bindgen-shared",
1958
+
]
1959
+
1960
+
[[package]]
1961
+
name = "wasm-bindgen-shared"
1962
+
version = "0.2.93"
1963
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1964
+
checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
1965
+
1966
+
[[package]]
1967
+
name = "web-sys"
1968
+
version = "0.3.70"
1969
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1970
+
checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0"
1971
+
dependencies = [
1972
+
"js-sys",
1973
+
"wasm-bindgen",
1848
1974
]
1849
1975
1850
1976
[[package]]
1851
-
name = "winapi-i686-pc-windows-gnu"
1852
-
version = "0.4.0"
1977
+
name = "whoami"
1978
+
version = "1.5.1"
1853
1979
source = "registry+https://github.com/rust-lang/crates.io-index"
1854
-
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
1980
+
checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9"
1981
+
dependencies = [
1982
+
"redox_syscall 0.4.1",
1983
+
"wasite",
1984
+
"web-sys",
1985
+
]
1855
1986
1856
1987
[[package]]
1857
1988
name = "winapi-util"
1858
-
version = "0.1.5"
1989
+
version = "0.1.9"
1859
1990
source = "registry+https://github.com/rust-lang/crates.io-index"
1860
-
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
1991
+
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
1861
1992
dependencies = [
1862
-
"winapi",
1993
+
"windows-sys 0.59.0",
1863
1994
]
1864
1995
1865
1996
[[package]]
1866
-
name = "winapi-x86_64-pc-windows-gnu"
1867
-
version = "0.4.0"
1997
+
name = "windows-sys"
1998
+
version = "0.52.0"
1868
1999
source = "registry+https://github.com/rust-lang/crates.io-index"
1869
-
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
2000
+
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
2001
+
dependencies = [
2002
+
"windows-targets",
2003
+
]
1870
2004
1871
2005
[[package]]
1872
2006
name = "windows-sys"
1873
-
version = "0.48.0"
2007
+
version = "0.59.0"
1874
2008
source = "registry+https://github.com/rust-lang/crates.io-index"
1875
-
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
2009
+
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
1876
2010
dependencies = [
1877
2011
"windows-targets",
1878
2012
]
1879
2013
1880
2014
[[package]]
1881
2015
name = "windows-targets"
1882
-
version = "0.48.3"
2016
+
version = "0.52.6"
1883
2017
source = "registry+https://github.com/rust-lang/crates.io-index"
1884
-
checksum = "27f51fb4c64f8b770a823c043c7fad036323e1c48f55287b7bbb7987b2fcdf3b"
2018
+
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
1885
2019
dependencies = [
1886
2020
"windows_aarch64_gnullvm",
1887
2021
"windows_aarch64_msvc",
1888
2022
"windows_i686_gnu",
2023
+
"windows_i686_gnullvm",
1889
2024
"windows_i686_msvc",
1890
2025
"windows_x86_64_gnu",
1891
2026
"windows_x86_64_gnullvm",
···
1894
2029
1895
2030
[[package]]
1896
2031
name = "windows_aarch64_gnullvm"
1897
-
version = "0.48.3"
2032
+
version = "0.52.6"
1898
2033
source = "registry+https://github.com/rust-lang/crates.io-index"
1899
-
checksum = "fde1bb55ae4ce76a597a8566d82c57432bc69c039449d61572a7a353da28f68c"
2034
+
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
1900
2035
1901
2036
[[package]]
1902
2037
name = "windows_aarch64_msvc"
1903
-
version = "0.48.3"
2038
+
version = "0.52.6"
1904
2039
source = "registry+https://github.com/rust-lang/crates.io-index"
1905
-
checksum = "1513e8d48365a78adad7322fd6b5e4c4e99d92a69db8df2d435b25b1f1f286d4"
2040
+
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
1906
2041
1907
2042
[[package]]
1908
2043
name = "windows_i686_gnu"
1909
-
version = "0.48.3"
2044
+
version = "0.52.6"
1910
2045
source = "registry+https://github.com/rust-lang/crates.io-index"
1911
-
checksum = "60587c0265d2b842298f5858e1a5d79d146f9ee0c37be5782e92a6eb5e1d7a83"
2046
+
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
2047
+
2048
+
[[package]]
2049
+
name = "windows_i686_gnullvm"
2050
+
version = "0.52.6"
2051
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2052
+
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
1912
2053
1913
2054
[[package]]
1914
2055
name = "windows_i686_msvc"
1915
-
version = "0.48.3"
2056
+
version = "0.52.6"
1916
2057
source = "registry+https://github.com/rust-lang/crates.io-index"
1917
-
checksum = "224fe0e0ffff5d2ea6a29f82026c8f43870038a0ffc247aa95a52b47df381ac4"
2058
+
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
1918
2059
1919
2060
[[package]]
1920
2061
name = "windows_x86_64_gnu"
1921
-
version = "0.48.3"
2062
+
version = "0.52.6"
1922
2063
source = "registry+https://github.com/rust-lang/crates.io-index"
1923
-
checksum = "62fc52a0f50a088de499712cbc012df7ebd94e2d6eb948435449d76a6287e7ad"
2064
+
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
1924
2065
1925
2066
[[package]]
1926
2067
name = "windows_x86_64_gnullvm"
1927
-
version = "0.48.3"
2068
+
version = "0.52.6"
1928
2069
source = "registry+https://github.com/rust-lang/crates.io-index"
1929
-
checksum = "2093925509d91ea3d69bcd20238f4c2ecdb1a29d3c281d026a09705d0dd35f3d"
2070
+
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
1930
2071
1931
2072
[[package]]
1932
2073
name = "windows_x86_64_msvc"
1933
-
version = "0.48.3"
2074
+
version = "0.52.6"
1934
2075
source = "registry+https://github.com/rust-lang/crates.io-index"
1935
-
checksum = "b6ade45bc8bf02ae2aa34a9d54ba660a1a58204da34ba793c00d83ca3730b5f1"
2076
+
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
1936
2077
1937
2078
[[package]]
1938
2079
name = "winnow"
1939
-
version = "0.5.12"
2080
+
version = "0.6.18"
1940
2081
source = "registry+https://github.com/rust-lang/crates.io-index"
1941
-
checksum = "83817bbecf72c73bad717ee86820ebf286203d2e04c3951f3cd538869c897364"
2082
+
checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f"
1942
2083
dependencies = [
1943
2084
"memchr",
1944
2085
]
2086
+
2087
+
[[package]]
2088
+
name = "zerocopy"
2089
+
version = "0.7.35"
2090
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2091
+
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
2092
+
dependencies = [
2093
+
"byteorder",
2094
+
"zerocopy-derive",
2095
+
]
2096
+
2097
+
[[package]]
2098
+
name = "zerocopy-derive"
2099
+
version = "0.7.35"
2100
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2101
+
checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
2102
+
dependencies = [
2103
+
"proc-macro2",
2104
+
"quote",
2105
+
"syn",
2106
+
]
+4
-4
Dockerfile
+4
-4
Dockerfile
···
1
-
FROM rust:1.68.2-slim-buster
1
+
FROM rust:1.80.1-slim
2
2
ARG DEBIAN_FRONTEND=noninteractive
3
3
RUN apt-get update && apt-get install -y --no-install-recommends --no-install-suggests ca-certificates pkg-config libssl-dev libpq-dev
4
4
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
5
5
6
6
RUN --mount=type=cache,target=$CARGO_HOME/registry \
7
-
cargo install diesel_cli --version 2.0.1 --no-default-features --features postgres
7
+
cargo install diesel_cli --version 2.2.1 --no-default-features --features postgres
8
8
9
9
COPY common /lumen/common
10
10
COPY lumen /lumen/lumen
11
11
COPY Cargo.toml /lumen/
12
12
RUN --mount=type=cache,target=$CARGO_HOME/registry,target=/lumen/target \
13
-
cd /lumen && cargo build --release && cp /lumen/target/release/lumen /root/
13
+
cd /lumen && cargo build --release && cp /lumen/target/release/lumen /root/
14
14
15
15
FROM debian:buster-slim
16
16
ARG DEBIAN_FRONTEND=noninteractive
17
17
RUN apt-get update && apt-get install -y --no-install-recommends --no-install-suggests openssl libpq5 && \
18
-
sed -i -e 's,\[ v3_req \],\[ v3_req \]\nextendedKeyUsage = serverAuth,' /etc/ssl/openssl.cnf
18
+
sed -i -e 's,\[ v3_req \],\[ v3_req \]\nextendedKeyUsage = serverAuth,' /etc/ssl/openssl.cnf
19
19
RUN mkdir /usr/lib/lumen/
20
20
21
21
COPY --from=0 /usr/local/cargo/bin/diesel /usr/bin/diesel
+125
-100
README.md
+125
-100
README.md
···
1
-
# Lumen
2
-
A private Lumina server that can be used with IDA Pro 7.2+.
3
-
4
-
[lumen.abda.nl](https://lumen.abda.nl/) runs this server.
5
-
6
-
You can read about the protocol research [here](https://abda.nl/posts/introducing-lumen/).
7
-
8
-
## Features
9
-
- Stores function signatures so you (and your team) can quickly identify functions that you found in the past using IDA's built-in Lumina features.
10
-
- Backed by PostgreSQL
11
-
- Experimental HTTP API that allows querying the database for comments by file or function hash.
12
-
13
-
## Getting Started
14
-
15
-
### Docker Method (Recommended)
16
-
In this method precompiled docker images will be downloaded, All you need is [docker-compose.yml](./docker-compose.yml).
17
-
18
-
1. Install `docker-engine` and `docker-compose`.
19
-
2. If using a custom TLS certificate, copy the private key (`.p12`/`.pfx` extension) to `./dockershare` and set the key password in `.env` as `PKCSPASSWD`.
20
-
3. If using a custom Lumen config, copy it to `./dockershare/config.toml`.
21
-
4. Otherwise, or if you have finished these steps, just run `docker-compose up`.
22
-
5. Regardless, if TLS is enabled in the `config.toml`, a `hexrays.crt` will be generated in `./dockershare` to be copied to the IDA install directory.
23
-
24
-
### Building from source with Rust
25
-
1. `git clone https://github.com/naim94a/lumen.git`
26
-
2. Get a rust toolchain: https://rustup.rs/
27
-
3. `cd lumen`
28
-
4. Setup a Postgres database and execute src/schema.sql on it
29
-
5. `cargo build --release`
30
-
31
-
### Usage
32
-
```
33
-
./lumen -c config.toml
34
-
```
35
-
36
-
### Configuring IDA
37
-
38
-
#### IDA Pro >= 8.1
39
-
If you used LUMEN in the past, remove the LUMINA settings in the ida.cfg or idauser.cfg files, otherwise you will get a warning about
40
-
bad config parameters.
41
-
42
-
##### Setup under Linux :
43
-
```
44
-
#!/bin/sh
45
-
export LUMINA_TLS=false
46
-
$1
47
-
```
48
-
- save as ida_lumen.sh, "chmod +x ida_lumen.sh", now you can run IDA using "./ida_lumen.sh ./ida" or "./ida_lumen ./ida64"
49
-
50
-
##### Setup under Windows :
51
-
```
52
-
set LUMINA_TLS=false
53
-
%1
54
-
```
55
-
- save as ida_lumen.bat, now you can run IDA using "./ida_lumen.bat ida.exe" or "./ida_lumen.bat ida64.exe"
56
-
57
-
##### Setup IDA
58
-
- Go to Options, General, Lumina. Select "Use a private server", then set your host and port and "guest" as username and password. Click on ok.
59
-
60
-
#### IDA Pro < 8.1
61
-
You will need IDA Pro 7.2 or above in order to use _lumen_.
62
-
63
-
> The following information may get sent to _lumen_ server: IDA key, Hostname, IDB path, original file path, file MD5, function signature, stack frames & comments.
64
-
65
-
- In your IDA's installation directory open "cfg\ida.cfg" with your favorite text editor _(Example: C:\Program Files\IDA Pro 7.5\cfg\ida.cfg)_
66
-
- Locate the commented out `LUMINA_HOST`, `LUMINA_PORT`, and change their values to the address of your _lumen_ server.
67
-
- If you didn't configure TLS, Add "LUMINA_TLS = NO" after the line with `LUMINA_PORT`.
68
-
69
-
Example:
70
-
```C
71
-
LUMINA_HOST = "192.168.1.1";
72
-
LUMINA_PORT = 1234
73
-
74
-
// Only if TLS isn't used:
75
-
LUMINA_TLS = NO
76
-
```
77
-
78
-
### Configuring TLS
79
-
IDA Pro uses a pinned certificate for Lumina's communcation, so adding a self-signed certificate to your root certificates won't work.
80
-
Luckily, we can override the hard-coded public key by writing a DER-base64 encoded certificate to "hexrays.crt" in IDA's install directory.
81
-
82
-
You may find the following commands useful:
83
-
```bash
84
-
# create a certificate
85
-
openssl req -x509 -newkey rsa:4096 -keyout lumen_key.pem -out lumen_crt.pem -days 365 -nodes
86
-
87
-
# convert to pkcs12 for lumen; used for `lumen.tls` in config
88
-
openssl pkcs12 -export -out lumen.p12 -inkey lumen_key.pem -in lumen_crt.pem
89
-
90
-
# export public-key for IDA; Copy hexrays.crt to IDA installation folder
91
-
openssl x509 -in lumen_crt.pem -out hexrays.crt
92
-
```
93
-
94
-
No attempt is made to merge function data - this may casuse a situation where metadata is inconsistent.
95
-
Instead, the metadata with the highest calculated score is returned to the user.
96
-
97
-
98
-
---
99
-
100
-
Developed by [Naim A.](https://github.com/naim94a); License: MIT.
1
+
# Lumen
2
+
3
+
A private Lumina server that can be used with IDA Pro 7.2+.
4
+
5
+
[lumen.abda.nl](https://lumen.abda.nl/) runs this server.
6
+
7
+
You can read about the protocol research [here](https://abda.nl/posts/introducing-lumen/).
8
+
9
+
## Features
10
+
11
+
- Stores function signatures so you (and your team) can quickly identify functions that you found in the past using IDA's built-in Lumina features.
12
+
- Backed by PostgreSQL
13
+
- Experimental HTTP API that allows querying the database for comments by file or function hash.
14
+
15
+
## Getting Started
16
+
17
+
### Docker Method (Recommended)
18
+
19
+
In this method precompiled docker images will be downloaded, All you need is [docker-compose.yml](./docker-compose.yml).
20
+
21
+
1. Install `docker-engine` and `docker-compose`.
22
+
2. If using a custom TLS certificate, copy the private key (`.p12`/`.pfx` extension) to `./dockershare` and set the key password in `.env` as `PKCSPASSWD`.
23
+
3. If using a custom Lumen config, copy it to `./dockershare/config.toml`.
24
+
4. Otherwise, or if you have finished these steps, just run `docker-compose up`.
25
+
5. Regardless, if TLS is enabled in the `config.toml`, a `hexrays.crt` will be generated in `./dockershare` to be copied to the IDA install directory.
26
+
27
+
### Building from source with Rust
28
+
29
+
1. `git clone https://github.com/naim94a/lumen.git`
30
+
2. Get a rust toolchain: https://rustup.rs/
31
+
3. `cd lumen`
32
+
4. Setup a the database
33
+
34
+
- install postgres
35
+
- install diesel-cli and run migrations:
36
+
37
+
```bash
38
+
cargo install diesel_cli --no-default-features -Fpostgres
39
+
diesel --config-file common/diesel.toml \
40
+
--database-url postgres://postgres:password@localhost/lumen \
41
+
migration run
42
+
```
43
+
44
+
5. `cargo build --release`
45
+
46
+
### Usage
47
+
48
+
```bash
49
+
./lumen -c config.toml
50
+
```
51
+
52
+
### Configuring IDA
53
+
54
+
#### IDA Pro >= 8.1
55
+
56
+
If you used LUMEN in the past, remove the LUMINA settings in the ida.cfg or idauser.cfg files, otherwise you will get a warning about
57
+
bad config parameters.
58
+
59
+
##### Setup under Linux :
60
+
61
+
```bash
62
+
#!/bin/sh
63
+
export LUMINA_TLS=false
64
+
$1
65
+
```
66
+
67
+
- save as ida_lumen.sh, "chmod +x ida_lumen.sh", now you can run IDA using "./ida_lumen.sh ./ida" or "./ida_lumen ./ida64"
68
+
69
+
##### Setup under Windows :
70
+
71
+
```batch
72
+
set LUMINA_TLS=false
73
+
%1
74
+
```
75
+
76
+
- save as ida_lumen.bat, now you can run IDA using "./ida_lumen.bat ida.exe" or "./ida_lumen.bat ida64.exe"
77
+
78
+
##### Setup IDA
79
+
80
+
- Go to Options, General, Lumina. Select "Use a private server", then set your host and port and "guest" as username and password. Click on ok.
81
+
82
+
#### IDA Pro < 8.1
83
+
84
+
You will need IDA Pro 7.2 or above in order to use _lumen_.
85
+
86
+
> The following information may get sent to _lumen_ server: IDA key, Hostname, IDB path, original file path, file MD5, function signature, stack frames & comments.
87
+
88
+
- In your IDA's installation directory open "cfg\ida.cfg" with your favorite text editor _(Example: C:\Program Files\IDA Pro 7.5\cfg\ida.cfg)_
89
+
- Locate the commented out `LUMINA_HOST`, `LUMINA_PORT`, and change their values to the address of your _lumen_ server.
90
+
- If you didn't configure TLS, Add "LUMINA_TLS = NO" after the line with `LUMINA_PORT`.
91
+
92
+
Example:
93
+
94
+
```C
95
+
LUMINA_HOST = "192.168.1.1";
96
+
LUMINA_PORT = 1234
97
+
98
+
// Only if TLS isn't used:
99
+
LUMINA_TLS = NO
100
+
```
101
+
102
+
### Configuring TLS
103
+
104
+
IDA Pro uses a pinned certificate for Lumina's communcation, so adding a self-signed certificate to your root certificates won't work.
105
+
Luckily, we can override the hard-coded public key by writing a DER-base64 encoded certificate to "hexrays.crt" in IDA's install directory.
106
+
107
+
You may find the following commands useful:
108
+
109
+
```bash
110
+
# create a certificate
111
+
openssl req -x509 -newkey rsa:4096 -keyout lumen_key.pem -out lumen_crt.pem -days 365 -nodes
112
+
113
+
# convert to pkcs12 for lumen; used for `lumen.tls` in config
114
+
openssl pkcs12 -export -out lumen.p12 -inkey lumen_key.pem -in lumen_crt.pem
115
+
116
+
# export public-key for IDA; Copy hexrays.crt to IDA installation folder
117
+
openssl x509 -in lumen_crt.pem -out hexrays.crt
118
+
```
119
+
120
+
No attempt is made to merge function data - this may cause a situation where metadata is inconsistent.
121
+
Instead, the metadata with the highest calculated score is returned to the user.
122
+
123
+
---
124
+
125
+
Developed by [Naim A.](https://github.com/naim94a); License: MIT.
+27
-12
common/Cargo.toml
+27
-12
common/Cargo.toml
···
7
7
publish = false
8
8
9
9
[dependencies]
10
-
tokio = {version = "1.32", features = ["full"], optional = true}
11
-
log = {version = "0.4", features = ["release_max_level_debug"]}
12
-
serde = {version = "1.0", features = ["derive"]}
13
-
postgres-native-tls = {version = "0.5", optional = true}
14
-
native-tls = {version = "0.2", optional = true}
10
+
tokio = { version = "1.39", features = ["full"], optional = true }
11
+
log = { version = "0.4", features = ["release_max_level_debug"] }
12
+
serde = { version = "1.0", features = ["derive"] }
13
+
postgres-native-tls = { version = "0.5", optional = true }
14
+
native-tls = { version = "0.2", optional = true }
15
15
futures-util = "0.3"
16
-
toml = "0.7"
17
-
warp = {version = "0.3", optional = true}
16
+
toml = "0.8"
17
+
warp = { version = "0.3", optional = true }
18
18
binascii = "0.1"
19
19
20
-
tokio-postgres = {version = "0.7", default-features = false, optional = true}
21
-
diesel = {version = "2.1", optional = true, default-features = false, features = ["postgres_backend", "time"]}
22
-
diesel-async = {version = "0.3", optional = true, features = ["postgres", "bb8"]}
20
+
tokio-postgres = { version = "0.7", default-features = false, optional = true }
21
+
diesel = { version = "2.2", optional = true, default-features = false, features = [
22
+
"postgres_backend",
23
+
"time",
24
+
] }
25
+
time = { version = "0.3.36", optional = true }
26
+
diesel-async = { version = "0.5", optional = true, features = [
27
+
"postgres",
28
+
"bb8",
29
+
] }
23
30
anyhow = "1.0"
24
-
prometheus-client = "0.21.2"
31
+
prometheus-client = "0.22"
25
32
26
33
[features]
27
34
default = ["web", "db"]
28
35
web = ["warp"]
29
-
db = ["tokio", "postgres-native-tls", "native-tls", "diesel", "diesel-async", "tokio-postgres"]
36
+
db = [
37
+
"tokio",
38
+
"postgres-native-tls",
39
+
"native-tls",
40
+
"diesel",
41
+
"diesel-async",
42
+
"tokio-postgres",
43
+
"time",
44
+
]
+3
-6
common/src/async_drop.rs
+3
-6
common/src/async_drop.rs
···
1
1
use futures_util::{future::BoxFuture, Future};
2
2
use log::trace;
3
-
use tokio::{sync::mpsc::{UnboundedSender, unbounded_channel, WeakUnboundedSender}};
3
+
use tokio::sync::mpsc::{unbounded_channel, UnboundedSender, WeakUnboundedSender};
4
4
5
5
enum AsyncDropperMsg {
6
6
Future(BoxFuture<'static, ()>),
···
29
29
AsyncDropperMsg::Termination => {
30
30
trace!("term received for '{orig}'...");
31
31
break;
32
-
}
32
+
},
33
33
}
34
34
}
35
35
trace!("dropper '{orig}' exited.");
···
41
41
/// Defers execution of a future to when the returned `AsyncDropGuard` is dropped
42
42
pub fn defer<F: Future<Output = ()> + Send + 'static>(&self, fut: F) -> AsyncDropGuard {
43
43
let tx = self.tx.downgrade();
44
-
AsyncDropGuard {
45
-
tx,
46
-
run: Some(Box::pin(fut))
47
-
}
44
+
AsyncDropGuard { tx, run: Some(Box::pin(fut)) }
48
45
}
49
46
}
50
47
impl Drop for AsyncDropper {
+92
-57
common/src/config.rs
+92
-57
common/src/config.rs
···
1
-
use serde::Deserialize;
2
-
use toml::from_str;
3
-
use std::{net::SocketAddr, path::PathBuf};
4
-
5
-
#[derive(Deserialize)]
6
-
pub struct TlsIdentity {
7
-
pub server_cert: PathBuf,
8
-
}
9
-
10
-
#[derive(Deserialize)]
11
-
pub struct LuminaServer {
12
-
pub bind_addr: SocketAddr,
13
-
pub use_tls: Option<bool>,
14
-
pub tls: Option<TlsIdentity>,
15
-
pub server_name: Option<String>,
16
-
pub allow_deletes: Option<bool>,
17
-
}
18
-
19
-
#[derive(Deserialize)]
20
-
pub struct WebServer {
21
-
pub bind_addr: SocketAddr,
22
-
}
23
-
24
-
#[derive(Deserialize)]
25
-
pub struct Database {
26
-
pub connection_info: String,
27
-
28
-
pub use_tls: bool,
29
-
pub server_ca: Option<PathBuf>,
30
-
pub client_id: Option<PathBuf>,
31
-
}
32
-
33
-
#[derive(Deserialize)]
34
-
pub struct Config {
35
-
pub lumina: LuminaServer,
36
-
pub api_server: Option<WebServer>,
37
-
pub database: Database,
38
-
}
39
-
40
-
pub trait HasConfig {
41
-
fn get_config(&self) -> &Config;
42
-
}
43
-
44
-
impl HasConfig for Config {
45
-
fn get_config(&self) -> &Config {
46
-
self
47
-
}
48
-
}
49
-
50
-
pub fn load_config<R: std::io::Read>(mut fd: R) -> Config {
51
-
let mut buf = vec![];
52
-
fd.read_to_end(&mut buf).expect("failed to read config");
53
-
54
-
let buf = std::str::from_utf8(&buf).expect("file contains invalid utf-8");
55
-
56
-
from_str(buf).expect("failed to parse configuration")
57
-
}
1
+
use serde::Deserialize;
2
+
use std::time::Duration;
3
+
use std::{net::SocketAddr, path::PathBuf};
4
+
use toml::from_str;
5
+
6
+
#[derive(Deserialize)]
7
+
pub struct TlsIdentity {
8
+
pub server_cert: PathBuf,
9
+
}
10
+
11
+
#[derive(Deserialize)]
12
+
pub struct LuminaServer {
13
+
pub bind_addr: SocketAddr,
14
+
pub use_tls: Option<bool>,
15
+
pub tls: Option<TlsIdentity>,
16
+
pub server_name: Option<String>,
17
+
pub allow_deletes: Option<bool>,
18
+
19
+
/// limit of function histories to return per function.
20
+
/// `None`, or `Some(0)` will disable the feature on the server.
21
+
pub get_history_limit: Option<u32>,
22
+
}
23
+
24
+
#[derive(Deserialize)]
25
+
pub struct WebServer {
26
+
pub bind_addr: SocketAddr,
27
+
}
28
+
29
+
#[derive(Deserialize)]
30
+
pub struct Database {
31
+
pub connection_info: String,
32
+
33
+
pub use_tls: bool,
34
+
pub server_ca: Option<PathBuf>,
35
+
pub client_id: Option<PathBuf>,
36
+
}
37
+
38
+
#[derive(Deserialize, Debug)]
39
+
#[serde(default)]
40
+
pub struct Limits {
41
+
/// Maximum time to wait on an idle connection between commands.
42
+
pub command_timeout: Duration,
43
+
44
+
/// Maximum time to all `PULL_MD` queries.
45
+
pub pull_md_timeout: Duration,
46
+
47
+
/// Maximum time to wait for `HELO` message.
48
+
pub hello_timeout: Duration,
49
+
50
+
/// Maximum time allowed until TLS handshake completes.
51
+
pub tls_handshake_timeout: Duration,
52
+
}
53
+
54
+
impl Default for Limits {
55
+
fn default() -> Self {
56
+
Self {
57
+
command_timeout: Duration::from_secs(3600),
58
+
pull_md_timeout: Duration::from_secs(4 * 60),
59
+
hello_timeout: Duration::from_secs(15),
60
+
tls_handshake_timeout: Duration::from_secs(10),
61
+
}
62
+
}
63
+
}
64
+
65
+
#[derive(Deserialize)]
66
+
pub struct Config {
67
+
pub lumina: LuminaServer,
68
+
pub api_server: Option<WebServer>,
69
+
pub database: Database,
70
+
71
+
#[serde(default)]
72
+
pub limits: Limits,
73
+
}
74
+
75
+
pub trait HasConfig {
76
+
fn get_config(&self) -> &Config;
77
+
}
78
+
79
+
impl HasConfig for Config {
80
+
fn get_config(&self) -> &Config {
81
+
self
82
+
}
83
+
}
84
+
85
+
pub fn load_config<R: std::io::Read>(mut fd: R) -> Config {
86
+
let mut buf = vec![];
87
+
fd.read_to_end(&mut buf).expect("failed to read config");
88
+
89
+
let buf = std::str::from_utf8(&buf).expect("file contains invalid utf-8");
90
+
91
+
from_str(buf).expect("failed to parse configuration")
92
+
}
+478
-406
common/src/db/mod.rs
+478
-406
common/src/db/mod.rs
···
1
-
use log::*;
2
-
use postgres_native_tls::MakeTlsConnector;
3
-
use serde::Serialize;
4
-
use tokio_postgres::{tls::MakeTlsConnect, Socket, NoTls};
5
-
use std::{collections::HashMap};
6
-
use crate::async_drop::{AsyncDropper, AsyncDropGuard};
7
-
mod schema_auto;
8
-
pub mod schema;
9
-
10
-
use diesel::{upsert::excluded, ExpressionMethods, QueryDsl, NullableExpressionMethods, sql_types::{Array, Binary, VarChar, Integer}, query_builder::{QueryFragment, Query}};
11
-
use diesel_async::RunQueryDsl;
12
-
13
-
pub type DynConfig = dyn crate::config::HasConfig + Send + Sync;
14
-
15
-
pub struct Database {
16
-
tls_connector: Option<MakeTlsConnector>,
17
-
diesel: diesel_async::pooled_connection::bb8::Pool<diesel_async::AsyncPgConnection>,
18
-
dropper: AsyncDropper,
19
-
}
20
-
21
-
pub struct FunctionInfo {
22
-
pub name: String,
23
-
pub len: u32,
24
-
pub data: Vec<u8>,
25
-
pub popularity: u32,
26
-
}
27
-
28
-
#[derive(Debug, Serialize)]
29
-
pub struct DbStats {
30
-
unique_lics: i32,
31
-
unique_hosts_per_lic: i32,
32
-
33
-
unique_funcs: i32,
34
-
total_funcs: i32,
35
-
36
-
dbs: i32,
37
-
unique_files: i32,
38
-
}
39
-
40
-
impl Database {
41
-
pub async fn open(config: &crate::config::Database) -> Result<Self, anyhow::Error> {
42
-
let connection_string = config.connection_info.as_str();
43
-
let tls_connector = if config.use_tls {
44
-
Some(Self::make_tls(config).await)
45
-
} else {
46
-
None
47
-
};
48
-
49
-
let (dropper, worker) = AsyncDropper::new();
50
-
tokio::task::spawn(worker);
51
-
52
-
let diesel = Self::make_bb8_pool(connection_string, tls_connector.clone()).await?;
53
-
54
-
Ok(Database{
55
-
tls_connector,
56
-
dropper,
57
-
diesel,
58
-
})
59
-
}
60
-
61
-
async fn make_pg_client<T>(db_url: &str, tls: T) -> diesel::result::ConnectionResult<diesel_async::AsyncPgConnection>
62
-
where T: MakeTlsConnect<Socket>,
63
-
T::Stream: Send + 'static {
64
-
let (cli, conn) = tokio_postgres::connect(db_url, tls)
65
-
.await
66
-
.map_err(|e| {
67
-
error!("failed to connect db: {e}");
68
-
diesel::result::ConnectionError::BadConnection(format!("{e}"))
69
-
})?;
70
-
71
-
tokio::spawn(async move {
72
-
if let Err(e) = conn.await {
73
-
error!("connection task error: {e}");
74
-
}
75
-
});
76
-
77
-
diesel_async::AsyncPgConnection::try_from(cli).await
78
-
}
79
-
80
-
async fn make_bb8_pool(db_url: &str, tls: Option<MakeTlsConnector>) -> Result<diesel_async::pooled_connection::bb8::Pool<diesel_async::AsyncPgConnection>, anyhow::Error> {
81
-
let cfg = diesel_async::pooled_connection::AsyncDieselConnectionManager::<diesel_async::AsyncPgConnection>::new_with_setup(db_url, move |db_url| {
82
-
let tls = tls.clone();
83
-
Box::pin( async move {
84
-
if let Some(tls) = tls {
85
-
Self::make_pg_client(db_url, tls).await
86
-
} else {
87
-
Self::make_pg_client(db_url, NoTls).await
88
-
}
89
-
})
90
-
});
91
-
92
-
let pool = diesel_async::pooled_connection::bb8::Pool::builder()
93
-
.min_idle(Some(1))
94
-
.build(cfg)
95
-
.await?;
96
-
Ok(pool)
97
-
}
98
-
99
-
async fn make_tls(database: &crate::config::Database) -> MakeTlsConnector {
100
-
use native_tls::{TlsConnector, Certificate, Identity};
101
-
102
-
let mut tls_connector = TlsConnector::builder();
103
-
104
-
if let Some(ref client_identity) = database.client_id {
105
-
let client_identity = tokio::fs::read(client_identity).await.expect("failed to read db's client id");
106
-
let client_identity = Identity::from_pkcs12(&client_identity, "").expect("failed to load db's client identity (PKCS12)");
107
-
tls_connector.identity(client_identity);
108
-
}
109
-
110
-
if let Some(ref server_ca) = database.server_ca {
111
-
let server_ca = tokio::fs::read(server_ca).await.expect("failed to read db's server ca");
112
-
let server_ca = Certificate::from_pem(&server_ca).expect("failed to load db's server ca (PEM)");
113
-
tls_connector.add_root_certificate(server_ca);
114
-
}
115
-
116
-
let tls_connector = tls_connector
117
-
.danger_accept_invalid_hostnames(true)
118
-
.build()
119
-
.expect("failed to build TlsConnector");
120
-
121
-
MakeTlsConnector::new(tls_connector)
122
-
}
123
-
124
-
pub async fn get_funcs(&self, funcs: &[crate::rpc::PullMetadataFunc<'_>]) -> Result<Vec<Option<FunctionInfo>>, anyhow::Error> {
125
-
let chksums: Vec<&[u8]> = funcs.iter().map(|v| v.mb_hash).collect();
126
-
127
-
let rows: Vec<(String, i32, Vec<u8>, Vec<u8>)> = {
128
-
let conn = &mut self.diesel.get().await?;
129
-
130
-
let ct = self.cancel_guard(&*conn);
131
-
132
-
let res: Vec<_> = BestMds(chksums.as_slice())
133
-
.get_results::<_>(conn).await?;
134
-
ct.consume();
135
-
res
136
-
};
137
-
138
-
let mut partial: HashMap<Vec<u8>, FunctionInfo> = rows
139
-
.into_iter()
140
-
.map(|row| {
141
-
let v = FunctionInfo {
142
-
name: row.0,
143
-
len: row.1 as u32,
144
-
data: row.2,
145
-
popularity: 0,
146
-
};
147
-
148
-
(row.3, v)
149
-
})
150
-
.collect();
151
-
152
-
let results = partial.len();
153
-
154
-
let res: Vec<Option<FunctionInfo>> = chksums.iter().map(|&chksum| {
155
-
partial.remove(chksum)
156
-
}).collect();
157
-
158
-
trace!("found {}/{} results", results, chksums.len());
159
-
debug_assert_eq!(chksums.len(), res.len());
160
-
Ok(res)
161
-
}
162
-
163
-
pub async fn get_or_create_user<'a>(&self, user: &'a crate::rpc::RpcHello<'a>, hostname: &str) -> Result<i32, anyhow::Error> {
164
-
use schema::users;
165
-
166
-
let conn = &mut self.diesel.get().await?;
167
-
168
-
let lic_id = &user.lic_number[..];
169
-
let lic_data = user.license_data;
170
-
171
-
let get_user = || users::table.select(users::id)
172
-
.filter(users::lic_data.eq(lic_data))
173
-
.filter(users::lic_id.eq(lic_id))
174
-
.filter(users::hostname.eq(hostname));
175
-
176
-
match get_user().get_result::<i32>(conn).await {
177
-
Ok(v) => return Ok(v),
178
-
Err(err) if err != diesel::result::Error::NotFound => return Err(err.into()),
179
-
_ => {},
180
-
};
181
-
182
-
match diesel::insert_into(users::table)
183
-
.values(vec![
184
-
(
185
-
users::lic_id.eq(lic_id),
186
-
users::lic_data.eq(lic_data),
187
-
users::hostname.eq(hostname),
188
-
)
189
-
])
190
-
.returning(users::id) // xmax = 0 if the row is new
191
-
.get_result::<i32>(conn)
192
-
.await {
193
-
Ok(v) => return Ok(v),
194
-
Err(diesel::result::Error::DatabaseError(diesel::result::DatabaseErrorKind::UniqueViolation, _)) => {},
195
-
Err(e) => return Err(e.into()),
196
-
}
197
-
198
-
Ok(get_user().get_result::<i32>(conn).await?)
199
-
}
200
-
201
-
async fn get_or_create_file<'a>(&self, funcs: &'a crate::rpc::PushMetadata<'a>) -> Result<i32, anyhow::Error> {
202
-
use schema::files::{table as files, chksum, id};
203
-
204
-
let hash = &funcs.md5[..];
205
-
206
-
let conn = &mut self.diesel.get().await?;
207
-
208
-
let get_file = || files.filter(chksum.eq(hash)).select(id);
209
-
210
-
match get_file().get_result::<i32>(conn).await {
211
-
Ok(v) => return Ok(v),
212
-
Err(err) if err != diesel::result::Error::NotFound => return Err(err.into()),
213
-
_ => {},
214
-
}
215
-
216
-
match diesel::insert_into(files)
217
-
.values(vec![(chksum.eq(hash),)])
218
-
.returning(id)
219
-
.get_result::<i32>(conn)
220
-
.await {
221
-
Ok(v) => return Ok(v),
222
-
Err(diesel::result::Error::DatabaseError(diesel::result::DatabaseErrorKind::UniqueViolation, _)) => {},
223
-
Err(e) => return Err(e.into()),
224
-
}
225
-
Ok(get_file().get_result::<i32>(conn).await?)
226
-
}
227
-
228
-
async fn get_or_create_db<'a>(&self, user: &'a crate::rpc::RpcHello<'a>, funcs: &'a crate::rpc::PushMetadata<'a>) -> Result<i32, anyhow::Error> {
229
-
use schema::dbs::{table as dbs, id as db_id, user_id as db_user, file_id as db_file_id, file_path, idb_path};
230
-
231
-
let file_id = self.get_or_create_file(funcs);
232
-
let user_id = self.get_or_create_user(user, funcs.hostname);
233
-
234
-
let (file_id, user_id): (i32, i32) = futures_util::try_join!(file_id, user_id)?;
235
-
236
-
let conn = &mut self.diesel.get().await?;
237
-
238
-
let get_db = || {
239
-
dbs.select(db_id)
240
-
.filter(db_user.eq(user_id))
241
-
.filter(db_file_id.eq(file_id))
242
-
.filter(file_path.eq(funcs.file_path))
243
-
.filter(idb_path.eq(funcs.idb_path))
244
-
};
245
-
246
-
match get_db().get_result::<i32>(conn).await {
247
-
Ok(v) => return Ok(v),
248
-
Err(err) if err != diesel::result::Error::NotFound => return Err(err.into()),
249
-
_ => {},
250
-
};
251
-
252
-
match diesel::insert_into(dbs)
253
-
.values(vec![(
254
-
db_user.eq(user_id),
255
-
db_file_id.eq(file_id),
256
-
file_path.eq(funcs.file_path),
257
-
idb_path.eq(funcs.idb_path),
258
-
)])
259
-
.returning(db_id)
260
-
.get_result::<i32>(conn)
261
-
.await {
262
-
Ok(id) => return Ok(id),
263
-
Err(diesel::result::Error::DatabaseError(diesel::result::DatabaseErrorKind::UniqueViolation, _)) => {},
264
-
Err(e) => return Err(e.into()),
265
-
};
266
-
Ok(get_db().get_result::<i32>(conn).await?)
267
-
}
268
-
269
-
pub async fn push_funcs<'a, 'b>(&'b self, user: &'a crate::rpc::RpcHello<'a>, funcs: &'a crate::rpc::PushMetadata<'a>, scores: &[u32]) -> Result<Vec<bool>, anyhow::Error> {
270
-
use futures_util::TryStreamExt;
271
-
272
-
// postgres has a limitation of binding per statement (i16::MAX). Split large push requests into smaller chunks.
273
-
const PUSH_FUNC_CHUNK_SIZE: usize = 3000;
274
-
275
-
let db_id = self.get_or_create_db(user, funcs).await?;
276
-
277
-
let mut rows = Vec::with_capacity(funcs.funcs.len().min(PUSH_FUNC_CHUNK_SIZE));
278
-
let mut is_new = Vec::with_capacity(funcs.funcs.len());
279
-
let conn = &mut self.diesel.get().await?;
280
-
let f2 = diesel::alias!(schema::funcs as f2);
281
-
282
-
for (idx, (func, &score)) in funcs.funcs.iter().zip(scores.iter()).enumerate() {
283
-
let name = func.name;
284
-
let len = func.func_len as i32;
285
-
let chksum = func.hash;
286
-
let md = func.func_data;
287
-
let score = score as i32;
288
-
289
-
rows.push((
290
-
schema::funcs::name.eq(name),
291
-
schema::funcs::len.eq(len),
292
-
schema::funcs::chksum.eq(chksum),
293
-
schema::funcs::metadata.eq(md),
294
-
schema::funcs::rank.eq(score),
295
-
schema::funcs::db_id.eq(db_id),
296
-
));
297
-
298
-
if rows.len() < PUSH_FUNC_CHUNK_SIZE && idx < funcs.funcs.len() - 1 {
299
-
continue;
300
-
}
301
-
302
-
let mut current_rows = Vec::with_capacity((funcs.funcs.len() - (idx + 1)).max(PUSH_FUNC_CHUNK_SIZE));
303
-
std::mem::swap(&mut current_rows, &mut rows);
304
-
305
-
diesel::insert_into(schema::funcs::table)
306
-
.values(current_rows)
307
-
.on_conflict((schema::funcs::chksum, schema::funcs::db_id))
308
-
.do_update()
309
-
.set((
310
-
schema::funcs::name.eq(excluded(schema::funcs::name)),
311
-
schema::funcs::metadata.eq(excluded(schema::funcs::metadata)),
312
-
schema::funcs::rank.eq(excluded(schema::funcs::rank)),
313
-
schema::funcs::update_dt.eq(diesel::dsl::now)
314
-
))
315
-
.returning(diesel::dsl::not(diesel::dsl::exists(f2.filter(f2.field(schema::funcs::chksum).eq(schema::funcs::chksum))))) // xmax=0 when a new row is created.
316
-
.load_stream::<bool>(conn)
317
-
.await?
318
-
.try_fold(&mut is_new, |acc, item: bool| {
319
-
acc.push(item);
320
-
futures_util::future::ready(Ok(acc))
321
-
})
322
-
.await?;
323
-
}
324
-
325
-
Ok(is_new)
326
-
}
327
-
328
-
pub async fn get_file_funcs(&self, md5: &[u8], offset: i64, limit: i64) -> Result<Vec<(String, i32, Vec<u8>)>, anyhow::Error> {
329
-
let conn = &mut self.diesel.get().await?;
330
-
let results = schema::funcs::table
331
-
.left_join(schema::dbs::table.left_join(schema::files::table))
332
-
.select((schema::funcs::name.assume_not_null(), schema::funcs::len.assume_not_null(), schema::funcs::chksum.assume_not_null()))
333
-
.filter(schema::files::chksum.eq(md5))
334
-
.offset(offset)
335
-
.limit(limit)
336
-
.get_results::<(String, i32, Vec<u8>)>(conn).await?;
337
-
Ok(results)
338
-
}
339
-
340
-
pub async fn get_files_with_func(&self, func: &[u8]) -> Result<Vec<Vec<u8>>, anyhow::Error> {
341
-
let conn = &mut self.diesel.get().await?;
342
-
343
-
let res = schema::files::table
344
-
.left_join(schema::dbs::table.left_join(schema::funcs::table))
345
-
.select(schema::files::chksum.assume_not_null())
346
-
.distinct()
347
-
.filter(schema::funcs::chksum.eq(func))
348
-
.get_results::<Vec<u8>>(conn)
349
-
.await?;
350
-
Ok(res)
351
-
}
352
-
353
-
fn cancel_guard(&self, conn: &diesel_async::pooled_connection::bb8::PooledConnection<'_, diesel_async::AsyncPgConnection>) -> AsyncDropGuard {
354
-
let token = conn.cancel_token();
355
-
let tls_connector = self.tls_connector.clone();
356
-
self.dropper.defer(async move {
357
-
debug!("cancelling query...");
358
-
359
-
if let Some(tls) = tls_connector {
360
-
let _ = token.cancel_query(tls).await;
361
-
} else {
362
-
let _ = token.cancel_query(NoTls).await;
363
-
}
364
-
})
365
-
}
366
-
367
-
pub async fn delete_metadata(&self, req: &crate::rpc::DelHistory<'_>) -> Result<(), anyhow::Error> {
368
-
use schema::funcs::{table as funcs, chksum};
369
-
370
-
let chksums = req.funcs.iter()
371
-
.map(|v| v.as_slice())
372
-
.collect::<Vec<_>>();
373
-
374
-
let conn = &mut self.diesel.get().await?;
375
-
let rows_modified = diesel::delete(funcs.filter(chksum.eq_any(&chksums)))
376
-
.execute(conn)
377
-
.await?;
378
-
379
-
debug!("deleted {rows_modified} rows");
380
-
381
-
Ok(())
382
-
}
383
-
}
384
-
385
-
// This is eww, but it's the fastest.
386
-
struct BestMds<'a>(&'a [&'a [u8]]);
387
-
impl<'a> QueryFragment<diesel::pg::Pg> for BestMds<'a> {
388
-
fn walk_ast<'b>(&'b self, mut pass: diesel::query_builder::AstPass<'_, 'b, diesel::pg::Pg>) -> diesel::QueryResult<()> {
389
-
pass.push_sql(r#"WITH best AS (
390
-
select chksum,MAX(rank) as maxrank from funcs f1
391
-
WHERE chksum = ANY("#);
392
-
pass.push_bind_param::<Array<Binary>, _>(&self.0)?;
393
-
pass.push_sql(r#")
394
-
GROUP BY chksum
395
-
)
396
-
SELECT f2.name,f2.len,f2.metadata,f2.chksum FROM best
397
-
LEFT JOIN funcs f2 ON (best.chksum=f2.chksum AND best.maxrank=f2.rank)"#);
398
-
Ok(())
399
-
}
400
-
}
401
-
impl<'a> diesel::query_builder::QueryId for BestMds<'a> {
402
-
type QueryId = BestMds<'static>;
403
-
}
404
-
impl<'a> Query for BestMds<'a> {
405
-
type SqlType = (VarChar, Integer, Binary, Binary);
406
-
}
1
+
use crate::async_drop::{AsyncDropGuard, AsyncDropper};
2
+
use log::*;
3
+
use postgres_native_tls::MakeTlsConnector;
4
+
use serde::Serialize;
5
+
use std::collections::HashMap;
6
+
use time::OffsetDateTime;
7
+
use tokio_postgres::{tls::MakeTlsConnect, NoTls, Socket};
8
+
pub mod schema;
9
+
mod schema_auto;
10
+
11
+
use diesel::{
12
+
query_builder::{Query, QueryFragment},
13
+
sql_types::{Array, Binary, Integer, VarChar},
14
+
upsert::excluded,
15
+
ExpressionMethods, NullableExpressionMethods, QueryDsl,
16
+
};
17
+
use diesel_async::{pooled_connection::ManagerConfig, RunQueryDsl};
18
+
19
+
pub type DynConfig = dyn crate::config::HasConfig + Send + Sync;
20
+
21
+
pub struct Database {
22
+
tls_connector: Option<MakeTlsConnector>,
23
+
diesel: diesel_async::pooled_connection::bb8::Pool<diesel_async::AsyncPgConnection>,
24
+
dropper: AsyncDropper,
25
+
}
26
+
27
+
pub struct FunctionInfo {
28
+
pub name: String,
29
+
pub len: u32,
30
+
pub data: Vec<u8>,
31
+
pub popularity: u32,
32
+
}
33
+
34
+
#[derive(Debug, Serialize)]
35
+
pub struct DbStats {
36
+
unique_lics: i32,
37
+
unique_hosts_per_lic: i32,
38
+
39
+
unique_funcs: i32,
40
+
total_funcs: i32,
41
+
42
+
dbs: i32,
43
+
unique_files: i32,
44
+
}
45
+
46
+
impl Database {
47
+
pub async fn open(config: &crate::config::Database) -> Result<Self, anyhow::Error> {
48
+
let connection_string = config.connection_info.as_str();
49
+
let tls_connector = if config.use_tls { Some(Self::make_tls(config).await) } else { None };
50
+
51
+
let (dropper, worker) = AsyncDropper::new();
52
+
tokio::task::spawn(worker);
53
+
54
+
let diesel = Self::make_bb8_pool(connection_string, tls_connector.clone()).await?;
55
+
56
+
Ok(Database { tls_connector, dropper, diesel })
57
+
}
58
+
59
+
async fn make_pg_client<T>(
60
+
db_url: &str, tls: T,
61
+
) -> diesel::result::ConnectionResult<diesel_async::AsyncPgConnection>
62
+
where
63
+
T: MakeTlsConnect<Socket>,
64
+
T::Stream: Send + 'static,
65
+
{
66
+
let (cli, conn) = tokio_postgres::connect(db_url, tls).await.map_err(|e| {
67
+
error!("failed to connect db: {e}");
68
+
diesel::result::ConnectionError::BadConnection(format!("{e}"))
69
+
})?;
70
+
71
+
tokio::spawn(async move {
72
+
if let Err(e) = conn.await {
73
+
error!("connection task error: {e}");
74
+
}
75
+
});
76
+
77
+
diesel_async::AsyncPgConnection::try_from(cli).await
78
+
}
79
+
80
+
async fn make_bb8_pool(
81
+
db_url: &str, tls: Option<MakeTlsConnector>,
82
+
) -> Result<
83
+
diesel_async::pooled_connection::bb8::Pool<diesel_async::AsyncPgConnection>,
84
+
anyhow::Error,
85
+
> {
86
+
let mut config = ManagerConfig::default();
87
+
config.custom_setup = Box::new(move |db_url| {
88
+
let tls = tls.clone();
89
+
Box::pin(async move {
90
+
if let Some(tls) = tls {
91
+
Self::make_pg_client(db_url, tls).await
92
+
} else {
93
+
Self::make_pg_client(db_url, NoTls).await
94
+
}
95
+
})
96
+
});
97
+
let cfg = diesel_async::pooled_connection::AsyncDieselConnectionManager::<
98
+
diesel_async::AsyncPgConnection,
99
+
>::new_with_config(db_url, config);
100
+
101
+
let pool = diesel_async::pooled_connection::bb8::Pool::builder()
102
+
.min_idle(Some(1))
103
+
.build(cfg)
104
+
.await?;
105
+
Ok(pool)
106
+
}
107
+
108
+
async fn make_tls(database: &crate::config::Database) -> MakeTlsConnector {
109
+
use native_tls::{Certificate, Identity, TlsConnector};
110
+
111
+
let mut tls_connector = TlsConnector::builder();
112
+
113
+
if let Some(ref client_identity) = database.client_id {
114
+
let client_identity =
115
+
tokio::fs::read(client_identity).await.expect("failed to read db's client id");
116
+
let client_identity = Identity::from_pkcs12(&client_identity, "")
117
+
.expect("failed to load db's client identity (PKCS12)");
118
+
tls_connector.identity(client_identity);
119
+
}
120
+
121
+
if let Some(ref server_ca) = database.server_ca {
122
+
let server_ca =
123
+
tokio::fs::read(server_ca).await.expect("failed to read db's server ca");
124
+
let server_ca =
125
+
Certificate::from_pem(&server_ca).expect("failed to load db's server ca (PEM)");
126
+
tls_connector.add_root_certificate(server_ca);
127
+
}
128
+
129
+
let tls_connector = tls_connector
130
+
.danger_accept_invalid_hostnames(true)
131
+
.build()
132
+
.expect("failed to build TlsConnector");
133
+
134
+
MakeTlsConnector::new(tls_connector)
135
+
}
136
+
137
+
pub async fn get_funcs(
138
+
&self, funcs: &[crate::rpc::PullMetadataFunc<'_>],
139
+
) -> Result<Vec<Option<FunctionInfo>>, anyhow::Error> {
140
+
let chksums: Vec<&[u8]> = funcs.iter().map(|v| v.mb_hash).collect();
141
+
142
+
let rows: Vec<(String, i32, Vec<u8>, Vec<u8>)> = {
143
+
let conn = &mut self.diesel.get().await?;
144
+
145
+
let ct = self.cancel_guard(&*conn);
146
+
147
+
let res: Vec<_> = BestMds(chksums.as_slice()).get_results::<_>(conn).await?;
148
+
ct.consume();
149
+
res
150
+
};
151
+
152
+
let mut partial: HashMap<Vec<u8>, FunctionInfo> = rows
153
+
.into_iter()
154
+
.map(|row| {
155
+
let v = FunctionInfo { name: row.0, len: row.1 as u32, data: row.2, popularity: 0 };
156
+
157
+
(row.3, v)
158
+
})
159
+
.collect();
160
+
161
+
let results = partial.len();
162
+
163
+
let res: Vec<Option<FunctionInfo>> =
164
+
chksums.iter().map(|&chksum| partial.remove(chksum)).collect();
165
+
166
+
trace!("found {}/{} results", results, chksums.len());
167
+
debug_assert_eq!(chksums.len(), res.len());
168
+
Ok(res)
169
+
}
170
+
171
+
pub async fn get_or_create_user<'a>(
172
+
&self, user: &'a crate::rpc::RpcHello<'a>, hostname: &str,
173
+
) -> Result<i32, anyhow::Error> {
174
+
use schema::users;
175
+
176
+
let conn = &mut self.diesel.get().await?;
177
+
178
+
let lic_id = &user.lic_number[..];
179
+
let lic_data = user.license_data;
180
+
181
+
let get_user = || {
182
+
users::table
183
+
.select(users::id)
184
+
.filter(users::lic_data.eq(lic_data))
185
+
.filter(users::lic_id.eq(lic_id))
186
+
.filter(users::hostname.eq(hostname))
187
+
};
188
+
189
+
match get_user().get_result::<i32>(conn).await {
190
+
Ok(v) => return Ok(v),
191
+
Err(err) if err != diesel::result::Error::NotFound => return Err(err.into()),
192
+
_ => {},
193
+
};
194
+
195
+
match diesel::insert_into(users::table)
196
+
.values(vec![(
197
+
users::lic_id.eq(lic_id),
198
+
users::lic_data.eq(lic_data),
199
+
users::hostname.eq(hostname),
200
+
)])
201
+
.returning(users::id) // xmax = 0 if the row is new
202
+
.get_result::<i32>(conn)
203
+
.await
204
+
{
205
+
Ok(v) => return Ok(v),
206
+
Err(diesel::result::Error::DatabaseError(
207
+
diesel::result::DatabaseErrorKind::UniqueViolation,
208
+
_,
209
+
)) => {},
210
+
Err(e) => return Err(e.into()),
211
+
}
212
+
213
+
Ok(get_user().get_result::<i32>(conn).await?)
214
+
}
215
+
216
+
async fn get_or_create_file<'a>(
217
+
&self, funcs: &'a crate::rpc::PushMetadata<'a>,
218
+
) -> Result<i32, anyhow::Error> {
219
+
use schema::files::{chksum, id, table as files};
220
+
221
+
let hash = &funcs.md5[..];
222
+
223
+
let conn = &mut self.diesel.get().await?;
224
+
225
+
let get_file = || files.filter(chksum.eq(hash)).select(id);
226
+
227
+
match get_file().get_result::<i32>(conn).await {
228
+
Ok(v) => return Ok(v),
229
+
Err(err) if err != diesel::result::Error::NotFound => return Err(err.into()),
230
+
_ => {},
231
+
}
232
+
233
+
match diesel::insert_into(files)
234
+
.values(vec![(chksum.eq(hash),)])
235
+
.returning(id)
236
+
.get_result::<i32>(conn)
237
+
.await
238
+
{
239
+
Ok(v) => return Ok(v),
240
+
Err(diesel::result::Error::DatabaseError(
241
+
diesel::result::DatabaseErrorKind::UniqueViolation,
242
+
_,
243
+
)) => {},
244
+
Err(e) => return Err(e.into()),
245
+
}
246
+
Ok(get_file().get_result::<i32>(conn).await?)
247
+
}
248
+
249
+
async fn get_or_create_db<'a>(
250
+
&self, user: &'a crate::rpc::RpcHello<'a>, funcs: &'a crate::rpc::PushMetadata<'a>,
251
+
) -> Result<i32, anyhow::Error> {
252
+
use schema::dbs::{
253
+
file_id as db_file_id, file_path, id as db_id, idb_path, table as dbs,
254
+
user_id as db_user,
255
+
};
256
+
257
+
let file_id = self.get_or_create_file(funcs);
258
+
let user_id = self.get_or_create_user(user, funcs.hostname);
259
+
260
+
let (file_id, user_id): (i32, i32) = futures_util::try_join!(file_id, user_id)?;
261
+
262
+
let conn = &mut self.diesel.get().await?;
263
+
264
+
let get_db = || {
265
+
dbs.select(db_id)
266
+
.filter(db_user.eq(user_id))
267
+
.filter(db_file_id.eq(file_id))
268
+
.filter(file_path.eq(funcs.file_path))
269
+
.filter(idb_path.eq(funcs.idb_path))
270
+
};
271
+
272
+
match get_db().get_result::<i32>(conn).await {
273
+
Ok(v) => return Ok(v),
274
+
Err(err) if err != diesel::result::Error::NotFound => return Err(err.into()),
275
+
_ => {},
276
+
};
277
+
278
+
match diesel::insert_into(dbs)
279
+
.values(vec![(
280
+
db_user.eq(user_id),
281
+
db_file_id.eq(file_id),
282
+
file_path.eq(funcs.file_path),
283
+
idb_path.eq(funcs.idb_path),
284
+
)])
285
+
.returning(db_id)
286
+
.get_result::<i32>(conn)
287
+
.await
288
+
{
289
+
Ok(id) => return Ok(id),
290
+
Err(diesel::result::Error::DatabaseError(
291
+
diesel::result::DatabaseErrorKind::UniqueViolation,
292
+
_,
293
+
)) => {},
294
+
Err(e) => return Err(e.into()),
295
+
};
296
+
Ok(get_db().get_result::<i32>(conn).await?)
297
+
}
298
+
299
+
pub async fn push_funcs<'a, 'b>(
300
+
&'b self, user: &'a crate::rpc::RpcHello<'a>, funcs: &'a crate::rpc::PushMetadata<'a>,
301
+
scores: &[u32],
302
+
) -> Result<Vec<bool>, anyhow::Error> {
303
+
use futures_util::TryStreamExt;
304
+
305
+
// postgres has a limitation of binding per statement (i16::MAX). Split large push requests into smaller chunks.
306
+
const PUSH_FUNC_CHUNK_SIZE: usize = 3000;
307
+
308
+
let db_id = self.get_or_create_db(user, funcs).await?;
309
+
310
+
let mut rows = Vec::with_capacity(funcs.funcs.len().min(PUSH_FUNC_CHUNK_SIZE));
311
+
let mut is_new = Vec::with_capacity(funcs.funcs.len());
312
+
let conn = &mut self.diesel.get().await?;
313
+
let f2 = diesel::alias!(schema::funcs as f2);
314
+
315
+
for (idx, (func, &score)) in funcs.funcs.iter().zip(scores.iter()).enumerate() {
316
+
let name = func.name;
317
+
let len = func.func_len as i32;
318
+
let chksum = func.hash;
319
+
let md = func.func_data;
320
+
let score = score as i32;
321
+
322
+
rows.push((
323
+
schema::funcs::name.eq(name),
324
+
schema::funcs::len.eq(len),
325
+
schema::funcs::chksum.eq(chksum),
326
+
schema::funcs::metadata.eq(md),
327
+
schema::funcs::rank.eq(score),
328
+
schema::funcs::db_id.eq(db_id),
329
+
));
330
+
331
+
if rows.len() < PUSH_FUNC_CHUNK_SIZE && idx < funcs.funcs.len() - 1 {
332
+
continue;
333
+
}
334
+
335
+
let mut current_rows =
336
+
Vec::with_capacity((funcs.funcs.len() - (idx + 1)).max(PUSH_FUNC_CHUNK_SIZE));
337
+
std::mem::swap(&mut current_rows, &mut rows);
338
+
339
+
diesel::insert_into(schema::funcs::table)
340
+
.values(current_rows)
341
+
.on_conflict((schema::funcs::chksum, schema::funcs::db_id))
342
+
.do_update()
343
+
.set((
344
+
schema::funcs::name.eq(excluded(schema::funcs::name)),
345
+
schema::funcs::metadata.eq(excluded(schema::funcs::metadata)),
346
+
schema::funcs::rank.eq(excluded(schema::funcs::rank)),
347
+
schema::funcs::update_dt.eq(diesel::dsl::now),
348
+
))
349
+
.returning(diesel::dsl::not(diesel::dsl::exists(
350
+
f2.filter(f2.field(schema::funcs::chksum).eq(schema::funcs::chksum)),
351
+
))) // xmax=0 when a new row is created.
352
+
.load_stream::<bool>(conn)
353
+
.await?
354
+
.try_fold(&mut is_new, |acc, item: bool| {
355
+
acc.push(item);
356
+
futures_util::future::ready(Ok(acc))
357
+
})
358
+
.await?;
359
+
}
360
+
361
+
Ok(is_new)
362
+
}
363
+
364
+
pub async fn get_file_funcs(
365
+
&self, md5: &[u8], offset: i64, limit: i64,
366
+
) -> Result<Vec<(String, i32, Vec<u8>)>, anyhow::Error> {
367
+
let conn = &mut self.diesel.get().await?;
368
+
let results = schema::funcs::table
369
+
.left_join(schema::dbs::table.left_join(schema::files::table))
370
+
.select((
371
+
schema::funcs::name.assume_not_null(),
372
+
schema::funcs::len.assume_not_null(),
373
+
schema::funcs::chksum.assume_not_null(),
374
+
))
375
+
.filter(schema::files::chksum.eq(md5))
376
+
.offset(offset)
377
+
.limit(limit)
378
+
.get_results::<(String, i32, Vec<u8>)>(conn)
379
+
.await?;
380
+
Ok(results)
381
+
}
382
+
383
+
pub async fn get_files_with_func(&self, func: &[u8]) -> Result<Vec<Vec<u8>>, anyhow::Error> {
384
+
let conn = &mut self.diesel.get().await?;
385
+
386
+
let res = schema::files::table
387
+
.left_join(schema::dbs::table.left_join(schema::funcs::table))
388
+
.select(schema::files::chksum.assume_not_null())
389
+
.distinct()
390
+
.filter(schema::funcs::chksum.eq(func))
391
+
.get_results::<Vec<u8>>(conn)
392
+
.await?;
393
+
Ok(res)
394
+
}
395
+
396
+
fn cancel_guard(
397
+
&self,
398
+
conn: &diesel_async::pooled_connection::bb8::PooledConnection<
399
+
'_,
400
+
diesel_async::AsyncPgConnection,
401
+
>,
402
+
) -> AsyncDropGuard {
403
+
let token = conn.cancel_token();
404
+
let tls_connector = self.tls_connector.clone();
405
+
self.dropper.defer(async move {
406
+
debug!("cancelling query...");
407
+
408
+
if let Some(tls) = tls_connector {
409
+
let _ = token.cancel_query(tls).await;
410
+
} else {
411
+
let _ = token.cancel_query(NoTls).await;
412
+
}
413
+
})
414
+
}
415
+
416
+
pub async fn delete_metadata(
417
+
&self, req: &crate::rpc::DelHistory<'_>,
418
+
) -> Result<(), anyhow::Error> {
419
+
use schema::funcs::{chksum, table as funcs};
420
+
421
+
let chksums = req.funcs.iter().map(|v| v.as_slice()).collect::<Vec<_>>();
422
+
423
+
let conn = &mut self.diesel.get().await?;
424
+
let rows_modified =
425
+
diesel::delete(funcs.filter(chksum.eq_any(&chksums))).execute(conn).await?;
426
+
427
+
debug!("deleted {rows_modified} rows");
428
+
429
+
Ok(())
430
+
}
431
+
432
+
pub async fn get_func_histories(
433
+
&self, chksum: &[u8], limit: u32,
434
+
) -> Result<Vec<(OffsetDateTime, String, Vec<u8>)>, anyhow::Error> {
435
+
let conn = &mut self.diesel.get().await?;
436
+
let rows = &schema::funcs::table.select((
437
+
schema::funcs::update_dt.assume_not_null(),
438
+
schema::funcs::name,
439
+
schema::funcs::metadata.assume_not_null(),
440
+
));
441
+
let rows = rows
442
+
.limit(limit as i64)
443
+
.order_by(schema::funcs::update_dt.desc())
444
+
.filter(schema::funcs::chksum.eq(chksum))
445
+
.get_results::<(time::OffsetDateTime, String, Vec<u8>)>(conn)
446
+
.await?;
447
+
Ok(rows)
448
+
}
449
+
}
450
+
451
+
// This is eww, but it's the fastest.
452
+
struct BestMds<'a>(&'a [&'a [u8]]);
453
+
impl<'a> QueryFragment<diesel::pg::Pg> for BestMds<'a> {
454
+
fn walk_ast<'b>(
455
+
&'b self, mut pass: diesel::query_builder::AstPass<'_, 'b, diesel::pg::Pg>,
456
+
) -> diesel::QueryResult<()> {
457
+
pass.push_sql(
458
+
r#"WITH best AS (
459
+
select chksum,MAX(rank) as maxrank from funcs f1
460
+
WHERE chksum = ANY("#,
461
+
);
462
+
pass.push_bind_param::<Array<Binary>, _>(&self.0)?;
463
+
pass.push_sql(
464
+
r#")
465
+
GROUP BY chksum
466
+
)
467
+
SELECT f2.name,f2.len,f2.metadata,f2.chksum FROM best
468
+
LEFT JOIN funcs f2 ON (best.chksum=f2.chksum AND best.maxrank=f2.rank)"#,
469
+
);
470
+
Ok(())
471
+
}
472
+
}
473
+
impl<'a> diesel::query_builder::QueryId for BestMds<'a> {
474
+
type QueryId = BestMds<'static>;
475
+
}
476
+
impl<'a> Query for BestMds<'a> {
477
+
type SqlType = (VarChar, Integer, Binary, Binary);
478
+
}
+1
-6
common/src/db/schema_auto.rs
+1
-6
common/src/db/schema_auto.rs
+8
-4
common/src/lib.rs
+8
-4
common/src/lib.rs
···
3
3
4
4
use std::fmt::Write;
5
5
6
+
pub mod async_drop;
7
+
pub mod config;
6
8
pub mod db;
7
-
pub mod config;
8
9
pub mod md;
10
+
pub mod metrics;
9
11
pub mod rpc;
10
12
pub mod web;
11
-
pub mod async_drop;
12
-
pub mod metrics;
13
13
14
14
pub struct SharedState_ {
15
15
pub db: db::Database,
···
33
33
}
34
34
35
35
let _ = write!(&mut output, " | ");
36
-
for ch in chunk.iter().chain(std::iter::repeat(&b' ').take(padding)).map(|&v| std::char::from_u32(v as u32).unwrap_or('.')) {
36
+
for ch in chunk
37
+
.iter()
38
+
.chain(std::iter::repeat(&b' ').take(padding))
39
+
.map(|&v| std::char::from_u32(v as u32).unwrap_or('.'))
40
+
{
37
41
if !ch.is_ascii_graphic() {
38
42
output.push('.');
39
43
} else {
+218
-214
common/src/md.rs
+218
-214
common/src/md.rs
···
1
-
use std::collections::HashSet;
2
-
3
-
use serde::{Serialize, Deserialize};
4
-
use crate::rpc::de::from_slice;
5
-
6
-
#[derive(Serialize, Deserialize)]
7
-
pub struct MetadataChunk<'a> {
8
-
code: u32,
9
-
data: &'a [u8],
10
-
}
11
-
12
-
#[derive(Debug)]
13
-
pub enum FunctionMetadata<'a> {
14
-
FunctionComment(FunctionComment<'a>),
15
-
ByteComment(ByteComment<'a>),
16
-
ExtraComment(ExtraComment<'a>),
17
-
}
18
-
19
-
#[derive(Debug)]
20
-
pub struct FunctionComment<'a> {
21
-
pub is_repeatable: bool,
22
-
pub comment: &'a str,
23
-
}
24
-
25
-
#[derive(Debug)]
26
-
pub struct ByteComment<'a> {
27
-
pub is_repeatable: bool,
28
-
pub offset: u32,
29
-
pub comment: &'a str,
30
-
}
31
-
32
-
#[derive(Debug)]
33
-
pub struct ExtraComment<'a> {
34
-
pub offset: u32,
35
-
pub anterior: &'a str,
36
-
pub posterior: &'a str,
37
-
}
38
-
39
-
impl<'a> FunctionMetadata<'a> {
40
-
fn is_useful(&self) -> bool {
41
-
// TODO: rewrite using regex with configurable library names
42
-
match self {
43
-
FunctionMetadata::ExtraComment(cmt) => {
44
-
if cmt.anterior.starts_with("; Exported entry ") // offset=0
45
-
{
46
-
return false;
47
-
}
48
-
if cmt.anterior.is_empty() && cmt.posterior.is_empty() {
49
-
return false;
50
-
}
51
-
},
52
-
FunctionMetadata::FunctionComment(cmt) => {
53
-
if cmt.comment == "Microsoft VisualC v14 64bit runtime"
54
-
|| cmt.comment == "Microsoft VisualC 64bit universal runtime"
55
-
{
56
-
return false;
57
-
}
58
-
if cmt.comment.is_empty() {
59
-
return false;
60
-
}
61
-
},
62
-
FunctionMetadata::ByteComment(cmt) => {
63
-
if cmt.comment == "Trap to Debugger"
64
-
|| (cmt.comment.starts_with("jumptable ") && cmt.comment.contains(" case")) // repeatable=true
65
-
|| cmt.comment == "switch jump"
66
-
|| (cmt.comment.starts_with("switch ") && cmt.comment.ends_with(" cases "))
67
-
|| cmt.comment == "jump table for switch statement"
68
-
|| cmt.comment == "indirect table for switch statement"
69
-
|| cmt.comment == "Microsoft VisualC v7/14 64bit runtime"
70
-
|| cmt.comment == "Microsoft VisualC v7/14 64bit runtime\nMicrosoft VisualC v14 64bit runtime"
71
-
|| cmt.comment == "Microsoft VisualC v14 64bit runtime" {
72
-
return false;
73
-
}
74
-
if cmt.comment.is_empty() {
75
-
return false;
76
-
}
77
-
},
78
-
}
79
-
true
80
-
}
81
-
}
82
-
83
-
fn deserialize_seq<'de, T: Deserialize<'de>>(mut data: &'de [u8]) -> Result<Vec<(u32, T)>, crate::rpc::Error> {
84
-
let mut res = vec![];
85
-
let mut reset = true;
86
-
let (mut offset, used): (u32, usize) = from_slice(data)?;
87
-
data = &data[used..];
88
-
if data.is_empty() {
89
-
return Err(crate::rpc::Error::UnexpectedEof);
90
-
}
91
-
92
-
loop {
93
-
let (offset_diff, used): (u32, usize) = from_slice(data)?;
94
-
data = &data[used..];
95
-
if data.is_empty() {
96
-
return Err(crate::rpc::Error::UnexpectedEof);
97
-
}
98
-
99
-
if (offset_diff > 0) || reset {
100
-
offset += offset_diff;
101
-
let (e, used): (T, usize) = from_slice(data)?;
102
-
data = &data[used..];
103
-
104
-
res.push((offset, e));
105
-
106
-
reset = false;
107
-
} else {
108
-
let (offset_diff, used): (u32, usize) = from_slice(data)?;
109
-
data = &data[used..];
110
-
111
-
offset = offset_diff;
112
-
reset = true;
113
-
}
114
-
115
-
if data.is_empty() {
116
-
break;
117
-
}
118
-
}
119
-
120
-
Ok(res)
121
-
}
122
-
123
-
pub fn parse_metadata(mut data: &[u8]) -> Result<Vec<FunctionMetadata<'_>>, crate::rpc::Error> {
124
-
let mut res = vec![];
125
-
let mut bad_codes = HashSet::new();
126
-
127
-
while !data.is_empty() {
128
-
let (chunk, used) :(MetadataChunk, _) = from_slice(data)?;
129
-
data = &data[used..];
130
-
131
-
let data = chunk.data;
132
-
133
-
if data.is_empty() {
134
-
continue;
135
-
}
136
-
137
-
match chunk.code {
138
-
1 => {}, // TODO: parse typeinfo
139
-
2 => {}, // nop
140
-
3 | 4 => { // function comments
141
-
let is_repeatable = chunk.code == 4;
142
-
let cmt = std::str::from_utf8(data)?;
143
-
res.push(FunctionMetadata::FunctionComment(FunctionComment{
144
-
is_repeatable,
145
-
comment: cmt,
146
-
}));
147
-
},
148
-
5 | 6 => { // comments
149
-
let is_repeatable = chunk.code == 6;
150
-
let byte_comments: Vec<(_, &[u8])> = match deserialize_seq(data) {
151
-
Ok(v) => v,
152
-
Err(err) => {
153
-
log::error!("err: {}\n{}", err, super::make_pretty_hex(data));
154
-
return Err(err);
155
-
},
156
-
};
157
-
158
-
for comment in byte_comments {
159
-
let cmt = std::str::from_utf8(comment.1)?;
160
-
res.push(FunctionMetadata::ByteComment(
161
-
ByteComment{
162
-
is_repeatable,
163
-
offset: comment.0,
164
-
comment: cmt,
165
-
}
166
-
));
167
-
}
168
-
},
169
-
7 => { // extra comments
170
-
let byte_comments: Vec<(_, (&[u8], &[u8]))> = match deserialize_seq(data) {
171
-
Ok(v) => v,
172
-
Err(err) => {
173
-
log::error!("err: {}\n{}", err, super::make_pretty_hex(data));
174
-
return Err(err);
175
-
},
176
-
};
177
-
178
-
for comment in byte_comments {
179
-
res.push(FunctionMetadata::ExtraComment(ExtraComment{
180
-
offset: comment.0,
181
-
anterior: std::str::from_utf8(comment.1.0)?,
182
-
posterior: std::str::from_utf8(comment.1.1)?,
183
-
}));
184
-
}
185
-
},
186
-
9 | 10 => { /* TODO! */ },
187
-
_ => {
188
-
bad_codes.insert(chunk.code);
189
-
},
190
-
}
191
-
}
192
-
193
-
Ok(res)
194
-
}
195
-
196
-
pub fn get_score(md: &crate::rpc::PushMetadataFunc) -> u32 {
197
-
let mut score = 0;
198
-
199
-
let md = match parse_metadata(md.func_data) {
200
-
Ok(v) => v,
201
-
Err(e) => {
202
-
log::warn!("failed to parse metadata: {}", e);
203
-
return 0;
204
-
}
205
-
};
206
-
207
-
for md in md {
208
-
if md.is_useful() {
209
-
score += 10;
210
-
}
211
-
}
212
-
213
-
score
214
-
}
1
+
use std::collections::HashSet;
2
+
3
+
use crate::rpc::de::from_slice;
4
+
use serde::{Deserialize, Serialize};
5
+
6
+
#[derive(Serialize, Deserialize)]
7
+
pub struct MetadataChunk<'a> {
8
+
code: u32,
9
+
data: &'a [u8],
10
+
}
11
+
12
+
#[derive(Debug)]
13
+
pub enum FunctionMetadata<'a> {
14
+
FunctionComment(FunctionComment<'a>),
15
+
ByteComment(ByteComment<'a>),
16
+
ExtraComment(ExtraComment<'a>),
17
+
}
18
+
19
+
#[derive(Debug)]
20
+
pub struct FunctionComment<'a> {
21
+
pub is_repeatable: bool,
22
+
pub comment: &'a str,
23
+
}
24
+
25
+
#[derive(Debug)]
26
+
pub struct ByteComment<'a> {
27
+
pub is_repeatable: bool,
28
+
pub offset: u32,
29
+
pub comment: &'a str,
30
+
}
31
+
32
+
#[derive(Debug)]
33
+
pub struct ExtraComment<'a> {
34
+
pub offset: u32,
35
+
pub anterior: &'a str,
36
+
pub posterior: &'a str,
37
+
}
38
+
39
+
impl<'a> FunctionMetadata<'a> {
40
+
fn is_useful(&self) -> bool {
41
+
// TODO: rewrite using regex with configurable library names
42
+
match self {
43
+
FunctionMetadata::ExtraComment(cmt) => {
44
+
if cmt.anterior.starts_with("; Exported entry ")
45
+
// offset=0
46
+
{
47
+
return false;
48
+
}
49
+
if cmt.anterior.is_empty() && cmt.posterior.is_empty() {
50
+
return false;
51
+
}
52
+
},
53
+
FunctionMetadata::FunctionComment(cmt) => {
54
+
if cmt.comment == "Microsoft VisualC v14 64bit runtime"
55
+
|| cmt.comment == "Microsoft VisualC 64bit universal runtime"
56
+
{
57
+
return false;
58
+
}
59
+
if cmt.comment.is_empty() {
60
+
return false;
61
+
}
62
+
},
63
+
FunctionMetadata::ByteComment(cmt) => {
64
+
if cmt.comment == "Trap to Debugger"
65
+
|| (cmt.comment.starts_with("jumptable ") && cmt.comment.contains(" case")) // repeatable=true
66
+
|| cmt.comment == "switch jump"
67
+
|| (cmt.comment.starts_with("switch ") && cmt.comment.ends_with(" cases "))
68
+
|| cmt.comment == "jump table for switch statement"
69
+
|| cmt.comment == "indirect table for switch statement"
70
+
|| cmt.comment == "Microsoft VisualC v7/14 64bit runtime"
71
+
|| cmt.comment == "Microsoft VisualC v7/14 64bit runtime\nMicrosoft VisualC v14 64bit runtime"
72
+
|| cmt.comment == "Microsoft VisualC v14 64bit runtime" {
73
+
return false;
74
+
}
75
+
if cmt.comment.is_empty() {
76
+
return false;
77
+
}
78
+
},
79
+
}
80
+
true
81
+
}
82
+
}
83
+
84
+
fn deserialize_seq<'de, T: Deserialize<'de>>(
85
+
mut data: &'de [u8],
86
+
) -> Result<Vec<(u32, T)>, crate::rpc::Error> {
87
+
let mut res = vec![];
88
+
let mut reset = true;
89
+
let (mut offset, used): (u32, usize) = from_slice(data)?;
90
+
data = &data[used..];
91
+
if data.is_empty() {
92
+
return Err(crate::rpc::Error::UnexpectedEof);
93
+
}
94
+
95
+
loop {
96
+
let (offset_diff, used): (u32, usize) = from_slice(data)?;
97
+
data = &data[used..];
98
+
if data.is_empty() {
99
+
return Err(crate::rpc::Error::UnexpectedEof);
100
+
}
101
+
102
+
if (offset_diff > 0) || reset {
103
+
offset += offset_diff;
104
+
let (e, used): (T, usize) = from_slice(data)?;
105
+
data = &data[used..];
106
+
107
+
res.push((offset, e));
108
+
109
+
reset = false;
110
+
} else {
111
+
let (offset_diff, used): (u32, usize) = from_slice(data)?;
112
+
data = &data[used..];
113
+
114
+
offset = offset_diff;
115
+
reset = true;
116
+
}
117
+
118
+
if data.is_empty() {
119
+
break;
120
+
}
121
+
}
122
+
123
+
Ok(res)
124
+
}
125
+
126
+
pub fn parse_metadata(mut data: &[u8]) -> Result<Vec<FunctionMetadata<'_>>, crate::rpc::Error> {
127
+
let mut res = vec![];
128
+
let mut bad_codes = HashSet::new();
129
+
130
+
while !data.is_empty() {
131
+
let (chunk, used): (MetadataChunk, _) = from_slice(data)?;
132
+
data = &data[used..];
133
+
134
+
let data = chunk.data;
135
+
136
+
if data.is_empty() {
137
+
continue;
138
+
}
139
+
140
+
match chunk.code {
141
+
1 => {}, // TODO: parse typeinfo
142
+
2 => {}, // nop
143
+
3 | 4 => {
144
+
// function comments
145
+
let is_repeatable = chunk.code == 4;
146
+
let cmt = std::str::from_utf8(data)?;
147
+
res.push(FunctionMetadata::FunctionComment(FunctionComment {
148
+
is_repeatable,
149
+
comment: cmt,
150
+
}));
151
+
},
152
+
5 | 6 => {
153
+
// comments
154
+
let is_repeatable = chunk.code == 6;
155
+
let byte_comments: Vec<(_, &[u8])> = match deserialize_seq(data) {
156
+
Ok(v) => v,
157
+
Err(err) => {
158
+
log::error!("err: {}\n{}", err, super::make_pretty_hex(data));
159
+
return Err(err);
160
+
},
161
+
};
162
+
163
+
for comment in byte_comments {
164
+
let cmt = std::str::from_utf8(comment.1)?;
165
+
res.push(FunctionMetadata::ByteComment(ByteComment {
166
+
is_repeatable,
167
+
offset: comment.0,
168
+
comment: cmt,
169
+
}));
170
+
}
171
+
},
172
+
7 => {
173
+
// extra comments
174
+
let byte_comments: Vec<(_, (&[u8], &[u8]))> = match deserialize_seq(data) {
175
+
Ok(v) => v,
176
+
Err(err) => {
177
+
log::error!("err: {}\n{}", err, super::make_pretty_hex(data));
178
+
return Err(err);
179
+
},
180
+
};
181
+
182
+
for comment in byte_comments {
183
+
res.push(FunctionMetadata::ExtraComment(ExtraComment {
184
+
offset: comment.0,
185
+
anterior: std::str::from_utf8(comment.1 .0)?,
186
+
posterior: std::str::from_utf8(comment.1 .1)?,
187
+
}));
188
+
}
189
+
},
190
+
9 | 10 => { /* TODO! */ },
191
+
_ => {
192
+
bad_codes.insert(chunk.code);
193
+
},
194
+
}
195
+
}
196
+
197
+
Ok(res)
198
+
}
199
+
200
+
pub fn get_score(md: &crate::rpc::PushMetadataFunc) -> u32 {
201
+
let mut score = 0;
202
+
203
+
let md = match parse_metadata(md.func_data) {
204
+
Ok(v) => v,
205
+
Err(e) => {
206
+
log::warn!("failed to parse metadata: {}", e);
207
+
return 0;
208
+
},
209
+
};
210
+
211
+
for md in md {
212
+
if md.is_useful() {
213
+
score += 10;
214
+
}
215
+
}
216
+
217
+
score
218
+
}
+20
-4
common/src/metrics.rs
+20
-4
common/src/metrics.rs
···
1
1
use std::sync::atomic::AtomicI64;
2
2
3
-
use prometheus_client::{registry::Registry, metrics::{gauge::Gauge, family::Family, counter::Counter}, encoding::EncodeLabelSet};
3
+
use prometheus_client::{
4
+
encoding::EncodeLabelSet,
5
+
metrics::{counter::Counter, family::Family, gauge::Gauge},
6
+
registry::Registry,
7
+
};
4
8
5
9
pub struct Metrics {
6
10
pub registry: Registry,
···
34
38
let mut registry = Registry::default();
35
39
36
40
let active_connections = Gauge::default();
37
-
registry.register("lumen_active_connections", "Active Lumina connections", active_connections.clone());
41
+
registry.register(
42
+
"lumen_active_connections",
43
+
"Active Lumina connections",
44
+
active_connections.clone(),
45
+
);
38
46
39
47
let lumina_version = Family::<LuminaVersion, Gauge>::default();
40
-
registry.register("lumen_protocol_version", "Version of Lumina protocol being used", lumina_version.clone());
48
+
registry.register(
49
+
"lumen_protocol_version",
50
+
"Version of Lumina protocol being used",
51
+
lumina_version.clone(),
52
+
);
41
53
42
54
let new_funcs = Counter::default();
43
-
registry.register("lumen_new_funcs", "Pushes previously unknown functions", new_funcs.clone());
55
+
registry.register(
56
+
"lumen_new_funcs",
57
+
"Pushes previously unknown functions",
58
+
new_funcs.clone(),
59
+
);
44
60
45
61
let pushes = Counter::default();
46
62
registry.register("lumen_pushes_total", "Total pushes functions", pushes.clone());
+163
-159
common/src/rpc/de.rs
+163
-159
common/src/rpc/de.rs
···
1
-
use serde::Deserialize;
2
-
use serde::de::{self, DeserializeSeed, SeqAccess, Visitor};
3
-
use super::Error;
4
-
5
-
struct Deserializer<'de> {
6
-
input: &'de [u8],
7
-
}
8
-
9
-
impl<'de> Deserializer<'de> {
10
-
fn from_bytes(b: &'de [u8]) -> Self {
11
-
Self {
12
-
input: b,
13
-
}
14
-
}
15
-
16
-
fn unpack_dd(&mut self) -> Result<u32, Error> {
17
-
let (v, len) = super::packing::unpack_dd(self.input);
18
-
if len == 0 {
19
-
Err(Error::UnexpectedEof)
20
-
} else {
21
-
self.input = &self.input[len..];
22
-
Ok(v)
23
-
}
24
-
}
25
-
26
-
fn unpack_dq(&mut self) -> Result<u64, Error> {
27
-
let a = self.unpack_dd()? as u64;
28
-
let b = self.unpack_dd()? as u64;
29
-
Ok((a << 32) | b)
30
-
}
31
-
32
-
fn unpack_var_bytes(&mut self) -> Result<&'de [u8], Error> {
33
-
let bytes = self.unpack_dd()? as usize;
34
-
if bytes > self.input.len() {
35
-
return Err(Error::UnexpectedEof);
36
-
}
37
-
38
-
let payload = &self.input[..bytes];
39
-
self.input = &self.input[bytes..];
40
-
assert_eq!(payload.len(), bytes);
41
-
42
-
Ok(payload)
43
-
}
44
-
45
-
fn unpack_cstr(&mut self) -> Result<&'de str, Error> {
46
-
let len = self.input.iter().enumerate().find_map(|(idx, &v)| if v == 0 { Some(idx) } else { None });
47
-
let len = match len {
48
-
Some(v) => v,
49
-
None => return Err(Error::UnexpectedEof),
50
-
};
51
-
let res = match std::str::from_utf8(&self.input[..len]) {
52
-
Ok(v) => v,
53
-
Err(err) => {
54
-
return Err(err.into());
55
-
}
56
-
};
57
-
self.input = &self.input[len + 1..];
58
-
Ok(res)
59
-
}
60
-
61
-
fn take_byte(&mut self) -> Result<u8, Error> {
62
-
if self.input.is_empty() {
63
-
return Err(Error::UnexpectedEof);
64
-
}
65
-
66
-
let v = self.input[0];
67
-
self.input = &self.input[1..];
68
-
Ok(v)
69
-
}
70
-
}
71
-
72
-
/// Returns: a tuple containing the deserialized struct and the bytes used
73
-
pub fn from_slice<'a, T: Deserialize<'a>>(b: &'a [u8]) -> Result<(T, usize), Error> {
74
-
let mut de = Deserializer::from_bytes(b);
75
-
let v = T::deserialize(&mut de)?;
76
-
Ok((v, b.len() - de.input.len()))
77
-
}
78
-
79
-
impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
80
-
type Error = Error;
81
-
82
-
fn deserialize_any<V: Visitor<'de>>(self, _: V) -> Result<V::Value, Self::Error> {
83
-
unimplemented!()
84
-
}
85
-
86
-
fn deserialize_u8<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
87
-
visitor.visit_u8(self.take_byte()?)
88
-
}
89
-
90
-
fn deserialize_u32<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
91
-
visitor.visit_u32(self.unpack_dd()?)
92
-
}
93
-
94
-
fn deserialize_u64<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
95
-
visitor.visit_u64(self.unpack_dq()?)
96
-
}
97
-
98
-
fn deserialize_seq<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
99
-
let len = self.unpack_dd()?;
100
-
101
-
visitor.visit_seq(Access {
102
-
len: len as usize,
103
-
de: &mut *self,
104
-
})
105
-
}
106
-
107
-
fn deserialize_str<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
108
-
visitor.visit_borrowed_str(self.unpack_cstr()?)
109
-
}
110
-
111
-
fn deserialize_bytes<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
112
-
let v = self.unpack_var_bytes()?;
113
-
visitor.visit_borrowed_bytes(v)
114
-
}
115
-
116
-
fn deserialize_tuple<V: Visitor<'de>>(self, len: usize, visitor: V) -> Result<V::Value, Self::Error> {
117
-
visitor.visit_seq(Access {
118
-
len,
119
-
de: &mut *self,
120
-
})
121
-
}
122
-
123
-
fn deserialize_tuple_struct<V: Visitor<'de>>(self, _name: &'static str, len: usize, visitor: V) -> Result<V::Value, Self::Error> {
124
-
self.deserialize_tuple(len, visitor)
125
-
}
126
-
127
-
fn deserialize_struct<V: Visitor<'de>>(self, name: &'static str, fields: &'static [&'static str], visitor: V) -> Result<V::Value, Self::Error> {
128
-
self.deserialize_tuple_struct(name, fields.len(), visitor)
129
-
}
130
-
131
-
serde::forward_to_deserialize_any! {
132
-
i8 i16 i32 i64 char u16 bool
133
-
f32 f64 string byte_buf option unit unit_struct newtype_struct map enum identifier ignored_any
134
-
}
135
-
}
136
-
137
-
struct Access<'a, 'de> {
138
-
de: &'a mut Deserializer<'de>,
139
-
len: usize,
140
-
}
141
-
142
-
impl<'de, 'a> SeqAccess<'a> for Access<'de, 'a> {
143
-
type Error = Error;
144
-
145
-
fn next_element_seed<T: DeserializeSeed<'a>>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error> {
146
-
if self.len > 0 {
147
-
self.len -= 1;
148
-
149
-
let v = serde::de::DeserializeSeed::deserialize(seed, &mut *self.de)?;
150
-
Ok(Some(v))
151
-
} else {
152
-
Ok(None)
153
-
}
154
-
}
155
-
156
-
fn size_hint(&self) -> Option<usize> {
157
-
Some(self.len)
158
-
}
159
-
}
1
+
use super::Error;
2
+
use serde::de::{self, DeserializeSeed, SeqAccess, Visitor};
3
+
use serde::Deserialize;
4
+
5
+
struct Deserializer<'de> {
6
+
input: &'de [u8],
7
+
}
8
+
9
+
impl<'de> Deserializer<'de> {
10
+
fn from_bytes(b: &'de [u8]) -> Self {
11
+
Self { input: b }
12
+
}
13
+
14
+
fn unpack_dd(&mut self) -> Result<u32, Error> {
15
+
let (v, len) = super::packing::unpack_dd(self.input);
16
+
if len == 0 {
17
+
Err(Error::UnexpectedEof)
18
+
} else {
19
+
self.input = &self.input[len..];
20
+
Ok(v)
21
+
}
22
+
}
23
+
24
+
fn unpack_dq(&mut self) -> Result<u64, Error> {
25
+
let a = self.unpack_dd()? as u64;
26
+
let b = self.unpack_dd()? as u64;
27
+
Ok((a << 32) | b)
28
+
}
29
+
30
+
fn unpack_var_bytes(&mut self) -> Result<&'de [u8], Error> {
31
+
let bytes = self.unpack_dd()? as usize;
32
+
if bytes > self.input.len() {
33
+
return Err(Error::UnexpectedEof);
34
+
}
35
+
36
+
let payload = &self.input[..bytes];
37
+
self.input = &self.input[bytes..];
38
+
assert_eq!(payload.len(), bytes);
39
+
40
+
Ok(payload)
41
+
}
42
+
43
+
fn unpack_cstr(&mut self) -> Result<&'de str, Error> {
44
+
let len = self
45
+
.input
46
+
.iter()
47
+
.enumerate()
48
+
.find_map(|(idx, &v)| if v == 0 { Some(idx) } else { None });
49
+
let len = match len {
50
+
Some(v) => v,
51
+
None => return Err(Error::UnexpectedEof),
52
+
};
53
+
let res = match std::str::from_utf8(&self.input[..len]) {
54
+
Ok(v) => v,
55
+
Err(err) => {
56
+
return Err(err.into());
57
+
},
58
+
};
59
+
self.input = &self.input[len + 1..];
60
+
Ok(res)
61
+
}
62
+
63
+
fn take_byte(&mut self) -> Result<u8, Error> {
64
+
if self.input.is_empty() {
65
+
return Err(Error::UnexpectedEof);
66
+
}
67
+
68
+
let v = self.input[0];
69
+
self.input = &self.input[1..];
70
+
Ok(v)
71
+
}
72
+
}
73
+
74
+
/// Returns: a tuple containing the deserialized struct and the bytes used
75
+
pub fn from_slice<'a, T: Deserialize<'a>>(b: &'a [u8]) -> Result<(T, usize), Error> {
76
+
let mut de = Deserializer::from_bytes(b);
77
+
let v = T::deserialize(&mut de)?;
78
+
Ok((v, b.len() - de.input.len()))
79
+
}
80
+
81
+
impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
82
+
type Error = Error;
83
+
84
+
fn deserialize_any<V: Visitor<'de>>(self, _: V) -> Result<V::Value, Self::Error> {
85
+
unimplemented!()
86
+
}
87
+
88
+
fn deserialize_u8<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
89
+
visitor.visit_u8(self.take_byte()?)
90
+
}
91
+
92
+
fn deserialize_u32<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
93
+
visitor.visit_u32(self.unpack_dd()?)
94
+
}
95
+
96
+
fn deserialize_u64<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
97
+
visitor.visit_u64(self.unpack_dq()?)
98
+
}
99
+
100
+
fn deserialize_seq<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
101
+
let len = self.unpack_dd()?;
102
+
103
+
visitor.visit_seq(Access { len: len as usize, de: &mut *self })
104
+
}
105
+
106
+
fn deserialize_str<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
107
+
visitor.visit_borrowed_str(self.unpack_cstr()?)
108
+
}
109
+
110
+
fn deserialize_bytes<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
111
+
let v = self.unpack_var_bytes()?;
112
+
visitor.visit_borrowed_bytes(v)
113
+
}
114
+
115
+
fn deserialize_tuple<V: Visitor<'de>>(
116
+
self, len: usize, visitor: V,
117
+
) -> Result<V::Value, Self::Error> {
118
+
visitor.visit_seq(Access { len, de: &mut *self })
119
+
}
120
+
121
+
fn deserialize_tuple_struct<V: Visitor<'de>>(
122
+
self, _name: &'static str, len: usize, visitor: V,
123
+
) -> Result<V::Value, Self::Error> {
124
+
self.deserialize_tuple(len, visitor)
125
+
}
126
+
127
+
fn deserialize_struct<V: Visitor<'de>>(
128
+
self, name: &'static str, fields: &'static [&'static str], visitor: V,
129
+
) -> Result<V::Value, Self::Error> {
130
+
self.deserialize_tuple_struct(name, fields.len(), visitor)
131
+
}
132
+
133
+
serde::forward_to_deserialize_any! {
134
+
i8 i16 i32 i64 char u16 bool
135
+
f32 f64 string byte_buf option unit unit_struct newtype_struct map enum identifier ignored_any
136
+
}
137
+
}
138
+
139
+
struct Access<'a, 'de> {
140
+
de: &'a mut Deserializer<'de>,
141
+
len: usize,
142
+
}
143
+
144
+
impl<'de, 'a> SeqAccess<'a> for Access<'de, 'a> {
145
+
type Error = Error;
146
+
147
+
fn next_element_seed<T: DeserializeSeed<'a>>(
148
+
&mut self, seed: T,
149
+
) -> Result<Option<T::Value>, Self::Error> {
150
+
if self.len > 0 {
151
+
self.len -= 1;
152
+
153
+
let v = serde::de::DeserializeSeed::deserialize(seed, &mut *self.de)?;
154
+
Ok(Some(v))
155
+
} else {
156
+
Ok(None)
157
+
}
158
+
}
159
+
160
+
fn size_hint(&self) -> Option<usize> {
161
+
Some(self.len)
162
+
}
163
+
}
+156
-118
common/src/rpc/messages.rs
+156
-118
common/src/rpc/messages.rs
···
1
-
use serde::{Serialize, Deserialize};
2
-
use std::borrow::Cow;
3
-
4
-
#[derive(Deserialize, Serialize)]
5
-
pub struct RpcFail<'a> {
6
-
pub code: u32,
7
-
pub message: &'a str,
8
-
}
9
-
10
-
#[derive(Serialize, Deserialize)]
11
-
pub struct RpcNotify<'a> {
12
-
pub code: u32,
13
-
pub msg: &'a str,
14
-
}
15
-
16
-
#[derive(Serialize, Deserialize, Debug)]
17
-
pub struct Creds<'a> {
18
-
pub username: &'a str,
19
-
pub password: &'a str,
20
-
}
21
-
22
-
#[derive(Serialize, Deserialize)]
23
-
pub struct RpcHello<'a> {
24
-
pub protocol_version: u32,
25
-
pub license_data: &'a [u8],
26
-
pub lic_number: [u8; 6],
27
-
pub unk2: u32,
28
-
}
29
-
30
-
#[derive(Deserialize, Serialize, Clone)]
31
-
pub struct PullMetadataFunc<'a> {
32
-
pub unk0: u32,
33
-
pub mb_hash: &'a [u8],
34
-
}
35
-
36
-
#[derive(Deserialize, Serialize)]
37
-
pub struct PullMetadata<'a> {
38
-
pub unk0: u32,
39
-
pub unk1: Cow<'a, [u32]>,
40
-
41
-
#[serde(borrow)]
42
-
pub funcs: Cow<'a, [PullMetadataFunc<'a>]>,
43
-
}
44
-
45
-
#[derive(Deserialize, Serialize, Clone)]
46
-
pub struct PullMetadataResultFunc<'a> {
47
-
pub name: Cow<'a, str>,
48
-
pub len: u32,
49
-
pub mb_data: Cow<'a, [u8]>,
50
-
pub popularity: u32,
51
-
}
52
-
53
-
#[derive(Deserialize, Serialize)]
54
-
pub struct PullMetadataResult<'a> {
55
-
pub unk0: Cow<'a, [u32]>,
56
-
#[serde(borrow)]
57
-
pub funcs: Cow<'a, [PullMetadataResultFunc<'a>]>,
58
-
}
59
-
60
-
#[derive(Clone, Deserialize, Serialize)]
61
-
pub struct PushMetadataFunc<'a> {
62
-
pub name: &'a str,
63
-
pub func_len: u32,
64
-
pub func_data: &'a [u8],
65
-
66
-
// PullMetadata's fields (tuple 'unk2') are similar to these two
67
-
pub unk2: u32,
68
-
pub hash: &'a [u8],
69
-
}
70
-
71
-
#[derive(Deserialize, Serialize)]
72
-
pub struct PushMetadata<'a> {
73
-
pub unk0: u32,
74
-
pub idb_path: &'a str,
75
-
pub file_path: &'a str,
76
-
pub md5: [u8; 16],
77
-
pub hostname: &'a str,
78
-
pub funcs: Cow<'a, [PushMetadataFunc<'a>]>,
79
-
pub unk1: Cow<'a, [u64]>,
80
-
}
81
-
82
-
#[derive(Deserialize, Serialize)]
83
-
pub struct PushMetadataResult<'a> {
84
-
// array of 0=exists, 1=NEW
85
-
pub status: Cow<'a, [u32]>,
86
-
}
87
-
88
-
#[derive(Debug, Deserialize, Serialize)]
89
-
pub struct DelHistory<'a> {
90
-
pub unk0: u32, // =0x08
91
-
pub unk1: Cow<'a, [Cow<'a, str>]>,
92
-
pub unk2: Cow<'a, [[u64; 2]]>,
93
-
pub unk3: Cow<'a, [[u64; 2]]>,
94
-
pub unk4: Cow<'a, [Cow<'a, str>]>,
95
-
pub unk5: Cow<'a, [Cow<'a, str>]>,
96
-
pub unk6: Cow<'a, [Cow<'a, str>]>,
97
-
pub unk7: Cow<'a, [Cow<'a, str>]>,
98
-
pub unk8: Cow<'a, [Cow<'a, [u8; 16]>]>,
99
-
pub funcs: Cow<'a, [Cow<'a, [u8; 16]>]>,
100
-
pub unk10: Cow<'a, [[u64; 2]]>,
101
-
pub unk11: u64,
102
-
}
103
-
104
-
#[derive(Deserialize, Serialize)]
105
-
pub struct DelHistoryResult {
106
-
pub deleted_mds: u32,
107
-
}
108
-
109
-
#[derive(Debug, Deserialize, Serialize)]
110
-
pub struct HelloResult<'a> {
111
-
pub unk0: Cow<'a, str>,
112
-
pub unk1: Cow<'a, str>,
113
-
pub unk2: Cow<'a, str>,
114
-
pub unk3: Cow<'a, str>,
115
-
pub unk4: u32,
116
-
pub unk5: u64,
117
-
pub unk6: u32,
118
-
}
1
+
use serde::{Deserialize, Serialize};
2
+
use std::borrow::Cow;
3
+
4
+
#[derive(Deserialize, Serialize)]
5
+
pub struct RpcFail<'a> {
6
+
pub code: u32,
7
+
pub message: &'a str,
8
+
}
9
+
10
+
#[derive(Serialize, Deserialize)]
11
+
pub struct RpcNotify<'a> {
12
+
pub code: u32,
13
+
pub msg: &'a str,
14
+
}
15
+
16
+
#[derive(Serialize, Deserialize, Debug)]
17
+
pub struct Creds<'a> {
18
+
pub username: &'a str,
19
+
pub password: &'a str,
20
+
}
21
+
22
+
#[derive(Serialize, Deserialize)]
23
+
pub struct RpcHello<'a> {
24
+
pub protocol_version: u32,
25
+
pub license_data: &'a [u8],
26
+
pub lic_number: [u8; 6],
27
+
pub unk2: u32,
28
+
}
29
+
30
+
#[derive(Debug, Deserialize, Serialize, Clone)]
31
+
pub struct PullMetadataFunc<'a> {
32
+
pub unk0: u32,
33
+
pub mb_hash: &'a [u8],
34
+
}
35
+
36
+
#[derive(Deserialize, Serialize)]
37
+
pub struct PullMetadata<'a> {
38
+
pub unk0: u32,
39
+
pub unk1: Cow<'a, [u32]>,
40
+
41
+
#[serde(borrow)]
42
+
pub funcs: Cow<'a, [PullMetadataFunc<'a>]>,
43
+
}
44
+
45
+
#[derive(Deserialize, Serialize, Clone)]
46
+
pub struct PullMetadataResultFunc<'a> {
47
+
pub name: Cow<'a, str>,
48
+
pub len: u32,
49
+
pub mb_data: Cow<'a, [u8]>,
50
+
pub popularity: u32,
51
+
}
52
+
53
+
#[derive(Deserialize, Serialize)]
54
+
pub struct PullMetadataResult<'a> {
55
+
pub unk0: Cow<'a, [u32]>,
56
+
#[serde(borrow)]
57
+
pub funcs: Cow<'a, [PullMetadataResultFunc<'a>]>,
58
+
}
59
+
60
+
#[derive(Clone, Deserialize, Serialize)]
61
+
pub struct PushMetadataFunc<'a> {
62
+
pub name: &'a str,
63
+
pub func_len: u32,
64
+
pub func_data: &'a [u8],
65
+
66
+
// PullMetadata's fields (tuple 'unk2') are similar to these two
67
+
pub unk2: u32,
68
+
pub hash: &'a [u8],
69
+
}
70
+
71
+
#[derive(Deserialize, Serialize)]
72
+
pub struct PushMetadata<'a> {
73
+
pub unk0: u32,
74
+
pub idb_path: &'a str,
75
+
pub file_path: &'a str,
76
+
pub md5: [u8; 16],
77
+
pub hostname: &'a str,
78
+
pub funcs: Cow<'a, [PushMetadataFunc<'a>]>,
79
+
pub unk1: Cow<'a, [u64]>,
80
+
}
81
+
82
+
#[derive(Deserialize, Serialize)]
83
+
pub struct PushMetadataResult<'a> {
84
+
// array of 0=exists, 1=NEW
85
+
pub status: Cow<'a, [u32]>,
86
+
}
87
+
88
+
#[derive(Debug, Deserialize, Serialize)]
89
+
pub struct DelHistory<'a> {
90
+
pub unk0: u32, // =0x08
91
+
pub unk1: Cow<'a, [Cow<'a, str>]>,
92
+
pub unk2: Cow<'a, [[u64; 2]]>,
93
+
pub unk3: Cow<'a, [[u64; 2]]>,
94
+
pub unk4: Cow<'a, [Cow<'a, str>]>,
95
+
pub unk5: Cow<'a, [Cow<'a, str>]>,
96
+
pub unk6: Cow<'a, [Cow<'a, str>]>,
97
+
pub unk7: Cow<'a, [Cow<'a, str>]>,
98
+
pub unk8: Cow<'a, [Cow<'a, [u8; 16]>]>,
99
+
pub funcs: Cow<'a, [Cow<'a, [u8; 16]>]>,
100
+
pub unk10: Cow<'a, [[u64; 2]]>,
101
+
pub unk11: u64,
102
+
}
103
+
104
+
#[derive(Deserialize, Serialize)]
105
+
pub struct DelHistoryResult {
106
+
pub deleted_mds: u32,
107
+
}
108
+
109
+
#[derive(Debug, Deserialize, Serialize, Default)]
110
+
pub struct LicenseInfo<'a> {
111
+
pub id: Cow<'a, str>,
112
+
pub name: Cow<'a, str>,
113
+
pub email: Cow<'a, str>,
114
+
}
115
+
116
+
#[derive(Debug, Deserialize, Serialize, Default)]
117
+
pub struct HelloResult<'a> {
118
+
pub license_info: LicenseInfo<'a>,
119
+
pub username: Cow<'a, str>,
120
+
pub karma: u32,
121
+
pub last_active: u64,
122
+
pub features: u32,
123
+
}
124
+
125
+
#[derive(Debug, Deserialize, Serialize)]
126
+
pub struct GetFuncHistories<'a> {
127
+
#[serde(borrow)]
128
+
pub funcs: Cow<'a, [PullMetadataFunc<'a>]>,
129
+
pub unk0: u32,
130
+
}
131
+
132
+
#[derive(Debug, Deserialize, Serialize, Clone)]
133
+
pub struct FunctionHistory<'a> {
134
+
pub unk0: u64,
135
+
pub unk1: u64,
136
+
pub name: Cow<'a, str>,
137
+
pub metadata: Cow<'a, [u8]>,
138
+
pub timestamp: u64,
139
+
pub author_idx: u32,
140
+
pub idb_path_idx: u32,
141
+
}
142
+
143
+
#[derive(Debug, Deserialize, Serialize, Clone)]
144
+
pub struct FunctionHistories<'a> {
145
+
#[serde(borrow)]
146
+
pub log: Cow<'a, [FunctionHistory<'a>]>,
147
+
}
148
+
149
+
#[derive(Debug, Deserialize, Serialize)]
150
+
pub struct GetFuncHistoriesResult<'a> {
151
+
pub status: Cow<'a, [u32]>,
152
+
#[serde(borrow)]
153
+
pub funcs: Cow<'a, [FunctionHistories<'a>]>,
154
+
pub users: Cow<'a, [Cow<'a, str>]>,
155
+
pub dbs: Cow<'a, [Cow<'a, str>]>,
156
+
}
+257
-234
common/src/rpc/mod.rs
+257
-234
common/src/rpc/mod.rs
···
1
-
use tokio::io::{AsyncWriteExt, AsyncWrite, AsyncRead, AsyncReadExt};
2
-
use log::*;
3
-
mod ser;
4
-
pub(crate) mod de;
5
-
mod messages;
6
-
mod packing;
7
-
use serde::Serializer;
8
-
9
-
pub use messages::*;
10
-
11
-
#[derive(Debug)]
12
-
pub enum Error {
13
-
UnexpectedEof,
14
-
Utf8Error(std::str::Utf8Error),
15
-
IOError(std::io::Error),
16
-
Serde(String),
17
-
InvalidData,
18
-
OutOfMemory,
19
-
Todo,
20
-
Timeout,
21
-
Eof,
22
-
}
23
-
24
-
impl std::fmt::Display for Error {
25
-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26
-
std::fmt::Debug::fmt(self, f)
27
-
}
28
-
}
29
-
30
-
impl std::error::Error for Error {}
31
-
impl serde::ser::Error for Error {
32
-
fn custom<T: std::fmt::Display>(msg: T) -> Self {
33
-
Error::Serde(msg.to_string())
34
-
}
35
-
}
36
-
impl serde::de::Error for Error {
37
-
fn custom<T: std::fmt::Display>(msg: T) -> Self {
38
-
Error::Serde(msg.to_string())
39
-
}
40
-
}
41
-
impl From<std::io::Error> for Error {
42
-
fn from(v: std::io::Error) -> Self {
43
-
Error::IOError(v)
44
-
}
45
-
}
46
-
impl From<std::str::Utf8Error> for Error {
47
-
fn from(v: std::str::Utf8Error) -> Self {
48
-
Error::Utf8Error(v)
49
-
}
50
-
}
51
-
impl From<std::collections::TryReserveError> for Error {
52
-
fn from(v: std::collections::TryReserveError) -> Self {
53
-
error!("failed to allocate {} bytes", v);
54
-
Error::OutOfMemory
55
-
}
56
-
}
57
-
58
-
fn get_code_maxlen(code: u8) -> usize {
59
-
match code {
60
-
0x0e => 50 * 1024 * 1024, // PullMD: 50 MiB
61
-
0x10 => 200 * 1024 * 1024, // PushMD: 200 MiB
62
-
_ => 1024 * 50, // otherwise 50K
63
-
}
64
-
}
65
-
66
-
pub async fn read_packet<R: AsyncRead + Unpin>(mut reader: R) -> Result<Vec<u8>, Error> {
67
-
let mut head = [0u8; 5];
68
-
match reader.read_exact(&mut head).await {
69
-
Ok(_) => {},
70
-
Err(e) if e.kind() == std::io::ErrorKind::UnexpectedEof => return Err(Error::Eof), // client decided to disconnect...
71
-
Err(e) => return Err(e.into()),
72
-
}
73
-
let code = head[4];
74
-
let mut buf_len = [0u8; 4];
75
-
buf_len.copy_from_slice(&head[..4]);
76
-
77
-
let buf_len = u32::from_be_bytes(buf_len) as usize;
78
-
if buf_len < 4 {
79
-
return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "payload size is too small").into());
80
-
}
81
-
82
-
let max_len = get_code_maxlen(code);
83
-
84
-
if buf_len > max_len {
85
-
info!("maxium size exceeded: code={}: max={}; req={}", code, max_len, buf_len);
86
-
return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "request length exceeded maximum limit").into());
87
-
}
88
-
89
-
// the additional byte is for the RPC code
90
-
trace!("expecting {} bytes...", buf_len);
91
-
let buf_len = buf_len + 1;
92
-
93
-
let mut data = Vec::new();
94
-
data.try_reserve_exact(buf_len)?;
95
-
data.resize(buf_len, 0);
96
-
data[0] = code;
97
-
reader.read_exact(&mut data[1..]).await?;
98
-
99
-
Ok(data)
100
-
}
101
-
102
-
async fn write_packet<W: AsyncWrite + Unpin>(mut w: W, data: &[u8]) -> Result<(), std::io::Error> {
103
-
let buf_len: u32 = (data.len() - 1) as u32;
104
-
let buf_len = buf_len.to_be_bytes();
105
-
w.write_all(&buf_len).await?;
106
-
w.write_all(data).await?;
107
-
Ok(())
108
-
}
109
-
110
-
pub enum RpcMessage<'a> {
111
-
Ok(()),
112
-
Fail(RpcFail<'a>),
113
-
Notify(RpcNotify<'a>),
114
-
Hello(RpcHello<'a>, Option<Creds<'a>>),
115
-
PullMetadata(PullMetadata<'a>),
116
-
PullMetadataResult(PullMetadataResult<'a>),
117
-
PushMetadata(PushMetadata<'a>),
118
-
PushMetadataResult(PushMetadataResult<'a>),
119
-
DelHistory(DelHistory<'a>),
120
-
DelHistoryResult(DelHistoryResult),
121
-
HelloResult(HelloResult<'a>),
122
-
}
123
-
124
-
impl<'a> serde::Serialize for RpcMessage<'a> {
125
-
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
126
-
use serde::ser::SerializeTuple;
127
-
128
-
let code = self.get_code();
129
-
let mut tuple = serializer.serialize_tuple(2)?;
130
-
131
-
// u8 is pushed without further encoding...
132
-
tuple.serialize_element(&code)?;
133
-
134
-
match self {
135
-
RpcMessage::Ok(msg) => tuple.serialize_element(msg)?,
136
-
RpcMessage::Fail(msg) => tuple.serialize_element(msg)?,
137
-
RpcMessage::Notify(msg) => tuple.serialize_element(msg)?,
138
-
RpcMessage::Hello(msg, _) => tuple.serialize_element(msg)?,
139
-
RpcMessage::PullMetadata(msg) => tuple.serialize_element(msg)?,
140
-
RpcMessage::PullMetadataResult(msg) => tuple.serialize_element(msg)?,
141
-
RpcMessage::PushMetadata(msg) => tuple.serialize_element(msg)?,
142
-
RpcMessage::PushMetadataResult(msg) => tuple.serialize_element(msg)?,
143
-
RpcMessage::DelHistory(msg) => tuple.serialize_element(msg)?,
144
-
RpcMessage::DelHistoryResult(msg) => tuple.serialize_element(msg)?,
145
-
RpcMessage::HelloResult(msg) => tuple.serialize_element(msg)?,
146
-
}
147
-
148
-
tuple.end()
149
-
}
150
-
}
151
-
152
-
impl<'a> RpcMessage<'a> {
153
-
fn deserialize_check<T: serde::Deserialize<'a>>(payload: &'a [u8]) -> Result<T, Error> {
154
-
let v = de::from_slice(payload)?;
155
-
if v.1 != payload.len() {
156
-
let bytes_remaining = crate::make_pretty_hex(&payload[v.1..]);
157
-
trace!("{} remaining bytes after deserializing {}\n{bytes_remaining}", payload.len() - v.1, std::any::type_name::<T>());
158
-
}
159
-
Ok(v.0)
160
-
}
161
-
162
-
pub fn deserialize(payload: &'a [u8]) -> Result<RpcMessage<'a>, Error> {
163
-
let msg_type = payload[0];
164
-
let payload = &payload[1..];
165
-
166
-
let res = match msg_type {
167
-
0x0a => {
168
-
if !payload.is_empty() {
169
-
trace!("Ok message with additional data: {} bytes: {payload:02x?}", payload.len());
170
-
}
171
-
RpcMessage::Ok(())
172
-
},
173
-
0x0b => RpcMessage::Fail(Self::deserialize_check(payload)?),
174
-
0x0c => RpcMessage::Notify(Self::deserialize_check(payload)?),
175
-
0x0d => {
176
-
let (hello, consumed) = de::from_slice::<messages::RpcHello>(payload)?;
177
-
let creds = if payload.len() > consumed && hello.protocol_version > 2 {
178
-
let payload = &payload[consumed..];
179
-
let (creds, consumed) = de::from_slice::<Creds>(payload)?;
180
-
if payload.len() != consumed {
181
-
trace!("bytes remaining after HelloV2: {payload:02x?}");
182
-
}
183
-
Some(creds)
184
-
} else {
185
-
if hello.protocol_version > 2 || payload.len() != consumed {
186
-
trace!("Unexpected Hello msg: {payload:02x?}");
187
-
}
188
-
None
189
-
};
190
-
RpcMessage::Hello(hello, creds)
191
-
},
192
-
0x0e => RpcMessage::PullMetadata(Self::deserialize_check(payload)?),
193
-
0x0f => RpcMessage::PullMetadataResult(Self::deserialize_check(payload)?),
194
-
0x10 => RpcMessage::PushMetadata(Self::deserialize_check(payload)?),
195
-
0x11 => RpcMessage::PushMetadataResult(Self::deserialize_check(payload)?),
196
-
0x18 => RpcMessage::DelHistory(Self::deserialize_check(payload)?),
197
-
0x19 => RpcMessage::DelHistoryResult(Self::deserialize_check(payload)?),
198
-
0x31 => RpcMessage::HelloResult(Self::deserialize_check(payload)?),
199
-
_ => {
200
-
trace!("got invalid message type '{:02x}'", msg_type);
201
-
return Err(Error::InvalidData);
202
-
},
203
-
};
204
-
205
-
Ok(res)
206
-
}
207
-
208
-
pub async fn async_write<W: AsyncWrite + Unpin>(&self, w: W) -> Result<(), Error> {
209
-
let mut output = Vec::with_capacity(32);
210
-
ser::to_writer(self, &mut output)?;
211
-
212
-
write_packet(w, &output).await?;
213
-
214
-
Ok(())
215
-
}
216
-
217
-
fn get_code(&self) -> u8 {
218
-
use RpcMessage::*;
219
-
220
-
match self {
221
-
Ok(_) => 0x0a,
222
-
Fail(_) => 0x0b,
223
-
Notify(_) => 0x0c,
224
-
Hello(..) => 0x0d,
225
-
PullMetadata(_) => 0x0e,
226
-
PullMetadataResult(_) => 0x0f,
227
-
PushMetadata(_) => 0x10,
228
-
PushMetadataResult(_) => 0x11,
229
-
DelHistory(_) => 0x18,
230
-
DelHistoryResult(_) => 0x19,
231
-
HelloResult(_) => 0x31,
232
-
}
233
-
}
234
-
}
1
+
use log::*;
2
+
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
3
+
pub(crate) mod de;
4
+
mod messages;
5
+
mod packing;
6
+
mod ser;
7
+
use serde::Serializer;
8
+
9
+
pub use messages::*;
10
+
11
+
#[derive(Debug)]
12
+
pub enum Error {
13
+
UnexpectedEof,
14
+
Utf8Error(std::str::Utf8Error),
15
+
IOError(std::io::Error),
16
+
Serde(String),
17
+
InvalidData,
18
+
OutOfMemory,
19
+
Todo,
20
+
Timeout,
21
+
Eof,
22
+
}
23
+
24
+
impl std::fmt::Display for Error {
25
+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26
+
std::fmt::Debug::fmt(self, f)
27
+
}
28
+
}
29
+
30
+
impl std::error::Error for Error {}
31
+
impl serde::ser::Error for Error {
32
+
fn custom<T: std::fmt::Display>(msg: T) -> Self {
33
+
Error::Serde(msg.to_string())
34
+
}
35
+
}
36
+
impl serde::de::Error for Error {
37
+
fn custom<T: std::fmt::Display>(msg: T) -> Self {
38
+
Error::Serde(msg.to_string())
39
+
}
40
+
}
41
+
impl From<std::io::Error> for Error {
42
+
fn from(v: std::io::Error) -> Self {
43
+
Error::IOError(v)
44
+
}
45
+
}
46
+
impl From<std::str::Utf8Error> for Error {
47
+
fn from(v: std::str::Utf8Error) -> Self {
48
+
Error::Utf8Error(v)
49
+
}
50
+
}
51
+
impl From<std::collections::TryReserveError> for Error {
52
+
fn from(v: std::collections::TryReserveError) -> Self {
53
+
error!("failed to allocate {} bytes", v);
54
+
Error::OutOfMemory
55
+
}
56
+
}
57
+
58
+
fn get_code_maxlen(code: u8) -> usize {
59
+
match code {
60
+
0x0e => 50 * 1024 * 1024, // PullMD: 50 MiB
61
+
0x10 => 200 * 1024 * 1024, // PushMD: 200 MiB
62
+
_ => 1024 * 50, // otherwise 50K
63
+
}
64
+
}
65
+
66
+
pub async fn read_packet<R: AsyncRead + Unpin>(mut reader: R) -> Result<Vec<u8>, Error> {
67
+
let mut head = [0u8; 5];
68
+
match reader.read_exact(&mut head).await {
69
+
Ok(_) => {},
70
+
Err(e) if e.kind() == std::io::ErrorKind::UnexpectedEof => return Err(Error::Eof), // client decided to disconnect...
71
+
Err(e) => return Err(e.into()),
72
+
}
73
+
let code = head[4];
74
+
let mut buf_len = [0u8; 4];
75
+
buf_len.copy_from_slice(&head[..4]);
76
+
77
+
let buf_len = u32::from_be_bytes(buf_len) as usize;
78
+
if buf_len < 4 {
79
+
return Err(std::io::Error::new(
80
+
std::io::ErrorKind::InvalidData,
81
+
"payload size is too small",
82
+
)
83
+
.into());
84
+
}
85
+
86
+
let max_len = get_code_maxlen(code);
87
+
88
+
if buf_len > max_len {
89
+
info!("maxium size exceeded: code={}: max={}; req={}", code, max_len, buf_len);
90
+
return Err(std::io::Error::new(
91
+
std::io::ErrorKind::InvalidData,
92
+
"request length exceeded maximum limit",
93
+
)
94
+
.into());
95
+
}
96
+
97
+
// the additional byte is for the RPC code
98
+
trace!("expecting {} bytes...", buf_len);
99
+
let buf_len = buf_len + 1;
100
+
101
+
let mut data = Vec::new();
102
+
data.try_reserve_exact(buf_len)?;
103
+
data.resize(buf_len, 0);
104
+
data[0] = code;
105
+
reader.read_exact(&mut data[1..]).await?;
106
+
107
+
Ok(data)
108
+
}
109
+
110
+
async fn write_packet<W: AsyncWrite + Unpin>(mut w: W, data: &[u8]) -> Result<(), std::io::Error> {
111
+
let buf_len: u32 = (data.len() - 1) as u32;
112
+
let buf_len = buf_len.to_be_bytes();
113
+
w.write_all(&buf_len).await?;
114
+
w.write_all(data).await?;
115
+
Ok(())
116
+
}
117
+
118
+
pub enum RpcMessage<'a> {
119
+
Ok(()),
120
+
Fail(RpcFail<'a>),
121
+
Notify(RpcNotify<'a>),
122
+
Hello(RpcHello<'a>, Option<Creds<'a>>),
123
+
PullMetadata(PullMetadata<'a>),
124
+
PullMetadataResult(PullMetadataResult<'a>),
125
+
PushMetadata(PushMetadata<'a>),
126
+
PushMetadataResult(PushMetadataResult<'a>),
127
+
DelHistory(DelHistory<'a>),
128
+
DelHistoryResult(DelHistoryResult),
129
+
GetFuncHistories(GetFuncHistories<'a>),
130
+
GetFuncHistoriesResult(GetFuncHistoriesResult<'a>),
131
+
HelloResult(HelloResult<'a>),
132
+
}
133
+
134
+
impl<'a> serde::Serialize for RpcMessage<'a> {
135
+
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
136
+
use serde::ser::SerializeTuple;
137
+
138
+
let code = self.get_code();
139
+
let mut tuple = serializer.serialize_tuple(2)?;
140
+
141
+
// u8 is pushed without further encoding...
142
+
tuple.serialize_element(&code)?;
143
+
144
+
match self {
145
+
RpcMessage::Ok(msg) => tuple.serialize_element(msg)?,
146
+
RpcMessage::Fail(msg) => tuple.serialize_element(msg)?,
147
+
RpcMessage::Notify(msg) => tuple.serialize_element(msg)?,
148
+
RpcMessage::Hello(msg, _) => tuple.serialize_element(msg)?,
149
+
RpcMessage::PullMetadata(msg) => tuple.serialize_element(msg)?,
150
+
RpcMessage::PullMetadataResult(msg) => tuple.serialize_element(msg)?,
151
+
RpcMessage::PushMetadata(msg) => tuple.serialize_element(msg)?,
152
+
RpcMessage::PushMetadataResult(msg) => tuple.serialize_element(msg)?,
153
+
RpcMessage::DelHistory(msg) => tuple.serialize_element(msg)?,
154
+
RpcMessage::DelHistoryResult(msg) => tuple.serialize_element(msg)?,
155
+
RpcMessage::GetFuncHistories(msg) => tuple.serialize_element(msg)?,
156
+
RpcMessage::GetFuncHistoriesResult(msg) => tuple.serialize_element(msg)?,
157
+
RpcMessage::HelloResult(msg) => tuple.serialize_element(msg)?,
158
+
}
159
+
160
+
tuple.end()
161
+
}
162
+
}
163
+
164
+
impl<'a> RpcMessage<'a> {
165
+
fn deserialize_check<T: serde::Deserialize<'a>>(payload: &'a [u8]) -> Result<T, Error> {
166
+
let v = de::from_slice(payload)?;
167
+
if v.1 != payload.len() {
168
+
let bytes_remaining = crate::make_pretty_hex(&payload[v.1..]);
169
+
trace!(
170
+
"{} remaining bytes after deserializing {}\n{bytes_remaining}",
171
+
payload.len() - v.1,
172
+
std::any::type_name::<T>()
173
+
);
174
+
}
175
+
Ok(v.0)
176
+
}
177
+
178
+
pub fn deserialize(payload: &'a [u8]) -> Result<RpcMessage<'a>, Error> {
179
+
let msg_type = payload[0];
180
+
let payload = &payload[1..];
181
+
182
+
let res = match msg_type {
183
+
0x0a => {
184
+
if !payload.is_empty() {
185
+
trace!(
186
+
"Ok message with additional data: {} bytes: {payload:02x?}",
187
+
payload.len()
188
+
);
189
+
}
190
+
RpcMessage::Ok(())
191
+
},
192
+
0x0b => RpcMessage::Fail(Self::deserialize_check(payload)?),
193
+
0x0c => RpcMessage::Notify(Self::deserialize_check(payload)?),
194
+
0x0d => {
195
+
let (hello, consumed) = de::from_slice::<messages::RpcHello>(payload)?;
196
+
let creds = if payload.len() > consumed && hello.protocol_version > 2 {
197
+
let payload = &payload[consumed..];
198
+
let (creds, consumed) = de::from_slice::<Creds>(payload)?;
199
+
if payload.len() != consumed {
200
+
trace!("bytes remaining after HelloV2: {payload:02x?}");
201
+
}
202
+
Some(creds)
203
+
} else {
204
+
if hello.protocol_version > 2 || payload.len() != consumed {
205
+
trace!("Unexpected Hello msg: {payload:02x?}");
206
+
}
207
+
None
208
+
};
209
+
RpcMessage::Hello(hello, creds)
210
+
},
211
+
0x0e => RpcMessage::PullMetadata(Self::deserialize_check(payload)?),
212
+
0x0f => RpcMessage::PullMetadataResult(Self::deserialize_check(payload)?),
213
+
0x10 => RpcMessage::PushMetadata(Self::deserialize_check(payload)?),
214
+
0x11 => RpcMessage::PushMetadataResult(Self::deserialize_check(payload)?),
215
+
0x18 => RpcMessage::DelHistory(Self::deserialize_check(payload)?),
216
+
0x19 => RpcMessage::DelHistoryResult(Self::deserialize_check(payload)?),
217
+
0x2f => RpcMessage::GetFuncHistories(Self::deserialize_check(payload)?),
218
+
0x30 => RpcMessage::GetFuncHistoriesResult(Self::deserialize_check(payload)?),
219
+
0x31 => RpcMessage::HelloResult(Self::deserialize_check(payload)?),
220
+
_ => {
221
+
trace!("got invalid message type '{:02x}'", msg_type);
222
+
return Err(Error::InvalidData);
223
+
},
224
+
};
225
+
226
+
Ok(res)
227
+
}
228
+
229
+
pub async fn async_write<W: AsyncWrite + Unpin>(&self, w: W) -> Result<(), Error> {
230
+
let mut output = Vec::with_capacity(32);
231
+
ser::to_writer(self, &mut output)?;
232
+
233
+
write_packet(w, &output).await?;
234
+
235
+
Ok(())
236
+
}
237
+
238
+
fn get_code(&self) -> u8 {
239
+
use RpcMessage::*;
240
+
241
+
match self {
242
+
Ok(_) => 0x0a,
243
+
Fail(_) => 0x0b,
244
+
Notify(_) => 0x0c,
245
+
Hello(..) => 0x0d,
246
+
PullMetadata(_) => 0x0e,
247
+
PullMetadataResult(_) => 0x0f,
248
+
PushMetadata(_) => 0x10,
249
+
PushMetadataResult(_) => 0x11,
250
+
DelHistory(_) => 0x18,
251
+
DelHistoryResult(_) => 0x19,
252
+
GetFuncHistories(_) => 0x2f,
253
+
GetFuncHistoriesResult(_) => 0x30,
254
+
HelloResult(_) => 0x31,
255
+
}
256
+
}
257
+
}
+111
-104
common/src/rpc/packing.rs
+111
-104
common/src/rpc/packing.rs
···
1
-
/// packs a dd into `buf` returning amout of bytes written.
2
-
/// Returns 0 if buffer is too small
3
-
pub fn pack_dd(v: u32, buf: &mut [u8]) -> usize {
4
-
let bytes = v.to_le_bytes();
5
-
match v {
6
-
0..=0x7f => { // 0..0XXXXXXX (7 bits)
7
-
if buf.is_empty() {
8
-
return 0;
9
-
}
10
-
buf[0] = bytes[0];
11
-
1
12
-
},
13
-
0x80..=0x3fff => { // 10AAAAAA..BBBBBBBB (14 bits)
14
-
if buf.len() < 2 {
15
-
return 0;
16
-
}
17
-
buf[0] = 0x80 | bytes[1];
18
-
buf[1] = bytes[0];
19
-
2
20
-
},
21
-
0x4000..=0x1fffff => { // 11000000_AAAAAAAA_BBBBBBBB_CCCCCCCC (24 bits)
22
-
if buf.len() < 3 {
23
-
return 0;
24
-
}
25
-
buf[0] = 0xc0;
26
-
buf[1] = bytes[2];
27
-
buf[2] = bytes[1];
28
-
buf[3] = bytes[0];
29
-
4
30
-
},
31
-
0x200000..=u32::MAX => { // 11111111_AAAAAAAA_BBBBBBBB_CCCCCCCC_DDDDDDDD (32 bits)
32
-
if buf.len() < 5 {
33
-
return 0;
34
-
}
35
-
buf[0] = 0xff;
36
-
buf[1] = bytes[3];
37
-
buf[2] = bytes[2];
38
-
buf[3] = bytes[1];
39
-
buf[4] = bytes[0];
40
-
5
41
-
}
42
-
}
43
-
}
44
-
45
-
/// unpacks a dd from `buf`, returning the amount (value, byte consumed)
46
-
pub fn unpack_dd(buf: &[u8]) -> (u32, usize) {
47
-
if buf.is_empty() {
48
-
return (0, 0);
49
-
}
50
-
51
-
let msb = buf[0];
52
-
let mut val = [0u8; 4];
53
-
54
-
if msb & 0x80 == 0 { // 0......
55
-
val[0] = msb;
56
-
return (u32::from_le_bytes(val), 1);
57
-
}
58
-
if msb & 0x40 == 0 { // 10....../0x80
59
-
if buf.len() < 2 {
60
-
return (0, 0);
61
-
}
62
-
val[1] = msb & 0x3f;
63
-
val[0] = buf[1];
64
-
return (u32::from_le_bytes(val), 2);
65
-
}
66
-
if msb & 0x20 == 0 { // 110...../0xC0
67
-
if buf.len() < 4 {
68
-
return (0, 0);
69
-
}
70
-
val[3] = msb & 0x1f;
71
-
val[2] = buf[1];
72
-
val[1] = buf[2];
73
-
val[0] = buf[3];
74
-
return (u32::from_le_bytes(val), 4);
75
-
}
76
-
77
-
if buf.len() < 5 {
78
-
return (0, 0);
79
-
}
80
-
81
-
val[3] = buf[1];
82
-
val[2] = buf[2];
83
-
val[1] = buf[3];
84
-
val[0] = buf[4];
85
-
86
-
(u32::from_le_bytes(val), 5)
87
-
}
88
-
89
-
#[cfg(test)]
90
-
mod tests {
91
-
#[test]
92
-
#[ignore = "this is a very time consuming test, it should be run in release/profiling mode"]
93
-
fn pack_all_nums() {
94
-
for num in 0..=u32::MAX {
95
-
let mut buf = [0u8; 5];
96
-
let rlen = super::pack_dd(num, &mut buf);
97
-
assert!(rlen > 0);
98
-
99
-
let unpacked = super::unpack_dd(&buf[..rlen]);
100
-
assert_eq!(unpacked.1, rlen, "bad unpack size");
101
-
assert_eq!(unpacked.0, num, "values don't match");
102
-
}
103
-
}
104
-
}
1
+
/// packs a dd into `buf` returning amout of bytes written.
2
+
/// Returns 0 if buffer is too small
3
+
pub fn pack_dd(v: u32, buf: &mut [u8]) -> usize {
4
+
let bytes = v.to_le_bytes();
5
+
match v {
6
+
0..=0x7f => {
7
+
// 0..0XXXXXXX (7 bits)
8
+
if buf.is_empty() {
9
+
return 0;
10
+
}
11
+
buf[0] = bytes[0];
12
+
1
13
+
},
14
+
0x80..=0x3fff => {
15
+
// 10AAAAAA..BBBBBBBB (14 bits)
16
+
if buf.len() < 2 {
17
+
return 0;
18
+
}
19
+
buf[0] = 0x80 | bytes[1];
20
+
buf[1] = bytes[0];
21
+
2
22
+
},
23
+
0x4000..=0x1fffff => {
24
+
// 11000000_AAAAAAAA_BBBBBBBB_CCCCCCCC (24 bits)
25
+
if buf.len() < 3 {
26
+
return 0;
27
+
}
28
+
buf[0] = 0xc0;
29
+
buf[1] = bytes[2];
30
+
buf[2] = bytes[1];
31
+
buf[3] = bytes[0];
32
+
4
33
+
},
34
+
0x200000..=u32::MAX => {
35
+
// 11111111_AAAAAAAA_BBBBBBBB_CCCCCCCC_DDDDDDDD (32 bits)
36
+
if buf.len() < 5 {
37
+
return 0;
38
+
}
39
+
buf[0] = 0xff;
40
+
buf[1] = bytes[3];
41
+
buf[2] = bytes[2];
42
+
buf[3] = bytes[1];
43
+
buf[4] = bytes[0];
44
+
5
45
+
},
46
+
}
47
+
}
48
+
49
+
/// unpacks a dd from `buf`, returning the amount (value, byte consumed)
50
+
pub fn unpack_dd(buf: &[u8]) -> (u32, usize) {
51
+
if buf.is_empty() {
52
+
return (0, 0);
53
+
}
54
+
55
+
let msb = buf[0];
56
+
let mut val = [0u8; 4];
57
+
58
+
if msb & 0x80 == 0 {
59
+
// 0......
60
+
val[0] = msb;
61
+
return (u32::from_le_bytes(val), 1);
62
+
}
63
+
if msb & 0x40 == 0 {
64
+
// 10....../0x80
65
+
if buf.len() < 2 {
66
+
return (0, 0);
67
+
}
68
+
val[1] = msb & 0x3f;
69
+
val[0] = buf[1];
70
+
return (u32::from_le_bytes(val), 2);
71
+
}
72
+
if msb & 0x20 == 0 {
73
+
// 110...../0xC0
74
+
if buf.len() < 4 {
75
+
return (0, 0);
76
+
}
77
+
val[3] = msb & 0x1f;
78
+
val[2] = buf[1];
79
+
val[1] = buf[2];
80
+
val[0] = buf[3];
81
+
return (u32::from_le_bytes(val), 4);
82
+
}
83
+
84
+
if buf.len() < 5 {
85
+
return (0, 0);
86
+
}
87
+
88
+
val[3] = buf[1];
89
+
val[2] = buf[2];
90
+
val[1] = buf[3];
91
+
val[0] = buf[4];
92
+
93
+
(u32::from_le_bytes(val), 5)
94
+
}
95
+
96
+
#[cfg(test)]
97
+
mod tests {
98
+
#[test]
99
+
#[ignore = "this is a very time consuming test, it should be run in release/profiling mode"]
100
+
fn pack_all_nums() {
101
+
for num in 0..=u32::MAX {
102
+
let mut buf = [0u8; 5];
103
+
let rlen = super::pack_dd(num, &mut buf);
104
+
assert!(rlen > 0);
105
+
106
+
let unpacked = super::unpack_dd(&buf[..rlen]);
107
+
assert_eq!(unpacked.1, rlen, "bad unpack size");
108
+
assert_eq!(unpacked.0, num, "values don't match");
109
+
}
110
+
}
111
+
}
+255
-241
common/src/rpc/ser.rs
+255
-241
common/src/rpc/ser.rs
···
1
-
use std::io::Write;
2
-
use serde::{ser, Serialize, ser::Impossible};
3
-
use super::Error;
4
-
5
-
struct Serializer<W: Write> {
6
-
output: W,
7
-
}
8
-
9
-
pub fn to_writer<T: Serialize, W: Write>(v: &T, w: W) -> Result<(), Error> {
10
-
let mut serializer = Serializer {
11
-
output: w,
12
-
};
13
-
v.serialize(&mut serializer)?;
14
-
Ok(())
15
-
}
16
-
17
-
#[allow(dead_code)]
18
-
pub fn to_vec<T: Serialize>(v: &T) -> Result<Vec<u8>, Error> {
19
-
let mut buf = vec![];
20
-
to_writer(v, &mut buf)?;
21
-
Ok(buf)
22
-
}
23
-
24
-
impl<W: Write> Serializer<W> {
25
-
fn pack_dd(&mut self, num: u32) -> Result<(), Error> {
26
-
let mut buf = [0u8; 5];
27
-
let bytes = super::packing::pack_dd(num, &mut buf);
28
-
self.output.write_all(&buf[..bytes])?;
29
-
Ok(())
30
-
}
31
-
32
-
fn pack_str(&mut self, s: &str) -> Result<(), Error> {
33
-
self.output.write_all(s.as_bytes())?;
34
-
self.output.write_all(&[0])?;
35
-
Ok(())
36
-
}
37
-
38
-
fn pack_bytes(&mut self, b: &[u8]) -> Result<(), Error> {
39
-
self.pack_dd(b.len() as u32)?;
40
-
self.output.write_all(b)?;
41
-
Ok(())
42
-
}
43
-
}
44
-
45
-
impl<'a, W: Write> ser::Serializer for &'a mut Serializer<W> {
46
-
type Ok = ();
47
-
type Error = Error;
48
-
49
-
type SerializeSeq = Self;
50
-
type SerializeTuple = Self;
51
-
type SerializeTupleStruct = Impossible<(), Self::Error>;
52
-
type SerializeTupleVariant = Impossible<(), Self::Error>;
53
-
type SerializeMap = Impossible<(), Self::Error>;
54
-
type SerializeStruct = Self;
55
-
type SerializeStructVariant = Impossible<(), Self::Error>;
56
-
57
-
fn serialize_bool(self, _v: bool) -> Result<Self::Ok, Self::Error> {
58
-
unreachable!()
59
-
}
60
-
61
-
fn serialize_i8(self, _v: i8) -> Result<Self::Ok, Self::Error> {
62
-
unreachable!()
63
-
}
64
-
65
-
fn serialize_i16(self, _v: i16) -> Result<Self::Ok, Self::Error> {
66
-
unreachable!()
67
-
}
68
-
69
-
fn serialize_i32(self, _v: i32) -> Result<Self::Ok, Self::Error> {
70
-
unreachable!()
71
-
}
72
-
73
-
fn serialize_i64(self, _v: i64) -> Result<Self::Ok, Self::Error> {
74
-
unreachable!()
75
-
}
76
-
77
-
fn serialize_u8(self, v: u8) -> Result<Self::Ok, Self::Error> {
78
-
self.output.write_all(&[v])?;
79
-
Ok(())
80
-
}
81
-
82
-
fn serialize_u16(self, _v: u16) -> Result<Self::Ok, Self::Error> {
83
-
unreachable!()
84
-
}
85
-
86
-
fn serialize_u32(self, v: u32) -> Result<Self::Ok, Self::Error> {
87
-
self.pack_dd(v)
88
-
}
89
-
90
-
fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error> {
91
-
let high = (v >> 32) & 0xffffffff;
92
-
let low = v & 0xffffffff;
93
-
self.pack_dd(high as u32)?;
94
-
self.pack_dd(low as u32)?;
95
-
Ok(())
96
-
}
97
-
98
-
fn serialize_f32(self, _v: f32) -> Result<Self::Ok, Self::Error> {
99
-
unreachable!()
100
-
}
101
-
102
-
fn serialize_f64(self, _v: f64) -> Result<Self::Ok, Self::Error> {
103
-
unreachable!()
104
-
}
105
-
106
-
fn serialize_char(self, _v: char) -> Result<Self::Ok, Self::Error> {
107
-
unreachable!()
108
-
}
109
-
110
-
fn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error> {
111
-
self.pack_str(v)
112
-
}
113
-
114
-
fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error> {
115
-
self.pack_bytes(v)
116
-
}
117
-
118
-
fn serialize_none(self) -> Result<Self::Ok, Self::Error> {
119
-
unreachable!()
120
-
}
121
-
122
-
fn serialize_some<T: ?Sized + Serialize>(self, _value: &T) -> Result<Self::Ok, Self::Error> {
123
-
unreachable!()
124
-
}
125
-
126
-
fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
127
-
// unit contains no information...
128
-
Ok(())
129
-
}
130
-
131
-
fn serialize_unit_struct(self, _name: &'static str) -> Result<Self::Ok, Self::Error> {
132
-
unreachable!()
133
-
}
134
-
135
-
fn serialize_unit_variant(self, _name: &'static str, _variant_index: u32, _variant: &'static str) -> Result<Self::Ok, Self::Error> {
136
-
unreachable!()
137
-
}
138
-
139
-
fn serialize_newtype_struct<T: ?Sized + Serialize>(self, _name: &'static str, _value: &T) -> Result<Self::Ok, Self::Error> {
140
-
unreachable!()
141
-
}
142
-
143
-
fn serialize_newtype_variant<T: ?Sized + Serialize>(self, _name: &'static str, _variant_index: u32, _variant: &'static str, _value: &T) -> Result<Self::Ok, Self::Error> {
144
-
unreachable!()
145
-
}
146
-
147
-
fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq, Self::Error> {
148
-
let len = len.unwrap();
149
-
self.pack_dd(len as u32)?;
150
-
Ok(self)
151
-
}
152
-
153
-
fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple, Self::Error> {
154
-
Ok(self)
155
-
}
156
-
157
-
fn serialize_tuple_struct(self, _name: &'static str, _len: usize) -> Result<Self::SerializeTupleStruct, Self::Error> {
158
-
unreachable!();
159
-
}
160
-
161
-
fn serialize_tuple_variant(self, _name: &'static str, _variant_index: u32, _variant: &'static str, _len: usize) -> Result<Self::SerializeTupleVariant, Self::Error> {
162
-
unreachable!()
163
-
}
164
-
165
-
fn serialize_map(self, _len: Option<usize>) -> Result<Self::SerializeMap, Self::Error> {
166
-
unreachable!()
167
-
}
168
-
169
-
fn serialize_struct(self, _name: &'static str, _len: usize) -> Result<Self::SerializeStruct, Self::Error> {
170
-
// structs will simply be flattened
171
-
Ok(self)
172
-
}
173
-
174
-
fn serialize_struct_variant(self, _name: &'static str, _variant_index: u32, _variant: &'static str, _len: usize) -> Result<Self::SerializeStructVariant, Self::Error> {
175
-
unreachable!()
176
-
}
177
-
}
178
-
179
-
impl<'a, W: Write> ser::SerializeSeq for &'a mut Serializer<W> {
180
-
type Ok = ();
181
-
type Error = Error;
182
-
183
-
fn serialize_element<T: ?Sized + Serialize>(&mut self, value: &T) -> Result<(), Self::Error> {
184
-
value.serialize(&mut **self)
185
-
}
186
-
187
-
fn end(self) -> Result<Self::Ok, Self::Error> {
188
-
Ok(())
189
-
}
190
-
}
191
-
192
-
impl<'a, W: Write> ser::SerializeTuple for &'a mut Serializer<W> {
193
-
type Ok = ();
194
-
type Error = Error;
195
-
196
-
fn serialize_element<T: ?Sized + Serialize>(&mut self, value: &T) -> Result<(), Self::Error> {
197
-
value.serialize(&mut **self)
198
-
}
199
-
200
-
fn end(self) -> Result<Self::Ok, Self::Error> {
201
-
Ok(())
202
-
}
203
-
}
204
-
205
-
impl<'a, W: Write> ser::SerializeStruct for &'a mut Serializer<W> {
206
-
type Ok = ();
207
-
type Error = Error;
208
-
209
-
fn serialize_field<T: ?Sized + Serialize>(&mut self, _key: &'static str, value: &T) -> Result<(), Self::Error> {
210
-
// struct names have no meaning
211
-
value.serialize(&mut **self)
212
-
}
213
-
214
-
fn end(self) -> Result<Self::Ok, Self::Error> {
215
-
Ok(())
216
-
}
217
-
}
218
-
219
-
#[cfg(test)]
220
-
mod tests {
221
-
#[test]
222
-
fn ser_hello() {
223
-
#[derive(serde::Serialize)]
224
-
struct Test<'a> {
225
-
arr: [u8; 16],
226
-
s: &'a str,
227
-
b: &'a [u8],
228
-
i: u32,
229
-
q: u64,
230
-
}
231
-
let v = Test {
232
-
arr: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
233
-
s: "somestring",
234
-
b: b"bytes",
235
-
i: 0x20,
236
-
q: 0x20,
237
-
};
238
-
let v = super::to_vec(&v).expect("failed to serialize dummy");
239
-
assert_eq!(v, b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10somestring\x00\x05bytes\x20\x00\x20");
240
-
}
241
-
}
1
+
use super::Error;
2
+
use serde::{ser, ser::Impossible, Serialize};
3
+
use std::io::Write;
4
+
5
+
struct Serializer<W: Write> {
6
+
output: W,
7
+
}
8
+
9
+
pub fn to_writer<T: Serialize, W: Write>(v: &T, w: W) -> Result<(), Error> {
10
+
let mut serializer = Serializer { output: w };
11
+
v.serialize(&mut serializer)?;
12
+
Ok(())
13
+
}
14
+
15
+
#[allow(dead_code)]
16
+
pub fn to_vec<T: Serialize>(v: &T) -> Result<Vec<u8>, Error> {
17
+
let mut buf = vec![];
18
+
to_writer(v, &mut buf)?;
19
+
Ok(buf)
20
+
}
21
+
22
+
impl<W: Write> Serializer<W> {
23
+
fn pack_dd(&mut self, num: u32) -> Result<(), Error> {
24
+
let mut buf = [0u8; 5];
25
+
let bytes = super::packing::pack_dd(num, &mut buf);
26
+
self.output.write_all(&buf[..bytes])?;
27
+
Ok(())
28
+
}
29
+
30
+
fn pack_str(&mut self, s: &str) -> Result<(), Error> {
31
+
self.output.write_all(s.as_bytes())?;
32
+
self.output.write_all(&[0])?;
33
+
Ok(())
34
+
}
35
+
36
+
fn pack_bytes(&mut self, b: &[u8]) -> Result<(), Error> {
37
+
self.pack_dd(b.len() as u32)?;
38
+
self.output.write_all(b)?;
39
+
Ok(())
40
+
}
41
+
}
42
+
43
+
impl<'a, W: Write> ser::Serializer for &'a mut Serializer<W> {
44
+
type Ok = ();
45
+
type Error = Error;
46
+
47
+
type SerializeSeq = Self;
48
+
type SerializeTuple = Self;
49
+
type SerializeTupleStruct = Impossible<(), Self::Error>;
50
+
type SerializeTupleVariant = Impossible<(), Self::Error>;
51
+
type SerializeMap = Impossible<(), Self::Error>;
52
+
type SerializeStruct = Self;
53
+
type SerializeStructVariant = Impossible<(), Self::Error>;
54
+
55
+
fn serialize_bool(self, _v: bool) -> Result<Self::Ok, Self::Error> {
56
+
unreachable!()
57
+
}
58
+
59
+
fn serialize_i8(self, _v: i8) -> Result<Self::Ok, Self::Error> {
60
+
unreachable!()
61
+
}
62
+
63
+
fn serialize_i16(self, _v: i16) -> Result<Self::Ok, Self::Error> {
64
+
unreachable!()
65
+
}
66
+
67
+
fn serialize_i32(self, _v: i32) -> Result<Self::Ok, Self::Error> {
68
+
unreachable!()
69
+
}
70
+
71
+
fn serialize_i64(self, _v: i64) -> Result<Self::Ok, Self::Error> {
72
+
unreachable!()
73
+
}
74
+
75
+
fn serialize_u8(self, v: u8) -> Result<Self::Ok, Self::Error> {
76
+
self.output.write_all(&[v])?;
77
+
Ok(())
78
+
}
79
+
80
+
fn serialize_u16(self, _v: u16) -> Result<Self::Ok, Self::Error> {
81
+
unreachable!()
82
+
}
83
+
84
+
fn serialize_u32(self, v: u32) -> Result<Self::Ok, Self::Error> {
85
+
self.pack_dd(v)
86
+
}
87
+
88
+
fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error> {
89
+
let high = (v >> 32) & 0xffffffff;
90
+
let low = v & 0xffffffff;
91
+
self.pack_dd(high as u32)?;
92
+
self.pack_dd(low as u32)?;
93
+
Ok(())
94
+
}
95
+
96
+
fn serialize_f32(self, _v: f32) -> Result<Self::Ok, Self::Error> {
97
+
unreachable!()
98
+
}
99
+
100
+
fn serialize_f64(self, _v: f64) -> Result<Self::Ok, Self::Error> {
101
+
unreachable!()
102
+
}
103
+
104
+
fn serialize_char(self, _v: char) -> Result<Self::Ok, Self::Error> {
105
+
unreachable!()
106
+
}
107
+
108
+
fn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error> {
109
+
self.pack_str(v)
110
+
}
111
+
112
+
fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error> {
113
+
self.pack_bytes(v)
114
+
}
115
+
116
+
fn serialize_none(self) -> Result<Self::Ok, Self::Error> {
117
+
unreachable!()
118
+
}
119
+
120
+
fn serialize_some<T: ?Sized + Serialize>(self, _value: &T) -> Result<Self::Ok, Self::Error> {
121
+
unreachable!()
122
+
}
123
+
124
+
fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
125
+
// unit contains no information...
126
+
Ok(())
127
+
}
128
+
129
+
fn serialize_unit_struct(self, _name: &'static str) -> Result<Self::Ok, Self::Error> {
130
+
unreachable!()
131
+
}
132
+
133
+
fn serialize_unit_variant(
134
+
self, _name: &'static str, _variant_index: u32, _variant: &'static str,
135
+
) -> Result<Self::Ok, Self::Error> {
136
+
unreachable!()
137
+
}
138
+
139
+
fn serialize_newtype_struct<T: ?Sized + Serialize>(
140
+
self, _name: &'static str, _value: &T,
141
+
) -> Result<Self::Ok, Self::Error> {
142
+
unreachable!()
143
+
}
144
+
145
+
fn serialize_newtype_variant<T: ?Sized + Serialize>(
146
+
self, _name: &'static str, _variant_index: u32, _variant: &'static str, _value: &T,
147
+
) -> Result<Self::Ok, Self::Error> {
148
+
unreachable!()
149
+
}
150
+
151
+
fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq, Self::Error> {
152
+
let len = len.unwrap();
153
+
self.pack_dd(len as u32)?;
154
+
Ok(self)
155
+
}
156
+
157
+
fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple, Self::Error> {
158
+
Ok(self)
159
+
}
160
+
161
+
fn serialize_tuple_struct(
162
+
self, _name: &'static str, _len: usize,
163
+
) -> Result<Self::SerializeTupleStruct, Self::Error> {
164
+
unreachable!();
165
+
}
166
+
167
+
fn serialize_tuple_variant(
168
+
self, _name: &'static str, _variant_index: u32, _variant: &'static str, _len: usize,
169
+
) -> Result<Self::SerializeTupleVariant, Self::Error> {
170
+
unreachable!()
171
+
}
172
+
173
+
fn serialize_map(self, _len: Option<usize>) -> Result<Self::SerializeMap, Self::Error> {
174
+
unreachable!()
175
+
}
176
+
177
+
fn serialize_struct(
178
+
self, _name: &'static str, _len: usize,
179
+
) -> Result<Self::SerializeStruct, Self::Error> {
180
+
// structs will simply be flattened
181
+
Ok(self)
182
+
}
183
+
184
+
fn serialize_struct_variant(
185
+
self, _name: &'static str, _variant_index: u32, _variant: &'static str, _len: usize,
186
+
) -> Result<Self::SerializeStructVariant, Self::Error> {
187
+
unreachable!()
188
+
}
189
+
}
190
+
191
+
impl<'a, W: Write> ser::SerializeSeq for &'a mut Serializer<W> {
192
+
type Ok = ();
193
+
type Error = Error;
194
+
195
+
fn serialize_element<T: ?Sized + Serialize>(&mut self, value: &T) -> Result<(), Self::Error> {
196
+
value.serialize(&mut **self)
197
+
}
198
+
199
+
fn end(self) -> Result<Self::Ok, Self::Error> {
200
+
Ok(())
201
+
}
202
+
}
203
+
204
+
impl<'a, W: Write> ser::SerializeTuple for &'a mut Serializer<W> {
205
+
type Ok = ();
206
+
type Error = Error;
207
+
208
+
fn serialize_element<T: ?Sized + Serialize>(&mut self, value: &T) -> Result<(), Self::Error> {
209
+
value.serialize(&mut **self)
210
+
}
211
+
212
+
fn end(self) -> Result<Self::Ok, Self::Error> {
213
+
Ok(())
214
+
}
215
+
}
216
+
217
+
impl<'a, W: Write> ser::SerializeStruct for &'a mut Serializer<W> {
218
+
type Ok = ();
219
+
type Error = Error;
220
+
221
+
fn serialize_field<T: ?Sized + Serialize>(
222
+
&mut self, _key: &'static str, value: &T,
223
+
) -> Result<(), Self::Error> {
224
+
// struct names have no meaning
225
+
value.serialize(&mut **self)
226
+
}
227
+
228
+
fn end(self) -> Result<Self::Ok, Self::Error> {
229
+
Ok(())
230
+
}
231
+
}
232
+
233
+
#[cfg(test)]
234
+
mod tests {
235
+
#[test]
236
+
fn ser_hello() {
237
+
#[derive(serde::Serialize)]
238
+
struct Test<'a> {
239
+
arr: [u8; 16],
240
+
s: &'a str,
241
+
b: &'a [u8],
242
+
i: u32,
243
+
q: u64,
244
+
}
245
+
let v = Test {
246
+
arr: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
247
+
s: "somestring",
248
+
b: b"bytes",
249
+
i: 0x20,
250
+
q: 0x20,
251
+
};
252
+
let v = super::to_vec(&v).expect("failed to serialize dummy");
253
+
assert_eq!(v, b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10somestring\x00\x05bytes\x20\x00\x20");
254
+
}
255
+
}
+192
-204
common/src/web/api.rs
+192
-204
common/src/web/api.rs
···
1
-
use std::borrow::Cow;
2
-
use log::*;
3
-
use warp::{Filter, Reply, Rejection};
4
-
use serde::Serialize;
5
-
6
-
use super::SharedState;
7
-
8
-
struct Md5([u8; 16]);
9
-
impl std::str::FromStr for Md5 {
10
-
type Err = &'static str;
11
-
fn from_str(s: &str) -> Result<Md5, Self::Err> {
12
-
let mut res = [0u8; 16];
13
-
let s = s.trim();
14
-
if s.len() != 32 {
15
-
return Err("bad md5 length");
16
-
}
17
-
binascii::hex2bin(s.as_bytes(), &mut res)
18
-
.map_err(|_| "bad md5")?;
19
-
Ok(Md5(res))
20
-
}
21
-
}
22
-
23
-
#[derive(Serialize)]
24
-
struct Error<'a> {
25
-
error: &'a str,
26
-
}
27
-
28
-
impl std::fmt::Display for Md5 {
29
-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30
-
let mut out = [0u8; 32];
31
-
binascii::bin2hex(&self.0, &mut out).unwrap();
32
-
let out = std::str::from_utf8(&out).unwrap();
33
-
write!(f, "{}", &out)
34
-
}
35
-
}
36
-
37
-
impl Serialize for Md5 {
38
-
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
39
-
serializer.serialize_str(&format!("{}", &self))
40
-
}
41
-
}
42
-
43
-
pub fn api_root(state: SharedState) -> impl Filter<Extract = (impl Reply + 'static, ), Error=Rejection> + Clone {
44
-
let view_file = warp::get()
45
-
.and(warp::path("files"))
46
-
.and(super::with_state(state.clone()))
47
-
.and(warp::filters::path::param::<Md5>())
48
-
.and_then(view_file_by_hash);
49
-
let view_func = warp::get()
50
-
.and(warp::path("funcs"))
51
-
.and(super::with_state(state))
52
-
.and(warp::filters::path::param::<Md5>())
53
-
.and_then(view_func_by_hash);
54
-
55
-
view_file
56
-
.or(view_func)
57
-
}
58
-
59
-
// GET server/api/files/:md5
60
-
async fn view_file_by_hash(state: SharedState, md5: Md5) -> Result<impl Reply, Rejection> {
61
-
#[derive(Serialize)]
62
-
struct FileFunc {
63
-
hash: Md5,
64
-
len: u32,
65
-
name: String,
66
-
}
67
-
68
-
let v = match state.db.get_file_funcs(&md5.0[..], 0, 10_000).await {
69
-
Ok(v) => v,
70
-
Err(err) => {
71
-
error!("failed to get file's funcs {}: {}", &md5, err);
72
-
return Ok(warp::reply::json(&Error{error: "internal server error"}));
73
-
},
74
-
};
75
-
let v: Vec<_> = v.into_iter()
76
-
.map(|v| {
77
-
let mut hash = [0u8; 16];
78
-
hash.copy_from_slice(&v.2);
79
-
FileFunc {
80
-
name: v.0,
81
-
len: v.1 as u32,
82
-
hash: Md5(hash),
83
-
}
84
-
})
85
-
.collect();
86
-
87
-
Result::<_, Rejection>::Ok(warp::reply::json(&v))
88
-
}
89
-
90
-
// GET server/api/funcs/:md5
91
-
async fn view_func_by_hash(state: SharedState, md5: Md5) -> Result<impl Reply, Rejection> {
92
-
#[derive(Serialize)]
93
-
enum CommentType {
94
-
Posterior,
95
-
Anterior,
96
-
Function{ repeatable: bool },
97
-
Byte { repeatable: bool },
98
-
}
99
-
100
-
#[derive(Serialize)]
101
-
struct Comment<'a> {
102
-
#[serde(skip_serializing_if = "Option::is_none")]
103
-
offset: Option<u32>,
104
-
#[serde(rename = "type")]
105
-
type_: CommentType,
106
-
comment: Cow<'a, str>,
107
-
}
108
-
109
-
#[derive(Serialize)]
110
-
struct FuncInfo<'a> {
111
-
name: &'a str,
112
-
comments: Vec<Comment<'a>>,
113
-
length: u32,
114
-
in_files: &'a [Md5],
115
-
}
116
-
117
-
let funcs = [crate::rpc::PullMetadataFunc {
118
-
unk0: 1,
119
-
mb_hash: &md5.0
120
-
}];
121
-
122
-
let files_with = state.db.get_files_with_func(&md5.0[..]);
123
-
let files_info = state.db.get_funcs(&funcs);
124
-
125
-
let (files_with, files_info) = match futures_util::try_join!(files_with, files_info) {
126
-
Ok(v) => v,
127
-
Err(err) => {
128
-
error!("failed to execute db queries: {}", err);
129
-
return Ok(warp::reply::json(&Error {error: "internal server error"}));
130
-
}
131
-
};
132
-
133
-
let files_with: Vec<Md5> = files_with.into_iter().map(|v| {
134
-
let mut md5 = [0u8; 16];
135
-
md5.copy_from_slice(&v);
136
-
Md5(md5)
137
-
}).collect();
138
-
139
-
let v = files_info;
140
-
let v: Vec<FuncInfo> = v
141
-
.iter()
142
-
.take(1)
143
-
.filter_map(|v| v.as_ref())
144
-
.filter_map(|v| {
145
-
let md = match crate::md::parse_metadata(&v.data) {
146
-
Ok(v) => v,
147
-
Err(e) => {
148
-
error!("error parsing metadata for {}: {}", &md5, e);
149
-
return None;
150
-
}
151
-
};
152
-
let comments: Vec<Comment> = md.into_iter()
153
-
.filter_map(|md| {
154
-
match md {
155
-
crate::md::FunctionMetadata::ByteComment(c) => {
156
-
Some(vec![Comment {
157
-
offset: Some(c.offset),
158
-
type_: CommentType::Byte{ repeatable: c.is_repeatable },
159
-
comment: c.comment.into(),
160
-
}])
161
-
},
162
-
crate::md::FunctionMetadata::FunctionComment(c) => {
163
-
Some(vec![Comment {
164
-
offset: None,
165
-
type_: CommentType::Function{ repeatable: c.is_repeatable },
166
-
comment: c.comment.into(),
167
-
}])
168
-
},
169
-
crate::md::FunctionMetadata::ExtraComment(c) => {
170
-
let mut res = vec![];
171
-
if !c.anterior.is_empty() {
172
-
res.push(Comment {
173
-
offset: Some(c.offset),
174
-
type_: CommentType::Anterior,
175
-
comment: c.anterior.into(),
176
-
});
177
-
}
178
-
if !c.posterior.is_empty() {
179
-
res.push(Comment {
180
-
offset: Some(c.offset),
181
-
type_: CommentType::Posterior,
182
-
comment: c.posterior.into(),
183
-
});
184
-
}
185
-
if !res.is_empty() {
186
-
Some(res)
187
-
} else {
188
-
None
189
-
}
190
-
},
191
-
}
192
-
})
193
-
.flatten()
194
-
.collect();
195
-
Some(FuncInfo {
196
-
name: &v.name,
197
-
length: v.len,
198
-
comments,
199
-
in_files: &files_with,
200
-
})
201
-
}).collect();
202
-
203
-
Result::<_, Rejection>::Ok(warp::reply::json(&v))
204
-
}
1
+
use log::*;
2
+
use serde::Serialize;
3
+
use std::borrow::Cow;
4
+
use warp::{Filter, Rejection, Reply};
5
+
6
+
use super::SharedState;
7
+
8
+
struct Md5([u8; 16]);
9
+
impl std::str::FromStr for Md5 {
10
+
type Err = &'static str;
11
+
fn from_str(s: &str) -> Result<Md5, Self::Err> {
12
+
let mut res = [0u8; 16];
13
+
let s = s.trim();
14
+
if s.len() != 32 {
15
+
return Err("bad md5 length");
16
+
}
17
+
binascii::hex2bin(s.as_bytes(), &mut res).map_err(|_| "bad md5")?;
18
+
Ok(Md5(res))
19
+
}
20
+
}
21
+
22
+
#[derive(Serialize)]
23
+
struct Error<'a> {
24
+
error: &'a str,
25
+
}
26
+
27
+
impl std::fmt::Display for Md5 {
28
+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29
+
let mut out = [0u8; 32];
30
+
binascii::bin2hex(&self.0, &mut out).unwrap();
31
+
let out = std::str::from_utf8(&out).unwrap();
32
+
write!(f, "{}", &out)
33
+
}
34
+
}
35
+
36
+
impl Serialize for Md5 {
37
+
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
38
+
serializer.serialize_str(&format!("{}", &self))
39
+
}
40
+
}
41
+
42
+
pub fn api_root(
43
+
state: SharedState,
44
+
) -> impl Filter<Extract = (impl Reply + 'static,), Error = Rejection> + Clone {
45
+
let view_file = warp::get()
46
+
.and(warp::path("files"))
47
+
.and(super::with_state(state.clone()))
48
+
.and(warp::filters::path::param::<Md5>())
49
+
.and_then(view_file_by_hash);
50
+
let view_func = warp::get()
51
+
.and(warp::path("funcs"))
52
+
.and(super::with_state(state))
53
+
.and(warp::filters::path::param::<Md5>())
54
+
.and_then(view_func_by_hash);
55
+
56
+
view_file.or(view_func)
57
+
}
58
+
59
+
// GET server/api/files/:md5
60
+
async fn view_file_by_hash(state: SharedState, md5: Md5) -> Result<impl Reply, Rejection> {
61
+
#[derive(Serialize)]
62
+
struct FileFunc {
63
+
hash: Md5,
64
+
len: u32,
65
+
name: String,
66
+
}
67
+
68
+
let v = match state.db.get_file_funcs(&md5.0[..], 0, 10_000).await {
69
+
Ok(v) => v,
70
+
Err(err) => {
71
+
error!("failed to get file's funcs {}: {}", &md5, err);
72
+
return Ok(warp::reply::json(&Error { error: "internal server error" }));
73
+
},
74
+
};
75
+
let v: Vec<_> = v
76
+
.into_iter()
77
+
.map(|v| {
78
+
let mut hash = [0u8; 16];
79
+
hash.copy_from_slice(&v.2);
80
+
FileFunc { name: v.0, len: v.1 as u32, hash: Md5(hash) }
81
+
})
82
+
.collect();
83
+
84
+
Result::<_, Rejection>::Ok(warp::reply::json(&v))
85
+
}
86
+
87
+
// GET server/api/funcs/:md5
88
+
async fn view_func_by_hash(state: SharedState, md5: Md5) -> Result<impl Reply, Rejection> {
89
+
#[derive(Serialize)]
90
+
enum CommentType {
91
+
Posterior,
92
+
Anterior,
93
+
Function { repeatable: bool },
94
+
Byte { repeatable: bool },
95
+
}
96
+
97
+
#[derive(Serialize)]
98
+
struct Comment<'a> {
99
+
#[serde(skip_serializing_if = "Option::is_none")]
100
+
offset: Option<u32>,
101
+
#[serde(rename = "type")]
102
+
type_: CommentType,
103
+
comment: Cow<'a, str>,
104
+
}
105
+
106
+
#[derive(Serialize)]
107
+
struct FuncInfo<'a> {
108
+
name: &'a str,
109
+
comments: Vec<Comment<'a>>,
110
+
length: u32,
111
+
in_files: &'a [Md5],
112
+
}
113
+
114
+
let funcs = [crate::rpc::PullMetadataFunc { unk0: 1, mb_hash: &md5.0 }];
115
+
116
+
let files_with = state.db.get_files_with_func(&md5.0[..]);
117
+
let files_info = state.db.get_funcs(&funcs);
118
+
119
+
let (files_with, files_info) = match futures_util::try_join!(files_with, files_info) {
120
+
Ok(v) => v,
121
+
Err(err) => {
122
+
error!("failed to execute db queries: {}", err);
123
+
return Ok(warp::reply::json(&Error { error: "internal server error" }));
124
+
},
125
+
};
126
+
127
+
let files_with: Vec<Md5> = files_with
128
+
.into_iter()
129
+
.map(|v| {
130
+
let mut md5 = [0u8; 16];
131
+
md5.copy_from_slice(&v);
132
+
Md5(md5)
133
+
})
134
+
.collect();
135
+
136
+
let v = files_info;
137
+
let v: Vec<FuncInfo> = v
138
+
.iter()
139
+
.take(1)
140
+
.filter_map(|v| v.as_ref())
141
+
.filter_map(|v| {
142
+
let md = match crate::md::parse_metadata(&v.data) {
143
+
Ok(v) => v,
144
+
Err(e) => {
145
+
error!("error parsing metadata for {}: {}", &md5, e);
146
+
return None;
147
+
},
148
+
};
149
+
let comments: Vec<Comment> = md
150
+
.into_iter()
151
+
.filter_map(|md| match md {
152
+
crate::md::FunctionMetadata::ByteComment(c) => Some(vec![Comment {
153
+
offset: Some(c.offset),
154
+
type_: CommentType::Byte { repeatable: c.is_repeatable },
155
+
comment: c.comment.into(),
156
+
}]),
157
+
crate::md::FunctionMetadata::FunctionComment(c) => Some(vec![Comment {
158
+
offset: None,
159
+
type_: CommentType::Function { repeatable: c.is_repeatable },
160
+
comment: c.comment.into(),
161
+
}]),
162
+
crate::md::FunctionMetadata::ExtraComment(c) => {
163
+
let mut res = vec![];
164
+
if !c.anterior.is_empty() {
165
+
res.push(Comment {
166
+
offset: Some(c.offset),
167
+
type_: CommentType::Anterior,
168
+
comment: c.anterior.into(),
169
+
});
170
+
}
171
+
if !c.posterior.is_empty() {
172
+
res.push(Comment {
173
+
offset: Some(c.offset),
174
+
type_: CommentType::Posterior,
175
+
comment: c.posterior.into(),
176
+
});
177
+
}
178
+
if !res.is_empty() {
179
+
Some(res)
180
+
} else {
181
+
None
182
+
}
183
+
},
184
+
})
185
+
.flatten()
186
+
.collect();
187
+
Some(FuncInfo { name: &v.name, length: v.len, comments, in_files: &files_with })
188
+
})
189
+
.collect();
190
+
191
+
Result::<_, Rejection>::Ok(warp::reply::json(&v))
192
+
}
+10
-8
common/src/web.rs
+10
-8
common/src/web.rs
···
1
-
use crate::SharedState;
2
-
use warp::Filter;
3
-
4
-
pub mod api;
5
-
6
-
pub fn with_state(state: SharedState) -> impl Filter<Extract=(SharedState,), Error= std::convert::Infallible> + Clone {
7
-
warp::any().map(move || state.clone())
8
-
}
1
+
use crate::SharedState;
2
+
use warp::Filter;
3
+
4
+
pub mod api;
5
+
6
+
pub fn with_state(
7
+
state: SharedState,
8
+
) -> impl Filter<Extract = (SharedState,), Error = std::convert::Infallible> + Clone {
9
+
warp::any().map(move || state.clone())
10
+
}
+2
config-example.toml
+2
config-example.toml
+6
-6
lumen/Cargo.toml
+6
-6
lumen/Cargo.toml
···
7
7
publish = false
8
8
9
9
[dependencies]
10
-
common = {path = "../common"}
11
-
tokio = {version = "1.32", features = ["full"]}
12
-
log = {version = "0.4", features = ["release_max_level_debug"]}
10
+
common = { path = "../common" }
11
+
tokio = { version = "1.39", features = ["full"] }
12
+
log = { version = "0.4", features = ["release_max_level_debug"] }
13
13
pretty_env_logger = "0.5"
14
-
clap = "4.3"
14
+
clap = "4.5"
15
15
tokio-native-tls = "0.3"
16
-
native-tls = {version = "0.2"}
16
+
native-tls = { version = "0.2" }
17
17
warp = "0.3"
18
-
prometheus-client = "0.21.2"
18
+
prometheus-client = "0.22"
+11
-409
lumen/src/main.rs
+11
-409
lumen/src/main.rs
···
4
4
#![warn(unused_crate_dependencies)]
5
5
#![deny(clippy::all)]
6
6
7
-
use common::async_drop::AsyncDropper;
8
-
use common::metrics::LuminaVersion;
9
-
use common::rpc::{RpcHello, RpcFail, HelloResult};
10
-
use native_tls::Identity;
11
7
use clap::Arg;
12
8
use log::*;
13
-
use tokio::time::timeout;
14
-
use std::collections::HashMap;
15
-
use std::mem::discriminant;
16
-
use std::time::{Duration, Instant};
17
-
use std::{borrow::Cow, sync::Arc};
18
-
use tokio::{net::TcpListener, io::AsyncWrite, io::AsyncRead};
19
-
use std::process::exit;
20
-
use common::{SharedState, SharedState_};
9
+
use server::do_lumen;
10
+
use std::sync::Arc;
21
11
12
+
mod server;
22
13
mod web;
23
14
24
-
use common::{config, make_pretty_hex, md, rpc::{self, Error}};
25
-
use common::db::Database;
26
-
use rpc::RpcMessage;
15
+
use common::config;
27
16
28
17
fn setup_logger() {
29
18
if std::env::var("RUST_LOG").is_err() {
···
32
21
pretty_env_logger::init_timed();
33
22
}
34
23
35
-
async fn handle_transaction<'a, S: AsyncRead + AsyncWrite + Unpin>(state: &SharedState, user: &'a RpcHello<'a>, mut stream: S) -> Result<(), Error> {
36
-
let db = &state.db;
37
-
let server_name = state.server_name.as_str();
38
-
39
-
trace!("waiting for command..");
40
-
let req = match timeout(Duration::from_secs(3600), rpc::read_packet(&mut stream)).await {
41
-
Ok(res) => match res {
42
-
Ok(v) => v,
43
-
Err(e) => return Err(e),
44
-
},
45
-
Err(_) => {
46
-
_ = RpcMessage::Fail(RpcFail {
47
-
code: 0,
48
-
message: &format!("{server_name} client idle for too long.\n"),
49
-
}).async_write(&mut stream).await;
50
-
return Err(Error::Timeout);
51
-
},
52
-
};
53
-
trace!("got command!");
54
-
let req = match RpcMessage::deserialize(&req) {
55
-
Ok(v) => v,
56
-
Err(err) => {
57
-
warn!("bad message: \n{}\n", make_pretty_hex(&req));
58
-
error!("failed to process rpc message: {}", err);
59
-
let resp = rpc::RpcFail{ code: 0, message: &format!("{server_name}: error: invalid data.\n")};
60
-
let resp = RpcMessage::Fail(resp);
61
-
resp.async_write(&mut stream).await?;
62
-
63
-
return Ok(());
64
-
},
65
-
};
66
-
match req {
67
-
RpcMessage::PullMetadata(md) => {
68
-
let start = Instant::now();
69
-
let funcs = match timeout(Duration::from_secs(4 * 60), db.get_funcs(&md.funcs)).await {
70
-
Ok(r) => match r {
71
-
Ok(v) => v,
72
-
Err(e) => {
73
-
error!("pull failed, db: {}", e);
74
-
rpc::RpcMessage::Fail(rpc::RpcFail {
75
-
code: 0,
76
-
message: &format!("{server_name}: db error; please try again later..\n")
77
-
}).async_write(&mut stream).await?;
78
-
return Ok(());
79
-
},
80
-
},
81
-
Err(_) => {
82
-
RpcMessage::Fail(RpcFail {
83
-
code: 0,
84
-
message: &format!("{server_name}: query took too long to execute.\n"),
85
-
}).async_write(&mut stream).await?;
86
-
debug!("pull query timeout");
87
-
return Err(Error::Timeout);
88
-
}
89
-
};
90
-
let pulled_funcs = funcs.iter().filter(|v| v.is_some()).count();
91
-
state.metrics.pulls.inc_by(pulled_funcs as _);
92
-
state.metrics.queried_funcs.inc_by(md.funcs.len() as _);
93
-
debug!("pull {pulled_funcs}/{} funcs ended after {:?}", md.funcs.len(), start.elapsed());
94
-
95
-
let statuses: Vec<u32> = funcs.iter().map(|v| u32::from(v.is_none())).collect();
96
-
let found = funcs
97
-
.into_iter()
98
-
.flatten()
99
-
.map(|v| {
100
-
rpc::PullMetadataResultFunc {
101
-
popularity: v.popularity,
102
-
len: v.len,
103
-
name: Cow::Owned(v.name),
104
-
mb_data: Cow::Owned(v.data),
105
-
}
106
-
}).collect();
107
-
108
-
RpcMessage::PullMetadataResult(rpc::PullMetadataResult{
109
-
unk0: Cow::Owned(statuses),
110
-
funcs: Cow::Owned(found),
111
-
}).async_write(&mut stream).await?;
112
-
},
113
-
RpcMessage::PushMetadata(mds) => {
114
-
// parse the function's metadata
115
-
let start = Instant::now();
116
-
let scores: Vec<u32> = mds.funcs.iter()
117
-
.map(md::get_score)
118
-
.collect();
119
-
120
-
let status = match db.push_funcs(user, &mds, &scores).await {
121
-
Ok(v) => {
122
-
v.into_iter().map(u32::from).collect::<Vec<u32>>()
123
-
},
124
-
Err(err) => {
125
-
log::error!("push failed, db: {}", err);
126
-
rpc::RpcMessage::Fail(rpc::RpcFail {
127
-
code: 0,
128
-
message: &format!("{server_name}: db error; please try again later.\n")
129
-
}).async_write(&mut stream).await?;
130
-
return Ok(());
131
-
}
132
-
};
133
-
state.metrics.pushes.inc_by(status.len() as _);
134
-
let new_funcs = status
135
-
.iter()
136
-
.fold(0u64, |counter, &v| if v > 0 { counter + 1 } else {counter});
137
-
state.metrics.new_funcs.inc_by(new_funcs);
138
-
debug!("push {} funcs ended after {:?} ({new_funcs} new)", status.len(), start.elapsed());
139
-
140
-
RpcMessage::PushMetadataResult(rpc::PushMetadataResult {
141
-
status: Cow::Owned(status),
142
-
}).async_write(&mut stream).await?;
143
-
},
144
-
RpcMessage::DelHistory(req) => {
145
-
let is_delete_allowed = state.config.lumina.allow_deletes.unwrap_or(false);
146
-
if !is_delete_allowed {
147
-
RpcMessage::Fail(rpc::RpcFail {
148
-
code: 2,
149
-
message: &format!("{server_name}: Delete command is disabled on this server.")
150
-
}).async_write(&mut stream).await?;
151
-
} else {
152
-
if let Err(err) = db.delete_metadata(&req).await {
153
-
error!("delete failed. db: {err}");
154
-
RpcMessage::Fail(rpc::RpcFail {
155
-
code: 3,
156
-
message: &format!("{server_name}: db error, please try again later.")
157
-
}).async_write(&mut stream).await?;
158
-
return Ok(());
159
-
}
160
-
RpcMessage::DelHistoryResult(rpc::DelHistoryResult {
161
-
deleted_mds: req.funcs.len() as u32,
162
-
}).async_write(&mut stream).await?;
163
-
}
164
-
},
165
-
_ => {
166
-
RpcMessage::Fail(rpc::RpcFail{code: 0, message: &format!("{server_name}: invalid data.\n")}).async_write(&mut stream).await?;
167
-
}
168
-
}
169
-
Ok(())
170
-
}
171
-
172
-
async fn handle_client<S: AsyncRead + AsyncWrite + Unpin>(state: &SharedState, mut stream: S) -> Result<(), rpc::Error> {
173
-
let server_name = &state.server_name;
174
-
let hello = match timeout(Duration::from_secs(15), rpc::read_packet(&mut stream)).await {
175
-
Ok(v) => v?,
176
-
Err(_) => {
177
-
debug!("didn't get hello in time.");
178
-
return Ok(());
179
-
},
180
-
};
181
-
182
-
let (hello, creds) = match RpcMessage::deserialize(&hello) {
183
-
Ok(RpcMessage::Hello(v, creds)) => {
184
-
debug!("hello protocol={}, login creds: {creds:?}", v.protocol_version);
185
-
(v, creds)
186
-
},
187
-
_ => {
188
-
// send error
189
-
error!("got bad hello message");
190
-
191
-
let resp = rpc::RpcFail{ code: 0, message: &format!("{server_name}: bad sequence.") };
192
-
let resp = rpc::RpcMessage::Fail(resp);
193
-
resp.async_write(&mut stream).await?;
194
-
195
-
return Ok(());
196
-
}
197
-
};
198
-
state.metrics.lumina_version.get_or_create(&LuminaVersion {
199
-
protocol_version: hello.protocol_version,
200
-
}).inc();
201
-
202
-
if let Some(ref creds) = creds {
203
-
if creds.username != "guest" {
204
-
// Only allow "guest" to connect for now.
205
-
rpc::RpcMessage::Fail(rpc::RpcFail {
206
-
code: 1,
207
-
message: &format!("{server_name}: invalid username or password. Try logging in with `guest` instead."),
208
-
}).async_write(&mut stream).await?;
209
-
return Ok(());
210
-
}
211
-
}
212
-
213
-
let resp = match hello.protocol_version {
214
-
0..=4 => rpc::RpcMessage::Ok(()),
215
-
216
-
// starting IDA 8.3
217
-
5.. => rpc::RpcMessage::HelloResult(HelloResult {
218
-
unk0: "".into(),
219
-
unk1: "".into(),
220
-
unk2: "".into(),
221
-
unk3: "".into(),
222
-
unk4: 0,
223
-
unk5: 0,
224
-
unk6: 0,
225
-
})
226
-
};
227
-
resp.async_write(&mut stream).await?;
228
-
229
-
loop {
230
-
handle_transaction(state, &hello, &mut stream).await?;
231
-
}
232
-
}
233
-
234
-
async fn handle_connection<S: AsyncRead + AsyncWrite + Unpin>(state: &SharedState, s: S) {
235
-
if let Err(err) = handle_client(state, s).await {
236
-
if discriminant(&err) != discriminant(&Error::Eof) {
237
-
warn!("err: {}", err);
238
-
}
239
-
}
240
-
}
241
-
242
-
async fn serve(listener: TcpListener, accpt: Option<tokio_native_tls::TlsAcceptor>, state: SharedState, mut shutdown_signal: tokio::sync::oneshot::Receiver<()>) {
243
-
let accpt = accpt.map(Arc::new);
244
-
245
-
let (async_drop, worker) = AsyncDropper::new();
246
-
tokio::task::spawn(worker);
247
-
248
-
let connections = Arc::new(tokio::sync::Mutex::new(HashMap::<std::net::SocketAddr, tokio::task::JoinHandle<()>>::new()));
249
-
250
-
loop {
251
-
let (client, addr) = tokio::select! {
252
-
_ = &mut shutdown_signal => {
253
-
drop(state);
254
-
info!("shutting down...");
255
-
let m = connections.lock().await;
256
-
m.iter().for_each(|(k, v)| {
257
-
debug!("aborting task for {k}...");
258
-
v.abort();
259
-
});
260
-
return;
261
-
},
262
-
res = listener.accept() => match res {
263
-
Ok(v) => v,
264
-
Err(err) => {
265
-
warn!("failed to accept(): {}", err);
266
-
continue;
267
-
}
268
-
},
269
-
};
270
-
271
-
let start = Instant::now();
272
-
273
-
let state = state.clone();
274
-
let accpt = accpt.clone();
275
-
276
-
let conns2 = connections.clone();
277
-
let counter = state.metrics.active_connections.clone();
278
-
let guard = async_drop.defer(async move {
279
-
let count = counter.dec() - 1;
280
-
debug!("connection with {:?} ended after {:?}; {} active connections", addr, start.elapsed(), count);
281
-
282
-
let mut guard = conns2.lock().await;
283
-
if guard.remove(&addr).is_none() {
284
-
error!("Couldn't remove connection from set {addr}");
285
-
}
286
-
});
287
-
288
-
let counter = state.metrics.active_connections.clone();
289
-
let handle = tokio::spawn(async move {
290
-
let _guard = guard;
291
-
let count = {
292
-
counter.inc() + 1
293
-
};
294
-
let protocol = if accpt.is_some() {" [TLS]"} else {""};
295
-
debug!("Connection from {:?}{}: {} active connections", &addr, protocol, count);
296
-
match accpt {
297
-
Some(accpt) => {
298
-
match timeout(Duration::from_secs(10), accpt.accept(client)).await {
299
-
Ok(r) => match r {
300
-
Ok(s) => {
301
-
handle_connection(&state, s).await;
302
-
},
303
-
Err(err) => debug!("tls accept ({}): {}", &addr, err),
304
-
},
305
-
Err(_) => {
306
-
debug!("client {} didn't complete ssl handshake in time.", &addr);
307
-
},
308
-
};
309
-
},
310
-
None => handle_connection(&state, client).await,
311
-
}
312
-
});
313
-
314
-
let mut guard = connections.lock().await;
315
-
guard.insert(addr, handle);
316
-
}
317
-
}
318
-
319
-
fn main() {
24
+
#[tokio::main]
25
+
async fn main() {
320
26
setup_logger();
321
27
let matches = clap::Command::new("lumen")
322
28
.version(env!("CARGO_PKG_VERSION"))
···
325
31
.arg(
326
32
Arg::new("config")
327
33
.short('c')
328
-
.required(true)
329
34
.default_value("config.toml")
330
35
.help("Configuration file path")
331
36
)
332
37
.get_matches();
333
38
334
39
let config = {
335
-
config::load_config(std::fs::File::open(matches.get_one::<String>("config").unwrap()).expect("failed to read config"))
40
+
config::load_config(
41
+
std::fs::File::open(matches.get_one::<String>("config").unwrap())
42
+
.expect("failed to read config"),
43
+
)
336
44
};
337
45
let config = Arc::new(config);
338
46
339
-
info!("starting private lumen server...");
340
-
341
-
let rt = match tokio::runtime::Builder::new_multi_thread()
342
-
.enable_all()
343
-
.build() {
344
-
Ok(v) => v,
345
-
Err(err) => {
346
-
error!("failed to create tokio runtime: {}", err);
347
-
exit(1);
348
-
},
349
-
};
350
-
351
-
let db = rt.block_on(async {
352
-
match Database::open(&config.database).await {
353
-
Ok(v) => v,
354
-
Err(err) => {
355
-
error!("failed to open database: {}", err);
356
-
exit(1);
357
-
}
358
-
}
359
-
});
360
-
361
-
let server_name = config.lumina.server_name.clone().unwrap_or_else(|| String::from("lumen"));
362
-
363
-
let state = Arc::new(SharedState_{
364
-
db,
365
-
config,
366
-
server_name,
367
-
metrics: common::metrics::Metrics::default(),
368
-
});
369
-
370
-
let tls_acceptor;
371
-
372
-
if state.config.lumina.use_tls.unwrap_or_default() {
373
-
let cert_path = &state.config.lumina.tls.as_ref().expect("tls section is missing").server_cert;
374
-
let mut crt = match std::fs::read(cert_path) {
375
-
Ok(v) => v,
376
-
Err(err) => {
377
-
error!("failed to read certificate file: {}", err);
378
-
exit(1);
379
-
}
380
-
};
381
-
let pkcs_passwd = std::env::var("PKCSPASSWD").unwrap_or_default();
382
-
let id = match Identity::from_pkcs12(&crt, &pkcs_passwd) {
383
-
Ok(v) => v,
384
-
Err(err) => {
385
-
error!("failed to parse tls certificate: {}", err);
386
-
exit(1);
387
-
}
388
-
};
389
-
let _ = pkcs_passwd;
390
-
crt.iter_mut().for_each(|v| *v = 0);
391
-
let _ = crt;
392
-
let mut accpt = native_tls::TlsAcceptor::builder(id);
393
-
accpt.min_protocol_version(Some(native_tls::Protocol::Sslv3));
394
-
let accpt = match accpt.build() {
395
-
Ok(v) => v,
396
-
Err(err) => {
397
-
error!("failed to build tls acceptor: {}", err);
398
-
exit(1);
399
-
},
400
-
};
401
-
let accpt = tokio_native_tls::TlsAcceptor::from(accpt);
402
-
tls_acceptor = Some(accpt);
403
-
} else {
404
-
tls_acceptor = None;
405
-
}
406
-
407
-
let web_handle = if let Some(ref webcfg) = state.config.api_server {
408
-
let bind_addr = webcfg.bind_addr;
409
-
let state = state.clone();
410
-
info!("starting http api server on {:?}", &bind_addr);
411
-
Some(rt.spawn(async move {
412
-
web::start_webserver(bind_addr, state).await;
413
-
}))
414
-
} else {
415
-
None
416
-
};
417
-
418
-
let (exit_signal_tx, exit_signal_rx) = tokio::sync::oneshot::channel::<()>();
419
-
420
-
let async_server = async move {
421
-
let server = match TcpListener::bind(state.config.lumina.bind_addr).await {
422
-
Ok(v) => v,
423
-
Err(err) => {
424
-
error!("failed to bind server port: {}", err);
425
-
exit(1);
426
-
},
427
-
};
428
-
429
-
info!("listening on {:?} secure={}", server.local_addr().unwrap(), tls_acceptor.is_some());
430
-
431
-
serve(server, tls_acceptor, state, exit_signal_rx).await;
432
-
};
433
-
434
-
rt.block_on(async {
435
-
let server_handle = tokio::task::spawn(async_server);
436
-
tokio::signal::ctrl_c().await.unwrap();
437
-
debug!("CTRL-C; exiting...");
438
-
if let Some(handle) = web_handle {
439
-
handle.abort();
440
-
}
441
-
exit_signal_tx.send(()).unwrap();
442
-
server_handle.await.unwrap();
443
-
});
444
-
drop(rt);
445
-
info!("Goodbye.");
47
+
do_lumen(config).await;
446
48
}
+513
lumen/src/server.rs
+513
lumen/src/server.rs
···
1
+
use std::{
2
+
borrow::Cow,
3
+
collections::HashMap,
4
+
mem::discriminant,
5
+
process::exit,
6
+
sync::Arc,
7
+
time::{Duration, Instant},
8
+
};
9
+
10
+
use common::{
11
+
async_drop::AsyncDropper,
12
+
config::Config,
13
+
db::Database,
14
+
make_pretty_hex, md,
15
+
metrics::LuminaVersion,
16
+
rpc::{self, Error, HelloResult, RpcFail, RpcHello, RpcMessage},
17
+
SharedState, SharedState_,
18
+
};
19
+
use log::{debug, error, info, trace, warn};
20
+
use native_tls::Identity;
21
+
use tokio::{
22
+
io::{AsyncRead, AsyncWrite},
23
+
net::TcpListener,
24
+
time::timeout,
25
+
};
26
+
27
+
use crate::web;
28
+
29
+
async fn handle_transaction<'a, S: AsyncRead + AsyncWrite + Unpin>(
30
+
state: &SharedState, user: &'a RpcHello<'a>, mut stream: S,
31
+
) -> Result<(), Error> {
32
+
let db = &state.db;
33
+
let server_name = state.server_name.as_str();
34
+
35
+
trace!("waiting for command..");
36
+
let req = match timeout(Duration::from_secs(3600), rpc::read_packet(&mut stream)).await {
37
+
Ok(res) => match res {
38
+
Ok(v) => v,
39
+
Err(e) => return Err(e),
40
+
},
41
+
Err(_) => {
42
+
_ = RpcMessage::Fail(RpcFail {
43
+
code: 0,
44
+
message: &format!("{server_name} client idle for too long.\n"),
45
+
})
46
+
.async_write(&mut stream)
47
+
.await;
48
+
return Err(Error::Timeout);
49
+
},
50
+
};
51
+
trace!("got command!");
52
+
let req = match RpcMessage::deserialize(&req) {
53
+
Ok(v) => v,
54
+
Err(err) => {
55
+
warn!("bad message: \n{}\n", make_pretty_hex(&req));
56
+
error!("failed to process rpc message: {}", err);
57
+
let resp = rpc::RpcFail {
58
+
code: 0,
59
+
message: &format!("{server_name}: error: invalid data.\n"),
60
+
};
61
+
let resp = RpcMessage::Fail(resp);
62
+
resp.async_write(&mut stream).await?;
63
+
64
+
return Ok(());
65
+
},
66
+
};
67
+
match req {
68
+
RpcMessage::PullMetadata(md) => {
69
+
let start = Instant::now();
70
+
let funcs = match timeout(Duration::from_secs(4 * 60), db.get_funcs(&md.funcs)).await {
71
+
Ok(r) => match r {
72
+
Ok(v) => v,
73
+
Err(e) => {
74
+
error!("pull failed, db: {}", e);
75
+
rpc::RpcMessage::Fail(rpc::RpcFail {
76
+
code: 0,
77
+
message: &format!(
78
+
"{server_name}: db error; please try again later..\n"
79
+
),
80
+
})
81
+
.async_write(&mut stream)
82
+
.await?;
83
+
return Ok(());
84
+
},
85
+
},
86
+
Err(_) => {
87
+
RpcMessage::Fail(RpcFail {
88
+
code: 0,
89
+
message: &format!("{server_name}: query took too long to execute.\n"),
90
+
})
91
+
.async_write(&mut stream)
92
+
.await?;
93
+
debug!("pull query timeout");
94
+
return Err(Error::Timeout);
95
+
},
96
+
};
97
+
let pulled_funcs = funcs.iter().filter(|v| v.is_some()).count();
98
+
state.metrics.pulls.inc_by(pulled_funcs as _);
99
+
state.metrics.queried_funcs.inc_by(md.funcs.len() as _);
100
+
debug!(
101
+
"pull {pulled_funcs}/{} funcs ended after {:?}",
102
+
md.funcs.len(),
103
+
start.elapsed()
104
+
);
105
+
106
+
let statuses: Vec<u32> = funcs.iter().map(|v| u32::from(v.is_none())).collect();
107
+
let found = funcs
108
+
.into_iter()
109
+
.flatten()
110
+
.map(|v| rpc::PullMetadataResultFunc {
111
+
popularity: v.popularity,
112
+
len: v.len,
113
+
name: Cow::Owned(v.name),
114
+
mb_data: Cow::Owned(v.data),
115
+
})
116
+
.collect();
117
+
118
+
RpcMessage::PullMetadataResult(rpc::PullMetadataResult {
119
+
unk0: Cow::Owned(statuses),
120
+
funcs: Cow::Owned(found),
121
+
})
122
+
.async_write(&mut stream)
123
+
.await?;
124
+
},
125
+
RpcMessage::PushMetadata(mds) => {
126
+
// parse the function's metadata
127
+
let start = Instant::now();
128
+
let scores: Vec<u32> = mds.funcs.iter().map(md::get_score).collect();
129
+
130
+
let status = match db.push_funcs(user, &mds, &scores).await {
131
+
Ok(v) => v.into_iter().map(u32::from).collect::<Vec<u32>>(),
132
+
Err(err) => {
133
+
log::error!("push failed, db: {}", err);
134
+
rpc::RpcMessage::Fail(rpc::RpcFail {
135
+
code: 0,
136
+
message: &format!("{server_name}: db error; please try again later.\n"),
137
+
})
138
+
.async_write(&mut stream)
139
+
.await?;
140
+
return Ok(());
141
+
},
142
+
};
143
+
state.metrics.pushes.inc_by(status.len() as _);
144
+
let new_funcs =
145
+
status.iter().fold(0u64, |counter, &v| if v > 0 { counter + 1 } else { counter });
146
+
state.metrics.new_funcs.inc_by(new_funcs);
147
+
debug!(
148
+
"push {} funcs ended after {:?} ({new_funcs} new)",
149
+
status.len(),
150
+
start.elapsed()
151
+
);
152
+
153
+
RpcMessage::PushMetadataResult(rpc::PushMetadataResult { status: Cow::Owned(status) })
154
+
.async_write(&mut stream)
155
+
.await?;
156
+
},
157
+
RpcMessage::DelHistory(req) => {
158
+
let is_delete_allowed = state.config.lumina.allow_deletes.unwrap_or(false);
159
+
if !is_delete_allowed {
160
+
RpcMessage::Fail(rpc::RpcFail {
161
+
code: 2,
162
+
message: &format!("{server_name}: Delete command is disabled on this server."),
163
+
})
164
+
.async_write(&mut stream)
165
+
.await?;
166
+
} else {
167
+
if let Err(err) = db.delete_metadata(&req).await {
168
+
error!("delete failed. db: {err}");
169
+
RpcMessage::Fail(rpc::RpcFail {
170
+
code: 3,
171
+
message: &format!("{server_name}: db error, please try again later."),
172
+
})
173
+
.async_write(&mut stream)
174
+
.await?;
175
+
return Ok(());
176
+
}
177
+
RpcMessage::DelHistoryResult(rpc::DelHistoryResult {
178
+
deleted_mds: req.funcs.len() as u32,
179
+
})
180
+
.async_write(&mut stream)
181
+
.await?;
182
+
}
183
+
},
184
+
RpcMessage::GetFuncHistories(req) => {
185
+
let limit = state.config.lumina.get_history_limit.unwrap_or(0);
186
+
187
+
if limit == 0 {
188
+
RpcMessage::Fail(rpc::RpcFail {
189
+
code: 4,
190
+
message: &format!(
191
+
"{server_name}: function histories are disabled on this server."
192
+
),
193
+
})
194
+
.async_write(&mut stream)
195
+
.await?;
196
+
return Ok(());
197
+
}
198
+
199
+
let mut statuses = vec![];
200
+
let mut res = vec![];
201
+
for chksum in req.funcs.iter().map(|v| v.mb_hash) {
202
+
let history = match db.get_func_histories(chksum, limit).await {
203
+
Ok(v) => v,
204
+
Err(err) => {
205
+
error!("failed to get function histories: {err:?}");
206
+
RpcMessage::Fail(rpc::RpcFail {
207
+
code: 3,
208
+
message: &format!("{server_name}: db error, please try again later."),
209
+
})
210
+
.async_write(&mut stream)
211
+
.await?;
212
+
return Ok(());
213
+
},
214
+
};
215
+
let status = !history.is_empty() as u32;
216
+
statuses.push(status);
217
+
if history.is_empty() {
218
+
continue;
219
+
}
220
+
let log = history
221
+
.into_iter()
222
+
.map(|(updated, name, metadata)| rpc::FunctionHistory {
223
+
unk0: 0,
224
+
unk1: 0,
225
+
name: Cow::Owned(name),
226
+
metadata: Cow::Owned(metadata),
227
+
timestamp: updated.unix_timestamp() as u64,
228
+
author_idx: 0,
229
+
idb_path_idx: 0,
230
+
})
231
+
.collect::<Vec<_>>();
232
+
res.push(rpc::FunctionHistories { log: Cow::Owned(log) });
233
+
}
234
+
235
+
trace!("returning {} histories", res.len());
236
+
237
+
RpcMessage::GetFuncHistoriesResult(rpc::GetFuncHistoriesResult {
238
+
status: statuses.into(),
239
+
funcs: Cow::Owned(res),
240
+
users: vec![].into(),
241
+
dbs: vec![].into(),
242
+
})
243
+
.async_write(&mut stream)
244
+
.await?;
245
+
},
246
+
_ => {
247
+
RpcMessage::Fail(rpc::RpcFail {
248
+
code: 0,
249
+
message: &format!("{server_name}: invalid data.\n"),
250
+
})
251
+
.async_write(&mut stream)
252
+
.await?;
253
+
},
254
+
}
255
+
Ok(())
256
+
}
257
+
258
+
async fn handle_client<S: AsyncRead + AsyncWrite + Unpin>(
259
+
state: &SharedState, mut stream: S,
260
+
) -> Result<(), rpc::Error> {
261
+
let server_name = &state.server_name;
262
+
let hello = match timeout(Duration::from_secs(15), rpc::read_packet(&mut stream)).await {
263
+
Ok(v) => v?,
264
+
Err(_) => {
265
+
debug!("didn't get hello in time.");
266
+
return Ok(());
267
+
},
268
+
};
269
+
270
+
let (hello, creds) = match RpcMessage::deserialize(&hello) {
271
+
Ok(RpcMessage::Hello(v, creds)) => {
272
+
debug!("hello protocol={}, login creds: {creds:?}", v.protocol_version);
273
+
(v, creds)
274
+
},
275
+
_ => {
276
+
// send error
277
+
error!("got bad hello message");
278
+
279
+
let resp = rpc::RpcFail { code: 0, message: &format!("{server_name}: bad sequence.") };
280
+
let resp = rpc::RpcMessage::Fail(resp);
281
+
resp.async_write(&mut stream).await?;
282
+
283
+
return Ok(());
284
+
},
285
+
};
286
+
state
287
+
.metrics
288
+
.lumina_version
289
+
.get_or_create(&LuminaVersion { protocol_version: hello.protocol_version })
290
+
.inc();
291
+
292
+
if let Some(ref creds) = creds {
293
+
if creds.username != "guest" {
294
+
// Only allow "guest" to connect for now.
295
+
rpc::RpcMessage::Fail(rpc::RpcFail {
296
+
code: 1,
297
+
message: &format!("{server_name}: invalid username or password. Try logging in with `guest` instead."),
298
+
}).async_write(&mut stream).await?;
299
+
return Ok(());
300
+
}
301
+
}
302
+
303
+
let resp = match hello.protocol_version {
304
+
0..=4 => rpc::RpcMessage::Ok(()),
305
+
306
+
// starting IDA 8.3
307
+
5.. => {
308
+
let mut features = 0;
309
+
310
+
if state.config.lumina.allow_deletes.unwrap_or(false) {
311
+
features |= 0x02;
312
+
}
313
+
314
+
rpc::RpcMessage::HelloResult(HelloResult { features, ..Default::default() })
315
+
},
316
+
};
317
+
resp.async_write(&mut stream).await?;
318
+
319
+
loop {
320
+
handle_transaction(state, &hello, &mut stream).await?;
321
+
}
322
+
}
323
+
324
+
async fn handle_connection<S: AsyncRead + AsyncWrite + Unpin>(state: &SharedState, s: S) {
325
+
if let Err(err) = handle_client(state, s).await {
326
+
if discriminant(&err) != discriminant(&Error::Eof) {
327
+
warn!("err: {}", err);
328
+
}
329
+
}
330
+
}
331
+
332
+
async fn serve(
333
+
listener: TcpListener, accpt: Option<tokio_native_tls::TlsAcceptor>, state: SharedState,
334
+
mut shutdown_signal: tokio::sync::oneshot::Receiver<()>,
335
+
) {
336
+
let accpt = accpt.map(Arc::new);
337
+
338
+
let (async_drop, worker) = AsyncDropper::new();
339
+
tokio::task::spawn(worker);
340
+
341
+
let connections = Arc::new(tokio::sync::Mutex::new(HashMap::<
342
+
std::net::SocketAddr,
343
+
tokio::task::JoinHandle<()>,
344
+
>::new()));
345
+
346
+
loop {
347
+
let (client, addr) = tokio::select! {
348
+
_ = &mut shutdown_signal => {
349
+
drop(state);
350
+
info!("shutting down...");
351
+
let m = connections.lock().await;
352
+
m.iter().for_each(|(k, v)| {
353
+
debug!("aborting task for {k}...");
354
+
v.abort();
355
+
});
356
+
return;
357
+
},
358
+
res = listener.accept() => match res {
359
+
Ok(v) => v,
360
+
Err(err) => {
361
+
warn!("failed to accept(): {}", err);
362
+
continue;
363
+
}
364
+
},
365
+
};
366
+
367
+
let start = Instant::now();
368
+
369
+
let state = state.clone();
370
+
let accpt = accpt.clone();
371
+
372
+
let conns2 = connections.clone();
373
+
let counter = state.metrics.active_connections.clone();
374
+
let guard = async_drop.defer(async move {
375
+
let count = counter.dec() - 1;
376
+
debug!(
377
+
"connection with {:?} ended after {:?}; {} active connections",
378
+
addr,
379
+
start.elapsed(),
380
+
count
381
+
);
382
+
383
+
let mut guard = conns2.lock().await;
384
+
if guard.remove(&addr).is_none() {
385
+
error!("Couldn't remove connection from set {addr}");
386
+
}
387
+
});
388
+
389
+
let counter = state.metrics.active_connections.clone();
390
+
let handle = tokio::spawn(async move {
391
+
let _guard = guard;
392
+
let count = { counter.inc() + 1 };
393
+
let protocol = if accpt.is_some() { " [TLS]" } else { "" };
394
+
debug!("Connection from {:?}{}: {} active connections", &addr, protocol, count);
395
+
match accpt {
396
+
Some(accpt) => {
397
+
match timeout(Duration::from_secs(10), accpt.accept(client)).await {
398
+
Ok(r) => match r {
399
+
Ok(s) => {
400
+
handle_connection(&state, s).await;
401
+
},
402
+
Err(err) => debug!("tls accept ({}): {}", &addr, err),
403
+
},
404
+
Err(_) => {
405
+
debug!("client {} didn't complete ssl handshake in time.", &addr);
406
+
},
407
+
};
408
+
},
409
+
None => handle_connection(&state, client).await,
410
+
}
411
+
});
412
+
413
+
let mut guard = connections.lock().await;
414
+
guard.insert(addr, handle);
415
+
}
416
+
}
417
+
418
+
pub(crate) async fn do_lumen(config: Arc<Config>) {
419
+
info!("starting private lumen server...");
420
+
421
+
let db = match Database::open(&config.database).await {
422
+
Ok(v) => v,
423
+
Err(err) => {
424
+
error!("failed to open database: {}", err);
425
+
exit(1);
426
+
},
427
+
};
428
+
429
+
let server_name = config.lumina.server_name.clone().unwrap_or_else(|| String::from("lumen"));
430
+
431
+
let state = Arc::new(SharedState_ {
432
+
db,
433
+
config,
434
+
server_name,
435
+
metrics: common::metrics::Metrics::default(),
436
+
});
437
+
438
+
let tls_acceptor;
439
+
440
+
if state.config.lumina.use_tls.unwrap_or_default() {
441
+
let cert_path =
442
+
&state.config.lumina.tls.as_ref().expect("tls section is missing").server_cert;
443
+
let mut crt = match std::fs::read(cert_path) {
444
+
Ok(v) => v,
445
+
Err(err) => {
446
+
error!("failed to read certificate file: {}", err);
447
+
exit(1);
448
+
},
449
+
};
450
+
let pkcs_passwd = std::env::var("PKCSPASSWD").unwrap_or_default();
451
+
let id = match Identity::from_pkcs12(&crt, &pkcs_passwd) {
452
+
Ok(v) => v,
453
+
Err(err) => {
454
+
error!("failed to parse tls certificate: {}", err);
455
+
exit(1);
456
+
},
457
+
};
458
+
let _ = pkcs_passwd;
459
+
crt.iter_mut().for_each(|v| *v = 0);
460
+
let _ = crt;
461
+
let mut accpt = native_tls::TlsAcceptor::builder(id);
462
+
accpt.min_protocol_version(Some(native_tls::Protocol::Sslv3));
463
+
let accpt = match accpt.build() {
464
+
Ok(v) => v,
465
+
Err(err) => {
466
+
error!("failed to build tls acceptor: {}", err);
467
+
exit(1);
468
+
},
469
+
};
470
+
let accpt = tokio_native_tls::TlsAcceptor::from(accpt);
471
+
tls_acceptor = Some(accpt);
472
+
} else {
473
+
tls_acceptor = None;
474
+
}
475
+
476
+
let web_handle = if let Some(ref webcfg) = state.config.api_server {
477
+
let bind_addr = webcfg.bind_addr;
478
+
let state = state.clone();
479
+
info!("starting http api server on {:?}", &bind_addr);
480
+
Some(tokio::spawn(async move {
481
+
web::start_webserver(bind_addr, state).await;
482
+
}))
483
+
} else {
484
+
None
485
+
};
486
+
487
+
let (exit_signal_tx, exit_signal_rx) = tokio::sync::oneshot::channel::<()>();
488
+
489
+
let async_server = async move {
490
+
let server = match TcpListener::bind(state.config.lumina.bind_addr).await {
491
+
Ok(v) => v,
492
+
Err(err) => {
493
+
error!("failed to bind server port: {}", err);
494
+
exit(1);
495
+
},
496
+
};
497
+
498
+
info!("listening on {:?} secure={}", server.local_addr().unwrap(), tls_acceptor.is_some());
499
+
500
+
serve(server, tls_acceptor, state, exit_signal_rx).await;
501
+
};
502
+
503
+
let server_handle = tokio::task::spawn(async_server);
504
+
tokio::signal::ctrl_c().await.unwrap();
505
+
debug!("CTRL-C; exiting...");
506
+
if let Some(handle) = web_handle {
507
+
handle.abort();
508
+
}
509
+
exit_signal_tx.send(()).unwrap();
510
+
server_handle.await.unwrap();
511
+
512
+
info!("Goodbye.");
513
+
}
+33
-35
lumen/src/web.rs
+33
-35
lumen/src/web.rs
···
1
-
use std::net::SocketAddr;
2
-
3
-
use log::error;
4
-
use warp::{Filter, hyper::StatusCode, reply::Response};
5
-
use common::{SharedState, web::api::api_root};
6
-
7
-
pub async fn start_webserver<A: Into<SocketAddr> + 'static>(bind_addr: A, shared_state: SharedState) {
8
-
let root = warp::get()
9
-
.and(warp::path::end())
10
-
.map(|| warp::reply::html(include_str!("home.html")));
11
-
12
-
let shared_state1 = shared_state.clone();
13
-
let api = warp::path("api")
14
-
.and(api_root(shared_state1));
15
-
16
-
let metrics = warp::get().and(warp::path("metrics")).and(warp::path::end())
17
-
.map(move || {
18
-
let mut res = String::new();
19
-
if let Err(err) = prometheus_client::encoding::text::encode(&mut res, &shared_state.metrics.registry) {
20
-
error!("failed to encode metrics: {err}");
21
-
let mut r = Response::default();
22
-
*r.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
23
-
r
24
-
} else {
25
-
warp::reply::Response::new(res.into())
26
-
}
27
-
});
28
-
29
-
let routes = root
30
-
.or(api)
31
-
.or(metrics);
32
-
33
-
warp::serve(routes)
34
-
.run(bind_addr).await;
35
-
}
1
+
use std::net::SocketAddr;
2
+
3
+
use common::{web::api::api_root, SharedState};
4
+
use log::error;
5
+
use warp::{hyper::StatusCode, reply::Response, Filter};
6
+
7
+
pub async fn start_webserver<A: Into<SocketAddr> + 'static>(
8
+
bind_addr: A, shared_state: SharedState,
9
+
) {
10
+
let root =
11
+
warp::get().and(warp::path::end()).map(|| warp::reply::html(include_str!("home.html")));
12
+
13
+
let shared_state1 = shared_state.clone();
14
+
let api = warp::path("api").and(api_root(shared_state1));
15
+
16
+
let metrics = warp::get().and(warp::path("metrics")).and(warp::path::end()).map(move || {
17
+
let mut res = String::new();
18
+
if let Err(err) =
19
+
prometheus_client::encoding::text::encode(&mut res, &shared_state.metrics.registry)
20
+
{
21
+
error!("failed to encode metrics: {err}");
22
+
let mut r = Response::default();
23
+
*r.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
24
+
r
25
+
} else {
26
+
warp::reply::Response::new(res.into())
27
+
}
28
+
});
29
+
30
+
let routes = root.or(api).or(metrics);
31
+
32
+
warp::serve(routes).run(bind_addr).await;
33
+
}