+21
.github/workflows/build.yml
+21
.github/workflows/build.yml
···
1
+
name: Build
2
+
3
+
on:
4
+
push:
5
+
tags:
6
+
- "reflector-v*.*.*"
7
+
8
+
jobs:
9
+
build:
10
+
runs-on: ubuntu-latest
11
+
permissions:
12
+
contents: write
13
+
14
+
steps:
15
+
- uses: actions/checkout@v4
16
+
- name: build reflector
17
+
run: cargo build --bin reflector --release && mv target/release/reflector target/release/reflector_amd64
18
+
- name: release
19
+
uses: softprops/action-gh-release@v2
20
+
with:
21
+
files: target/release/reflector_amd64
+1
-1
.github/workflows/checks.yml
+1
-1
.github/workflows/checks.yml
···
28
28
- name: get nightly toolchain for jetstream fmt
29
29
run: rustup toolchain install nightly --allow-downgrade -c rustfmt
30
30
- name: fmt
31
-
run: cargo fmt --package links --package constellation --package ufos --package spacedust --package who-am-i -- --check
31
+
run: cargo fmt --package links --package constellation --package ufos --package spacedust --package who-am-i --package slingshot --package pocket -- --check
32
32
- name: fmt jetstream (nightly)
33
33
run: cargo +nightly fmt --package jetstream -- --check
34
34
- name: clippy
+1626
-255
Cargo.lock
+1626
-255
Cargo.lock
···
24
24
checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
25
25
dependencies = [
26
26
"cfg-if",
27
+
"getrandom 0.2.15",
27
28
"once_cell",
28
29
"version_check",
29
30
"zerocopy 0.7.35",
···
111
112
112
113
[[package]]
113
114
name = "anyhow"
114
-
version = "1.0.97"
115
+
version = "1.0.100"
115
116
source = "registry+https://github.com/rust-lang/crates.io-index"
116
-
checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f"
117
+
checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
117
118
118
119
[[package]]
119
120
name = "arbitrary"
···
122
123
checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223"
123
124
124
125
[[package]]
126
+
name = "arc-swap"
127
+
version = "1.7.1"
128
+
source = "registry+https://github.com/rust-lang/crates.io-index"
129
+
checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"
130
+
131
+
[[package]]
132
+
name = "arrayref"
133
+
version = "0.3.9"
134
+
source = "registry+https://github.com/rust-lang/crates.io-index"
135
+
checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
136
+
137
+
[[package]]
125
138
name = "arrayvec"
126
139
version = "0.7.6"
127
140
source = "registry+https://github.com/rust-lang/crates.io-index"
···
155
168
"proc-macro2",
156
169
"quote",
157
170
"serde",
158
-
"syn",
171
+
"syn 2.0.106",
159
172
]
160
173
161
174
[[package]]
···
174
187
]
175
188
176
189
[[package]]
190
+
name = "asn1-rs"
191
+
version = "0.7.1"
192
+
source = "registry+https://github.com/rust-lang/crates.io-index"
193
+
checksum = "56624a96882bb8c26d61312ae18cb45868e5a9992ea73c58e45c3101e56a1e60"
194
+
dependencies = [
195
+
"asn1-rs-derive",
196
+
"asn1-rs-impl",
197
+
"displaydoc",
198
+
"nom",
199
+
"num-traits",
200
+
"rusticata-macros",
201
+
"thiserror 2.0.17",
202
+
"time",
203
+
]
204
+
205
+
[[package]]
206
+
name = "asn1-rs-derive"
207
+
version = "0.6.0"
208
+
source = "registry+https://github.com/rust-lang/crates.io-index"
209
+
checksum = "3109e49b1e4909e9db6515a30c633684d68cdeaa252f215214cb4fa1a5bfee2c"
210
+
dependencies = [
211
+
"proc-macro2",
212
+
"quote",
213
+
"syn 2.0.106",
214
+
"synstructure",
215
+
]
216
+
217
+
[[package]]
218
+
name = "asn1-rs-impl"
219
+
version = "0.2.0"
220
+
source = "registry+https://github.com/rust-lang/crates.io-index"
221
+
checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7"
222
+
dependencies = [
223
+
"proc-macro2",
224
+
"quote",
225
+
"syn 2.0.106",
226
+
]
227
+
228
+
[[package]]
229
+
name = "async-channel"
230
+
version = "2.5.0"
231
+
source = "registry+https://github.com/rust-lang/crates.io-index"
232
+
checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2"
233
+
dependencies = [
234
+
"concurrent-queue",
235
+
"event-listener-strategy",
236
+
"futures-core",
237
+
"pin-project-lite",
238
+
]
239
+
240
+
[[package]]
177
241
name = "async-compression"
178
242
version = "0.4.25"
179
243
source = "registry+https://github.com/rust-lang/crates.io-index"
···
216
280
dependencies = [
217
281
"proc-macro2",
218
282
"quote",
219
-
"syn",
283
+
"syn 2.0.106",
220
284
]
221
285
222
286
[[package]]
287
+
name = "async-task"
288
+
version = "4.7.1"
289
+
source = "registry+https://github.com/rust-lang/crates.io-index"
290
+
checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de"
291
+
292
+
[[package]]
223
293
name = "async-trait"
224
294
version = "0.1.88"
225
295
source = "registry+https://github.com/rust-lang/crates.io-index"
···
227
297
dependencies = [
228
298
"proc-macro2",
229
299
"quote",
230
-
"syn",
300
+
"syn 2.0.106",
231
301
]
232
302
233
303
[[package]]
···
238
308
239
309
[[package]]
240
310
name = "atrium-api"
241
-
version = "0.25.3"
242
-
source = "git+https://github.com/uniphil/atrium?branch=fix%2Fnsid-allow-nonleading-name-digits#c4364f318d337bbc3e3e3aaf97c9f971e95f5f7e"
311
+
version = "0.25.4"
312
+
source = "registry+https://github.com/rust-lang/crates.io-index"
313
+
checksum = "46355d3245edc7b3160b2a45fe55d09a6963ebd3eee0252feb6b72fb0eb71463"
243
314
dependencies = [
244
-
"atrium-common 0.1.2 (git+https://github.com/uniphil/atrium?branch=fix%2Fnsid-allow-nonleading-name-digits)",
245
-
"atrium-xrpc 0.12.3 (git+https://github.com/uniphil/atrium?branch=fix%2Fnsid-allow-nonleading-name-digits)",
315
+
"atrium-common 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
316
+
"atrium-xrpc 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
246
317
"chrono",
247
318
"http",
248
319
"ipld-core",
···
252
323
"serde_bytes",
253
324
"serde_json",
254
325
"thiserror 1.0.69",
326
+
"tokio",
255
327
"trait-variant",
256
328
]
257
329
258
330
[[package]]
259
331
name = "atrium-api"
260
332
version = "0.25.4"
261
-
source = "registry+https://github.com/rust-lang/crates.io-index"
262
-
checksum = "46355d3245edc7b3160b2a45fe55d09a6963ebd3eee0252feb6b72fb0eb71463"
333
+
source = "git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace#80a355991ac9b48ba3f559d12aac74f071fc638c"
263
334
dependencies = [
264
-
"atrium-common 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
265
-
"atrium-xrpc 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
335
+
"atrium-common 0.1.2 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
336
+
"atrium-xrpc 0.12.3 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
266
337
"chrono",
267
338
"http",
268
339
"ipld-core",
···
294
365
[[package]]
295
366
name = "atrium-common"
296
367
version = "0.1.2"
297
-
source = "git+https://github.com/uniphil/atrium?branch=fix%2Fnsid-allow-nonleading-name-digits#c4364f318d337bbc3e3e3aaf97c9f971e95f5f7e"
368
+
source = "git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace#80a355991ac9b48ba3f559d12aac74f071fc638c"
298
369
dependencies = [
299
370
"dashmap",
300
371
"lru",
···
306
377
]
307
378
308
379
[[package]]
380
+
name = "atrium-crypto"
381
+
version = "0.1.2"
382
+
source = "registry+https://github.com/rust-lang/crates.io-index"
383
+
checksum = "73a3da430c71dd9006d61072c20771f264e5c498420a49c32305ceab8bd71955"
384
+
dependencies = [
385
+
"ecdsa",
386
+
"k256",
387
+
"multibase",
388
+
"p256",
389
+
"thiserror 1.0.69",
390
+
]
391
+
392
+
[[package]]
309
393
name = "atrium-identity"
310
394
version = "0.1.5"
311
395
source = "registry+https://github.com/rust-lang/crates.io-index"
312
396
checksum = "c9e2d42bb4dbea038f4f5f45e3af2a89d61a9894a75f06aa550b74a60d2be380"
313
397
dependencies = [
314
-
"atrium-api 0.25.4",
398
+
"atrium-api 0.25.4 (registry+https://github.com/rust-lang/crates.io-index)",
315
399
"atrium-common 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
316
400
"atrium-xrpc 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
317
401
"serde",
···
322
406
]
323
407
324
408
[[package]]
409
+
name = "atrium-identity"
410
+
version = "0.1.5"
411
+
source = "git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace#80a355991ac9b48ba3f559d12aac74f071fc638c"
412
+
dependencies = [
413
+
"atrium-api 0.25.4 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
414
+
"atrium-common 0.1.2 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
415
+
"atrium-xrpc 0.12.3 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
416
+
"serde",
417
+
"serde_html_form",
418
+
"serde_json",
419
+
"thiserror 1.0.69",
420
+
"trait-variant",
421
+
]
422
+
423
+
[[package]]
325
424
name = "atrium-oauth"
326
425
version = "0.1.3"
327
426
source = "registry+https://github.com/rust-lang/crates.io-index"
328
427
checksum = "ca22dc4eaf77fd9bf050b21192ac58cd654a437d28e000ec114ebd93a51d36f5"
329
428
dependencies = [
330
-
"atrium-api 0.25.4",
429
+
"atrium-api 0.25.4 (registry+https://github.com/rust-lang/crates.io-index)",
331
430
"atrium-common 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
332
-
"atrium-identity",
431
+
"atrium-identity 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
333
432
"atrium-xrpc 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
334
433
"base64 0.22.1",
335
434
"chrono",
···
351
450
]
352
451
353
452
[[package]]
453
+
name = "atrium-oauth"
454
+
version = "0.1.3"
455
+
source = "git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace#80a355991ac9b48ba3f559d12aac74f071fc638c"
456
+
dependencies = [
457
+
"atrium-api 0.25.4 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
458
+
"atrium-common 0.1.2 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
459
+
"atrium-identity 0.1.5 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
460
+
"atrium-xrpc 0.12.3 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
461
+
"base64 0.22.1",
462
+
"chrono",
463
+
"dashmap",
464
+
"ecdsa",
465
+
"elliptic-curve",
466
+
"jose-jwa",
467
+
"jose-jwk",
468
+
"p256",
469
+
"rand 0.8.5",
470
+
"reqwest",
471
+
"serde",
472
+
"serde_html_form",
473
+
"serde_json",
474
+
"sha2",
475
+
"thiserror 1.0.69",
476
+
"tokio",
477
+
"trait-variant",
478
+
]
479
+
480
+
[[package]]
354
481
name = "atrium-xrpc"
355
482
version = "0.12.3"
356
483
source = "registry+https://github.com/rust-lang/crates.io-index"
···
367
494
[[package]]
368
495
name = "atrium-xrpc"
369
496
version = "0.12.3"
370
-
source = "git+https://github.com/uniphil/atrium?branch=fix%2Fnsid-allow-nonleading-name-digits#c4364f318d337bbc3e3e3aaf97c9f971e95f5f7e"
497
+
source = "git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace#80a355991ac9b48ba3f559d12aac74f071fc638c"
371
498
dependencies = [
372
499
"http",
373
500
"serde",
···
375
502
"serde_json",
376
503
"thiserror 1.0.69",
377
504
"trait-variant",
505
+
]
506
+
507
+
[[package]]
508
+
name = "auto_enums"
509
+
version = "0.8.7"
510
+
source = "registry+https://github.com/rust-lang/crates.io-index"
511
+
checksum = "9c170965892137a3a9aeb000b4524aa3cc022a310e709d848b6e1cdce4ab4781"
512
+
dependencies = [
513
+
"derive_utils",
514
+
"proc-macro2",
515
+
"quote",
516
+
"syn 2.0.106",
378
517
]
379
518
380
519
[[package]]
···
470
609
"axum-core",
471
610
"bytes",
472
611
"cookie",
612
+
"form_urlencoded",
473
613
"futures-util",
474
614
"headers",
475
615
"http",
···
479
619
"pin-project-lite",
480
620
"rustversion",
481
621
"serde",
622
+
"serde_html_form",
623
+
"serde_path_to_error",
482
624
"tower",
483
625
"tower-layer",
484
626
"tower-service",
···
508
650
"axum",
509
651
"handlebars",
510
652
"serde",
511
-
"thiserror 2.0.12",
653
+
"thiserror 2.0.17",
512
654
]
513
655
514
656
[[package]]
···
537
679
version = "0.2.0"
538
680
source = "registry+https://github.com/rust-lang/crates.io-index"
539
681
checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
682
+
683
+
[[package]]
684
+
name = "base256emoji"
685
+
version = "1.0.2"
686
+
source = "registry+https://github.com/rust-lang/crates.io-index"
687
+
checksum = "b5e9430d9a245a77c92176e649af6e275f20839a48389859d1661e9a128d077c"
688
+
dependencies = [
689
+
"const-str",
690
+
"match-lookup",
691
+
]
540
692
541
693
[[package]]
542
694
name = "base64"
···
613
765
"regex",
614
766
"rustc-hash 1.1.0",
615
767
"shlex",
616
-
"syn",
768
+
"syn 2.0.106",
617
769
"which",
618
770
]
619
771
···
632
784
"regex",
633
785
"rustc-hash 1.1.0",
634
786
"shlex",
635
-
"syn",
787
+
"syn 2.0.106",
636
788
]
637
789
638
790
[[package]]
···
650
802
"regex",
651
803
"rustc-hash 2.1.1",
652
804
"shlex",
653
-
"syn",
805
+
"syn 2.0.106",
806
+
]
807
+
808
+
[[package]]
809
+
name = "bitcoin-io"
810
+
version = "0.1.3"
811
+
source = "registry+https://github.com/rust-lang/crates.io-index"
812
+
checksum = "0b47c4ab7a93edb0c7198c5535ed9b52b63095f4e9b45279c6736cec4b856baf"
813
+
814
+
[[package]]
815
+
name = "bitcoin_hashes"
816
+
version = "0.14.0"
817
+
source = "registry+https://github.com/rust-lang/crates.io-index"
818
+
checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16"
819
+
dependencies = [
820
+
"bitcoin-io",
821
+
"hex-conservative",
654
822
]
655
823
656
824
[[package]]
···
660
828
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
661
829
662
830
[[package]]
831
+
name = "blake3"
832
+
version = "1.8.2"
833
+
source = "registry+https://github.com/rust-lang/crates.io-index"
834
+
checksum = "3888aaa89e4b2a40fca9848e400f6a658a5a3978de7be858e209cafa8be9a4a0"
835
+
dependencies = [
836
+
"arrayref",
837
+
"arrayvec",
838
+
"cc",
839
+
"cfg-if",
840
+
"constant_time_eq",
841
+
]
842
+
843
+
[[package]]
663
844
name = "block-buffer"
664
845
version = "0.10.4"
665
846
source = "registry+https://github.com/rust-lang/crates.io-index"
···
687
868
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
688
869
689
870
[[package]]
871
+
name = "byteorder-lite"
872
+
version = "0.1.0"
873
+
source = "registry+https://github.com/rust-lang/crates.io-index"
874
+
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
875
+
876
+
[[package]]
690
877
name = "bytes"
691
878
version = "1.10.1"
692
879
source = "registry+https://github.com/rust-lang/crates.io-index"
···
699
886
checksum = "6236364b88b9b6d0bc181ba374cf1ab55ba3ef97a1cb6f8cddad48a273767fb5"
700
887
701
888
[[package]]
889
+
name = "byteview"
890
+
version = "0.8.0"
891
+
source = "registry+https://github.com/rust-lang/crates.io-index"
892
+
checksum = "1e6b0e42e210b794e14b152c6fe1a55831e30ef4a0f5dc39d73d714fb5f1906c"
893
+
894
+
[[package]]
702
895
name = "bzip2-sys"
703
896
version = "0.1.13+1.0.8"
704
897
source = "registry+https://github.com/rust-lang/crates.io-index"
···
710
903
711
904
[[package]]
712
905
name = "camino"
713
-
version = "1.1.9"
906
+
version = "1.2.1"
714
907
source = "registry+https://github.com/rust-lang/crates.io-index"
715
-
checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3"
908
+
checksum = "276a59bf2b2c967788139340c9f0c5b12d7fd6630315c15c217e559de85d2609"
716
909
dependencies = [
717
-
"serde",
910
+
"serde_core",
718
911
]
719
912
720
913
[[package]]
···
740
933
]
741
934
742
935
[[package]]
936
+
name = "cbor4ii"
937
+
version = "0.2.14"
938
+
source = "registry+https://github.com/rust-lang/crates.io-index"
939
+
checksum = "b544cf8c89359205f4f990d0e6f3828db42df85b5dac95d09157a250eb0749c4"
940
+
dependencies = [
941
+
"serde",
942
+
]
943
+
944
+
[[package]]
945
+
name = "cbor4ii"
946
+
version = "1.2.0"
947
+
source = "registry+https://github.com/rust-lang/crates.io-index"
948
+
checksum = "b28d2802395e3bccd95cc4ae984bff7444b6c1f5981da46a41360c42a2c7e2d9"
949
+
950
+
[[package]]
743
951
name = "cc"
744
952
version = "1.2.18"
745
953
source = "registry+https://github.com/rust-lang/crates.io-index"
···
787
995
]
788
996
789
997
[[package]]
998
+
name = "ciborium"
999
+
version = "0.2.2"
1000
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1001
+
checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e"
1002
+
dependencies = [
1003
+
"ciborium-io",
1004
+
"ciborium-ll",
1005
+
"serde",
1006
+
]
1007
+
1008
+
[[package]]
1009
+
name = "ciborium-io"
1010
+
version = "0.2.2"
1011
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1012
+
checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757"
1013
+
1014
+
[[package]]
1015
+
name = "ciborium-ll"
1016
+
version = "0.2.2"
1017
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1018
+
checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9"
1019
+
dependencies = [
1020
+
"ciborium-io",
1021
+
"half",
1022
+
]
1023
+
1024
+
[[package]]
790
1025
name = "cid"
791
1026
version = "0.11.1"
792
1027
source = "registry+https://github.com/rust-lang/crates.io-index"
···
797
1032
"multihash",
798
1033
"serde",
799
1034
"serde_bytes",
800
-
"unsigned-varint",
1035
+
"unsigned-varint 0.8.0",
801
1036
]
802
1037
803
1038
[[package]]
···
813
1048
814
1049
[[package]]
815
1050
name = "clap"
816
-
version = "4.5.40"
1051
+
version = "4.5.48"
817
1052
source = "registry+https://github.com/rust-lang/crates.io-index"
818
-
checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f"
1053
+
checksum = "e2134bb3ea021b78629caa971416385309e0131b351b25e01dc16fb54e1b5fae"
819
1054
dependencies = [
820
1055
"clap_builder",
821
1056
"clap_derive",
···
823
1058
824
1059
[[package]]
825
1060
name = "clap_builder"
826
-
version = "4.5.40"
1061
+
version = "4.5.48"
827
1062
source = "registry+https://github.com/rust-lang/crates.io-index"
828
-
checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e"
1063
+
checksum = "c2ba64afa3c0a6df7fa517765e31314e983f51dda798ffba27b988194fb65dc9"
829
1064
dependencies = [
830
1065
"anstream",
831
1066
"anstyle",
832
1067
"clap_lex",
833
-
"strsim",
1068
+
"strsim 0.11.1",
834
1069
]
835
1070
836
1071
[[package]]
837
1072
name = "clap_derive"
838
-
version = "4.5.40"
1073
+
version = "4.5.47"
839
1074
source = "registry+https://github.com/rust-lang/crates.io-index"
840
-
checksum = "d2c7947ae4cc3d851207c1adb5b5e260ff0cca11446b1d6d1423788e442257ce"
1075
+
checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c"
841
1076
dependencies = [
842
1077
"heck",
843
1078
"proc-macro2",
844
1079
"quote",
845
-
"syn",
1080
+
"syn 2.0.106",
846
1081
]
847
1082
848
1083
[[package]]
···
872
1107
]
873
1108
874
1109
[[package]]
1110
+
name = "cmsketch"
1111
+
version = "0.2.2"
1112
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1113
+
checksum = "553c840ee51da812c6cd621f9f7e07dfb00a49f91283a8e6380c78cba4f61aba"
1114
+
dependencies = [
1115
+
"paste",
1116
+
]
1117
+
1118
+
[[package]]
875
1119
name = "colorchoice"
876
1120
version = "1.0.3"
877
1121
source = "registry+https://github.com/rust-lang/crates.io-index"
···
899
1143
checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
900
1144
901
1145
[[package]]
1146
+
name = "const-str"
1147
+
version = "0.4.3"
1148
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1149
+
checksum = "2f421161cb492475f1661ddc9815a745a1c894592070661180fdec3d4872e9c3"
1150
+
1151
+
[[package]]
1152
+
name = "constant_time_eq"
1153
+
version = "0.3.1"
1154
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1155
+
checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6"
1156
+
1157
+
[[package]]
902
1158
name = "constellation"
903
1159
version = "0.1.0"
904
1160
dependencies = [
···
911
1167
"clap",
912
1168
"ctrlc",
913
1169
"flume",
914
-
"fs4",
1170
+
"fs4 0.12.0",
915
1171
"headers-accept",
916
1172
"links",
917
1173
"mediatype",
···
1043
1299
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
1044
1300
1045
1301
[[package]]
1302
+
name = "crunchy"
1303
+
version = "0.2.4"
1304
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1305
+
checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
1306
+
1307
+
[[package]]
1046
1308
name = "crypto-bigint"
1047
1309
version = "0.5.5"
1048
1310
source = "registry+https://github.com/rust-lang/crates.io-index"
···
1076
1338
1077
1339
[[package]]
1078
1340
name = "darling"
1341
+
version = "0.14.4"
1342
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1343
+
checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850"
1344
+
dependencies = [
1345
+
"darling_core 0.14.4",
1346
+
"darling_macro 0.14.4",
1347
+
]
1348
+
1349
+
[[package]]
1350
+
name = "darling"
1079
1351
version = "0.20.11"
1080
1352
source = "registry+https://github.com/rust-lang/crates.io-index"
1081
1353
checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee"
1082
1354
dependencies = [
1083
-
"darling_core",
1084
-
"darling_macro",
1355
+
"darling_core 0.20.11",
1356
+
"darling_macro 0.20.11",
1357
+
]
1358
+
1359
+
[[package]]
1360
+
name = "darling_core"
1361
+
version = "0.14.4"
1362
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1363
+
checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0"
1364
+
dependencies = [
1365
+
"fnv",
1366
+
"ident_case",
1367
+
"proc-macro2",
1368
+
"quote",
1369
+
"strsim 0.10.0",
1370
+
"syn 1.0.109",
1085
1371
]
1086
1372
1087
1373
[[package]]
···
1094
1380
"ident_case",
1095
1381
"proc-macro2",
1096
1382
"quote",
1097
-
"strsim",
1098
-
"syn",
1383
+
"strsim 0.11.1",
1384
+
"syn 2.0.106",
1385
+
]
1386
+
1387
+
[[package]]
1388
+
name = "darling_macro"
1389
+
version = "0.14.4"
1390
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1391
+
checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e"
1392
+
dependencies = [
1393
+
"darling_core 0.14.4",
1394
+
"quote",
1395
+
"syn 1.0.109",
1099
1396
]
1100
1397
1101
1398
[[package]]
···
1104
1401
source = "registry+https://github.com/rust-lang/crates.io-index"
1105
1402
checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead"
1106
1403
dependencies = [
1107
-
"darling_core",
1404
+
"darling_core 0.20.11",
1108
1405
"quote",
1109
-
"syn",
1406
+
"syn 2.0.106",
1110
1407
]
1111
1408
1112
1409
[[package]]
···
1124
1421
]
1125
1422
1126
1423
[[package]]
1424
+
name = "dasl"
1425
+
version = "0.2.0"
1426
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1427
+
checksum = "b59666035a4386b0fd272bd78da4cbc3ccb558941e97579ab00f0eb4639f2a49"
1428
+
dependencies = [
1429
+
"blake3",
1430
+
"cbor4ii 1.2.0",
1431
+
"data-encoding",
1432
+
"data-encoding-macro",
1433
+
"scopeguard",
1434
+
"serde",
1435
+
"serde_bytes",
1436
+
"sha2",
1437
+
"thiserror 2.0.17",
1438
+
]
1439
+
1440
+
[[package]]
1127
1441
name = "data-encoding"
1128
-
version = "2.8.0"
1442
+
version = "2.9.0"
1129
1443
source = "registry+https://github.com/rust-lang/crates.io-index"
1130
-
checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010"
1444
+
checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476"
1131
1445
1132
1446
[[package]]
1133
1447
name = "data-encoding-macro"
1134
-
version = "0.1.17"
1448
+
version = "0.1.18"
1135
1449
source = "registry+https://github.com/rust-lang/crates.io-index"
1136
-
checksum = "9f9724adfcf41f45bf652b3995837669d73c4d49a1b5ac1ff82905ac7d9b5558"
1450
+
checksum = "47ce6c96ea0102f01122a185683611bd5ac8d99e62bc59dd12e6bda344ee673d"
1137
1451
dependencies = [
1138
1452
"data-encoding",
1139
1453
"data-encoding-macro-internal",
···
1141
1455
1142
1456
[[package]]
1143
1457
name = "data-encoding-macro-internal"
1144
-
version = "0.1.15"
1458
+
version = "0.1.16"
1145
1459
source = "registry+https://github.com/rust-lang/crates.io-index"
1146
-
checksum = "18e4fdb82bd54a12e42fb58a800dcae6b9e13982238ce2296dc3570b92148e1f"
1460
+
checksum = "8d162beedaa69905488a8da94f5ac3edb4dd4788b732fadb7bd120b2625c1976"
1147
1461
dependencies = [
1148
1462
"data-encoding",
1149
-
"syn",
1463
+
"syn 2.0.106",
1150
1464
]
1151
1465
1152
1466
[[package]]
···
1167
1481
]
1168
1482
1169
1483
[[package]]
1484
+
name = "der-parser"
1485
+
version = "10.0.0"
1486
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1487
+
checksum = "07da5016415d5a3c4dd39b11ed26f915f52fc4e0dc197d87908bc916e51bc1a6"
1488
+
dependencies = [
1489
+
"asn1-rs",
1490
+
"displaydoc",
1491
+
"nom",
1492
+
"num-bigint",
1493
+
"num-traits",
1494
+
"rusticata-macros",
1495
+
]
1496
+
1497
+
[[package]]
1170
1498
name = "deranged"
1171
1499
version = "0.4.0"
1172
1500
source = "registry+https://github.com/rust-lang/crates.io-index"
···
1191
1519
source = "registry+https://github.com/rust-lang/crates.io-index"
1192
1520
checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8"
1193
1521
dependencies = [
1194
-
"darling",
1522
+
"darling 0.20.11",
1195
1523
"proc-macro2",
1196
1524
"quote",
1197
-
"syn",
1525
+
"syn 2.0.106",
1198
1526
]
1199
1527
1200
1528
[[package]]
···
1204
1532
checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c"
1205
1533
dependencies = [
1206
1534
"derive_builder_core",
1207
-
"syn",
1535
+
"syn 2.0.106",
1536
+
]
1537
+
1538
+
[[package]]
1539
+
name = "derive_more"
1540
+
version = "2.0.1"
1541
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1542
+
checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678"
1543
+
dependencies = [
1544
+
"derive_more-impl",
1545
+
]
1546
+
1547
+
[[package]]
1548
+
name = "derive_more-impl"
1549
+
version = "2.0.1"
1550
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1551
+
checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3"
1552
+
dependencies = [
1553
+
"proc-macro2",
1554
+
"quote",
1555
+
"syn 2.0.106",
1556
+
"unicode-xid",
1557
+
]
1558
+
1559
+
[[package]]
1560
+
name = "derive_utils"
1561
+
version = "0.15.0"
1562
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1563
+
checksum = "ccfae181bab5ab6c5478b2ccb69e4c68a02f8c3ec72f6616bfec9dbc599d2ee0"
1564
+
dependencies = [
1565
+
"proc-macro2",
1566
+
"quote",
1567
+
"syn 2.0.106",
1208
1568
]
1209
1569
1210
1570
[[package]]
···
1248
1608
dependencies = [
1249
1609
"proc-macro2",
1250
1610
"quote",
1251
-
"syn",
1611
+
"syn 2.0.106",
1252
1612
]
1253
1613
1254
1614
[[package]]
···
1258
1618
checksum = "c0d05e1c0dbad51b52c38bda7adceef61b9efc2baf04acfe8726a8c4630a6f57"
1259
1619
1260
1620
[[package]]
1621
+
name = "downcast-rs"
1622
+
version = "1.2.1"
1623
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1624
+
checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"
1625
+
1626
+
[[package]]
1261
1627
name = "dropshot"
1262
-
version = "0.16.2"
1628
+
version = "0.16.3"
1263
1629
source = "registry+https://github.com/rust-lang/crates.io-index"
1264
-
checksum = "50e8fed669e35e757646ad10f97c4d26dd22cce3da689b307954f7000d2719d0"
1630
+
checksum = "eedf902e40c1024b8ed9ca16378a54e9655cdf0e698245ba82d81a3778dcbc54"
1265
1631
dependencies = [
1266
1632
"async-stream",
1267
1633
"async-trait",
···
1278
1644
"http-body-util",
1279
1645
"hyper",
1280
1646
"hyper-util",
1281
-
"indexmap 2.9.0",
1647
+
"indexmap 2.11.4",
1282
1648
"multer",
1283
1649
"openapiv3",
1284
1650
"paste",
···
1298
1664
"slog-bunyan",
1299
1665
"slog-json",
1300
1666
"slog-term",
1301
-
"thiserror 2.0.12",
1667
+
"thiserror 2.0.17",
1302
1668
"tokio",
1303
1669
"tokio-rustls 0.25.0",
1304
-
"toml",
1670
+
"toml 0.9.7",
1305
1671
"uuid",
1306
1672
"version_check",
1307
1673
"waitgroup",
···
1309
1675
1310
1676
[[package]]
1311
1677
name = "dropshot_endpoint"
1312
-
version = "0.16.2"
1678
+
version = "0.16.4"
1313
1679
source = "registry+https://github.com/rust-lang/crates.io-index"
1314
-
checksum = "acebb687581abdeaa2c89fa448818a5f803b0e68e5d7e7a1cf585a8f3c5c57ac"
1680
+
checksum = "89d09440e73a9dcf8a0f7fbd6ab889a7751d59f0fe76e5082a0a6d5623ec6da3"
1315
1681
dependencies = [
1316
1682
"heck",
1317
1683
"proc-macro2",
···
1319
1685
"semver",
1320
1686
"serde",
1321
1687
"serde_tokenstream",
1322
-
"syn",
1688
+
"syn 2.0.106",
1323
1689
]
1324
1690
1325
1691
[[package]]
···
1392
1758
"heck",
1393
1759
"proc-macro2",
1394
1760
"quote",
1395
-
"syn",
1761
+
"syn 2.0.106",
1396
1762
]
1397
1763
1398
1764
[[package]]
···
1404
1770
"once_cell",
1405
1771
"proc-macro2",
1406
1772
"quote",
1407
-
"syn",
1773
+
"syn 2.0.106",
1408
1774
]
1409
1775
1410
1776
[[package]]
···
1468
1834
]
1469
1835
1470
1836
[[package]]
1837
+
name = "fallible-iterator"
1838
+
version = "0.3.0"
1839
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1840
+
checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
1841
+
1842
+
[[package]]
1843
+
name = "fallible-streaming-iterator"
1844
+
version = "0.1.9"
1845
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1846
+
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
1847
+
1848
+
[[package]]
1471
1849
name = "fastrand"
1472
1850
version = "2.3.0"
1473
1851
source = "registry+https://github.com/rust-lang/crates.io-index"
···
1485
1863
1486
1864
[[package]]
1487
1865
name = "fjall"
1488
-
version = "2.8.0"
1866
+
version = "2.11.2"
1489
1867
source = "registry+https://github.com/rust-lang/crates.io-index"
1490
-
checksum = "26b2ced3483989a62b3533c9f99054d73b527c6c0045cf22b00fe87956f1a46f"
1868
+
checksum = "0b25ad44cd4360a0448a9b5a0a6f1c7a621101cca4578706d43c9a821418aebc"
1869
+
dependencies = [
1870
+
"byteorder",
1871
+
"byteview 0.6.1",
1872
+
"dashmap",
1873
+
"log",
1874
+
"lsm-tree 2.10.4",
1875
+
"path-absolutize",
1876
+
"std-semaphore",
1877
+
"tempfile",
1878
+
"xxhash-rust",
1879
+
]
1880
+
1881
+
[[package]]
1882
+
name = "fjall"
1883
+
version = "2.11.2"
1884
+
source = "git+https://github.com/fjall-rs/fjall.git#42d811f7c8cc9004407d520d37d2a1d8d246c03d"
1491
1885
dependencies = [
1492
1886
"byteorder",
1493
-
"byteview",
1887
+
"byteview 0.6.1",
1494
1888
"dashmap",
1495
1889
"log",
1496
-
"lsm-tree",
1890
+
"lsm-tree 2.10.4",
1497
1891
"path-absolutize",
1498
1892
"std-semaphore",
1499
1893
"tempfile",
···
1501
1895
]
1502
1896
1503
1897
[[package]]
1898
+
name = "fjall"
1899
+
version = "3.0.0-pre.0"
1900
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1901
+
checksum = "467588c1f15d1cfa9e43f02a45cf55d82fa1f12a6ae961b848c520458525600c"
1902
+
dependencies = [
1903
+
"byteorder-lite",
1904
+
"byteview 0.8.0",
1905
+
"dashmap",
1906
+
"log",
1907
+
"lsm-tree 3.0.0-pre.0",
1908
+
"std-semaphore",
1909
+
"tempfile",
1910
+
"xxhash-rust",
1911
+
]
1912
+
1913
+
[[package]]
1504
1914
name = "flate2"
1505
1915
version = "1.1.2"
1506
1916
source = "registry+https://github.com/rust-lang/crates.io-index"
···
1526
1936
source = "registry+https://github.com/rust-lang/crates.io-index"
1527
1937
checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095"
1528
1938
dependencies = [
1939
+
"futures-core",
1940
+
"futures-sink",
1941
+
"nanorand",
1529
1942
"spin",
1530
1943
]
1531
1944
···
1566
1979
]
1567
1980
1568
1981
[[package]]
1982
+
name = "foyer"
1983
+
version = "0.18.0"
1984
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1985
+
checksum = "0b4d8e96374206ff1b4265f2e2e6e1f80bc3048957b2a1e7fdeef929d68f318f"
1986
+
dependencies = [
1987
+
"equivalent",
1988
+
"foyer-common",
1989
+
"foyer-memory",
1990
+
"foyer-storage",
1991
+
"madsim-tokio",
1992
+
"mixtrics",
1993
+
"pin-project",
1994
+
"serde",
1995
+
"thiserror 2.0.17",
1996
+
"tokio",
1997
+
"tracing",
1998
+
]
1999
+
2000
+
[[package]]
2001
+
name = "foyer-common"
2002
+
version = "0.18.0"
2003
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2004
+
checksum = "911b8e3f23d5fe55b0b240f75af1d2fa5cb7261d3f9b38ef1c57bbc9f0449317"
2005
+
dependencies = [
2006
+
"bincode 1.3.3",
2007
+
"bytes",
2008
+
"cfg-if",
2009
+
"itertools 0.14.0",
2010
+
"madsim-tokio",
2011
+
"mixtrics",
2012
+
"parking_lot",
2013
+
"pin-project",
2014
+
"serde",
2015
+
"thiserror 2.0.17",
2016
+
"tokio",
2017
+
"twox-hash",
2018
+
]
2019
+
2020
+
[[package]]
2021
+
name = "foyer-intrusive-collections"
2022
+
version = "0.10.0-dev"
2023
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2024
+
checksum = "6e4fee46bea69e0596130e3210e65d3424e0ac1e6df3bde6636304bdf1ca4a3b"
2025
+
dependencies = [
2026
+
"memoffset",
2027
+
]
2028
+
2029
+
[[package]]
2030
+
name = "foyer-memory"
2031
+
version = "0.18.0"
2032
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2033
+
checksum = "506883d5a8500dea1b1662f7180f3534bdcbfa718d3253db7179552ef83612fa"
2034
+
dependencies = [
2035
+
"arc-swap",
2036
+
"bitflags",
2037
+
"cmsketch",
2038
+
"equivalent",
2039
+
"foyer-common",
2040
+
"foyer-intrusive-collections",
2041
+
"hashbrown 0.15.2",
2042
+
"itertools 0.14.0",
2043
+
"madsim-tokio",
2044
+
"mixtrics",
2045
+
"parking_lot",
2046
+
"pin-project",
2047
+
"serde",
2048
+
"thiserror 2.0.17",
2049
+
"tokio",
2050
+
"tracing",
2051
+
]
2052
+
2053
+
[[package]]
2054
+
name = "foyer-storage"
2055
+
version = "0.18.0"
2056
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2057
+
checksum = "1ba8403a54a2f2032fb647e49c442e5feeb33f3989f7024f1b178341a016f06d"
2058
+
dependencies = [
2059
+
"allocator-api2",
2060
+
"anyhow",
2061
+
"auto_enums",
2062
+
"bytes",
2063
+
"equivalent",
2064
+
"flume",
2065
+
"foyer-common",
2066
+
"foyer-memory",
2067
+
"fs4 0.13.1",
2068
+
"futures-core",
2069
+
"futures-util",
2070
+
"itertools 0.14.0",
2071
+
"libc",
2072
+
"lz4",
2073
+
"madsim-tokio",
2074
+
"ordered_hash_map",
2075
+
"parking_lot",
2076
+
"paste",
2077
+
"pin-project",
2078
+
"rand 0.9.1",
2079
+
"serde",
2080
+
"thiserror 2.0.17",
2081
+
"tokio",
2082
+
"tracing",
2083
+
"twox-hash",
2084
+
"zstd",
2085
+
]
2086
+
2087
+
[[package]]
1569
2088
name = "fs4"
1570
2089
version = "0.12.0"
1571
2090
source = "registry+https://github.com/rust-lang/crates.io-index"
···
1573
2092
dependencies = [
1574
2093
"rustix 0.38.44",
1575
2094
"windows-sys 0.52.0",
2095
+
]
2096
+
2097
+
[[package]]
2098
+
name = "fs4"
2099
+
version = "0.13.1"
2100
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2101
+
checksum = "8640e34b88f7652208ce9e88b1a37a2ae95227d84abec377ccd3c5cfeb141ed4"
2102
+
dependencies = [
2103
+
"rustix 1.0.5",
2104
+
"windows-sys 0.59.0",
1576
2105
]
1577
2106
1578
2107
[[package]]
···
1637
2166
dependencies = [
1638
2167
"proc-macro2",
1639
2168
"quote",
1640
-
"syn",
2169
+
"syn 2.0.106",
1641
2170
]
1642
2171
1643
2172
[[package]]
···
1714
2243
checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
1715
2244
dependencies = [
1716
2245
"cfg-if",
2246
+
"js-sys",
1717
2247
"libc",
1718
2248
"r-efi",
1719
2249
"wasi 0.14.2+wasi-0.2.4",
2250
+
"wasm-bindgen",
1720
2251
]
1721
2252
1722
2253
[[package]]
···
1760
2291
"futures-core",
1761
2292
"futures-sink",
1762
2293
"http",
1763
-
"indexmap 2.9.0",
2294
+
"indexmap 2.11.4",
1764
2295
"slab",
1765
2296
"tokio",
1766
2297
"tokio-util",
1767
2298
"tracing",
2299
+
]
2300
+
2301
+
[[package]]
2302
+
name = "half"
2303
+
version = "2.6.0"
2304
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2305
+
checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9"
2306
+
dependencies = [
2307
+
"cfg-if",
2308
+
"crunchy",
1768
2309
]
1769
2310
1770
2311
[[package]]
···
1780
2321
"pest_derive",
1781
2322
"serde",
1782
2323
"serde_json",
1783
-
"thiserror 2.0.12",
2324
+
"thiserror 2.0.17",
1784
2325
"walkdir",
1785
2326
]
1786
2327
···
1792
2333
1793
2334
[[package]]
1794
2335
name = "hashbrown"
2336
+
version = "0.13.2"
2337
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2338
+
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
2339
+
dependencies = [
2340
+
"ahash",
2341
+
]
2342
+
2343
+
[[package]]
2344
+
name = "hashbrown"
1795
2345
version = "0.14.5"
1796
2346
source = "registry+https://github.com/rust-lang/crates.io-index"
1797
2347
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
···
1805
2355
"allocator-api2",
1806
2356
"equivalent",
1807
2357
"foldhash",
2358
+
]
2359
+
2360
+
[[package]]
2361
+
name = "hashlink"
2362
+
version = "0.10.0"
2363
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2364
+
checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
2365
+
dependencies = [
2366
+
"hashbrown 0.15.2",
1808
2367
]
1809
2368
1810
2369
[[package]]
···
1859
2418
version = "0.4.3"
1860
2419
source = "registry+https://github.com/rust-lang/crates.io-index"
1861
2420
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
2421
+
2422
+
[[package]]
2423
+
name = "hex-conservative"
2424
+
version = "0.2.1"
2425
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2426
+
checksum = "5313b072ce3c597065a808dbf612c4c8e8590bdbf8b579508bf7a762c5eae6cd"
2427
+
dependencies = [
2428
+
"arrayvec",
2429
+
]
1862
2430
1863
2431
[[package]]
1864
2432
name = "hickory-proto"
···
1878
2446
"once_cell",
1879
2447
"rand 0.9.1",
1880
2448
"ring",
1881
-
"thiserror 2.0.12",
2449
+
"thiserror 2.0.17",
1882
2450
"tinyvec",
1883
2451
"tokio",
1884
2452
"tracing",
···
1901
2469
"rand 0.9.1",
1902
2470
"resolv-conf",
1903
2471
"smallvec",
1904
-
"thiserror 2.0.12",
2472
+
"thiserror 2.0.17",
1905
2473
"tokio",
1906
2474
"tracing",
1907
2475
]
···
2031
2599
"http",
2032
2600
"hyper",
2033
2601
"hyper-util",
2034
-
"rustls 0.23.28",
2602
+
"rustls 0.23.31",
2035
2603
"rustls-native-certs",
2036
2604
"rustls-pki-types",
2037
2605
"tokio",
···
2057
2625
2058
2626
[[package]]
2059
2627
name = "hyper-util"
2060
-
version = "0.1.14"
2628
+
version = "0.1.16"
2061
2629
source = "registry+https://github.com/rust-lang/crates.io-index"
2062
-
checksum = "dc2fdfdbff08affe55bb779f33b053aa1fe5dd5b54c257343c17edfa55711bdb"
2630
+
checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e"
2063
2631
dependencies = [
2064
2632
"base64 0.22.1",
2065
2633
"bytes",
···
2073
2641
"libc",
2074
2642
"percent-encoding",
2075
2643
"pin-project-lite",
2076
-
"socket2",
2644
+
"socket2 0.6.0",
2077
2645
"system-configuration",
2078
2646
"tokio",
2079
2647
"tower-service",
···
2093
2661
"js-sys",
2094
2662
"log",
2095
2663
"wasm-bindgen",
2096
-
"windows-core 0.61.0",
2664
+
"windows-core",
2097
2665
]
2098
2666
2099
2667
[[package]]
···
2220
2788
dependencies = [
2221
2789
"proc-macro2",
2222
2790
"quote",
2223
-
"syn",
2791
+
"syn 2.0.106",
2224
2792
]
2225
2793
2226
2794
[[package]]
···
2263
2831
2264
2832
[[package]]
2265
2833
name = "indexmap"
2266
-
version = "2.9.0"
2834
+
version = "2.11.4"
2267
2835
source = "registry+https://github.com/rust-lang/crates.io-index"
2268
-
checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e"
2836
+
checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5"
2269
2837
dependencies = [
2270
2838
"equivalent",
2271
2839
"hashbrown 0.15.2",
2272
2840
"serde",
2841
+
"serde_core",
2273
2842
]
2274
2843
2275
2844
[[package]]
···
2282
2851
]
2283
2852
2284
2853
[[package]]
2854
+
name = "io-uring"
2855
+
version = "0.7.9"
2856
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2857
+
checksum = "d93587f37623a1a17d94ef2bc9ada592f5465fe7732084ab7beefabe5c77c0c4"
2858
+
dependencies = [
2859
+
"bitflags",
2860
+
"cfg-if",
2861
+
"libc",
2862
+
]
2863
+
2864
+
[[package]]
2285
2865
name = "ipconfig"
2286
2866
version = "0.3.2"
2287
2867
source = "registry+https://github.com/rust-lang/crates.io-index"
2288
2868
checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f"
2289
2869
dependencies = [
2290
-
"socket2",
2870
+
"socket2 0.5.9",
2291
2871
"widestring",
2292
2872
"windows-sys 0.48.0",
2293
2873
"winreg",
···
2321
2901
]
2322
2902
2323
2903
[[package]]
2904
+
name = "iroh-car"
2905
+
version = "0.5.1"
2906
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2907
+
checksum = "cb7f8cd4cb9aa083fba8b52e921764252d0b4dcb1cd6d120b809dbfe1106e81a"
2908
+
dependencies = [
2909
+
"anyhow",
2910
+
"cid",
2911
+
"futures",
2912
+
"serde",
2913
+
"serde_ipld_dagcbor",
2914
+
"thiserror 1.0.69",
2915
+
"tokio",
2916
+
"unsigned-varint 0.7.2",
2917
+
]
2918
+
2919
+
[[package]]
2324
2920
name = "is-terminal"
2325
2921
version = "0.4.16"
2326
2922
source = "registry+https://github.com/rust-lang/crates.io-index"
···
2351
2947
version = "0.13.0"
2352
2948
source = "registry+https://github.com/rust-lang/crates.io-index"
2353
2949
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
2950
+
dependencies = [
2951
+
"either",
2952
+
]
2953
+
2954
+
[[package]]
2955
+
name = "itertools"
2956
+
version = "0.14.0"
2957
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2958
+
checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285"
2354
2959
dependencies = [
2355
2960
"either",
2356
2961
]
···
2367
2972
dependencies = [
2368
2973
"anyhow",
2369
2974
"async-trait",
2370
-
"atrium-api 0.25.3",
2975
+
"atrium-api 0.25.4 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
2371
2976
"chrono",
2372
2977
"clap",
2373
2978
"futures-util",
···
2375
2980
"metrics",
2376
2981
"serde",
2377
2982
"serde_json",
2378
-
"thiserror 2.0.12",
2983
+
"thiserror 2.0.17",
2379
2984
"tokio",
2380
2985
"tokio-tungstenite 0.26.2",
2381
2986
"url",
···
2403
3008
dependencies = [
2404
3009
"proc-macro2",
2405
3010
"quote",
2406
-
"syn",
3011
+
"syn 2.0.106",
2407
3012
]
2408
3013
2409
3014
[[package]]
···
2478
3083
]
2479
3084
2480
3085
[[package]]
3086
+
name = "jwt-compact"
3087
+
version = "0.9.0-beta.1"
3088
+
source = "git+https://github.com/fatfingers23/jwt-compact.git#aed088b8ff5ad44ef2785c453f6a4b7916728b1c"
3089
+
dependencies = [
3090
+
"anyhow",
3091
+
"base64ct",
3092
+
"chrono",
3093
+
"ciborium",
3094
+
"hmac",
3095
+
"lazy_static",
3096
+
"rand_core 0.6.4",
3097
+
"secp256k1",
3098
+
"serde",
3099
+
"serde_json",
3100
+
"sha2",
3101
+
"smallvec",
3102
+
"subtle",
3103
+
"zeroize",
3104
+
]
3105
+
3106
+
[[package]]
3107
+
name = "k256"
3108
+
version = "0.13.4"
3109
+
source = "registry+https://github.com/rust-lang/crates.io-index"
3110
+
checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b"
3111
+
dependencies = [
3112
+
"cfg-if",
3113
+
"ecdsa",
3114
+
"elliptic-curve",
3115
+
"sha2",
3116
+
]
3117
+
3118
+
[[package]]
2481
3119
name = "langtag"
2482
3120
version = "0.3.4"
2483
3121
source = "registry+https://github.com/rust-lang/crates.io-index"
···
2503
3141
2504
3142
[[package]]
2505
3143
name = "libc"
2506
-
version = "0.2.171"
3144
+
version = "0.2.174"
2507
3145
source = "registry+https://github.com/rust-lang/crates.io-index"
2508
-
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
3146
+
checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
2509
3147
2510
3148
[[package]]
2511
3149
name = "libfuzzer-sys"
···
2570
3208
]
2571
3209
2572
3210
[[package]]
3211
+
name = "libsqlite3-sys"
3212
+
version = "0.35.0"
3213
+
source = "registry+https://github.com/rust-lang/crates.io-index"
3214
+
checksum = "133c182a6a2c87864fe97778797e46c7e999672690dc9fa3ee8e241aa4a9c13f"
3215
+
dependencies = [
3216
+
"pkg-config",
3217
+
"vcpkg",
3218
+
]
3219
+
3220
+
[[package]]
2573
3221
name = "libz-sys"
2574
3222
version = "1.1.22"
2575
3223
source = "registry+https://github.com/rust-lang/crates.io-index"
···
2585
3233
version = "0.1.0"
2586
3234
dependencies = [
2587
3235
"anyhow",
3236
+
"dasl",
2588
3237
"fluent-uri",
2589
3238
"nom",
2590
-
"thiserror 2.0.12",
3239
+
"serde",
3240
+
"thiserror 2.0.17",
2591
3241
"tinyjson",
2592
3242
]
2593
3243
···
2621
3271
2622
3272
[[package]]
2623
3273
name = "log"
2624
-
version = "0.4.27"
3274
+
version = "0.4.28"
2625
3275
source = "registry+https://github.com/rust-lang/crates.io-index"
2626
-
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
3276
+
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
2627
3277
2628
3278
[[package]]
2629
3279
name = "loom"
···
2646
3296
dependencies = [
2647
3297
"hashbrown 0.15.2",
2648
3298
]
3299
+
3300
+
[[package]]
3301
+
name = "lru-slab"
3302
+
version = "0.1.2"
3303
+
source = "registry+https://github.com/rust-lang/crates.io-index"
3304
+
checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154"
2649
3305
2650
3306
[[package]]
2651
3307
name = "lsm-tree"
2652
-
version = "2.8.0"
3308
+
version = "2.10.4"
2653
3309
source = "registry+https://github.com/rust-lang/crates.io-index"
2654
-
checksum = "d0a63a5e98a38b51765274137d8aedfbd848da5f4d016867e186b673fcc06a8c"
3310
+
checksum = "799399117a2bfb37660e08be33f470958babb98386b04185288d829df362ea15"
2655
3311
dependencies = [
2656
3312
"byteorder",
2657
3313
"crossbeam-skiplist",
···
2672
3328
]
2673
3329
2674
3330
[[package]]
3331
+
name = "lsm-tree"
3332
+
version = "3.0.0-pre.0"
3333
+
source = "registry+https://github.com/rust-lang/crates.io-index"
3334
+
checksum = "be375d45e348328e78582dffbda4f1709dd52fca27c1a81c7bf6ca134e6335f7"
3335
+
dependencies = [
3336
+
"byteorder-lite",
3337
+
"byteview 0.8.0",
3338
+
"crossbeam-skiplist",
3339
+
"enum_dispatch",
3340
+
"interval-heap",
3341
+
"log",
3342
+
"lz4_flex",
3343
+
"quick_cache",
3344
+
"rustc-hash 2.1.1",
3345
+
"self_cell",
3346
+
"sfa",
3347
+
"tempfile",
3348
+
"varint-rs",
3349
+
"xxhash-rust",
3350
+
]
3351
+
3352
+
[[package]]
3353
+
name = "lz4"
3354
+
version = "1.28.1"
3355
+
source = "registry+https://github.com/rust-lang/crates.io-index"
3356
+
checksum = "a20b523e860d03443e98350ceaac5e71c6ba89aea7d960769ec3ce37f4de5af4"
3357
+
dependencies = [
3358
+
"lz4-sys",
3359
+
]
3360
+
3361
+
[[package]]
2675
3362
name = "lz4-sys"
2676
3363
version = "1.11.1+lz4-1.10.0"
2677
3364
source = "registry+https://github.com/rust-lang/crates.io-index"
···
2683
3370
2684
3371
[[package]]
2685
3372
name = "lz4_flex"
2686
-
version = "0.11.3"
3373
+
version = "0.11.5"
2687
3374
source = "registry+https://github.com/rust-lang/crates.io-index"
2688
-
checksum = "75761162ae2b0e580d7e7c390558127e5f01b4194debd6221fd8c207fc80e3f5"
3375
+
checksum = "08ab2867e3eeeca90e844d1940eab391c9dc5228783db2ed999acbc0a9ed375a"
2689
3376
2690
3377
[[package]]
2691
3378
name = "mach2"
···
2697
3384
]
2698
3385
2699
3386
[[package]]
3387
+
name = "madsim"
3388
+
version = "0.2.32"
3389
+
source = "registry+https://github.com/rust-lang/crates.io-index"
3390
+
checksum = "db6694555643da293dfb89e33c2880a13b62711d64b6588bc7df6ce4110b27f1"
3391
+
dependencies = [
3392
+
"ahash",
3393
+
"async-channel",
3394
+
"async-stream",
3395
+
"async-task",
3396
+
"bincode 1.3.3",
3397
+
"bytes",
3398
+
"downcast-rs",
3399
+
"futures-util",
3400
+
"lazy_static",
3401
+
"libc",
3402
+
"madsim-macros",
3403
+
"naive-timer",
3404
+
"panic-message",
3405
+
"rand 0.8.5",
3406
+
"rand_xoshiro 0.6.0",
3407
+
"rustversion",
3408
+
"serde",
3409
+
"spin",
3410
+
"tokio",
3411
+
"tokio-util",
3412
+
"toml 0.8.23",
3413
+
"tracing",
3414
+
"tracing-subscriber",
3415
+
]
3416
+
3417
+
[[package]]
3418
+
name = "madsim-macros"
3419
+
version = "0.2.12"
3420
+
source = "registry+https://github.com/rust-lang/crates.io-index"
3421
+
checksum = "f3d248e97b1a48826a12c3828d921e8548e714394bf17274dd0a93910dc946e1"
3422
+
dependencies = [
3423
+
"darling 0.14.4",
3424
+
"proc-macro2",
3425
+
"quote",
3426
+
"syn 1.0.109",
3427
+
]
3428
+
3429
+
[[package]]
3430
+
name = "madsim-tokio"
3431
+
version = "0.2.30"
3432
+
source = "registry+https://github.com/rust-lang/crates.io-index"
3433
+
checksum = "7d3eb2acc57c82d21d699119b859e2df70a91dbdb84734885a1e72be83bdecb5"
3434
+
dependencies = [
3435
+
"madsim",
3436
+
"spin",
3437
+
"tokio",
3438
+
]
3439
+
3440
+
[[package]]
3441
+
name = "match-lookup"
3442
+
version = "0.1.1"
3443
+
source = "registry+https://github.com/rust-lang/crates.io-index"
3444
+
checksum = "1265724d8cb29dbbc2b0f06fffb8bf1a8c0cf73a78eede9ba73a4a66c52a981e"
3445
+
dependencies = [
3446
+
"proc-macro2",
3447
+
"quote",
3448
+
"syn 1.0.109",
3449
+
]
3450
+
3451
+
[[package]]
2700
3452
name = "match_cfg"
2701
3453
version = "0.1.0"
2702
3454
source = "registry+https://github.com/rust-lang/crates.io-index"
···
2704
3456
2705
3457
[[package]]
2706
3458
name = "matchers"
2707
-
version = "0.1.0"
3459
+
version = "0.2.0"
2708
3460
source = "registry+https://github.com/rust-lang/crates.io-index"
2709
-
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
3461
+
checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9"
2710
3462
dependencies = [
2711
-
"regex-automata 0.1.10",
3463
+
"regex-automata",
2712
3464
]
2713
3465
2714
3466
[[package]]
···
2730
3482
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
2731
3483
2732
3484
[[package]]
3485
+
name = "memoffset"
3486
+
version = "0.9.1"
3487
+
source = "registry+https://github.com/rust-lang/crates.io-index"
3488
+
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
3489
+
dependencies = [
3490
+
"autocfg",
3491
+
]
3492
+
3493
+
[[package]]
2733
3494
name = "metrics"
2734
3495
version = "0.24.2"
2735
3496
source = "registry+https://github.com/rust-lang/crates.io-index"
···
2749
3510
"http-body-util",
2750
3511
"hyper",
2751
3512
"hyper-util",
2752
-
"indexmap 2.9.0",
3513
+
"indexmap 2.11.4",
2753
3514
"ipnet",
2754
3515
"metrics",
2755
3516
"metrics-util 0.19.0",
···
2770
3531
"hyper",
2771
3532
"hyper-rustls",
2772
3533
"hyper-util",
2773
-
"indexmap 2.9.0",
3534
+
"indexmap 2.11.4",
2774
3535
"ipnet",
2775
3536
"metrics",
2776
3537
"metrics-util 0.20.0",
2777
3538
"quanta",
2778
-
"thiserror 2.0.12",
3539
+
"thiserror 2.0.17",
2779
3540
"tokio",
2780
3541
"tracing",
2781
3542
]
···
2871
3632
]
2872
3633
2873
3634
[[package]]
3635
+
name = "mixtrics"
3636
+
version = "0.2.0"
3637
+
source = "registry+https://github.com/rust-lang/crates.io-index"
3638
+
checksum = "adbcddf5a90b959eea97ae505e0391f5c6dd411fbf546d43b9c59ad1c3bd4391"
3639
+
dependencies = [
3640
+
"itertools 0.14.0",
3641
+
"parking_lot",
3642
+
]
3643
+
3644
+
[[package]]
2874
3645
name = "moka"
2875
3646
version = "0.12.10"
2876
3647
source = "registry+https://github.com/rust-lang/crates.io-index"
···
2906
3677
"memchr",
2907
3678
"mime",
2908
3679
"spin",
3680
+
"tokio",
2909
3681
"version_check",
2910
3682
]
2911
3683
2912
3684
[[package]]
2913
3685
name = "multibase"
2914
-
version = "0.9.1"
3686
+
version = "0.9.2"
2915
3687
source = "registry+https://github.com/rust-lang/crates.io-index"
2916
-
checksum = "9b3539ec3c1f04ac9748a260728e855f261b4977f5c3406612c884564f329404"
3688
+
checksum = "8694bb4835f452b0e3bb06dbebb1d6fc5385b6ca1caf2e55fd165c042390ec77"
2917
3689
dependencies = [
2918
3690
"base-x",
3691
+
"base256emoji",
2919
3692
"data-encoding",
2920
3693
"data-encoding-macro",
2921
3694
]
···
2928
3701
dependencies = [
2929
3702
"core2",
2930
3703
"serde",
2931
-
"unsigned-varint",
3704
+
"unsigned-varint 0.8.0",
3705
+
]
3706
+
3707
+
[[package]]
3708
+
name = "naive-timer"
3709
+
version = "0.2.0"
3710
+
source = "registry+https://github.com/rust-lang/crates.io-index"
3711
+
checksum = "034a0ad7deebf0c2abcf2435950a6666c3c15ea9d8fad0c0f48efa8a7f843fed"
3712
+
3713
+
[[package]]
3714
+
name = "nanorand"
3715
+
version = "0.7.0"
3716
+
source = "registry+https://github.com/rust-lang/crates.io-index"
3717
+
checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3"
3718
+
dependencies = [
3719
+
"getrandom 0.2.15",
2932
3720
]
2933
3721
2934
3722
[[package]]
···
2972
3760
2973
3761
[[package]]
2974
3762
name = "nu-ansi-term"
2975
-
version = "0.46.0"
3763
+
version = "0.50.1"
2976
3764
source = "registry+https://github.com/rust-lang/crates.io-index"
2977
-
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
3765
+
checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399"
2978
3766
dependencies = [
2979
-
"overload",
2980
-
"winapi",
3767
+
"windows-sys 0.52.0",
2981
3768
]
2982
3769
2983
3770
[[package]]
···
3087
3874
]
3088
3875
3089
3876
[[package]]
3877
+
name = "oid-registry"
3878
+
version = "0.8.1"
3879
+
source = "registry+https://github.com/rust-lang/crates.io-index"
3880
+
checksum = "12f40cff3dde1b6087cc5d5f5d4d65712f34016a03ed60e9c08dcc392736b5b7"
3881
+
dependencies = [
3882
+
"asn1-rs",
3883
+
]
3884
+
3885
+
[[package]]
3090
3886
name = "once_cell"
3091
3887
version = "1.21.3"
3092
3888
source = "registry+https://github.com/rust-lang/crates.io-index"
···
3098
3894
3099
3895
[[package]]
3100
3896
name = "openapiv3"
3101
-
version = "2.0.0"
3897
+
version = "2.2.0"
3102
3898
source = "registry+https://github.com/rust-lang/crates.io-index"
3103
-
checksum = "cc02deea53ffe807708244e5914f6b099ad7015a207ee24317c22112e17d9c5c"
3899
+
checksum = "5c8d427828b22ae1fff2833a03d8486c2c881367f1c336349f307f321e7f4d05"
3104
3900
dependencies = [
3105
-
"indexmap 2.9.0",
3901
+
"indexmap 2.11.4",
3106
3902
"serde",
3107
3903
"serde_json",
3108
3904
]
···
3130
3926
dependencies = [
3131
3927
"proc-macro2",
3132
3928
"quote",
3133
-
"syn",
3929
+
"syn 2.0.106",
3134
3930
]
3135
3931
3136
3932
[[package]]
···
3162
3958
]
3163
3959
3164
3960
[[package]]
3165
-
name = "overload"
3166
-
version = "0.1.1"
3961
+
name = "ordered_hash_map"
3962
+
version = "0.4.0"
3167
3963
source = "registry+https://github.com/rust-lang/crates.io-index"
3168
-
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
3964
+
checksum = "ab0e5f22bf6dd04abd854a8874247813a8fa2c8c1260eba6fbb150270ce7c176"
3965
+
dependencies = [
3966
+
"hashbrown 0.13.2",
3967
+
]
3169
3968
3170
3969
[[package]]
3171
3970
name = "p256"
···
3188
3987
"elliptic-curve",
3189
3988
"primeorder",
3190
3989
]
3990
+
3991
+
[[package]]
3992
+
name = "panic-message"
3993
+
version = "0.3.0"
3994
+
source = "registry+https://github.com/rust-lang/crates.io-index"
3995
+
checksum = "384e52fd8fbd4cbe3c317e8216260c21a0f9134de108cea8a4dd4e7e152c472d"
3191
3996
3192
3997
[[package]]
3193
3998
name = "parking"
···
3274
4079
checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323"
3275
4080
dependencies = [
3276
4081
"memchr",
3277
-
"thiserror 2.0.12",
4082
+
"thiserror 2.0.17",
3278
4083
"ucd-trie",
3279
4084
]
3280
4085
···
3298
4103
"pest_meta",
3299
4104
"proc-macro2",
3300
4105
"quote",
3301
-
"syn",
4106
+
"syn 2.0.106",
3302
4107
]
3303
4108
3304
4109
[[package]]
···
3312
4117
]
3313
4118
3314
4119
[[package]]
4120
+
name = "pin-project"
4121
+
version = "1.1.10"
4122
+
source = "registry+https://github.com/rust-lang/crates.io-index"
4123
+
checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a"
4124
+
dependencies = [
4125
+
"pin-project-internal",
4126
+
]
4127
+
4128
+
[[package]]
4129
+
name = "pin-project-internal"
4130
+
version = "1.1.10"
4131
+
source = "registry+https://github.com/rust-lang/crates.io-index"
4132
+
checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861"
4133
+
dependencies = [
4134
+
"proc-macro2",
4135
+
"quote",
4136
+
"syn 2.0.106",
4137
+
]
4138
+
4139
+
[[package]]
3315
4140
name = "pin-project-lite"
3316
4141
version = "0.2.16"
3317
4142
source = "registry+https://github.com/rust-lang/crates.io-index"
···
3349
4174
version = "0.3.32"
3350
4175
source = "registry+https://github.com/rust-lang/crates.io-index"
3351
4176
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
4177
+
4178
+
[[package]]
4179
+
name = "pocket"
4180
+
version = "0.1.0"
4181
+
dependencies = [
4182
+
"atrium-crypto",
4183
+
"clap",
4184
+
"jwt-compact",
4185
+
"log",
4186
+
"poem",
4187
+
"poem-openapi",
4188
+
"reqwest",
4189
+
"rusqlite",
4190
+
"serde",
4191
+
"serde_json",
4192
+
"thiserror 2.0.17",
4193
+
"tokio",
4194
+
"tracing-subscriber",
4195
+
]
4196
+
4197
+
[[package]]
4198
+
name = "poem"
4199
+
version = "3.1.12"
4200
+
source = "registry+https://github.com/rust-lang/crates.io-index"
4201
+
checksum = "9f977080932c87287147dca052951c3e2696f8759863f6b4e4c0c9ffe7a4cc8b"
4202
+
dependencies = [
4203
+
"base64 0.22.1",
4204
+
"bytes",
4205
+
"chrono",
4206
+
"futures-util",
4207
+
"headers",
4208
+
"http",
4209
+
"http-body-util",
4210
+
"httpdate",
4211
+
"hyper",
4212
+
"hyper-util",
4213
+
"mime",
4214
+
"mime_guess",
4215
+
"multer",
4216
+
"nix",
4217
+
"parking_lot",
4218
+
"percent-encoding",
4219
+
"pin-project-lite",
4220
+
"poem-derive",
4221
+
"quick-xml",
4222
+
"rcgen",
4223
+
"regex",
4224
+
"reqwest",
4225
+
"rfc7239",
4226
+
"ring",
4227
+
"rustls-pemfile",
4228
+
"serde",
4229
+
"serde_json",
4230
+
"serde_urlencoded",
4231
+
"serde_yaml",
4232
+
"smallvec",
4233
+
"sync_wrapper",
4234
+
"tempfile",
4235
+
"thiserror 2.0.17",
4236
+
"tokio",
4237
+
"tokio-rustls 0.26.2",
4238
+
"tokio-stream",
4239
+
"tokio-util",
4240
+
"tracing",
4241
+
"wildmatch",
4242
+
"x509-parser",
4243
+
]
4244
+
4245
+
[[package]]
4246
+
name = "poem-derive"
4247
+
version = "3.1.12"
4248
+
source = "registry+https://github.com/rust-lang/crates.io-index"
4249
+
checksum = "056e2fea6de1cb240ffe23cfc4fc370b629f8be83b5f27e16b7acd5231a72de4"
4250
+
dependencies = [
4251
+
"proc-macro-crate",
4252
+
"proc-macro2",
4253
+
"quote",
4254
+
"syn 2.0.106",
4255
+
]
4256
+
4257
+
[[package]]
4258
+
name = "poem-openapi"
4259
+
version = "5.1.16"
4260
+
source = "registry+https://github.com/rust-lang/crates.io-index"
4261
+
checksum = "1ccbcc395bf4dd03df1da32da351b6b6732e4074ce27ddec315650e52a2be44c"
4262
+
dependencies = [
4263
+
"base64 0.22.1",
4264
+
"bytes",
4265
+
"derive_more",
4266
+
"futures-util",
4267
+
"indexmap 2.11.4",
4268
+
"itertools 0.14.0",
4269
+
"mime",
4270
+
"num-traits",
4271
+
"poem",
4272
+
"poem-openapi-derive",
4273
+
"quick-xml",
4274
+
"regex",
4275
+
"serde",
4276
+
"serde_json",
4277
+
"serde_urlencoded",
4278
+
"serde_yaml",
4279
+
"thiserror 2.0.17",
4280
+
"tokio",
4281
+
]
4282
+
4283
+
[[package]]
4284
+
name = "poem-openapi-derive"
4285
+
version = "5.1.16"
4286
+
source = "registry+https://github.com/rust-lang/crates.io-index"
4287
+
checksum = "41273b691a3d467a8c44d05506afba9f7b6bd56c9cdf80123de13fe52d7ec587"
4288
+
dependencies = [
4289
+
"darling 0.20.11",
4290
+
"http",
4291
+
"indexmap 2.11.4",
4292
+
"mime",
4293
+
"proc-macro-crate",
4294
+
"proc-macro2",
4295
+
"quote",
4296
+
"regex",
4297
+
"syn 2.0.106",
4298
+
"thiserror 2.0.17",
4299
+
]
3352
4300
3353
4301
[[package]]
3354
4302
name = "portable-atomic"
···
3387
4335
checksum = "6837b9e10d61f45f987d50808f83d1ee3d206c66acf650c3e4ae2e1f6ddedf55"
3388
4336
dependencies = [
3389
4337
"proc-macro2",
3390
-
"syn",
4338
+
"syn 2.0.106",
3391
4339
]
3392
4340
3393
4341
[[package]]
···
3397
4345
checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6"
3398
4346
dependencies = [
3399
4347
"elliptic-curve",
4348
+
]
4349
+
4350
+
[[package]]
4351
+
name = "proc-macro-crate"
4352
+
version = "3.3.0"
4353
+
source = "registry+https://github.com/rust-lang/crates.io-index"
4354
+
checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35"
4355
+
dependencies = [
4356
+
"toml_edit",
3400
4357
]
3401
4358
3402
4359
[[package]]
···
3446
4403
]
3447
4404
3448
4405
[[package]]
4406
+
name = "quasar"
4407
+
version = "0.1.0"
4408
+
dependencies = [
4409
+
"clap",
4410
+
"fjall 2.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
4411
+
]
4412
+
4413
+
[[package]]
4414
+
name = "quick-xml"
4415
+
version = "0.36.2"
4416
+
source = "registry+https://github.com/rust-lang/crates.io-index"
4417
+
checksum = "f7649a7b4df05aed9ea7ec6f628c67c9953a43869b8bc50929569b2999d443fe"
4418
+
dependencies = [
4419
+
"memchr",
4420
+
"serde",
4421
+
]
4422
+
4423
+
[[package]]
3449
4424
name = "quick_cache"
3450
-
version = "0.6.12"
4425
+
version = "0.6.16"
3451
4426
source = "registry+https://github.com/rust-lang/crates.io-index"
3452
-
checksum = "8f8ed0655cbaf18a26966142ad23b95d8ab47221c50c4f73a1db7d0d2d6e3da8"
4427
+
checksum = "9ad6644cb07b7f3488b9f3d2fde3b4c0a7fa367cafefb39dff93a659f76eb786"
3453
4428
dependencies = [
3454
4429
"equivalent",
3455
4430
"hashbrown 0.15.2",
3456
4431
]
3457
4432
3458
4433
[[package]]
4434
+
name = "quinn"
4435
+
version = "0.11.8"
4436
+
source = "registry+https://github.com/rust-lang/crates.io-index"
4437
+
checksum = "626214629cda6781b6dc1d316ba307189c85ba657213ce642d9c77670f8202c8"
4438
+
dependencies = [
4439
+
"bytes",
4440
+
"cfg_aliases",
4441
+
"pin-project-lite",
4442
+
"quinn-proto",
4443
+
"quinn-udp",
4444
+
"rustc-hash 2.1.1",
4445
+
"rustls 0.23.31",
4446
+
"socket2 0.5.9",
4447
+
"thiserror 2.0.17",
4448
+
"tokio",
4449
+
"tracing",
4450
+
"web-time",
4451
+
]
4452
+
4453
+
[[package]]
4454
+
name = "quinn-proto"
4455
+
version = "0.11.12"
4456
+
source = "registry+https://github.com/rust-lang/crates.io-index"
4457
+
checksum = "49df843a9161c85bb8aae55f101bc0bac8bcafd637a620d9122fd7e0b2f7422e"
4458
+
dependencies = [
4459
+
"bytes",
4460
+
"getrandom 0.3.3",
4461
+
"lru-slab",
4462
+
"rand 0.9.1",
4463
+
"ring",
4464
+
"rustc-hash 2.1.1",
4465
+
"rustls 0.23.31",
4466
+
"rustls-pki-types",
4467
+
"slab",
4468
+
"thiserror 2.0.17",
4469
+
"tinyvec",
4470
+
"tracing",
4471
+
"web-time",
4472
+
]
4473
+
4474
+
[[package]]
4475
+
name = "quinn-udp"
4476
+
version = "0.5.13"
4477
+
source = "registry+https://github.com/rust-lang/crates.io-index"
4478
+
checksum = "fcebb1209ee276352ef14ff8732e24cc2b02bbac986cd74a4c81bcb2f9881970"
4479
+
dependencies = [
4480
+
"cfg_aliases",
4481
+
"libc",
4482
+
"once_cell",
4483
+
"socket2 0.5.9",
4484
+
"tracing",
4485
+
"windows-sys 0.59.0",
4486
+
]
4487
+
4488
+
[[package]]
3459
4489
name = "quote"
3460
4490
version = "1.0.40"
3461
4491
source = "registry+https://github.com/rust-lang/crates.io-index"
···
3568
4598
]
3569
4599
3570
4600
[[package]]
4601
+
name = "rcgen"
4602
+
version = "0.12.1"
4603
+
source = "registry+https://github.com/rust-lang/crates.io-index"
4604
+
checksum = "48406db8ac1f3cbc7dcdb56ec355343817958a356ff430259bb07baf7607e1e1"
4605
+
dependencies = [
4606
+
"pem",
4607
+
"ring",
4608
+
"time",
4609
+
"yasna",
4610
+
]
4611
+
4612
+
[[package]]
3571
4613
name = "redox_syscall"
3572
4614
version = "0.5.11"
3573
4615
source = "registry+https://github.com/rust-lang/crates.io-index"
···
3604
4646
dependencies = [
3605
4647
"proc-macro2",
3606
4648
"quote",
3607
-
"syn",
4649
+
"syn 2.0.106",
4650
+
]
4651
+
4652
+
[[package]]
4653
+
name = "reflector"
4654
+
version = "0.1.0"
4655
+
dependencies = [
4656
+
"clap",
4657
+
"log",
4658
+
"poem",
4659
+
"serde",
4660
+
"tokio",
4661
+
"tracing-subscriber",
3608
4662
]
3609
4663
3610
4664
[[package]]
···
3615
4669
dependencies = [
3616
4670
"aho-corasick",
3617
4671
"memchr",
3618
-
"regex-automata 0.4.9",
3619
-
"regex-syntax 0.8.5",
3620
-
]
3621
-
3622
-
[[package]]
3623
-
name = "regex-automata"
3624
-
version = "0.1.10"
3625
-
source = "registry+https://github.com/rust-lang/crates.io-index"
3626
-
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
3627
-
dependencies = [
3628
-
"regex-syntax 0.6.29",
4672
+
"regex-automata",
4673
+
"regex-syntax",
3629
4674
]
3630
4675
3631
4676
[[package]]
···
3636
4681
dependencies = [
3637
4682
"aho-corasick",
3638
4683
"memchr",
3639
-
"regex-syntax 0.8.5",
4684
+
"regex-syntax",
3640
4685
]
3641
4686
3642
4687
[[package]]
3643
4688
name = "regex-syntax"
3644
-
version = "0.6.29"
4689
+
version = "0.8.5"
3645
4690
source = "registry+https://github.com/rust-lang/crates.io-index"
3646
-
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
4691
+
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
3647
4692
3648
4693
[[package]]
3649
-
name = "regex-syntax"
3650
-
version = "0.8.5"
4694
+
name = "repo-stream"
4695
+
version = "0.2.2"
3651
4696
source = "registry+https://github.com/rust-lang/crates.io-index"
3652
-
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
4697
+
checksum = "093b48e604c138949bf3d4a1a9bc1165feb1db28a73af0101c84eb703d279f43"
4698
+
dependencies = [
4699
+
"bincode 2.0.1",
4700
+
"futures",
4701
+
"futures-core",
4702
+
"ipld-core",
4703
+
"iroh-car",
4704
+
"log",
4705
+
"multibase",
4706
+
"rusqlite",
4707
+
"serde",
4708
+
"serde_bytes",
4709
+
"serde_ipld_dagcbor",
4710
+
"sha2",
4711
+
"thiserror 2.0.17",
4712
+
"tokio",
4713
+
]
3653
4714
3654
4715
[[package]]
3655
4716
name = "reqwest"
3656
-
version = "0.12.22"
4717
+
version = "0.12.24"
3657
4718
source = "registry+https://github.com/rust-lang/crates.io-index"
3658
-
checksum = "cbc931937e6ca3a06e3b6c0aa7841849b160a90351d6ab467a8b9b9959767531"
4719
+
checksum = "9d0946410b9f7b082a427e4ef5c8ff541a88b357bc6c637c40db3a68ac70a36f"
3659
4720
dependencies = [
3660
4721
"async-compression",
3661
4722
"base64 0.22.1",
···
3677
4738
"native-tls",
3678
4739
"percent-encoding",
3679
4740
"pin-project-lite",
4741
+
"quinn",
4742
+
"rustls 0.23.31",
4743
+
"rustls-native-certs",
3680
4744
"rustls-pki-types",
3681
4745
"serde",
3682
4746
"serde_json",
···
3684
4748
"sync_wrapper",
3685
4749
"tokio",
3686
4750
"tokio-native-tls",
4751
+
"tokio-rustls 0.26.2",
3687
4752
"tokio-util",
3688
4753
"tower",
3689
4754
"tower-http",
···
3691
4756
"url",
3692
4757
"wasm-bindgen",
3693
4758
"wasm-bindgen-futures",
4759
+
"wasm-streams",
3694
4760
"web-sys",
3695
4761
]
3696
4762
···
3708
4774
dependencies = [
3709
4775
"hmac",
3710
4776
"subtle",
4777
+
]
4778
+
4779
+
[[package]]
4780
+
name = "rfc7239"
4781
+
version = "0.1.3"
4782
+
source = "registry+https://github.com/rust-lang/crates.io-index"
4783
+
checksum = "4a82f1d1e38e9a85bb58ffcfadf22ed6f2c94e8cd8581ec2b0f80a2a6858350f"
4784
+
dependencies = [
4785
+
"uncased",
3711
4786
]
3712
4787
3713
4788
[[package]]
···
3764
4839
]
3765
4840
3766
4841
[[package]]
4842
+
name = "rusqlite"
4843
+
version = "0.37.0"
4844
+
source = "registry+https://github.com/rust-lang/crates.io-index"
4845
+
checksum = "165ca6e57b20e1351573e3729b958bc62f0e48025386970b6e4d29e7a7e71f3f"
4846
+
dependencies = [
4847
+
"bitflags",
4848
+
"fallible-iterator",
4849
+
"fallible-streaming-iterator",
4850
+
"hashlink",
4851
+
"libsqlite3-sys",
4852
+
"smallvec",
4853
+
]
4854
+
4855
+
[[package]]
3767
4856
name = "rustc-demangle"
3768
4857
version = "0.1.24"
3769
4858
source = "registry+https://github.com/rust-lang/crates.io-index"
···
3791
4880
]
3792
4881
3793
4882
[[package]]
4883
+
name = "rusticata-macros"
4884
+
version = "4.1.0"
4885
+
source = "registry+https://github.com/rust-lang/crates.io-index"
4886
+
checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632"
4887
+
dependencies = [
4888
+
"nom",
4889
+
]
4890
+
4891
+
[[package]]
3794
4892
name = "rustix"
3795
4893
version = "0.38.44"
3796
4894
source = "registry+https://github.com/rust-lang/crates.io-index"
···
3832
4930
3833
4931
[[package]]
3834
4932
name = "rustls"
3835
-
version = "0.23.28"
4933
+
version = "0.23.31"
3836
4934
source = "registry+https://github.com/rust-lang/crates.io-index"
3837
-
checksum = "7160e3e10bf4535308537f3c4e1641468cd0e485175d6163087c0393c7d46643"
4935
+
checksum = "c0ebcbd2f03de0fc1122ad9bb24b127a5a6cd51d72604a3f3c50ac459762b6cc"
3838
4936
dependencies = [
3839
4937
"aws-lc-rs",
4938
+
"log",
3840
4939
"once_cell",
4940
+
"ring",
3841
4941
"rustls-pki-types",
3842
-
"rustls-webpki 0.103.3",
4942
+
"rustls-webpki 0.103.4",
3843
4943
"subtle",
3844
4944
"zeroize",
3845
4945
]
···
3867
4967
3868
4968
[[package]]
3869
4969
name = "rustls-pki-types"
3870
-
version = "1.11.0"
4970
+
version = "1.12.0"
3871
4971
source = "registry+https://github.com/rust-lang/crates.io-index"
3872
-
checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c"
4972
+
checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79"
4973
+
dependencies = [
4974
+
"web-time",
4975
+
"zeroize",
4976
+
]
3873
4977
3874
4978
[[package]]
3875
4979
name = "rustls-webpki"
···
3884
4988
3885
4989
[[package]]
3886
4990
name = "rustls-webpki"
3887
-
version = "0.103.3"
4991
+
version = "0.103.4"
3888
4992
source = "registry+https://github.com/rust-lang/crates.io-index"
3889
-
checksum = "e4a72fe2bcf7a6ac6fd7d0b9e5cb68aeb7d4c0a0271730218b3e92d43b4eb435"
4993
+
checksum = "0a17884ae0c1b773f1ccd2bd4a8c72f16da897310a98b0e84bf349ad5ead92fc"
3890
4994
dependencies = [
3891
4995
"aws-lc-rs",
3892
4996
"ring",
···
3947
5051
"proc-macro2",
3948
5052
"quote",
3949
5053
"serde_derive_internals",
3950
-
"syn",
5054
+
"syn 2.0.106",
3951
5055
]
3952
5056
3953
5057
[[package]]
···
3977
5081
]
3978
5082
3979
5083
[[package]]
5084
+
name = "secp256k1"
5085
+
version = "0.30.0"
5086
+
source = "registry+https://github.com/rust-lang/crates.io-index"
5087
+
checksum = "b50c5943d326858130af85e049f2661ba3c78b26589b8ab98e65e80ae44a1252"
5088
+
dependencies = [
5089
+
"bitcoin_hashes",
5090
+
"rand 0.8.5",
5091
+
"secp256k1-sys",
5092
+
]
5093
+
5094
+
[[package]]
5095
+
name = "secp256k1-sys"
5096
+
version = "0.10.1"
5097
+
source = "registry+https://github.com/rust-lang/crates.io-index"
5098
+
checksum = "d4387882333d3aa8cb20530a17c69a3752e97837832f34f6dccc760e715001d9"
5099
+
dependencies = [
5100
+
"cc",
5101
+
]
5102
+
5103
+
[[package]]
3980
5104
name = "security-framework"
3981
5105
version = "2.11.1"
3982
5106
source = "registry+https://github.com/rust-lang/crates.io-index"
···
4014
5138
4015
5139
[[package]]
4016
5140
name = "self_cell"
4017
-
version = "1.1.0"
5141
+
version = "1.2.0"
4018
5142
source = "registry+https://github.com/rust-lang/crates.io-index"
4019
-
checksum = "c2fdfc24bc566f839a2da4c4295b82db7d25a24253867d5c64355abb5799bdbe"
5143
+
checksum = "0f7d95a54511e0c7be3f51e8867aa8cf35148d7b9445d44de2f943e2b206e749"
4020
5144
4021
5145
[[package]]
4022
5146
name = "semver"
···
4026
5150
4027
5151
[[package]]
4028
5152
name = "serde"
4029
-
version = "1.0.219"
5153
+
version = "1.0.228"
4030
5154
source = "registry+https://github.com/rust-lang/crates.io-index"
4031
-
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
5155
+
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
4032
5156
dependencies = [
5157
+
"serde_core",
4033
5158
"serde_derive",
4034
5159
]
4035
5160
4036
5161
[[package]]
4037
5162
name = "serde_bytes"
4038
-
version = "0.11.17"
5163
+
version = "0.11.19"
4039
5164
source = "registry+https://github.com/rust-lang/crates.io-index"
4040
-
checksum = "8437fd221bde2d4ca316d61b90e337e9e702b3820b87d63caa9ba6c02bd06d96"
5165
+
checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8"
4041
5166
dependencies = [
4042
5167
"serde",
5168
+
"serde_core",
5169
+
]
5170
+
5171
+
[[package]]
5172
+
name = "serde_core"
5173
+
version = "1.0.228"
5174
+
source = "registry+https://github.com/rust-lang/crates.io-index"
5175
+
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
5176
+
dependencies = [
5177
+
"serde_derive",
4043
5178
]
4044
5179
4045
5180
[[package]]
4046
5181
name = "serde_derive"
4047
-
version = "1.0.219"
5182
+
version = "1.0.228"
4048
5183
source = "registry+https://github.com/rust-lang/crates.io-index"
4049
-
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
5184
+
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
4050
5185
dependencies = [
4051
5186
"proc-macro2",
4052
5187
"quote",
4053
-
"syn",
5188
+
"syn 2.0.106",
4054
5189
]
4055
5190
4056
5191
[[package]]
···
4061
5196
dependencies = [
4062
5197
"proc-macro2",
4063
5198
"quote",
4064
-
"syn",
5199
+
"syn 2.0.106",
4065
5200
]
4066
5201
4067
5202
[[package]]
···
4071
5206
checksum = "9d2de91cf02bbc07cde38891769ccd5d4f073d22a40683aa4bc7a95781aaa2c4"
4072
5207
dependencies = [
4073
5208
"form_urlencoded",
4074
-
"indexmap 2.9.0",
5209
+
"indexmap 2.11.4",
4075
5210
"itoa",
4076
5211
"ryu",
4077
5212
"serde",
4078
5213
]
4079
5214
4080
5215
[[package]]
5216
+
name = "serde_ipld_dagcbor"
5217
+
version = "0.6.4"
5218
+
source = "registry+https://github.com/rust-lang/crates.io-index"
5219
+
checksum = "46182f4f08349a02b45c998ba3215d3f9de826246ba02bb9dddfe9a2a2100778"
5220
+
dependencies = [
5221
+
"cbor4ii 0.2.14",
5222
+
"ipld-core",
5223
+
"scopeguard",
5224
+
"serde",
5225
+
]
5226
+
5227
+
[[package]]
4081
5228
name = "serde_json"
4082
-
version = "1.0.140"
5229
+
version = "1.0.145"
4083
5230
source = "registry+https://github.com/rust-lang/crates.io-index"
4084
-
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
5231
+
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
4085
5232
dependencies = [
4086
5233
"itoa",
4087
5234
"memchr",
4088
5235
"ryu",
4089
5236
"serde",
5237
+
"serde_core",
4090
5238
]
4091
5239
4092
5240
[[package]]
···
4109
5257
"percent-encoding",
4110
5258
"ryu",
4111
5259
"serde",
4112
-
"thiserror 2.0.12",
5260
+
"thiserror 2.0.17",
4113
5261
]
4114
5262
4115
5263
[[package]]
···
4122
5270
]
4123
5271
4124
5272
[[package]]
5273
+
name = "serde_spanned"
5274
+
version = "1.0.2"
5275
+
source = "registry+https://github.com/rust-lang/crates.io-index"
5276
+
checksum = "5417783452c2be558477e104686f7de5dae53dba813c28435e0e70f82d9b04ee"
5277
+
dependencies = [
5278
+
"serde_core",
5279
+
]
5280
+
5281
+
[[package]]
4125
5282
name = "serde_tokenstream"
4126
5283
version = "0.2.2"
4127
5284
source = "registry+https://github.com/rust-lang/crates.io-index"
···
4130
5287
"proc-macro2",
4131
5288
"quote",
4132
5289
"serde",
4133
-
"syn",
5290
+
"syn 2.0.106",
4134
5291
]
4135
5292
4136
5293
[[package]]
···
4155
5312
"chrono",
4156
5313
"hex",
4157
5314
"indexmap 1.9.3",
4158
-
"indexmap 2.9.0",
5315
+
"indexmap 2.11.4",
4159
5316
"serde",
4160
5317
"serde_derive",
4161
5318
"serde_json",
···
4169
5326
source = "registry+https://github.com/rust-lang/crates.io-index"
4170
5327
checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e"
4171
5328
dependencies = [
4172
-
"darling",
5329
+
"darling 0.20.11",
4173
5330
"proc-macro2",
4174
5331
"quote",
4175
-
"syn",
5332
+
"syn 2.0.106",
5333
+
]
5334
+
5335
+
[[package]]
5336
+
name = "serde_yaml"
5337
+
version = "0.9.34+deprecated"
5338
+
source = "registry+https://github.com/rust-lang/crates.io-index"
5339
+
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
5340
+
dependencies = [
5341
+
"indexmap 2.11.4",
5342
+
"itoa",
5343
+
"ryu",
5344
+
"serde",
5345
+
"unsafe-libyaml",
5346
+
]
5347
+
5348
+
[[package]]
5349
+
name = "sfa"
5350
+
version = "0.0.1"
5351
+
source = "registry+https://github.com/rust-lang/crates.io-index"
5352
+
checksum = "e5f5f9dc21f55409f15103d5a7e7601b804935923c7fe4746dc806c3a422a038"
5353
+
dependencies = [
5354
+
"byteorder-lite",
5355
+
"log",
5356
+
"xxhash-rust",
4176
5357
]
4177
5358
4178
5359
[[package]]
···
4239
5420
dependencies = [
4240
5421
"num-bigint",
4241
5422
"num-traits",
4242
-
"thiserror 2.0.12",
5423
+
"thiserror 2.0.17",
4243
5424
"time",
4244
5425
]
4245
5426
···
4259
5440
]
4260
5441
4261
5442
[[package]]
5443
+
name = "slingshot"
5444
+
version = "0.1.0"
5445
+
dependencies = [
5446
+
"atrium-api 0.25.4 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
5447
+
"atrium-common 0.1.2 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
5448
+
"atrium-identity 0.1.5 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
5449
+
"atrium-oauth 0.1.3 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
5450
+
"clap",
5451
+
"ctrlc",
5452
+
"foyer",
5453
+
"hickory-resolver",
5454
+
"jetstream",
5455
+
"links",
5456
+
"log",
5457
+
"metrics",
5458
+
"metrics-exporter-prometheus 0.17.2",
5459
+
"poem",
5460
+
"poem-openapi",
5461
+
"reqwest",
5462
+
"rustls 0.23.31",
5463
+
"serde",
5464
+
"serde_json",
5465
+
"thiserror 2.0.17",
5466
+
"time",
5467
+
"tokio",
5468
+
"tokio-util",
5469
+
"tracing-subscriber",
5470
+
"url",
5471
+
]
5472
+
5473
+
[[package]]
4262
5474
name = "slog"
4263
5475
version = "2.7.0"
4264
5476
source = "registry+https://github.com/rust-lang/crates.io-index"
···
4330
5542
]
4331
5543
4332
5544
[[package]]
5545
+
name = "socket2"
5546
+
version = "0.6.0"
5547
+
source = "registry+https://github.com/rust-lang/crates.io-index"
5548
+
checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807"
5549
+
dependencies = [
5550
+
"libc",
5551
+
"windows-sys 0.59.0",
5552
+
]
5553
+
5554
+
[[package]]
4333
5555
name = "spacedust"
4334
5556
version = "0.1.0"
4335
5557
dependencies = [
5558
+
"anyhow",
5559
+
"async-channel",
4336
5560
"async-trait",
4337
5561
"clap",
4338
5562
"ctrlc",
5563
+
"dasl",
4339
5564
"dropshot",
4340
5565
"env_logger",
5566
+
"fjall 3.0.0-pre.0",
4341
5567
"futures",
4342
5568
"http",
5569
+
"ipld-core",
4343
5570
"jetstream",
4344
5571
"links",
4345
5572
"log",
4346
5573
"metrics",
4347
5574
"metrics-exporter-prometheus 0.17.2",
4348
5575
"rand 0.9.1",
5576
+
"repo-stream",
5577
+
"reqwest",
4349
5578
"schemars",
4350
5579
"semver",
4351
5580
"serde",
5581
+
"serde_ipld_dagcbor",
4352
5582
"serde_json",
4353
5583
"serde_qs",
4354
-
"thiserror 2.0.12",
5584
+
"thiserror 2.0.17",
4355
5585
"tinyjson",
4356
5586
"tokio",
4357
5587
"tokio-tungstenite 0.27.0",
···
4391
5621
4392
5622
[[package]]
4393
5623
name = "strsim"
5624
+
version = "0.10.0"
5625
+
source = "registry+https://github.com/rust-lang/crates.io-index"
5626
+
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
5627
+
5628
+
[[package]]
5629
+
name = "strsim"
4394
5630
version = "0.11.1"
4395
5631
source = "registry+https://github.com/rust-lang/crates.io-index"
4396
5632
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
···
4403
5639
4404
5640
[[package]]
4405
5641
name = "syn"
4406
-
version = "2.0.103"
5642
+
version = "1.0.109"
5643
+
source = "registry+https://github.com/rust-lang/crates.io-index"
5644
+
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
5645
+
dependencies = [
5646
+
"proc-macro2",
5647
+
"quote",
5648
+
"unicode-ident",
5649
+
]
5650
+
5651
+
[[package]]
5652
+
name = "syn"
5653
+
version = "2.0.106"
4407
5654
source = "registry+https://github.com/rust-lang/crates.io-index"
4408
-
checksum = "e4307e30089d6fd6aff212f2da3a1f9e32f3223b1f010fb09b7c95f90f3ca1e8"
5655
+
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
4409
5656
dependencies = [
4410
5657
"proc-macro2",
4411
5658
"quote",
···
4429
5676
dependencies = [
4430
5677
"proc-macro2",
4431
5678
"quote",
4432
-
"syn",
5679
+
"syn 2.0.106",
4433
5680
]
4434
5681
4435
5682
[[package]]
···
4467
5714
4468
5715
[[package]]
4469
5716
name = "tempfile"
4470
-
version = "3.19.1"
5717
+
version = "3.23.0"
4471
5718
source = "registry+https://github.com/rust-lang/crates.io-index"
4472
-
checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf"
5719
+
checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16"
4473
5720
dependencies = [
4474
5721
"fastrand",
4475
5722
"getrandom 0.3.3",
···
4500
5747
4501
5748
[[package]]
4502
5749
name = "thiserror"
4503
-
version = "2.0.12"
5750
+
version = "2.0.17"
4504
5751
source = "registry+https://github.com/rust-lang/crates.io-index"
4505
-
checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
5752
+
checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
4506
5753
dependencies = [
4507
-
"thiserror-impl 2.0.12",
5754
+
"thiserror-impl 2.0.17",
4508
5755
]
4509
5756
4510
5757
[[package]]
···
4515
5762
dependencies = [
4516
5763
"proc-macro2",
4517
5764
"quote",
4518
-
"syn",
5765
+
"syn 2.0.106",
4519
5766
]
4520
5767
4521
5768
[[package]]
4522
5769
name = "thiserror-impl"
4523
-
version = "2.0.12"
5770
+
version = "2.0.17"
4524
5771
source = "registry+https://github.com/rust-lang/crates.io-index"
4525
-
checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
5772
+
checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
4526
5773
dependencies = [
4527
5774
"proc-macro2",
4528
5775
"quote",
4529
-
"syn",
5776
+
"syn 2.0.106",
4530
5777
]
4531
5778
4532
5779
[[package]]
···
4625
5872
4626
5873
[[package]]
4627
5874
name = "tokio"
4628
-
version = "1.45.1"
5875
+
version = "1.47.1"
4629
5876
source = "registry+https://github.com/rust-lang/crates.io-index"
4630
-
checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779"
5877
+
checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038"
4631
5878
dependencies = [
4632
5879
"backtrace",
4633
5880
"bytes",
5881
+
"io-uring",
4634
5882
"libc",
4635
5883
"mio",
4636
5884
"parking_lot",
4637
5885
"pin-project-lite",
4638
5886
"signal-hook-registry",
4639
-
"socket2",
5887
+
"slab",
5888
+
"socket2 0.6.0",
4640
5889
"tokio-macros",
4641
-
"windows-sys 0.52.0",
5890
+
"windows-sys 0.59.0",
4642
5891
]
4643
5892
4644
5893
[[package]]
···
4649
5898
dependencies = [
4650
5899
"proc-macro2",
4651
5900
"quote",
4652
-
"syn",
5901
+
"syn 2.0.106",
4653
5902
]
4654
5903
4655
5904
[[package]]
···
4679
5928
source = "registry+https://github.com/rust-lang/crates.io-index"
4680
5929
checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b"
4681
5930
dependencies = [
4682
-
"rustls 0.23.28",
5931
+
"rustls 0.23.31",
5932
+
"tokio",
5933
+
]
5934
+
5935
+
[[package]]
5936
+
name = "tokio-stream"
5937
+
version = "0.1.17"
5938
+
source = "registry+https://github.com/rust-lang/crates.io-index"
5939
+
checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047"
5940
+
dependencies = [
5941
+
"futures-core",
5942
+
"pin-project-lite",
4683
5943
"tokio",
4684
5944
]
4685
5945
···
4729
5989
checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"
4730
5990
dependencies = [
4731
5991
"serde",
4732
-
"serde_spanned",
4733
-
"toml_datetime",
5992
+
"serde_spanned 0.6.9",
5993
+
"toml_datetime 0.6.11",
4734
5994
"toml_edit",
4735
5995
]
4736
5996
4737
5997
[[package]]
5998
+
name = "toml"
5999
+
version = "0.9.7"
6000
+
source = "registry+https://github.com/rust-lang/crates.io-index"
6001
+
checksum = "00e5e5d9bf2475ac9d4f0d9edab68cc573dc2fd644b0dba36b0c30a92dd9eaa0"
6002
+
dependencies = [
6003
+
"indexmap 2.11.4",
6004
+
"serde_core",
6005
+
"serde_spanned 1.0.2",
6006
+
"toml_datetime 0.7.2",
6007
+
"toml_parser",
6008
+
"toml_writer",
6009
+
"winnow",
6010
+
]
6011
+
6012
+
[[package]]
4738
6013
name = "toml_datetime"
4739
6014
version = "0.6.11"
4740
6015
source = "registry+https://github.com/rust-lang/crates.io-index"
···
4744
6019
]
4745
6020
4746
6021
[[package]]
6022
+
name = "toml_datetime"
6023
+
version = "0.7.2"
6024
+
source = "registry+https://github.com/rust-lang/crates.io-index"
6025
+
checksum = "32f1085dec27c2b6632b04c80b3bb1b4300d6495d1e129693bdda7d91e72eec1"
6026
+
dependencies = [
6027
+
"serde_core",
6028
+
]
6029
+
6030
+
[[package]]
4747
6031
name = "toml_edit"
4748
6032
version = "0.22.27"
4749
6033
source = "registry+https://github.com/rust-lang/crates.io-index"
4750
6034
checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
4751
6035
dependencies = [
4752
-
"indexmap 2.9.0",
6036
+
"indexmap 2.11.4",
4753
6037
"serde",
4754
-
"serde_spanned",
4755
-
"toml_datetime",
6038
+
"serde_spanned 0.6.9",
6039
+
"toml_datetime 0.6.11",
4756
6040
"toml_write",
4757
6041
"winnow",
4758
6042
]
4759
6043
4760
6044
[[package]]
6045
+
name = "toml_parser"
6046
+
version = "1.0.3"
6047
+
source = "registry+https://github.com/rust-lang/crates.io-index"
6048
+
checksum = "4cf893c33be71572e0e9aa6dd15e6677937abd686b066eac3f8cd3531688a627"
6049
+
dependencies = [
6050
+
"winnow",
6051
+
]
6052
+
6053
+
[[package]]
4761
6054
name = "toml_write"
4762
6055
version = "0.1.2"
4763
6056
source = "registry+https://github.com/rust-lang/crates.io-index"
4764
6057
checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
6058
+
6059
+
[[package]]
6060
+
name = "toml_writer"
6061
+
version = "1.0.3"
6062
+
source = "registry+https://github.com/rust-lang/crates.io-index"
6063
+
checksum = "d163a63c116ce562a22cda521fcc4d79152e7aba014456fb5eb442f6d6a10109"
4765
6064
4766
6065
[[package]]
4767
6066
name = "tower"
···
4817
6116
dependencies = [
4818
6117
"log",
4819
6118
"pin-project-lite",
6119
+
"tracing-attributes",
4820
6120
"tracing-core",
4821
6121
]
4822
6122
4823
6123
[[package]]
6124
+
name = "tracing-attributes"
6125
+
version = "0.1.30"
6126
+
source = "registry+https://github.com/rust-lang/crates.io-index"
6127
+
checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903"
6128
+
dependencies = [
6129
+
"proc-macro2",
6130
+
"quote",
6131
+
"syn 2.0.106",
6132
+
]
6133
+
6134
+
[[package]]
4824
6135
name = "tracing-core"
4825
6136
version = "0.1.33"
4826
6137
source = "registry+https://github.com/rust-lang/crates.io-index"
···
4843
6154
4844
6155
[[package]]
4845
6156
name = "tracing-subscriber"
4846
-
version = "0.3.19"
6157
+
version = "0.3.20"
4847
6158
source = "registry+https://github.com/rust-lang/crates.io-index"
4848
-
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
6159
+
checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5"
4849
6160
dependencies = [
4850
6161
"matchers",
4851
6162
"nu-ansi-term",
4852
6163
"once_cell",
4853
-
"regex",
6164
+
"regex-automata",
4854
6165
"sharded-slab",
4855
6166
"smallvec",
4856
6167
"thread_local",
···
4867
6178
dependencies = [
4868
6179
"proc-macro2",
4869
6180
"quote",
4870
-
"syn",
6181
+
"syn 2.0.106",
4871
6182
]
4872
6183
4873
6184
[[package]]
···
4890
6201
"native-tls",
4891
6202
"rand 0.9.1",
4892
6203
"sha1",
4893
-
"thiserror 2.0.12",
6204
+
"thiserror 2.0.17",
4894
6205
"url",
4895
6206
"utf-8",
4896
6207
]
···
4908
6219
"log",
4909
6220
"rand 0.9.1",
4910
6221
"sha1",
4911
-
"thiserror 2.0.12",
6222
+
"thiserror 2.0.17",
4912
6223
"utf-8",
4913
6224
]
4914
6225
4915
6226
[[package]]
6227
+
name = "twox-hash"
6228
+
version = "2.1.1"
6229
+
source = "registry+https://github.com/rust-lang/crates.io-index"
6230
+
checksum = "8b907da542cbced5261bd3256de1b3a1bf340a3d37f93425a07362a1d687de56"
6231
+
dependencies = [
6232
+
"rand 0.9.1",
6233
+
]
6234
+
6235
+
[[package]]
4916
6236
name = "typenum"
4917
6237
version = "1.18.0"
4918
6238
source = "registry+https://github.com/rust-lang/crates.io-index"
···
4937
6257
"clap",
4938
6258
"dropshot",
4939
6259
"env_logger",
4940
-
"fjall",
6260
+
"fjall 2.11.2 (git+https://github.com/fjall-rs/fjall.git)",
4941
6261
"getrandom 0.3.3",
4942
6262
"http",
4943
6263
"jetstream",
4944
6264
"log",
4945
-
"lsm-tree",
6265
+
"lsm-tree 2.10.4",
4946
6266
"metrics",
4947
6267
"metrics-exporter-prometheus 0.17.2",
4948
6268
"schemars",
···
4952
6272
"serde_qs",
4953
6273
"sha2",
4954
6274
"tempfile",
4955
-
"thiserror 2.0.12",
6275
+
"thiserror 2.0.17",
4956
6276
"tikv-jemallocator",
4957
6277
"tokio",
4958
6278
"tokio-util",
···
4971
6291
]
4972
6292
4973
6293
[[package]]
6294
+
name = "uncased"
6295
+
version = "0.9.10"
6296
+
source = "registry+https://github.com/rust-lang/crates.io-index"
6297
+
checksum = "e1b88fcfe09e89d3866a5c11019378088af2d24c3fbd4f0543f96b479ec90697"
6298
+
dependencies = [
6299
+
"version_check",
6300
+
]
6301
+
6302
+
[[package]]
4974
6303
name = "unicase"
4975
6304
version = "2.8.1"
4976
6305
source = "registry+https://github.com/rust-lang/crates.io-index"
···
4981
6310
version = "1.0.18"
4982
6311
source = "registry+https://github.com/rust-lang/crates.io-index"
4983
6312
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
6313
+
6314
+
[[package]]
6315
+
name = "unicode-xid"
6316
+
version = "0.2.6"
6317
+
source = "registry+https://github.com/rust-lang/crates.io-index"
6318
+
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
6319
+
6320
+
[[package]]
6321
+
name = "unsafe-libyaml"
6322
+
version = "0.2.11"
6323
+
source = "registry+https://github.com/rust-lang/crates.io-index"
6324
+
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
6325
+
6326
+
[[package]]
6327
+
name = "unsigned-varint"
6328
+
version = "0.7.2"
6329
+
source = "registry+https://github.com/rust-lang/crates.io-index"
6330
+
checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105"
4984
6331
4985
6332
[[package]]
4986
6333
name = "unsigned-varint"
···
5037
6384
5038
6385
[[package]]
5039
6386
name = "uuid"
5040
-
version = "1.16.0"
6387
+
version = "1.18.1"
5041
6388
source = "registry+https://github.com/rust-lang/crates.io-index"
5042
-
checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9"
6389
+
checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2"
5043
6390
dependencies = [
5044
6391
"getrandom 0.3.3",
6392
+
"js-sys",
5045
6393
"serde",
6394
+
"wasm-bindgen",
5046
6395
]
5047
6396
5048
6397
[[package]]
···
5053
6402
5054
6403
[[package]]
5055
6404
name = "value-log"
5056
-
version = "1.8.0"
6405
+
version = "1.9.0"
5057
6406
source = "registry+https://github.com/rust-lang/crates.io-index"
5058
-
checksum = "fd29b17c041f94e0885179637289815cd038f0c9fc19c4549d5a97017404fb7d"
6407
+
checksum = "62fc7c4ce161f049607ecea654dca3f2d727da5371ae85e2e4f14ce2b98ed67c"
5059
6408
dependencies = [
5060
6409
"byteorder",
5061
-
"byteview",
6410
+
"byteview 0.6.1",
5062
6411
"interval-heap",
5063
6412
"log",
5064
6413
"path-absolutize",
···
5157
6506
"log",
5158
6507
"proc-macro2",
5159
6508
"quote",
5160
-
"syn",
6509
+
"syn 2.0.106",
5161
6510
"wasm-bindgen-shared",
5162
6511
]
5163
6512
···
5192
6541
dependencies = [
5193
6542
"proc-macro2",
5194
6543
"quote",
5195
-
"syn",
6544
+
"syn 2.0.106",
5196
6545
"wasm-bindgen-backend",
5197
6546
"wasm-bindgen-shared",
5198
6547
]
···
5207
6556
]
5208
6557
5209
6558
[[package]]
6559
+
name = "wasm-streams"
6560
+
version = "0.4.2"
6561
+
source = "registry+https://github.com/rust-lang/crates.io-index"
6562
+
checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65"
6563
+
dependencies = [
6564
+
"futures-util",
6565
+
"js-sys",
6566
+
"wasm-bindgen",
6567
+
"wasm-bindgen-futures",
6568
+
"web-sys",
6569
+
]
6570
+
6571
+
[[package]]
5210
6572
name = "web-sys"
5211
6573
version = "0.3.77"
5212
6574
source = "registry+https://github.com/rust-lang/crates.io-index"
···
5242
6604
name = "who-am-i"
5243
6605
version = "0.1.0"
5244
6606
dependencies = [
5245
-
"atrium-api 0.25.4",
6607
+
"atrium-api 0.25.4 (registry+https://github.com/rust-lang/crates.io-index)",
5246
6608
"atrium-common 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
5247
-
"atrium-identity",
5248
-
"atrium-oauth",
6609
+
"atrium-identity 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
6610
+
"atrium-oauth 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
5249
6611
"axum",
5250
6612
"axum-extra",
5251
6613
"axum-template",
···
5265
6627
"reqwest",
5266
6628
"serde",
5267
6629
"serde_json",
5268
-
"thiserror 2.0.12",
6630
+
"thiserror 2.0.17",
5269
6631
"tokio",
5270
6632
"tokio-util",
5271
6633
"url",
···
5278
6640
checksum = "dd7cf3379ca1aac9eea11fba24fd7e315d621f8dfe35c8d7d2be8b793726e07d"
5279
6641
5280
6642
[[package]]
6643
+
name = "wildmatch"
6644
+
version = "2.4.0"
6645
+
source = "registry+https://github.com/rust-lang/crates.io-index"
6646
+
checksum = "68ce1ab1f8c62655ebe1350f589c61e505cf94d385bc6a12899442d9081e71fd"
6647
+
6648
+
[[package]]
5281
6649
name = "winapi"
5282
6650
version = "0.3.9"
5283
6651
source = "registry+https://github.com/rust-lang/crates.io-index"
···
5314
6682
source = "registry+https://github.com/rust-lang/crates.io-index"
5315
6683
checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6"
5316
6684
dependencies = [
5317
-
"windows-core 0.58.0",
6685
+
"windows-core",
5318
6686
"windows-targets 0.52.6",
5319
6687
]
5320
6688
···
5324
6692
source = "registry+https://github.com/rust-lang/crates.io-index"
5325
6693
checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
5326
6694
dependencies = [
5327
-
"windows-implement 0.58.0",
5328
-
"windows-interface 0.58.0",
6695
+
"windows-implement",
6696
+
"windows-interface",
5329
6697
"windows-result 0.2.0",
5330
6698
"windows-strings 0.1.0",
5331
6699
"windows-targets 0.52.6",
5332
6700
]
5333
6701
5334
6702
[[package]]
5335
-
name = "windows-core"
5336
-
version = "0.61.0"
5337
-
source = "registry+https://github.com/rust-lang/crates.io-index"
5338
-
checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980"
5339
-
dependencies = [
5340
-
"windows-implement 0.60.0",
5341
-
"windows-interface 0.59.1",
5342
-
"windows-link",
5343
-
"windows-result 0.3.4",
5344
-
"windows-strings 0.4.2",
5345
-
]
5346
-
5347
-
[[package]]
5348
6703
name = "windows-implement"
5349
6704
version = "0.58.0"
5350
6705
source = "registry+https://github.com/rust-lang/crates.io-index"
···
5352
6707
dependencies = [
5353
6708
"proc-macro2",
5354
6709
"quote",
5355
-
"syn",
5356
-
]
5357
-
5358
-
[[package]]
5359
-
name = "windows-implement"
5360
-
version = "0.60.0"
5361
-
source = "registry+https://github.com/rust-lang/crates.io-index"
5362
-
checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836"
5363
-
dependencies = [
5364
-
"proc-macro2",
5365
-
"quote",
5366
-
"syn",
6710
+
"syn 2.0.106",
5367
6711
]
5368
6712
5369
6713
[[package]]
···
5374
6718
dependencies = [
5375
6719
"proc-macro2",
5376
6720
"quote",
5377
-
"syn",
5378
-
]
5379
-
5380
-
[[package]]
5381
-
name = "windows-interface"
5382
-
version = "0.59.1"
5383
-
source = "registry+https://github.com/rust-lang/crates.io-index"
5384
-
checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8"
5385
-
dependencies = [
5386
-
"proc-macro2",
5387
-
"quote",
5388
-
"syn",
6721
+
"syn 2.0.106",
5389
6722
]
5390
6723
5391
6724
[[package]]
···
5592
6925
5593
6926
[[package]]
5594
6927
name = "winnow"
5595
-
version = "0.7.11"
6928
+
version = "0.7.13"
5596
6929
source = "registry+https://github.com/rust-lang/crates.io-index"
5597
-
checksum = "74c7b26e3480b707944fc872477815d29a8e429d2f93a1ce000f5fa84a15cbcd"
6930
+
checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf"
5598
6931
dependencies = [
5599
6932
"memchr",
5600
6933
]
···
5640
6973
]
5641
6974
5642
6975
[[package]]
6976
+
name = "x509-parser"
6977
+
version = "0.17.0"
6978
+
source = "registry+https://github.com/rust-lang/crates.io-index"
6979
+
checksum = "4569f339c0c402346d4a75a9e39cf8dad310e287eef1ff56d4c68e5067f53460"
6980
+
dependencies = [
6981
+
"asn1-rs",
6982
+
"data-encoding",
6983
+
"der-parser",
6984
+
"lazy_static",
6985
+
"nom",
6986
+
"oid-registry",
6987
+
"rusticata-macros",
6988
+
"thiserror 2.0.17",
6989
+
"time",
6990
+
]
6991
+
6992
+
[[package]]
5643
6993
name = "xxhash-rust"
5644
6994
version = "0.8.15"
5645
6995
source = "registry+https://github.com/rust-lang/crates.io-index"
5646
6996
checksum = "fdd20c5420375476fbd4394763288da7eb0cc0b8c11deed431a91562af7335d3"
5647
6997
5648
6998
[[package]]
6999
+
name = "yasna"
7000
+
version = "0.5.2"
7001
+
source = "registry+https://github.com/rust-lang/crates.io-index"
7002
+
checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd"
7003
+
dependencies = [
7004
+
"time",
7005
+
]
7006
+
7007
+
[[package]]
5649
7008
name = "yoke"
5650
7009
version = "0.7.5"
5651
7010
source = "registry+https://github.com/rust-lang/crates.io-index"
···
5665
7024
dependencies = [
5666
7025
"proc-macro2",
5667
7026
"quote",
5668
-
"syn",
7027
+
"syn 2.0.106",
5669
7028
"synstructure",
5670
7029
]
5671
7030
···
5695
7054
dependencies = [
5696
7055
"proc-macro2",
5697
7056
"quote",
5698
-
"syn",
7057
+
"syn 2.0.106",
5699
7058
]
5700
7059
5701
7060
[[package]]
···
5706
7065
dependencies = [
5707
7066
"proc-macro2",
5708
7067
"quote",
5709
-
"syn",
7068
+
"syn 2.0.106",
5710
7069
]
5711
7070
5712
7071
[[package]]
···
5726
7085
dependencies = [
5727
7086
"proc-macro2",
5728
7087
"quote",
5729
-
"syn",
7088
+
"syn 2.0.106",
5730
7089
"synstructure",
5731
7090
]
5732
7091
···
5737
7096
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
5738
7097
dependencies = [
5739
7098
"serde",
7099
+
"zeroize_derive",
7100
+
]
7101
+
7102
+
[[package]]
7103
+
name = "zeroize_derive"
7104
+
version = "1.4.2"
7105
+
source = "registry+https://github.com/rust-lang/crates.io-index"
7106
+
checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
7107
+
dependencies = [
7108
+
"proc-macro2",
7109
+
"quote",
7110
+
"syn 2.0.106",
5740
7111
]
5741
7112
5742
7113
[[package]]
···
5758
7129
dependencies = [
5759
7130
"proc-macro2",
5760
7131
"quote",
5761
-
"syn",
7132
+
"syn 2.0.106",
5762
7133
]
5763
7134
5764
7135
[[package]]
+4
Cargo.toml
+4
Cargo.toml
+8
-1
Makefile
+8
-1
Makefile
···
5
5
cargo test --all-features
6
6
7
7
fmt:
8
-
cargo fmt --package links --package constellation --package ufos --package spacedust --package who-am-i
8
+
cargo fmt --package links \
9
+
--package constellation \
10
+
--package ufos \
11
+
--package spacedust \
12
+
--package who-am-i \
13
+
--package slingshot \
14
+
--package pocket \
15
+
--package reflector
9
16
cargo +nightly fmt --package jetstream
10
17
11
18
clippy:
+1
-1
constellation/Cargo.toml
+1
-1
constellation/Cargo.toml
···
8
8
anyhow = "1.0.95"
9
9
askama = { version = "0.12.1", features = ["serde-json"] }
10
10
axum = "0.8.1"
11
-
axum-extra = { version = "0.10.0", features = ["typed-header"] }
11
+
axum-extra = { version = "0.10.0", features = ["query", "typed-header"] }
12
12
axum-metrics = "0.2"
13
13
bincode = "1.3.3"
14
14
clap = { version = "4.5.26", features = ["derive"] }
+661
constellation/LICENSE
+661
constellation/LICENSE
···
1
+
GNU AFFERO GENERAL PUBLIC LICENSE
2
+
Version 3, 19 November 2007
3
+
4
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+
Everyone is permitted to copy and distribute verbatim copies
6
+
of this license document, but changing it is not allowed.
7
+
8
+
Preamble
9
+
10
+
The GNU Affero General Public License is a free, copyleft license for
11
+
software and other kinds of works, specifically designed to ensure
12
+
cooperation with the community in the case of network server software.
13
+
14
+
The licenses for most software and other practical works are designed
15
+
to take away your freedom to share and change the works. By contrast,
16
+
our General Public Licenses are intended to guarantee your freedom to
17
+
share and change all versions of a program--to make sure it remains free
18
+
software for all its users.
19
+
20
+
When we speak of free software, we are referring to freedom, not
21
+
price. Our General Public Licenses are designed to make sure that you
22
+
have the freedom to distribute copies of free software (and charge for
23
+
them if you wish), that you receive source code or can get it if you
24
+
want it, that you can change the software or use pieces of it in new
25
+
free programs, and that you know you can do these things.
26
+
27
+
Developers that use our General Public Licenses protect your rights
28
+
with two steps: (1) assert copyright on the software, and (2) offer
29
+
you this License which gives you legal permission to copy, distribute
30
+
and/or modify the software.
31
+
32
+
A secondary benefit of defending all users' freedom is that
33
+
improvements made in alternate versions of the program, if they
34
+
receive widespread use, become available for other developers to
35
+
incorporate. Many developers of free software are heartened and
36
+
encouraged by the resulting cooperation. However, in the case of
37
+
software used on network servers, this result may fail to come about.
38
+
The GNU General Public License permits making a modified version and
39
+
letting the public access it on a server without ever releasing its
40
+
source code to the public.
41
+
42
+
The GNU Affero General Public License is designed specifically to
43
+
ensure that, in such cases, the modified source code becomes available
44
+
to the community. It requires the operator of a network server to
45
+
provide the source code of the modified version running there to the
46
+
users of that server. Therefore, public use of a modified version, on
47
+
a publicly accessible server, gives the public access to the source
48
+
code of the modified version.
49
+
50
+
An older license, called the Affero General Public License and
51
+
published by Affero, was designed to accomplish similar goals. This is
52
+
a different license, not a version of the Affero GPL, but Affero has
53
+
released a new version of the Affero GPL which permits relicensing under
54
+
this license.
55
+
56
+
The precise terms and conditions for copying, distribution and
57
+
modification follow.
58
+
59
+
TERMS AND CONDITIONS
60
+
61
+
0. Definitions.
62
+
63
+
"This License" refers to version 3 of the GNU Affero General Public License.
64
+
65
+
"Copyright" also means copyright-like laws that apply to other kinds of
66
+
works, such as semiconductor masks.
67
+
68
+
"The Program" refers to any copyrightable work licensed under this
69
+
License. Each licensee is addressed as "you". "Licensees" and
70
+
"recipients" may be individuals or organizations.
71
+
72
+
To "modify" a work means to copy from or adapt all or part of the work
73
+
in a fashion requiring copyright permission, other than the making of an
74
+
exact copy. The resulting work is called a "modified version" of the
75
+
earlier work or a work "based on" the earlier work.
76
+
77
+
A "covered work" means either the unmodified Program or a work based
78
+
on the Program.
79
+
80
+
To "propagate" a work means to do anything with it that, without
81
+
permission, would make you directly or secondarily liable for
82
+
infringement under applicable copyright law, except executing it on a
83
+
computer or modifying a private copy. Propagation includes copying,
84
+
distribution (with or without modification), making available to the
85
+
public, and in some countries other activities as well.
86
+
87
+
To "convey" a work means any kind of propagation that enables other
88
+
parties to make or receive copies. Mere interaction with a user through
89
+
a computer network, with no transfer of a copy, is not conveying.
90
+
91
+
An interactive user interface displays "Appropriate Legal Notices"
92
+
to the extent that it includes a convenient and prominently visible
93
+
feature that (1) displays an appropriate copyright notice, and (2)
94
+
tells the user that there is no warranty for the work (except to the
95
+
extent that warranties are provided), that licensees may convey the
96
+
work under this License, and how to view a copy of this License. If
97
+
the interface presents a list of user commands or options, such as a
98
+
menu, a prominent item in the list meets this criterion.
99
+
100
+
1. Source Code.
101
+
102
+
The "source code" for a work means the preferred form of the work
103
+
for making modifications to it. "Object code" means any non-source
104
+
form of a work.
105
+
106
+
A "Standard Interface" means an interface that either is an official
107
+
standard defined by a recognized standards body, or, in the case of
108
+
interfaces specified for a particular programming language, one that
109
+
is widely used among developers working in that language.
110
+
111
+
The "System Libraries" of an executable work include anything, other
112
+
than the work as a whole, that (a) is included in the normal form of
113
+
packaging a Major Component, but which is not part of that Major
114
+
Component, and (b) serves only to enable use of the work with that
115
+
Major Component, or to implement a Standard Interface for which an
116
+
implementation is available to the public in source code form. A
117
+
"Major Component", in this context, means a major essential component
118
+
(kernel, window system, and so on) of the specific operating system
119
+
(if any) on which the executable work runs, or a compiler used to
120
+
produce the work, or an object code interpreter used to run it.
121
+
122
+
The "Corresponding Source" for a work in object code form means all
123
+
the source code needed to generate, install, and (for an executable
124
+
work) run the object code and to modify the work, including scripts to
125
+
control those activities. However, it does not include the work's
126
+
System Libraries, or general-purpose tools or generally available free
127
+
programs which are used unmodified in performing those activities but
128
+
which are not part of the work. For example, Corresponding Source
129
+
includes interface definition files associated with source files for
130
+
the work, and the source code for shared libraries and dynamically
131
+
linked subprograms that the work is specifically designed to require,
132
+
such as by intimate data communication or control flow between those
133
+
subprograms and other parts of the work.
134
+
135
+
The Corresponding Source need not include anything that users
136
+
can regenerate automatically from other parts of the Corresponding
137
+
Source.
138
+
139
+
The Corresponding Source for a work in source code form is that
140
+
same work.
141
+
142
+
2. Basic Permissions.
143
+
144
+
All rights granted under this License are granted for the term of
145
+
copyright on the Program, and are irrevocable provided the stated
146
+
conditions are met. This License explicitly affirms your unlimited
147
+
permission to run the unmodified Program. The output from running a
148
+
covered work is covered by this License only if the output, given its
149
+
content, constitutes a covered work. This License acknowledges your
150
+
rights of fair use or other equivalent, as provided by copyright law.
151
+
152
+
You may make, run and propagate covered works that you do not
153
+
convey, without conditions so long as your license otherwise remains
154
+
in force. You may convey covered works to others for the sole purpose
155
+
of having them make modifications exclusively for you, or provide you
156
+
with facilities for running those works, provided that you comply with
157
+
the terms of this License in conveying all material for which you do
158
+
not control copyright. Those thus making or running the covered works
159
+
for you must do so exclusively on your behalf, under your direction
160
+
and control, on terms that prohibit them from making any copies of
161
+
your copyrighted material outside their relationship with you.
162
+
163
+
Conveying under any other circumstances is permitted solely under
164
+
the conditions stated below. Sublicensing is not allowed; section 10
165
+
makes it unnecessary.
166
+
167
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168
+
169
+
No covered work shall be deemed part of an effective technological
170
+
measure under any applicable law fulfilling obligations under article
171
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
172
+
similar laws prohibiting or restricting circumvention of such
173
+
measures.
174
+
175
+
When you convey a covered work, you waive any legal power to forbid
176
+
circumvention of technological measures to the extent such circumvention
177
+
is effected by exercising rights under this License with respect to
178
+
the covered work, and you disclaim any intention to limit operation or
179
+
modification of the work as a means of enforcing, against the work's
180
+
users, your or third parties' legal rights to forbid circumvention of
181
+
technological measures.
182
+
183
+
4. Conveying Verbatim Copies.
184
+
185
+
You may convey verbatim copies of the Program's source code as you
186
+
receive it, in any medium, provided that you conspicuously and
187
+
appropriately publish on each copy an appropriate copyright notice;
188
+
keep intact all notices stating that this License and any
189
+
non-permissive terms added in accord with section 7 apply to the code;
190
+
keep intact all notices of the absence of any warranty; and give all
191
+
recipients a copy of this License along with the Program.
192
+
193
+
You may charge any price or no price for each copy that you convey,
194
+
and you may offer support or warranty protection for a fee.
195
+
196
+
5. Conveying Modified Source Versions.
197
+
198
+
You may convey a work based on the Program, or the modifications to
199
+
produce it from the Program, in the form of source code under the
200
+
terms of section 4, provided that you also meet all of these conditions:
201
+
202
+
a) The work must carry prominent notices stating that you modified
203
+
it, and giving a relevant date.
204
+
205
+
b) The work must carry prominent notices stating that it is
206
+
released under this License and any conditions added under section
207
+
7. This requirement modifies the requirement in section 4 to
208
+
"keep intact all notices".
209
+
210
+
c) You must license the entire work, as a whole, under this
211
+
License to anyone who comes into possession of a copy. This
212
+
License will therefore apply, along with any applicable section 7
213
+
additional terms, to the whole of the work, and all its parts,
214
+
regardless of how they are packaged. This License gives no
215
+
permission to license the work in any other way, but it does not
216
+
invalidate such permission if you have separately received it.
217
+
218
+
d) If the work has interactive user interfaces, each must display
219
+
Appropriate Legal Notices; however, if the Program has interactive
220
+
interfaces that do not display Appropriate Legal Notices, your
221
+
work need not make them do so.
222
+
223
+
A compilation of a covered work with other separate and independent
224
+
works, which are not by their nature extensions of the covered work,
225
+
and which are not combined with it such as to form a larger program,
226
+
in or on a volume of a storage or distribution medium, is called an
227
+
"aggregate" if the compilation and its resulting copyright are not
228
+
used to limit the access or legal rights of the compilation's users
229
+
beyond what the individual works permit. Inclusion of a covered work
230
+
in an aggregate does not cause this License to apply to the other
231
+
parts of the aggregate.
232
+
233
+
6. Conveying Non-Source Forms.
234
+
235
+
You may convey a covered work in object code form under the terms
236
+
of sections 4 and 5, provided that you also convey the
237
+
machine-readable Corresponding Source under the terms of this License,
238
+
in one of these ways:
239
+
240
+
a) Convey the object code in, or embodied in, a physical product
241
+
(including a physical distribution medium), accompanied by the
242
+
Corresponding Source fixed on a durable physical medium
243
+
customarily used for software interchange.
244
+
245
+
b) Convey the object code in, or embodied in, a physical product
246
+
(including a physical distribution medium), accompanied by a
247
+
written offer, valid for at least three years and valid for as
248
+
long as you offer spare parts or customer support for that product
249
+
model, to give anyone who possesses the object code either (1) a
250
+
copy of the Corresponding Source for all the software in the
251
+
product that is covered by this License, on a durable physical
252
+
medium customarily used for software interchange, for a price no
253
+
more than your reasonable cost of physically performing this
254
+
conveying of source, or (2) access to copy the
255
+
Corresponding Source from a network server at no charge.
256
+
257
+
c) Convey individual copies of the object code with a copy of the
258
+
written offer to provide the Corresponding Source. This
259
+
alternative is allowed only occasionally and noncommercially, and
260
+
only if you received the object code with such an offer, in accord
261
+
with subsection 6b.
262
+
263
+
d) Convey the object code by offering access from a designated
264
+
place (gratis or for a charge), and offer equivalent access to the
265
+
Corresponding Source in the same way through the same place at no
266
+
further charge. You need not require recipients to copy the
267
+
Corresponding Source along with the object code. If the place to
268
+
copy the object code is a network server, the Corresponding Source
269
+
may be on a different server (operated by you or a third party)
270
+
that supports equivalent copying facilities, provided you maintain
271
+
clear directions next to the object code saying where to find the
272
+
Corresponding Source. Regardless of what server hosts the
273
+
Corresponding Source, you remain obligated to ensure that it is
274
+
available for as long as needed to satisfy these requirements.
275
+
276
+
e) Convey the object code using peer-to-peer transmission, provided
277
+
you inform other peers where the object code and Corresponding
278
+
Source of the work are being offered to the general public at no
279
+
charge under subsection 6d.
280
+
281
+
A separable portion of the object code, whose source code is excluded
282
+
from the Corresponding Source as a System Library, need not be
283
+
included in conveying the object code work.
284
+
285
+
A "User Product" is either (1) a "consumer product", which means any
286
+
tangible personal property which is normally used for personal, family,
287
+
or household purposes, or (2) anything designed or sold for incorporation
288
+
into a dwelling. In determining whether a product is a consumer product,
289
+
doubtful cases shall be resolved in favor of coverage. For a particular
290
+
product received by a particular user, "normally used" refers to a
291
+
typical or common use of that class of product, regardless of the status
292
+
of the particular user or of the way in which the particular user
293
+
actually uses, or expects or is expected to use, the product. A product
294
+
is a consumer product regardless of whether the product has substantial
295
+
commercial, industrial or non-consumer uses, unless such uses represent
296
+
the only significant mode of use of the product.
297
+
298
+
"Installation Information" for a User Product means any methods,
299
+
procedures, authorization keys, or other information required to install
300
+
and execute modified versions of a covered work in that User Product from
301
+
a modified version of its Corresponding Source. The information must
302
+
suffice to ensure that the continued functioning of the modified object
303
+
code is in no case prevented or interfered with solely because
304
+
modification has been made.
305
+
306
+
If you convey an object code work under this section in, or with, or
307
+
specifically for use in, a User Product, and the conveying occurs as
308
+
part of a transaction in which the right of possession and use of the
309
+
User Product is transferred to the recipient in perpetuity or for a
310
+
fixed term (regardless of how the transaction is characterized), the
311
+
Corresponding Source conveyed under this section must be accompanied
312
+
by the Installation Information. But this requirement does not apply
313
+
if neither you nor any third party retains the ability to install
314
+
modified object code on the User Product (for example, the work has
315
+
been installed in ROM).
316
+
317
+
The requirement to provide Installation Information does not include a
318
+
requirement to continue to provide support service, warranty, or updates
319
+
for a work that has been modified or installed by the recipient, or for
320
+
the User Product in which it has been modified or installed. Access to a
321
+
network may be denied when the modification itself materially and
322
+
adversely affects the operation of the network or violates the rules and
323
+
protocols for communication across the network.
324
+
325
+
Corresponding Source conveyed, and Installation Information provided,
326
+
in accord with this section must be in a format that is publicly
327
+
documented (and with an implementation available to the public in
328
+
source code form), and must require no special password or key for
329
+
unpacking, reading or copying.
330
+
331
+
7. Additional Terms.
332
+
333
+
"Additional permissions" are terms that supplement the terms of this
334
+
License by making exceptions from one or more of its conditions.
335
+
Additional permissions that are applicable to the entire Program shall
336
+
be treated as though they were included in this License, to the extent
337
+
that they are valid under applicable law. If additional permissions
338
+
apply only to part of the Program, that part may be used separately
339
+
under those permissions, but the entire Program remains governed by
340
+
this License without regard to the additional permissions.
341
+
342
+
When you convey a copy of a covered work, you may at your option
343
+
remove any additional permissions from that copy, or from any part of
344
+
it. (Additional permissions may be written to require their own
345
+
removal in certain cases when you modify the work.) You may place
346
+
additional permissions on material, added by you to a covered work,
347
+
for which you have or can give appropriate copyright permission.
348
+
349
+
Notwithstanding any other provision of this License, for material you
350
+
add to a covered work, you may (if authorized by the copyright holders of
351
+
that material) supplement the terms of this License with terms:
352
+
353
+
a) Disclaiming warranty or limiting liability differently from the
354
+
terms of sections 15 and 16 of this License; or
355
+
356
+
b) Requiring preservation of specified reasonable legal notices or
357
+
author attributions in that material or in the Appropriate Legal
358
+
Notices displayed by works containing it; or
359
+
360
+
c) Prohibiting misrepresentation of the origin of that material, or
361
+
requiring that modified versions of such material be marked in
362
+
reasonable ways as different from the original version; or
363
+
364
+
d) Limiting the use for publicity purposes of names of licensors or
365
+
authors of the material; or
366
+
367
+
e) Declining to grant rights under trademark law for use of some
368
+
trade names, trademarks, or service marks; or
369
+
370
+
f) Requiring indemnification of licensors and authors of that
371
+
material by anyone who conveys the material (or modified versions of
372
+
it) with contractual assumptions of liability to the recipient, for
373
+
any liability that these contractual assumptions directly impose on
374
+
those licensors and authors.
375
+
376
+
All other non-permissive additional terms are considered "further
377
+
restrictions" within the meaning of section 10. If the Program as you
378
+
received it, or any part of it, contains a notice stating that it is
379
+
governed by this License along with a term that is a further
380
+
restriction, you may remove that term. If a license document contains
381
+
a further restriction but permits relicensing or conveying under this
382
+
License, you may add to a covered work material governed by the terms
383
+
of that license document, provided that the further restriction does
384
+
not survive such relicensing or conveying.
385
+
386
+
If you add terms to a covered work in accord with this section, you
387
+
must place, in the relevant source files, a statement of the
388
+
additional terms that apply to those files, or a notice indicating
389
+
where to find the applicable terms.
390
+
391
+
Additional terms, permissive or non-permissive, may be stated in the
392
+
form of a separately written license, or stated as exceptions;
393
+
the above requirements apply either way.
394
+
395
+
8. Termination.
396
+
397
+
You may not propagate or modify a covered work except as expressly
398
+
provided under this License. Any attempt otherwise to propagate or
399
+
modify it is void, and will automatically terminate your rights under
400
+
this License (including any patent licenses granted under the third
401
+
paragraph of section 11).
402
+
403
+
However, if you cease all violation of this License, then your
404
+
license from a particular copyright holder is reinstated (a)
405
+
provisionally, unless and until the copyright holder explicitly and
406
+
finally terminates your license, and (b) permanently, if the copyright
407
+
holder fails to notify you of the violation by some reasonable means
408
+
prior to 60 days after the cessation.
409
+
410
+
Moreover, your license from a particular copyright holder is
411
+
reinstated permanently if the copyright holder notifies you of the
412
+
violation by some reasonable means, this is the first time you have
413
+
received notice of violation of this License (for any work) from that
414
+
copyright holder, and you cure the violation prior to 30 days after
415
+
your receipt of the notice.
416
+
417
+
Termination of your rights under this section does not terminate the
418
+
licenses of parties who have received copies or rights from you under
419
+
this License. If your rights have been terminated and not permanently
420
+
reinstated, you do not qualify to receive new licenses for the same
421
+
material under section 10.
422
+
423
+
9. Acceptance Not Required for Having Copies.
424
+
425
+
You are not required to accept this License in order to receive or
426
+
run a copy of the Program. Ancillary propagation of a covered work
427
+
occurring solely as a consequence of using peer-to-peer transmission
428
+
to receive a copy likewise does not require acceptance. However,
429
+
nothing other than this License grants you permission to propagate or
430
+
modify any covered work. These actions infringe copyright if you do
431
+
not accept this License. Therefore, by modifying or propagating a
432
+
covered work, you indicate your acceptance of this License to do so.
433
+
434
+
10. Automatic Licensing of Downstream Recipients.
435
+
436
+
Each time you convey a covered work, the recipient automatically
437
+
receives a license from the original licensors, to run, modify and
438
+
propagate that work, subject to this License. You are not responsible
439
+
for enforcing compliance by third parties with this License.
440
+
441
+
An "entity transaction" is a transaction transferring control of an
442
+
organization, or substantially all assets of one, or subdividing an
443
+
organization, or merging organizations. If propagation of a covered
444
+
work results from an entity transaction, each party to that
445
+
transaction who receives a copy of the work also receives whatever
446
+
licenses to the work the party's predecessor in interest had or could
447
+
give under the previous paragraph, plus a right to possession of the
448
+
Corresponding Source of the work from the predecessor in interest, if
449
+
the predecessor has it or can get it with reasonable efforts.
450
+
451
+
You may not impose any further restrictions on the exercise of the
452
+
rights granted or affirmed under this License. For example, you may
453
+
not impose a license fee, royalty, or other charge for exercise of
454
+
rights granted under this License, and you may not initiate litigation
455
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
456
+
any patent claim is infringed by making, using, selling, offering for
457
+
sale, or importing the Program or any portion of it.
458
+
459
+
11. Patents.
460
+
461
+
A "contributor" is a copyright holder who authorizes use under this
462
+
License of the Program or a work on which the Program is based. The
463
+
work thus licensed is called the contributor's "contributor version".
464
+
465
+
A contributor's "essential patent claims" are all patent claims
466
+
owned or controlled by the contributor, whether already acquired or
467
+
hereafter acquired, that would be infringed by some manner, permitted
468
+
by this License, of making, using, or selling its contributor version,
469
+
but do not include claims that would be infringed only as a
470
+
consequence of further modification of the contributor version. For
471
+
purposes of this definition, "control" includes the right to grant
472
+
patent sublicenses in a manner consistent with the requirements of
473
+
this License.
474
+
475
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
476
+
patent license under the contributor's essential patent claims, to
477
+
make, use, sell, offer for sale, import and otherwise run, modify and
478
+
propagate the contents of its contributor version.
479
+
480
+
In the following three paragraphs, a "patent license" is any express
481
+
agreement or commitment, however denominated, not to enforce a patent
482
+
(such as an express permission to practice a patent or covenant not to
483
+
sue for patent infringement). To "grant" such a patent license to a
484
+
party means to make such an agreement or commitment not to enforce a
485
+
patent against the party.
486
+
487
+
If you convey a covered work, knowingly relying on a patent license,
488
+
and the Corresponding Source of the work is not available for anyone
489
+
to copy, free of charge and under the terms of this License, through a
490
+
publicly available network server or other readily accessible means,
491
+
then you must either (1) cause the Corresponding Source to be so
492
+
available, or (2) arrange to deprive yourself of the benefit of the
493
+
patent license for this particular work, or (3) arrange, in a manner
494
+
consistent with the requirements of this License, to extend the patent
495
+
license to downstream recipients. "Knowingly relying" means you have
496
+
actual knowledge that, but for the patent license, your conveying the
497
+
covered work in a country, or your recipient's use of the covered work
498
+
in a country, would infringe one or more identifiable patents in that
499
+
country that you have reason to believe are valid.
500
+
501
+
If, pursuant to or in connection with a single transaction or
502
+
arrangement, you convey, or propagate by procuring conveyance of, a
503
+
covered work, and grant a patent license to some of the parties
504
+
receiving the covered work authorizing them to use, propagate, modify
505
+
or convey a specific copy of the covered work, then the patent license
506
+
you grant is automatically extended to all recipients of the covered
507
+
work and works based on it.
508
+
509
+
A patent license is "discriminatory" if it does not include within
510
+
the scope of its coverage, prohibits the exercise of, or is
511
+
conditioned on the non-exercise of one or more of the rights that are
512
+
specifically granted under this License. You may not convey a covered
513
+
work if you are a party to an arrangement with a third party that is
514
+
in the business of distributing software, under which you make payment
515
+
to the third party based on the extent of your activity of conveying
516
+
the work, and under which the third party grants, to any of the
517
+
parties who would receive the covered work from you, a discriminatory
518
+
patent license (a) in connection with copies of the covered work
519
+
conveyed by you (or copies made from those copies), or (b) primarily
520
+
for and in connection with specific products or compilations that
521
+
contain the covered work, unless you entered into that arrangement,
522
+
or that patent license was granted, prior to 28 March 2007.
523
+
524
+
Nothing in this License shall be construed as excluding or limiting
525
+
any implied license or other defenses to infringement that may
526
+
otherwise be available to you under applicable patent law.
527
+
528
+
12. No Surrender of Others' Freedom.
529
+
530
+
If conditions are imposed on you (whether by court order, agreement or
531
+
otherwise) that contradict the conditions of this License, they do not
532
+
excuse you from the conditions of this License. If you cannot convey a
533
+
covered work so as to satisfy simultaneously your obligations under this
534
+
License and any other pertinent obligations, then as a consequence you may
535
+
not convey it at all. For example, if you agree to terms that obligate you
536
+
to collect a royalty for further conveying from those to whom you convey
537
+
the Program, the only way you could satisfy both those terms and this
538
+
License would be to refrain entirely from conveying the Program.
539
+
540
+
13. Remote Network Interaction; Use with the GNU General Public License.
541
+
542
+
Notwithstanding any other provision of this License, if you modify the
543
+
Program, your modified version must prominently offer all users
544
+
interacting with it remotely through a computer network (if your version
545
+
supports such interaction) an opportunity to receive the Corresponding
546
+
Source of your version by providing access to the Corresponding Source
547
+
from a network server at no charge, through some standard or customary
548
+
means of facilitating copying of software. This Corresponding Source
549
+
shall include the Corresponding Source for any work covered by version 3
550
+
of the GNU General Public License that is incorporated pursuant to the
551
+
following paragraph.
552
+
553
+
Notwithstanding any other provision of this License, you have
554
+
permission to link or combine any covered work with a work licensed
555
+
under version 3 of the GNU General Public License into a single
556
+
combined work, and to convey the resulting work. The terms of this
557
+
License will continue to apply to the part which is the covered work,
558
+
but the work with which it is combined will remain governed by version
559
+
3 of the GNU General Public License.
560
+
561
+
14. Revised Versions of this License.
562
+
563
+
The Free Software Foundation may publish revised and/or new versions of
564
+
the GNU Affero General Public License from time to time. Such new versions
565
+
will be similar in spirit to the present version, but may differ in detail to
566
+
address new problems or concerns.
567
+
568
+
Each version is given a distinguishing version number. If the
569
+
Program specifies that a certain numbered version of the GNU Affero General
570
+
Public License "or any later version" applies to it, you have the
571
+
option of following the terms and conditions either of that numbered
572
+
version or of any later version published by the Free Software
573
+
Foundation. If the Program does not specify a version number of the
574
+
GNU Affero General Public License, you may choose any version ever published
575
+
by the Free Software Foundation.
576
+
577
+
If the Program specifies that a proxy can decide which future
578
+
versions of the GNU Affero General Public License can be used, that proxy's
579
+
public statement of acceptance of a version permanently authorizes you
580
+
to choose that version for the Program.
581
+
582
+
Later license versions may give you additional or different
583
+
permissions. However, no additional obligations are imposed on any
584
+
author or copyright holder as a result of your choosing to follow a
585
+
later version.
586
+
587
+
15. Disclaimer of Warranty.
588
+
589
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597
+
598
+
16. Limitation of Liability.
599
+
600
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608
+
SUCH DAMAGES.
609
+
610
+
17. Interpretation of Sections 15 and 16.
611
+
612
+
If the disclaimer of warranty and limitation of liability provided
613
+
above cannot be given local legal effect according to their terms,
614
+
reviewing courts shall apply local law that most closely approximates
615
+
an absolute waiver of all civil liability in connection with the
616
+
Program, unless a warranty or assumption of liability accompanies a
617
+
copy of the Program in return for a fee.
618
+
619
+
END OF TERMS AND CONDITIONS
620
+
621
+
How to Apply These Terms to Your New Programs
622
+
623
+
If you develop a new program, and you want it to be of the greatest
624
+
possible use to the public, the best way to achieve this is to make it
625
+
free software which everyone can redistribute and change under these terms.
626
+
627
+
To do so, attach the following notices to the program. It is safest
628
+
to attach them to the start of each source file to most effectively
629
+
state the exclusion of warranty; and each file should have at least
630
+
the "copyright" line and a pointer to where the full notice is found.
631
+
632
+
<one line to give the program's name and a brief idea of what it does.>
633
+
Copyright (C) <year> <name of author>
634
+
635
+
This program is free software: you can redistribute it and/or modify
636
+
it under the terms of the GNU Affero General Public License as published
637
+
by the Free Software Foundation, either version 3 of the License, or
638
+
(at your option) any later version.
639
+
640
+
This program is distributed in the hope that it will be useful,
641
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
642
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643
+
GNU Affero General Public License for more details.
644
+
645
+
You should have received a copy of the GNU Affero General Public License
646
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
647
+
648
+
Also add information on how to contact you by electronic and paper mail.
649
+
650
+
If your software can interact with users remotely through a computer
651
+
network, you should also make sure that it provides a way for users to
652
+
get its source. For example, if your program is a web application, its
653
+
interface could display a "Source" link that leads users to an archive
654
+
of the code. There are many ways you could offer source, and different
655
+
solutions will be better for different programs; see section 13 for the
656
+
specific requirements.
657
+
658
+
You should also get your employer (if you work as a programmer) or school,
659
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
660
+
For more information on this, and how to apply and follow the GNU AGPL, see
661
+
<https://www.gnu.org/licenses/>.
+3
constellation/LICENSE.future
+3
constellation/LICENSE.future
+9
constellation/readme.md
+9
constellation/readme.md
···
83
83
```
84
84
85
85
86
+
## Contributions
87
+
88
+
### Licensing
89
+
90
+
Constellation's source code is currently available exclusively under the AGPL license (see [LICENSE](./LICENSE)).
91
+
92
+
In the future, its code MAY become available under the MIT and/or Apache2.0 licenses, at the sole discretion of the microcosm organization. Contributing implies acceptance with this possible future licensing change. The change has not happed yet and is not guaranteed.
93
+
94
+
86
95
some todos
87
96
88
97
- [x] find links and write them to rocksdb
+57
-14
constellation/src/bin/main.rs
+57
-14
constellation/src/bin/main.rs
···
1
1
use anyhow::{bail, Result};
2
2
use clap::{Parser, ValueEnum};
3
3
use metrics_exporter_prometheus::PrometheusBuilder;
4
+
use std::net::SocketAddr;
4
5
use std::num::NonZero;
5
6
use std::path::PathBuf;
6
7
use std::sync::{atomic::AtomicU32, Arc};
···
21
22
#[derive(Parser, Debug)]
22
23
#[command(version, about, long_about = None)]
23
24
struct Args {
24
-
#[arg(short, long)]
25
+
/// constellation server's listen address
26
+
#[arg(long)]
27
+
#[clap(default_value = "0.0.0.0:6789")]
28
+
bind: SocketAddr,
29
+
/// metrics server's listen address
30
+
#[arg(long)]
31
+
#[clap(default_value = "0.0.0.0:8765")]
32
+
bind_metrics: SocketAddr,
25
33
/// Jetstream server to connect to (exclusive with --fixture). Provide either a wss:// URL, or a shorhand value:
26
34
/// 'us-east-1', 'us-east-2', 'us-west-1', or 'us-west-2'
27
35
#[arg(short, long)]
···
46
54
/// Saved jsonl from jetstream to use instead of a live subscription
47
55
#[arg(short, long)]
48
56
fixture: Option<PathBuf>,
57
+
/// run a scan across the target id table and write all key -> ids to id -> keys
58
+
#[arg(long, action)]
59
+
repair_target_ids: bool,
49
60
}
50
61
51
62
#[derive(Debug, Clone, ValueEnum)]
···
78
89
let stream = jetstream_url(&args.jetstream);
79
90
println!("using jetstream server {stream:?}...",);
80
91
92
+
let bind = args.bind;
93
+
let metrics_bind = args.bind_metrics;
94
+
81
95
let stay_alive = CancellationToken::new();
82
96
83
97
match args.backend {
84
-
StorageBackend::Memory => run(MemStorage::new(), fixture, None, stream, stay_alive),
98
+
StorageBackend::Memory => run(
99
+
MemStorage::new(),
100
+
fixture,
101
+
None,
102
+
stream,
103
+
bind,
104
+
metrics_bind,
105
+
stay_alive,
106
+
),
85
107
#[cfg(feature = "rocks")]
86
108
StorageBackend::Rocks => {
87
109
let storage_dir = args.data.clone().unwrap_or("rocks.test".into());
···
96
118
rocks.start_backup(backup_dir, auto_backup, stay_alive.clone())?;
97
119
}
98
120
println!("rocks ready.");
99
-
run(rocks, fixture, args.data, stream, stay_alive)
121
+
std::thread::scope(|s| {
122
+
if args.repair_target_ids {
123
+
let rocks = rocks.clone();
124
+
let stay_alive = stay_alive.clone();
125
+
s.spawn(move || {
126
+
let rep = rocks.run_repair(time::Duration::from_millis(0), stay_alive);
127
+
eprintln!("repair finished: {rep:?}");
128
+
rep
129
+
});
130
+
}
131
+
s.spawn(|| {
132
+
let r = run(
133
+
rocks,
134
+
fixture,
135
+
args.data,
136
+
stream,
137
+
bind,
138
+
metrics_bind,
139
+
stay_alive,
140
+
);
141
+
eprintln!("run finished: {r:?}");
142
+
r
143
+
});
144
+
});
145
+
Ok(())
100
146
}
101
147
}
102
148
}
···
106
152
fixture: Option<PathBuf>,
107
153
data_dir: Option<PathBuf>,
108
154
stream: String,
155
+
bind: SocketAddr,
156
+
metrics_bind: SocketAddr,
109
157
stay_alive: CancellationToken,
110
158
) -> Result<()> {
111
159
ctrlc::set_handler({
···
150
198
.build()
151
199
.expect("axum startup")
152
200
.block_on(async {
153
-
install_metrics_server()?;
154
-
serve(readable, "0.0.0.0:6789", staying_alive).await
201
+
install_metrics_server(metrics_bind)?;
202
+
serve(readable, bind, staying_alive).await
155
203
})
156
204
.unwrap();
157
205
stay_alive.drop_guard();
···
184
232
185
233
'monitor: loop {
186
234
match readable.get_stats() {
187
-
Ok(StorageStats { dids, targetables, linking_records }) => {
235
+
Ok(StorageStats { dids, targetables, linking_records, .. }) => {
188
236
metrics::gauge!("storage.stats.dids").set(dids as f64);
189
237
metrics::gauge!("storage.stats.targetables").set(targetables as f64);
190
238
metrics::gauge!("storage.stats.linking_records").set(linking_records as f64);
···
218
266
Ok(())
219
267
}
220
268
221
-
fn install_metrics_server() -> Result<()> {
269
+
fn install_metrics_server(metrics_bind: SocketAddr) -> Result<()> {
222
270
println!("installing metrics server...");
223
-
let host = [0, 0, 0, 0];
224
-
let port = 8765;
225
271
PrometheusBuilder::new()
226
272
.set_quantiles(&[0.5, 0.9, 0.99, 1.0])?
227
273
.set_bucket_duration(time::Duration::from_secs(30))?
228
274
.set_bucket_count(NonZero::new(10).unwrap()) // count * duration = 5 mins. stuff doesn't happen that fast here.
229
275
.set_enable_unit_suffix(true)
230
-
.with_http_listener((host, port))
276
+
.with_http_listener(metrics_bind)
231
277
.install()?;
232
-
println!(
233
-
"metrics server installed! listening on http://{}.{}.{}.{}:{port}",
234
-
host[0], host[1], host[2], host[3]
235
-
);
278
+
println!("metrics server installed! listening at {metrics_bind:?}");
236
279
Ok(())
237
280
}
238
281
+239
-238
constellation/src/bin/rocks-link-stats.rs
+239
-238
constellation/src/bin/rocks-link-stats.rs
···
1
-
use bincode::config::Options;
2
-
use clap::Parser;
3
-
use serde::Serialize;
4
-
use std::collections::HashMap;
5
-
use std::path::PathBuf;
1
+
// use bincode::config::Options;
2
+
// use clap::Parser;
3
+
// use serde::Serialize;
4
+
// use std::collections::HashMap;
5
+
// use std::path::PathBuf;
6
6
7
-
use tokio_util::sync::CancellationToken;
7
+
// use tokio_util::sync::CancellationToken;
8
8
9
-
use constellation::storage::rocks_store::{
10
-
Collection, DidId, RKey, RPath, Target, TargetKey, TargetLinkers, _bincode_opts,
11
-
};
12
-
use constellation::storage::RocksStorage;
13
-
use constellation::Did;
9
+
// use constellation::storage::rocks_store::{
10
+
// Collection, DidId, RKey, RPath, Target, TargetKey, TargetLinkers, _bincode_opts,
11
+
// };
12
+
// use constellation::storage::RocksStorage;
13
+
// use constellation::Did;
14
14
15
-
use links::parse_any_link;
16
-
use rocksdb::IteratorMode;
17
-
use std::time;
15
+
// use links::parse_any_link;
16
+
// use rocksdb::IteratorMode;
17
+
// use std::time;
18
18
19
-
/// Aggregate links in the at-mosphere
20
-
#[derive(Parser, Debug)]
21
-
#[command(version, about, long_about = None)]
22
-
struct Args {
23
-
/// where is rocksdb's data
24
-
#[arg(short, long)]
25
-
data: PathBuf,
26
-
/// slow down so we don't kill the firehose consumer, if running concurrently
27
-
#[arg(short, long)]
28
-
limit: Option<u64>,
29
-
}
19
+
// xxxx/// Aggregate links in the at-mosphere
20
+
// #[derive(Parser, Debug)]
21
+
// #[command(version, about, long_about = None)]
22
+
// struct Args {
23
+
// /// where is rocksdb's data
24
+
// #[arg(short, long)]
25
+
// data: PathBuf,
26
+
// /// slow down so we don't kill the firehose consumer, if running concurrently
27
+
// #[arg(short, long)]
28
+
// limit: Option<u64>,
29
+
// }
30
30
31
-
type LinkType = String;
31
+
// type LinkType = String;
32
32
33
-
#[derive(Debug, Eq, Hash, PartialEq, Serialize)]
34
-
struct SourceLink(Collection, RPath, LinkType, Option<Collection>); // last is target collection, if it's an at-uri link with a collection
33
+
// #[derive(Debug, Eq, Hash, PartialEq, Serialize)]
34
+
// struct SourceLink(Collection, RPath, LinkType, Option<Collection>); // last is target collection, if it's an at-uri link with a collection
35
35
36
-
#[derive(Debug, Serialize)]
37
-
struct SourceSample {
38
-
did: String,
39
-
rkey: String,
40
-
}
36
+
// #[derive(Debug, Serialize)]
37
+
// struct SourceSample {
38
+
// did: String,
39
+
// rkey: String,
40
+
// }
41
41
42
-
#[derive(Debug, Default, Serialize)]
43
-
struct Bucket {
44
-
count: u64,
45
-
sum: u64,
46
-
sample: Option<SourceSample>,
47
-
}
42
+
// #[derive(Debug, Default, Serialize)]
43
+
// struct Bucket {
44
+
// count: u64,
45
+
// sum: u64,
46
+
// sample: Option<SourceSample>,
47
+
// }
48
48
49
-
#[derive(Debug, Default, Serialize)]
50
-
struct Buckets([Bucket; 23]);
49
+
// #[derive(Debug, Default, Serialize)]
50
+
// struct Buckets([Bucket; 23]);
51
51
52
-
const BUCKETS: [u64; 23] = [
53
-
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 16, 32, 64, 128, 256, 512, 1024, 4096, 16_384, 65_535,
54
-
262_144, 1_048_576,
55
-
];
52
+
// const BUCKETS: [u64; 23] = [
53
+
// 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 16, 32, 64, 128, 256, 512, 1024, 4096, 16_384, 65_535,
54
+
// 262_144, 1_048_576,
55
+
// ];
56
56
57
-
// b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b12, b16, b32, b64, b128, b256, b512, b1024, b4096, b16384, b65535, b262144, bmax
57
+
// xxx// b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b12, b16, b32, b64, b128, b256, b512, b1024, b4096, b16384, b65535, b262144, bmax
58
58
59
-
static DID_IDS_CF: &str = "did_ids";
60
-
static TARGET_IDS_CF: &str = "target_ids";
61
-
static TARGET_LINKERS_CF: &str = "target_links";
59
+
// static DID_IDS_CF: &str = "did_ids";
60
+
// static TARGET_IDS_CF: &str = "target_ids";
61
+
// static TARGET_LINKERS_CF: &str = "target_links";
62
62
63
-
const REPORT_INTERVAL: usize = 50_000;
63
+
// const REPORT_INTERVAL: usize = 50_000;
64
64
65
-
type Stats = HashMap<SourceLink, Buckets>;
65
+
// type Stats = HashMap<SourceLink, Buckets>;
66
66
67
-
#[derive(Debug, Serialize)]
68
-
struct Printable {
69
-
collection: String,
70
-
path: String,
71
-
link_type: String,
72
-
target_collection: Option<String>,
73
-
buckets: Buckets,
74
-
}
67
+
// #[derive(Debug, Serialize)]
68
+
// struct Printable {
69
+
// collection: String,
70
+
// path: String,
71
+
// link_type: String,
72
+
// target_collection: Option<String>,
73
+
// buckets: Buckets,
74
+
// }
75
75
76
-
#[derive(Debug, Default)]
77
-
struct ErrStats {
78
-
failed_to_get_sample: usize,
79
-
failed_to_read_target_id: usize,
80
-
failed_to_deserialize_target_key: usize,
81
-
failed_to_parse_target_as_link: usize,
82
-
failed_to_get_links: usize,
83
-
failed_to_deserialize_linkers: usize,
84
-
}
76
+
// #[derive(Debug, Default)]
77
+
// struct ErrStats {
78
+
// failed_to_get_sample: usize,
79
+
// failed_to_read_target_id: usize,
80
+
// failed_to_deserialize_target_key: usize,
81
+
// failed_to_parse_target_as_link: usize,
82
+
// failed_to_get_links: usize,
83
+
// failed_to_deserialize_linkers: usize,
84
+
// }
85
85
86
-
fn thousands(n: usize) -> String {
87
-
n.to_string()
88
-
.as_bytes()
89
-
.rchunks(3)
90
-
.rev()
91
-
.map(std::str::from_utf8)
92
-
.collect::<Result<Vec<&str>, _>>()
93
-
.unwrap()
94
-
.join(",")
95
-
}
86
+
// fn thousands(n: usize) -> String {
87
+
// n.to_string()
88
+
// .as_bytes()
89
+
// .rchunks(3)
90
+
// .rev()
91
+
// .map(std::str::from_utf8)
92
+
// .collect::<Result<Vec<&str>, _>>()
93
+
// .unwrap()
94
+
// .join(",")
95
+
// }
96
96
97
-
fn main() {
98
-
let args = Args::parse();
97
+
// fn main() {
98
+
// let args = Args::parse();
99
99
100
-
let limit = args.limit.map(|amount| {
101
-
ratelimit::Ratelimiter::builder(amount, time::Duration::from_secs(1))
102
-
.max_tokens(amount)
103
-
.initial_available(amount)
104
-
.build()
105
-
.unwrap()
106
-
});
100
+
// let limit = args.limit.map(|amount| {
101
+
// ratelimit::Ratelimiter::builder(amount, time::Duration::from_secs(1))
102
+
// .max_tokens(amount)
103
+
// .initial_available(amount)
104
+
// .build()
105
+
// .unwrap()
106
+
// });
107
107
108
-
eprintln!("starting rocksdb...");
109
-
let rocks = RocksStorage::open_readonly(args.data).unwrap();
110
-
eprintln!("rocks ready.");
108
+
// eprintln!("starting rocksdb...");
109
+
// let rocks = RocksStorage::open_readonly(args.data).unwrap();
110
+
// eprintln!("rocks ready.");
111
111
112
-
let RocksStorage { ref db, .. } = rocks;
112
+
// let RocksStorage { ref db, .. } = rocks;
113
113
114
-
let stay_alive = CancellationToken::new();
115
-
ctrlc::set_handler({
116
-
let mut desperation: u8 = 0;
117
-
let stay_alive = stay_alive.clone();
118
-
move || match desperation {
119
-
0 => {
120
-
eprintln!("ok, shutting down...");
121
-
stay_alive.cancel();
122
-
desperation += 1;
123
-
}
124
-
1.. => panic!("fine, panicking!"),
125
-
}
126
-
})
127
-
.unwrap();
114
+
// let stay_alive = CancellationToken::new();
115
+
// ctrlc::set_handler({
116
+
// let mut desperation: u8 = 0;
117
+
// let stay_alive = stay_alive.clone();
118
+
// move || match desperation {
119
+
// 0 => {
120
+
// eprintln!("ok, shutting down...");
121
+
// stay_alive.cancel();
122
+
// desperation += 1;
123
+
// }
124
+
// 1.. => panic!("fine, panicking!"),
125
+
// }
126
+
// })
127
+
// .unwrap();
128
128
129
-
let mut stats = Stats::new();
130
-
let mut err_stats: ErrStats = Default::default();
129
+
// let mut stats = Stats::new();
130
+
// let mut err_stats: ErrStats = Default::default();
131
131
132
-
let did_ids_cf = db.cf_handle(DID_IDS_CF).unwrap();
133
-
let target_id_cf = db.cf_handle(TARGET_IDS_CF).unwrap();
134
-
let target_links_cf = db.cf_handle(TARGET_LINKERS_CF).unwrap();
132
+
// let did_ids_cf = db.cf_handle(DID_IDS_CF).unwrap();
133
+
// let target_id_cf = db.cf_handle(TARGET_IDS_CF).unwrap();
134
+
// let target_links_cf = db.cf_handle(TARGET_LINKERS_CF).unwrap();
135
135
136
-
let t0 = time::Instant::now();
137
-
let mut t_prev = t0;
136
+
// let t0 = time::Instant::now();
137
+
// let mut t_prev = t0;
138
138
139
-
let mut i = 0;
140
-
for item in db.iterator_cf(&target_id_cf, IteratorMode::Start) {
141
-
if stay_alive.is_cancelled() {
142
-
break;
143
-
}
139
+
// let mut i = 0;
140
+
// for item in db.iterator_cf(&target_id_cf, IteratorMode::Start) {
141
+
// if stay_alive.is_cancelled() {
142
+
// break;
143
+
// }
144
144
145
-
if let Some(ref limiter) = limit {
146
-
if let Err(dur) = limiter.try_wait() {
147
-
std::thread::sleep(dur)
148
-
}
149
-
}
145
+
// if let Some(ref limiter) = limit {
146
+
// if let Err(dur) = limiter.try_wait() {
147
+
// std::thread::sleep(dur)
148
+
// }
149
+
// }
150
150
151
-
if i > 0 && i % REPORT_INTERVAL == 0 {
152
-
let now = time::Instant::now();
153
-
let rate = (REPORT_INTERVAL as f32) / (now.duration_since(t_prev).as_secs_f32());
154
-
eprintln!(
155
-
"{i}\t({}k)\t{:.2}\t{rate:.1}/s",
156
-
thousands(i / 1000),
157
-
t0.elapsed().as_secs_f32()
158
-
);
159
-
t_prev = now;
160
-
}
161
-
i += 1;
151
+
// if i > 0 && i % REPORT_INTERVAL == 0 {
152
+
// let now = time::Instant::now();
153
+
// let rate = (REPORT_INTERVAL as f32) / (now.duration_since(t_prev).as_secs_f32());
154
+
// eprintln!(
155
+
// "{i}\t({}k)\t{:.2}\t{rate:.1}/s",
156
+
// thousands(i / 1000),
157
+
// t0.elapsed().as_secs_f32()
158
+
// );
159
+
// t_prev = now;
160
+
// }
161
+
// i += 1;
162
162
163
-
let Ok((target_key, target_id)) = item else {
164
-
err_stats.failed_to_read_target_id += 1;
165
-
continue;
166
-
};
163
+
// let Ok((target_key, target_id)) = item else {
164
+
// err_stats.failed_to_read_target_id += 1;
165
+
// continue;
166
+
// };
167
167
168
-
let Ok(TargetKey(Target(target), collection, rpath)) =
169
-
_bincode_opts().deserialize(&target_key)
170
-
else {
171
-
err_stats.failed_to_deserialize_target_key += 1;
172
-
continue;
173
-
};
168
+
// let Ok(TargetKey(Target(target), collection, rpath)) =
169
+
// _bincode_opts().deserialize(&target_key)
170
+
// else {
171
+
// err_stats.failed_to_deserialize_target_key += 1;
172
+
// continue;
173
+
// };
174
174
175
-
let source = {
176
-
let Some(parsed) = parse_any_link(&target) else {
177
-
err_stats.failed_to_parse_target_as_link += 1;
178
-
continue;
179
-
};
180
-
SourceLink(
181
-
collection,
182
-
rpath,
183
-
parsed.name().into(),
184
-
parsed.at_uri_collection().map(Collection),
185
-
)
186
-
};
175
+
// let source = {
176
+
// let Some(parsed) = parse_any_link(&target) else {
177
+
// err_stats.failed_to_parse_target_as_link += 1;
178
+
// continue;
179
+
// };
180
+
// SourceLink(
181
+
// collection,
182
+
// rpath,
183
+
// parsed.name().into(),
184
+
// parsed.at_uri_collection().map(Collection),
185
+
// )
186
+
// };
187
187
188
-
let Ok(Some(links_raw)) = db.get_cf(&target_links_cf, &target_id) else {
189
-
err_stats.failed_to_get_links += 1;
190
-
continue;
191
-
};
192
-
let Ok(linkers) = _bincode_opts().deserialize::<TargetLinkers>(&links_raw) else {
193
-
err_stats.failed_to_deserialize_linkers += 1;
194
-
continue;
195
-
};
196
-
let (n, _) = linkers.count();
188
+
// let Ok(Some(links_raw)) = db.get_cf(&target_links_cf, &target_id) else {
189
+
// err_stats.failed_to_get_links += 1;
190
+
// continue;
191
+
// };
192
+
// let Ok(linkers) = _bincode_opts().deserialize::<TargetLinkers>(&links_raw) else {
193
+
// err_stats.failed_to_deserialize_linkers += 1;
194
+
// continue;
195
+
// };
196
+
// let (n, _) = linkers.count();
197
197
198
-
if n == 0 {
199
-
continue;
200
-
}
198
+
// if n == 0 {
199
+
// continue;
200
+
// }
201
201
202
-
let mut bucket = 0;
203
-
for edge in BUCKETS {
204
-
if n <= edge || bucket == 22 {
205
-
break;
206
-
}
207
-
bucket += 1;
208
-
}
202
+
// let mut bucket = 0;
203
+
// for edge in BUCKETS {
204
+
// if n <= edge || bucket == 22 {
205
+
// break;
206
+
// }
207
+
// bucket += 1;
208
+
// }
209
209
210
-
let b = &mut stats.entry(source).or_default().0[bucket];
211
-
b.count += 1;
212
-
b.sum += n;
213
-
if b.sample.is_none() {
214
-
let (DidId(did_id), RKey(k)) = &linkers.0[(n - 1) as usize];
215
-
if let Ok(Some(did_bytes)) = db.get_cf(&did_ids_cf, did_id.to_be_bytes()) {
216
-
if let Ok(Did(did)) = _bincode_opts().deserialize(&did_bytes) {
217
-
b.sample = Some(SourceSample {
218
-
did,
219
-
rkey: k.clone(),
220
-
});
221
-
} else {
222
-
err_stats.failed_to_get_sample += 1;
223
-
}
224
-
} else {
225
-
err_stats.failed_to_get_sample += 1;
226
-
}
227
-
}
210
+
// let b = &mut stats.entry(source).or_default().0[bucket];
211
+
// b.count += 1;
212
+
// b.sum += n;
213
+
// if b.sample.is_none() {
214
+
// let (DidId(did_id), RKey(k)) = &linkers.0[(n - 1) as usize];
215
+
// if let Ok(Some(did_bytes)) = db.get_cf(&did_ids_cf, did_id.to_be_bytes()) {
216
+
// if let Ok(Did(did)) = _bincode_opts().deserialize(&did_bytes) {
217
+
// b.sample = Some(SourceSample {
218
+
// did,
219
+
// rkey: k.clone(),
220
+
// });
221
+
// } else {
222
+
// err_stats.failed_to_get_sample += 1;
223
+
// }
224
+
// } else {
225
+
// err_stats.failed_to_get_sample += 1;
226
+
// }
227
+
// }
228
228
229
-
// if i >= 40_000 {
230
-
// break;
231
-
// }
232
-
}
229
+
// // if i >= 40_000 {
230
+
// // break;
231
+
// // }
232
+
// }
233
233
234
-
let dt = t0.elapsed();
234
+
// let dt = t0.elapsed();
235
235
236
-
eprintln!("gathering stats for output...");
236
+
// eprintln!("gathering stats for output...");
237
237
238
-
let itemified = stats
239
-
.into_iter()
240
-
.map(
241
-
|(
242
-
SourceLink(Collection(collection), RPath(path), link_type, target_collection),
243
-
buckets,
244
-
)| Printable {
245
-
collection,
246
-
path,
247
-
link_type,
248
-
target_collection: target_collection.map(|Collection(c)| c),
249
-
buckets,
250
-
},
251
-
)
252
-
.collect::<Vec<_>>();
238
+
// let itemified = stats
239
+
// .into_iter()
240
+
// .map(
241
+
// |(
242
+
// SourceLink(Collection(collection), RPath(path), link_type, target_collection),
243
+
// buckets,
244
+
// )| Printable {
245
+
// collection,
246
+
// path,
247
+
// link_type,
248
+
// target_collection: target_collection.map(|Collection(c)| c),
249
+
// buckets,
250
+
// },
251
+
// )
252
+
// .collect::<Vec<_>>();
253
253
254
-
match serde_json::to_string(&itemified) {
255
-
Ok(s) => println!("{s}"),
256
-
Err(e) => eprintln!("failed to serialize results: {e:?}"),
257
-
}
254
+
// match serde_json::to_string(&itemified) {
255
+
// Ok(s) => println!("{s}"),
256
+
// Err(e) => eprintln!("failed to serialize results: {e:?}"),
257
+
// }
258
258
259
-
eprintln!(
260
-
"{} summarizing {} link targets in {:.1}s",
261
-
if stay_alive.is_cancelled() {
262
-
"STOPPED"
263
-
} else {
264
-
"FINISHED"
265
-
},
266
-
thousands(i),
267
-
dt.as_secs_f32()
268
-
);
269
-
eprintln!("{err_stats:?}");
270
-
eprintln!("bye.");
271
-
}
259
+
// eprintln!(
260
+
// "{} summarizing {} link targets in {:.1}s",
261
+
// if stay_alive.is_cancelled() {
262
+
// "STOPPED"
263
+
// } else {
264
+
// "FINISHED"
265
+
// },
266
+
// thousands(i),
267
+
// dt.as_secs_f32()
268
+
// );
269
+
// eprintln!("{err_stats:?}");
270
+
// eprintln!("bye.");
271
+
// }
272
272
273
-
// scan plan
273
+
// xxx// scan plan
274
274
275
-
// buckets (backlink count)
276
-
// 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 16, 32, 64, 128, 256, 512, 1024, 4096, 16384, 65535, 262144, 1048576+
277
-
// by
278
-
// - collection
279
-
// - json path
280
-
// - link type
281
-
// samples for each bucket for each variation
275
+
// xxx// buckets (backlink count)
276
+
// xxx// 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 16, 32, 64, 128, 256, 512, 1024, 4096, 16384, 65535, 262144, 1048576+
277
+
// xxx// by
278
+
// xxx// - collection
279
+
// xxx// - json path
280
+
// xxx// - link type
281
+
// xxx// samples for each bucket for each variation
282
+
fn main() {}
+2
constellation/src/bin/rocks-restore-from-backup.rs
+2
constellation/src/bin/rocks-restore-from-backup.rs
···
3
3
use clap::Parser;
4
4
use std::path::PathBuf;
5
5
6
+
#[cfg(feature = "rocks")]
6
7
use rocksdb::backup::{BackupEngine, BackupEngineOptions, RestoreOptions};
7
8
8
9
use std::time;
···
19
20
to_data_dir: PathBuf,
20
21
}
21
22
23
+
#[cfg(feature = "rocks")]
22
24
fn main() -> Result<()> {
23
25
let args = Args::parse();
24
26
+8
-6
constellation/src/server/filters.rs
+8
-6
constellation/src/server/filters.rs
···
5
5
Ok({
6
6
if let Some(link) = parse_any_link(s) {
7
7
match link {
8
-
Link::AtUri(at_uri) => at_uri.strip_prefix("at://").map(|noproto| {
9
-
format!("https://atproto-browser-plus-links.vercel.app/at/{noproto}")
10
-
}),
11
-
Link::Did(did) => Some(format!(
12
-
"https://atproto-browser-plus-links.vercel.app/at/{did}"
13
-
)),
8
+
Link::AtUri(at_uri) => at_uri
9
+
.strip_prefix("at://")
10
+
.map(|noproto| format!("https://pdsls.dev/at://{noproto}")),
11
+
Link::Did(did) => Some(format!("https://pdsls.dev/at://{did}")),
14
12
Link::Uri(uri) => Some(uri),
15
13
}
16
14
} else {
···
22
20
pub fn human_number(n: &u64) -> askama::Result<String> {
23
21
Ok(n.to_formatted_string(&Locale::en))
24
22
}
23
+
24
+
pub fn to_u64(n: usize) -> askama::Result<u64> {
25
+
Ok(n as u64)
26
+
}
+332
-19
constellation/src/server/mod.rs
+332
-19
constellation/src/server/mod.rs
···
11
11
use bincode::Options;
12
12
use serde::{Deserialize, Serialize};
13
13
use serde_with::serde_as;
14
-
use std::collections::HashMap;
14
+
use std::collections::{HashMap, HashSet};
15
15
use std::time::{Duration, UNIX_EPOCH};
16
16
use tokio::net::{TcpListener, ToSocketAddrs};
17
-
use tokio::task::block_in_place;
17
+
use tokio::task::spawn_blocking;
18
18
use tokio_util::sync::CancellationToken;
19
19
20
20
use crate::storage::{LinkReader, StorageStats};
···
28
28
const DEFAULT_CURSOR_LIMIT: u64 = 16;
29
29
const DEFAULT_CURSOR_LIMIT_MAX: u64 = 100;
30
30
31
-
const INDEX_BEGAN_AT_TS: u64 = 1738083600; // TODO: not this
31
+
fn get_default_cursor_limit() -> u64 {
32
+
DEFAULT_CURSOR_LIMIT
33
+
}
34
+
35
+
fn to500(e: tokio::task::JoinError) -> http::StatusCode {
36
+
eprintln!("handler error: {e}");
37
+
http::StatusCode::INTERNAL_SERVER_ERROR
38
+
}
32
39
33
40
pub async fn serve<S, A>(store: S, addr: A, stay_alive: CancellationToken) -> anyhow::Result<()>
34
41
where
···
41
48
"/",
42
49
get({
43
50
let store = store.clone();
44
-
move |accept| async { block_in_place(|| hello(accept, store)) }
51
+
move |accept| async {
52
+
spawn_blocking(|| hello(accept, store))
53
+
.await
54
+
.map_err(to500)?
55
+
}
56
+
}),
57
+
)
58
+
.route(
59
+
"/xrpc/blue.microcosm.links.getManyToManyCounts",
60
+
get({
61
+
let store = store.clone();
62
+
move |accept, query| async {
63
+
spawn_blocking(|| get_many_to_many_counts(accept, query, store))
64
+
.await
65
+
.map_err(to500)?
66
+
}
45
67
}),
46
68
)
47
69
.route(
48
70
"/links/count",
49
71
get({
50
72
let store = store.clone();
51
-
move |accept, query| async { block_in_place(|| count_links(accept, query, store)) }
73
+
move |accept, query| async {
74
+
spawn_blocking(|| count_links(accept, query, store))
75
+
.await
76
+
.map_err(to500)?
77
+
}
52
78
}),
53
79
)
54
80
.route(
···
56
82
get({
57
83
let store = store.clone();
58
84
move |accept, query| async {
59
-
block_in_place(|| count_distinct_dids(accept, query, store))
85
+
spawn_blocking(|| count_distinct_dids(accept, query, store))
86
+
.await
87
+
.map_err(to500)?
88
+
}
89
+
}),
90
+
)
91
+
.route(
92
+
"/xrpc/blue.microcosm.links.getBacklinks",
93
+
get({
94
+
let store = store.clone();
95
+
move |accept, query| async {
96
+
spawn_blocking(|| get_backlinks(accept, query, store))
97
+
.await
98
+
.map_err(to500)?
60
99
}
61
100
}),
62
101
)
···
64
103
"/links",
65
104
get({
66
105
let store = store.clone();
67
-
move |accept, query| async { block_in_place(|| get_links(accept, query, store)) }
106
+
move |accept, query| async {
107
+
spawn_blocking(|| get_links(accept, query, store))
108
+
.await
109
+
.map_err(to500)?
110
+
}
68
111
}),
69
112
)
70
113
.route(
···
72
115
get({
73
116
let store = store.clone();
74
117
move |accept, query| async {
75
-
block_in_place(|| get_distinct_dids(accept, query, store))
118
+
spawn_blocking(|| get_distinct_dids(accept, query, store))
119
+
.await
120
+
.map_err(to500)?
76
121
}
77
122
}),
78
123
)
···
82
127
get({
83
128
let store = store.clone();
84
129
move |accept, query| async {
85
-
block_in_place(|| count_all_links(accept, query, store))
130
+
spawn_blocking(|| count_all_links(accept, query, store))
131
+
.await
132
+
.map_err(to500)?
86
133
}
87
134
}),
88
135
)
···
91
138
get({
92
139
let store = store.clone();
93
140
move |accept, query| async {
94
-
block_in_place(|| explore_links(accept, query, store))
141
+
spawn_blocking(|| explore_links(accept, query, store))
142
+
.await
143
+
.map_err(to500)?
95
144
}
96
145
}),
97
146
)
···
150
199
#[template(path = "hello.html.j2")]
151
200
struct HelloReponse {
152
201
help: &'static str,
153
-
days_indexed: u64,
202
+
days_indexed: Option<u64>,
154
203
stats: StorageStats,
155
204
}
156
205
fn hello(
···
160
209
let stats = store
161
210
.get_stats()
162
211
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?;
163
-
let days_indexed = (UNIX_EPOCH + Duration::from_secs(INDEX_BEGAN_AT_TS))
164
-
.elapsed()
212
+
let days_indexed = stats
213
+
.started_at
214
+
.map(|c| (UNIX_EPOCH + Duration::from_micros(c)).elapsed())
215
+
.transpose()
165
216
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?
166
-
.as_secs()
167
-
/ 86400;
217
+
.map(|d| d.as_secs() / 86_400);
168
218
Ok(acceptable(accept, HelloReponse {
169
219
help: "open this URL in a web browser (or request with Accept: text/html) for information about this API.",
170
220
days_indexed,
···
173
223
}
174
224
175
225
#[derive(Clone, Deserialize)]
226
+
#[serde(rename_all = "camelCase")]
227
+
struct GetManyToManyCountsQuery {
228
+
subject: String,
229
+
source: String,
230
+
/// path to the secondary link in the linking record
231
+
path_to_other: String,
232
+
/// filter to linking records (join of the m2m) by these DIDs
233
+
#[serde(default)]
234
+
did: Vec<String>,
235
+
/// filter to specific secondary records
236
+
#[serde(default)]
237
+
other_subject: Vec<String>,
238
+
cursor: Option<OpaqueApiCursor>,
239
+
/// Set the max number of links to return per page of results
240
+
#[serde(default = "get_default_cursor_limit")]
241
+
limit: u64,
242
+
}
243
+
#[derive(Serialize)]
244
+
struct OtherSubjectCount {
245
+
subject: String,
246
+
total: u64,
247
+
distinct: u64,
248
+
}
249
+
#[derive(Template, Serialize)]
250
+
#[template(path = "get-many-to-many-counts.html.j2")]
251
+
struct GetManyToManyCountsResponse {
252
+
counts_by_other_subject: Vec<OtherSubjectCount>,
253
+
cursor: Option<OpaqueApiCursor>,
254
+
#[serde(skip_serializing)]
255
+
query: GetManyToManyCountsQuery,
256
+
}
257
+
fn get_many_to_many_counts(
258
+
accept: ExtractAccept,
259
+
query: axum_extra::extract::Query<GetManyToManyCountsQuery>,
260
+
store: impl LinkReader,
261
+
) -> Result<impl IntoResponse, http::StatusCode> {
262
+
let cursor_key = query
263
+
.cursor
264
+
.clone()
265
+
.map(|oc| ApiKeyedCursor::try_from(oc).map_err(|_| http::StatusCode::BAD_REQUEST))
266
+
.transpose()?
267
+
.map(|c| c.next);
268
+
269
+
let limit = query.limit;
270
+
if limit > DEFAULT_CURSOR_LIMIT_MAX {
271
+
return Err(http::StatusCode::BAD_REQUEST);
272
+
}
273
+
274
+
let filter_dids: HashSet<Did> = HashSet::from_iter(
275
+
query
276
+
.did
277
+
.iter()
278
+
.map(|d| d.trim())
279
+
.filter(|d| !d.is_empty())
280
+
.map(|d| Did(d.to_string())),
281
+
);
282
+
283
+
let filter_other_subjects: HashSet<String> = HashSet::from_iter(
284
+
query
285
+
.other_subject
286
+
.iter()
287
+
.map(|s| s.trim().to_string())
288
+
.filter(|s| !s.is_empty()),
289
+
);
290
+
291
+
let Some((collection, path)) = query.source.split_once(':') else {
292
+
return Err(http::StatusCode::BAD_REQUEST);
293
+
};
294
+
let path = format!(".{path}");
295
+
296
+
let path_to_other = format!(".{}", query.path_to_other);
297
+
298
+
let paged = store
299
+
.get_many_to_many_counts(
300
+
&query.subject,
301
+
collection,
302
+
&path,
303
+
&path_to_other,
304
+
limit,
305
+
cursor_key,
306
+
&filter_dids,
307
+
&filter_other_subjects,
308
+
)
309
+
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?;
310
+
311
+
let cursor = paged.next.map(|next| ApiKeyedCursor { next }.into());
312
+
313
+
let items = paged
314
+
.items
315
+
.into_iter()
316
+
.map(|(subject, total, distinct)| OtherSubjectCount {
317
+
subject,
318
+
total,
319
+
distinct,
320
+
})
321
+
.collect();
322
+
323
+
Ok(acceptable(
324
+
accept,
325
+
GetManyToManyCountsResponse {
326
+
counts_by_other_subject: items,
327
+
cursor,
328
+
query: (*query).clone(),
329
+
},
330
+
))
331
+
}
332
+
333
+
#[derive(Clone, Deserialize)]
176
334
struct GetLinksCountQuery {
177
335
target: String,
178
336
collection: String,
···
233
391
}
234
392
235
393
#[derive(Clone, Deserialize)]
394
+
struct GetBacklinksQuery {
395
+
/// The link target
396
+
///
397
+
/// can be an AT-URI, plain DID, or regular URI
398
+
subject: String,
399
+
/// Filter links only from this link source
400
+
///
401
+
/// eg.: `app.bsky.feed.like:subject.uri`
402
+
source: String,
403
+
cursor: Option<OpaqueApiCursor>,
404
+
/// Filter links only from these DIDs
405
+
///
406
+
/// include multiple times to filter by multiple source DIDs
407
+
#[serde(default)]
408
+
did: Vec<String>,
409
+
/// Set the max number of links to return per page of results
410
+
#[serde(default = "get_default_cursor_limit")]
411
+
limit: u64,
412
+
// TODO: allow reverse (er, forward) order as well
413
+
}
414
+
#[derive(Template, Serialize)]
415
+
#[template(path = "get-backlinks.html.j2")]
416
+
struct GetBacklinksResponse {
417
+
total: u64,
418
+
records: Vec<RecordId>,
419
+
cursor: Option<OpaqueApiCursor>,
420
+
#[serde(skip_serializing)]
421
+
query: GetBacklinksQuery,
422
+
#[serde(skip_serializing)]
423
+
collection: String,
424
+
#[serde(skip_serializing)]
425
+
path: String,
426
+
}
427
+
fn get_backlinks(
428
+
accept: ExtractAccept,
429
+
query: axum_extra::extract::Query<GetBacklinksQuery>, // supports multiple param occurrences
430
+
store: impl LinkReader,
431
+
) -> Result<impl IntoResponse, http::StatusCode> {
432
+
let until = query
433
+
.cursor
434
+
.clone()
435
+
.map(|oc| ApiCursor::try_from(oc).map_err(|_| http::StatusCode::BAD_REQUEST))
436
+
.transpose()?
437
+
.map(|c| c.next);
438
+
439
+
let limit = query.limit;
440
+
if limit > DEFAULT_CURSOR_LIMIT_MAX {
441
+
return Err(http::StatusCode::BAD_REQUEST);
442
+
}
443
+
444
+
let filter_dids: HashSet<Did> = HashSet::from_iter(
445
+
query
446
+
.did
447
+
.iter()
448
+
.map(|d| d.trim())
449
+
.filter(|d| !d.is_empty())
450
+
.map(|d| Did(d.to_string())),
451
+
);
452
+
453
+
let Some((collection, path)) = query.source.split_once(':') else {
454
+
return Err(http::StatusCode::BAD_REQUEST);
455
+
};
456
+
let path = format!(".{path}");
457
+
458
+
let paged = store
459
+
.get_links(
460
+
&query.subject,
461
+
collection,
462
+
&path,
463
+
limit,
464
+
until,
465
+
&filter_dids,
466
+
)
467
+
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?;
468
+
469
+
let cursor = paged.next.map(|next| {
470
+
ApiCursor {
471
+
version: paged.version,
472
+
next,
473
+
}
474
+
.into()
475
+
});
476
+
477
+
Ok(acceptable(
478
+
accept,
479
+
GetBacklinksResponse {
480
+
total: paged.total,
481
+
records: paged.items,
482
+
cursor,
483
+
query: (*query).clone(),
484
+
collection: collection.to_string(),
485
+
path,
486
+
},
487
+
))
488
+
}
489
+
490
+
#[derive(Clone, Deserialize)]
236
491
struct GetLinkItemsQuery {
237
492
target: String,
238
493
collection: String,
239
494
path: String,
240
495
cursor: Option<OpaqueApiCursor>,
241
-
limit: Option<u64>,
496
+
/// Filter links only from these DIDs
497
+
///
498
+
/// include multiple times to filter by multiple source DIDs
499
+
#[serde(default)]
500
+
did: Vec<String>,
501
+
/// [deprecated] Filter links only from these DIDs
502
+
///
503
+
/// format: comma-separated sequence of DIDs
504
+
///
505
+
/// errors: if `did` parameter is also present
506
+
///
507
+
/// deprecated: use `did`, which can be repeated multiple times
508
+
from_dids: Option<String>, // comma separated: gross
509
+
#[serde(default = "get_default_cursor_limit")]
510
+
limit: u64,
242
511
// TODO: allow reverse (er, forward) order as well
243
512
}
244
513
#[derive(Template, Serialize)]
···
255
524
}
256
525
fn get_links(
257
526
accept: ExtractAccept,
258
-
query: Query<GetLinkItemsQuery>,
527
+
query: axum_extra::extract::Query<GetLinkItemsQuery>, // supports multiple param occurrences
259
528
store: impl LinkReader,
260
529
) -> Result<impl IntoResponse, http::StatusCode> {
261
530
let until = query
···
265
534
.transpose()?
266
535
.map(|c| c.next);
267
536
268
-
let limit = query.limit.unwrap_or(DEFAULT_CURSOR_LIMIT);
537
+
let limit = query.limit;
269
538
if limit > DEFAULT_CURSOR_LIMIT_MAX {
270
539
return Err(http::StatusCode::BAD_REQUEST);
271
540
}
272
541
542
+
let mut filter_dids: HashSet<Did> = HashSet::from_iter(
543
+
query
544
+
.did
545
+
.iter()
546
+
.map(|d| d.trim())
547
+
.filter(|d| !d.is_empty())
548
+
.map(|d| Did(d.to_string())),
549
+
);
550
+
551
+
if let Some(comma_joined) = &query.from_dids {
552
+
if !filter_dids.is_empty() {
553
+
return Err(http::StatusCode::BAD_REQUEST);
554
+
}
555
+
for did in comma_joined.split(',') {
556
+
filter_dids.insert(Did(did.to_string()));
557
+
}
558
+
}
559
+
273
560
let paged = store
274
-
.get_links(&query.target, &query.collection, &query.path, limit, until)
561
+
.get_links(
562
+
&query.target,
563
+
&query.collection,
564
+
&query.path,
565
+
limit,
566
+
until,
567
+
&filter_dids,
568
+
)
275
569
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?;
276
570
277
571
let cursor = paged.next.map(|next| {
···
433
727
OpaqueApiCursor(bincode::DefaultOptions::new().serialize(&item).unwrap())
434
728
}
435
729
}
730
+
731
+
#[derive(Serialize, Deserialize)] // for bincode
732
+
struct ApiKeyedCursor {
733
+
next: String, // the key
734
+
}
735
+
736
+
impl TryFrom<OpaqueApiCursor> for ApiKeyedCursor {
737
+
type Error = bincode::Error;
738
+
739
+
fn try_from(item: OpaqueApiCursor) -> Result<Self, Self::Error> {
740
+
bincode::DefaultOptions::new().deserialize(&item.0)
741
+
}
742
+
}
743
+
744
+
impl From<ApiKeyedCursor> for OpaqueApiCursor {
745
+
fn from(item: ApiKeyedCursor) -> Self {
746
+
OpaqueApiCursor(bincode::DefaultOptions::new().serialize(&item).unwrap())
747
+
}
748
+
}
+93
-1
constellation/src/storage/mem_store.rs
+93
-1
constellation/src/storage/mem_store.rs
···
1
-
use super::{LinkReader, LinkStorage, PagedAppendingCollection, StorageStats};
1
+
use super::{
2
+
LinkReader, LinkStorage, PagedAppendingCollection, PagedOrderedCollection, StorageStats,
3
+
};
2
4
use crate::{ActionableEvent, CountsByCount, Did, RecordId};
3
5
use anyhow::Result;
4
6
use links::CollectedLink;
···
132
134
}
133
135
134
136
impl LinkReader for MemStorage {
137
+
fn get_many_to_many_counts(
138
+
&self,
139
+
target: &str,
140
+
collection: &str,
141
+
path: &str,
142
+
path_to_other: &str,
143
+
limit: u64,
144
+
after: Option<String>,
145
+
filter_dids: &HashSet<Did>,
146
+
filter_to_targets: &HashSet<String>,
147
+
) -> Result<PagedOrderedCollection<(String, u64, u64), String>> {
148
+
let data = self.0.lock().unwrap();
149
+
let Some(paths) = data.targets.get(&Target::new(target)) else {
150
+
return Ok(PagedOrderedCollection::default());
151
+
};
152
+
let Some(linkers) = paths.get(&Source::new(collection, path)) else {
153
+
return Ok(PagedOrderedCollection::default());
154
+
};
155
+
156
+
let path_to_other = RecordPath::new(path_to_other);
157
+
let filter_to_targets: HashSet<Target> =
158
+
HashSet::from_iter(filter_to_targets.iter().map(|s| Target::new(s)));
159
+
160
+
let mut grouped_counts: HashMap<Target, (u64, HashSet<Did>)> = HashMap::new();
161
+
for (did, rkey) in linkers.iter().flatten().cloned() {
162
+
if !filter_dids.is_empty() && !filter_dids.contains(&did) {
163
+
continue;
164
+
}
165
+
if let Some(fwd_target) = data
166
+
.links
167
+
.get(&did)
168
+
.unwrap_or(&HashMap::new())
169
+
.get(&RepoId {
170
+
collection: collection.to_string(),
171
+
rkey,
172
+
})
173
+
.unwrap_or(&Vec::new())
174
+
.iter()
175
+
.filter_map(|(path, target)| {
176
+
if *path == path_to_other
177
+
&& (filter_to_targets.is_empty() || filter_to_targets.contains(target))
178
+
{
179
+
Some(target)
180
+
} else {
181
+
None
182
+
}
183
+
})
184
+
.take(1)
185
+
.next()
186
+
{
187
+
let e = grouped_counts.entry(fwd_target.clone()).or_default();
188
+
e.0 += 1;
189
+
e.1.insert(did.clone());
190
+
}
191
+
}
192
+
let mut items: Vec<(String, u64, u64)> = grouped_counts
193
+
.iter()
194
+
.map(|(k, (n, u))| (k.0.clone(), *n, u.len() as u64))
195
+
.collect();
196
+
items.sort();
197
+
items = items
198
+
.into_iter()
199
+
.skip_while(|(t, _, _)| after.as_ref().map(|a| t <= a).unwrap_or(false))
200
+
.take(limit as usize)
201
+
.collect();
202
+
let next = if items.len() as u64 >= limit {
203
+
items.last().map(|(t, _, _)| t.clone())
204
+
} else {
205
+
None
206
+
};
207
+
Ok(PagedOrderedCollection { items, next })
208
+
}
209
+
135
210
fn get_count(&self, target: &str, collection: &str, path: &str) -> Result<u64> {
136
211
let data = self.0.lock().unwrap();
137
212
let Some(paths) = data.targets.get(&Target::new(target)) else {
···
166
241
path: &str,
167
242
limit: u64,
168
243
until: Option<u64>,
244
+
filter_dids: &HashSet<Did>,
169
245
) -> Result<PagedAppendingCollection<RecordId>> {
170
246
let data = self.0.lock().unwrap();
171
247
let Some(paths) = data.targets.get(&Target::new(target)) else {
···
183
259
next: None,
184
260
total: 0,
185
261
});
262
+
};
263
+
264
+
let did_rkeys: Vec<_> = if !filter_dids.is_empty() {
265
+
did_rkeys
266
+
.iter()
267
+
.filter(|m| {
268
+
Option::<(Did, RKey)>::clone(m)
269
+
.map(|(did, _)| filter_dids.contains(&did))
270
+
.unwrap_or(false)
271
+
})
272
+
.cloned()
273
+
.collect()
274
+
} else {
275
+
did_rkeys.to_vec()
186
276
};
187
277
188
278
let total = did_rkeys.len();
···
338
428
dids,
339
429
targetables,
340
430
linking_records,
431
+
started_at: None,
432
+
other_data: Default::default(),
341
433
})
342
434
}
343
435
}
+484
-14
constellation/src/storage/mod.rs
+484
-14
constellation/src/storage/mod.rs
···
1
1
use crate::{ActionableEvent, CountsByCount, Did, RecordId};
2
2
use anyhow::Result;
3
3
use serde::{Deserialize, Serialize};
4
-
use std::collections::HashMap;
4
+
use std::collections::{HashMap, HashSet};
5
5
6
6
pub mod mem_store;
7
7
pub use mem_store::MemStorage;
···
19
19
pub total: u64,
20
20
}
21
21
22
+
/// A paged collection whose keys are sorted instead of indexed
23
+
///
24
+
/// this has weaker guarantees than PagedAppendingCollection: it might
25
+
/// return a totally consistent snapshot. but it should avoid duplicates
26
+
/// and each page should at least be internally consistent.
27
+
#[derive(Debug, PartialEq, Default)]
28
+
pub struct PagedOrderedCollection<T, K: Ord> {
29
+
pub items: Vec<T>,
30
+
pub next: Option<K>,
31
+
}
32
+
22
33
#[derive(Debug, Deserialize, Serialize, PartialEq)]
23
34
pub struct StorageStats {
24
35
/// estimate of how many accounts we've seen create links. the _subjects_ of any links are not represented here.
···
33
44
/// records with multiple links are single-counted.
34
45
/// for LSM stores, deleted links don't decrement this, and updated records with any links will likely increment it.
35
46
pub linking_records: u64,
47
+
48
+
/// first jetstream cursor when this instance first started
49
+
pub started_at: Option<u64>,
50
+
51
+
/// anything else we want to throw in
52
+
pub other_data: HashMap<String, u64>,
36
53
}
37
54
38
55
pub trait LinkStorage: Send + Sync {
···
48
65
}
49
66
50
67
pub trait LinkReader: Clone + Send + Sync + 'static {
68
+
#[allow(clippy::too_many_arguments)]
69
+
fn get_many_to_many_counts(
70
+
&self,
71
+
target: &str,
72
+
collection: &str,
73
+
path: &str,
74
+
path_to_other: &str,
75
+
limit: u64,
76
+
after: Option<String>,
77
+
filter_dids: &HashSet<Did>,
78
+
filter_to_targets: &HashSet<String>,
79
+
) -> Result<PagedOrderedCollection<(String, u64, u64), String>>;
80
+
51
81
fn get_count(&self, target: &str, collection: &str, path: &str) -> Result<u64>;
52
82
53
83
fn get_distinct_did_count(&self, target: &str, collection: &str, path: &str) -> Result<u64>;
···
59
89
path: &str,
60
90
limit: u64,
61
91
until: Option<u64>,
92
+
filter_dids: &HashSet<Did>,
62
93
) -> Result<PagedAppendingCollection<RecordId>>;
63
94
64
95
fn get_distinct_dids(
···
145
176
);
146
177
assert_eq!(storage.get_distinct_did_count("", "", "")?, 0);
147
178
assert_eq!(
148
-
storage.get_links("a.com", "app.t.c", ".abc.uri", 100, None)?,
179
+
storage.get_links(
180
+
"a.com",
181
+
"app.t.c",
182
+
".abc.uri",
183
+
100,
184
+
None,
185
+
&HashSet::default()
186
+
)?,
149
187
PagedAppendingCollection {
150
188
version: (0, 0),
151
189
items: vec![],
···
641
679
0,
642
680
)?;
643
681
assert_eq!(
644
-
storage.get_links("a.com", "app.t.c", ".abc.uri", 100, None)?,
682
+
storage.get_links(
683
+
"a.com",
684
+
"app.t.c",
685
+
".abc.uri",
686
+
100,
687
+
None,
688
+
&HashSet::default()
689
+
)?,
645
690
PagedAppendingCollection {
646
691
version: (1, 0),
647
692
items: vec![RecordId {
···
682
727
0,
683
728
)?;
684
729
}
685
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None)?;
730
+
let links =
731
+
storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None, &HashSet::default())?;
686
732
let dids = storage.get_distinct_dids("a.com", "app.t.c", ".abc.uri", 2, None)?;
687
733
assert_eq!(
688
734
links,
···
713
759
total: 5,
714
760
}
715
761
);
716
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, links.next)?;
762
+
let links = storage.get_links(
763
+
"a.com",
764
+
"app.t.c",
765
+
".abc.uri",
766
+
2,
767
+
links.next,
768
+
&HashSet::default(),
769
+
)?;
717
770
let dids = storage.get_distinct_dids("a.com", "app.t.c", ".abc.uri", 2, dids.next)?;
718
771
assert_eq!(
719
772
links,
···
744
797
total: 5,
745
798
}
746
799
);
747
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, links.next)?;
800
+
let links = storage.get_links(
801
+
"a.com",
802
+
"app.t.c",
803
+
".abc.uri",
804
+
2,
805
+
links.next,
806
+
&HashSet::default(),
807
+
)?;
748
808
let dids = storage.get_distinct_dids("a.com", "app.t.c", ".abc.uri", 2, dids.next)?;
749
809
assert_eq!(
750
810
links,
···
771
831
assert_stats(storage.get_stats()?, 5..=5, 1..=1, 5..=5);
772
832
});
773
833
834
+
test_each_storage!(get_filtered_links, |storage| {
835
+
let links = storage.get_links(
836
+
"a.com",
837
+
"app.t.c",
838
+
".abc.uri",
839
+
2,
840
+
None,
841
+
&HashSet::from([Did("did:plc:linker".to_string())]),
842
+
)?;
843
+
assert_eq!(
844
+
links,
845
+
PagedAppendingCollection {
846
+
version: (0, 0),
847
+
items: vec![],
848
+
next: None,
849
+
total: 0,
850
+
}
851
+
);
852
+
853
+
storage.push(
854
+
&ActionableEvent::CreateLinks {
855
+
record_id: RecordId {
856
+
did: "did:plc:linker".into(),
857
+
collection: "app.t.c".into(),
858
+
rkey: "asdf".into(),
859
+
},
860
+
links: vec![CollectedLink {
861
+
target: Link::Uri("a.com".into()),
862
+
path: ".abc.uri".into(),
863
+
}],
864
+
},
865
+
0,
866
+
)?;
867
+
868
+
let links = storage.get_links(
869
+
"a.com",
870
+
"app.t.c",
871
+
".abc.uri",
872
+
2,
873
+
None,
874
+
&HashSet::from([Did("did:plc:linker".to_string())]),
875
+
)?;
876
+
assert_eq!(
877
+
links,
878
+
PagedAppendingCollection {
879
+
version: (1, 0),
880
+
items: vec![RecordId {
881
+
did: "did:plc:linker".into(),
882
+
collection: "app.t.c".into(),
883
+
rkey: "asdf".into(),
884
+
},],
885
+
next: None,
886
+
total: 1,
887
+
}
888
+
);
889
+
890
+
let links = storage.get_links(
891
+
"a.com",
892
+
"app.t.c",
893
+
".abc.uri",
894
+
2,
895
+
None,
896
+
&HashSet::from([Did("did:plc:someone-else".to_string())]),
897
+
)?;
898
+
assert_eq!(
899
+
links,
900
+
PagedAppendingCollection {
901
+
version: (0, 0),
902
+
items: vec![],
903
+
next: None,
904
+
total: 0,
905
+
}
906
+
);
907
+
908
+
storage.push(
909
+
&ActionableEvent::CreateLinks {
910
+
record_id: RecordId {
911
+
did: "did:plc:linker".into(),
912
+
collection: "app.t.c".into(),
913
+
rkey: "asdf-2".into(),
914
+
},
915
+
links: vec![CollectedLink {
916
+
target: Link::Uri("a.com".into()),
917
+
path: ".abc.uri".into(),
918
+
}],
919
+
},
920
+
0,
921
+
)?;
922
+
storage.push(
923
+
&ActionableEvent::CreateLinks {
924
+
record_id: RecordId {
925
+
did: "did:plc:someone-else".into(),
926
+
collection: "app.t.c".into(),
927
+
rkey: "asdf".into(),
928
+
},
929
+
links: vec![CollectedLink {
930
+
target: Link::Uri("a.com".into()),
931
+
path: ".abc.uri".into(),
932
+
}],
933
+
},
934
+
0,
935
+
)?;
936
+
937
+
let links = storage.get_links(
938
+
"a.com",
939
+
"app.t.c",
940
+
".abc.uri",
941
+
2,
942
+
None,
943
+
&HashSet::from([Did("did:plc:linker".to_string())]),
944
+
)?;
945
+
assert_eq!(
946
+
links,
947
+
PagedAppendingCollection {
948
+
version: (2, 0),
949
+
items: vec![
950
+
RecordId {
951
+
did: "did:plc:linker".into(),
952
+
collection: "app.t.c".into(),
953
+
rkey: "asdf-2".into(),
954
+
},
955
+
RecordId {
956
+
did: "did:plc:linker".into(),
957
+
collection: "app.t.c".into(),
958
+
rkey: "asdf".into(),
959
+
},
960
+
],
961
+
next: None,
962
+
total: 2,
963
+
}
964
+
);
965
+
966
+
let links = storage.get_links(
967
+
"a.com",
968
+
"app.t.c",
969
+
".abc.uri",
970
+
2,
971
+
None,
972
+
&HashSet::from([
973
+
Did("did:plc:linker".to_string()),
974
+
Did("did:plc:someone-else".to_string()),
975
+
]),
976
+
)?;
977
+
assert_eq!(
978
+
links,
979
+
PagedAppendingCollection {
980
+
version: (3, 0),
981
+
items: vec![
982
+
RecordId {
983
+
did: "did:plc:someone-else".into(),
984
+
collection: "app.t.c".into(),
985
+
rkey: "asdf".into(),
986
+
},
987
+
RecordId {
988
+
did: "did:plc:linker".into(),
989
+
collection: "app.t.c".into(),
990
+
rkey: "asdf-2".into(),
991
+
},
992
+
],
993
+
next: Some(1),
994
+
total: 3,
995
+
}
996
+
);
997
+
998
+
let links = storage.get_links(
999
+
"a.com",
1000
+
"app.t.c",
1001
+
".abc.uri",
1002
+
2,
1003
+
None,
1004
+
&HashSet::from([Did("did:plc:someone-unknown".to_string())]),
1005
+
)?;
1006
+
assert_eq!(
1007
+
links,
1008
+
PagedAppendingCollection {
1009
+
version: (0, 0),
1010
+
items: vec![],
1011
+
next: None,
1012
+
total: 0,
1013
+
}
1014
+
);
1015
+
});
1016
+
774
1017
test_each_storage!(get_links_exact_multiple, |storage| {
775
1018
for i in 1..=4 {
776
1019
storage.push(
···
788
1031
0,
789
1032
)?;
790
1033
}
791
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None)?;
1034
+
let links =
1035
+
storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None, &HashSet::default())?;
792
1036
assert_eq!(
793
1037
links,
794
1038
PagedAppendingCollection {
···
809
1053
total: 4,
810
1054
}
811
1055
);
812
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, links.next)?;
1056
+
let links = storage.get_links(
1057
+
"a.com",
1058
+
"app.t.c",
1059
+
".abc.uri",
1060
+
2,
1061
+
links.next,
1062
+
&HashSet::default(),
1063
+
)?;
813
1064
assert_eq!(
814
1065
links,
815
1066
PagedAppendingCollection {
···
850
1101
0,
851
1102
)?;
852
1103
}
853
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None)?;
1104
+
let links =
1105
+
storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None, &HashSet::default())?;
854
1106
assert_eq!(
855
1107
links,
856
1108
PagedAppendingCollection {
···
885
1137
},
886
1138
0,
887
1139
)?;
888
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, links.next)?;
1140
+
let links = storage.get_links(
1141
+
"a.com",
1142
+
"app.t.c",
1143
+
".abc.uri",
1144
+
2,
1145
+
links.next,
1146
+
&HashSet::default(),
1147
+
)?;
889
1148
assert_eq!(
890
1149
links,
891
1150
PagedAppendingCollection {
···
926
1185
0,
927
1186
)?;
928
1187
}
929
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None)?;
1188
+
let links =
1189
+
storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None, &HashSet::default())?;
930
1190
assert_eq!(
931
1191
links,
932
1192
PagedAppendingCollection {
···
955
1215
}),
956
1216
0,
957
1217
)?;
958
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, links.next)?;
1218
+
let links = storage.get_links(
1219
+
"a.com",
1220
+
"app.t.c",
1221
+
".abc.uri",
1222
+
2,
1223
+
links.next,
1224
+
&HashSet::default(),
1225
+
)?;
959
1226
assert_eq!(
960
1227
links,
961
1228
PagedAppendingCollection {
···
989
1256
0,
990
1257
)?;
991
1258
}
992
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None)?;
1259
+
let links =
1260
+
storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None, &HashSet::default())?;
993
1261
assert_eq!(
994
1262
links,
995
1263
PagedAppendingCollection {
···
1014
1282
&ActionableEvent::DeactivateAccount("did:plc:asdf-1".into()),
1015
1283
0,
1016
1284
)?;
1017
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, links.next)?;
1285
+
let links = storage.get_links(
1286
+
"a.com",
1287
+
"app.t.c",
1288
+
".abc.uri",
1289
+
2,
1290
+
links.next,
1291
+
&HashSet::default(),
1292
+
)?;
1018
1293
assert_eq!(
1019
1294
links,
1020
1295
PagedAppendingCollection {
···
1081
1356
counts
1082
1357
});
1083
1358
assert_stats(storage.get_stats()?, 1..=1, 2..=2, 1..=1);
1359
+
});
1360
+
1361
+
//////// many-to-many /////////
1362
+
1363
+
test_each_storage!(get_m2m_counts_empty, |storage| {
1364
+
assert_eq!(
1365
+
storage.get_many_to_many_counts(
1366
+
"a.com",
1367
+
"a.b.c",
1368
+
".d.e",
1369
+
".f.g",
1370
+
10,
1371
+
None,
1372
+
&HashSet::new(),
1373
+
&HashSet::new(),
1374
+
)?,
1375
+
PagedOrderedCollection {
1376
+
items: vec![],
1377
+
next: None,
1378
+
}
1379
+
);
1380
+
});
1381
+
1382
+
test_each_storage!(get_m2m_counts_single, |storage| {
1383
+
storage.push(
1384
+
&ActionableEvent::CreateLinks {
1385
+
record_id: RecordId {
1386
+
did: "did:plc:asdf".into(),
1387
+
collection: "app.t.c".into(),
1388
+
rkey: "asdf".into(),
1389
+
},
1390
+
links: vec![
1391
+
CollectedLink {
1392
+
target: Link::Uri("a.com".into()),
1393
+
path: ".abc.uri".into(),
1394
+
},
1395
+
CollectedLink {
1396
+
target: Link::Uri("b.com".into()),
1397
+
path: ".def.uri".into(),
1398
+
},
1399
+
CollectedLink {
1400
+
target: Link::Uri("b.com".into()),
1401
+
path: ".ghi.uri".into(),
1402
+
},
1403
+
],
1404
+
},
1405
+
0,
1406
+
)?;
1407
+
assert_eq!(
1408
+
storage.get_many_to_many_counts(
1409
+
"a.com",
1410
+
"app.t.c",
1411
+
".abc.uri",
1412
+
".def.uri",
1413
+
10,
1414
+
None,
1415
+
&HashSet::new(),
1416
+
&HashSet::new(),
1417
+
)?,
1418
+
PagedOrderedCollection {
1419
+
items: vec![("b.com".to_string(), 1, 1)],
1420
+
next: None,
1421
+
}
1422
+
);
1423
+
});
1424
+
1425
+
test_each_storage!(get_m2m_counts_filters, |storage| {
1426
+
storage.push(
1427
+
&ActionableEvent::CreateLinks {
1428
+
record_id: RecordId {
1429
+
did: "did:plc:asdf".into(),
1430
+
collection: "app.t.c".into(),
1431
+
rkey: "asdf".into(),
1432
+
},
1433
+
links: vec![
1434
+
CollectedLink {
1435
+
target: Link::Uri("a.com".into()),
1436
+
path: ".abc.uri".into(),
1437
+
},
1438
+
CollectedLink {
1439
+
target: Link::Uri("b.com".into()),
1440
+
path: ".def.uri".into(),
1441
+
},
1442
+
],
1443
+
},
1444
+
0,
1445
+
)?;
1446
+
storage.push(
1447
+
&ActionableEvent::CreateLinks {
1448
+
record_id: RecordId {
1449
+
did: "did:plc:asdfasdf".into(),
1450
+
collection: "app.t.c".into(),
1451
+
rkey: "asdf".into(),
1452
+
},
1453
+
links: vec![
1454
+
CollectedLink {
1455
+
target: Link::Uri("a.com".into()),
1456
+
path: ".abc.uri".into(),
1457
+
},
1458
+
CollectedLink {
1459
+
target: Link::Uri("b.com".into()),
1460
+
path: ".def.uri".into(),
1461
+
},
1462
+
],
1463
+
},
1464
+
1,
1465
+
)?;
1466
+
storage.push(
1467
+
&ActionableEvent::CreateLinks {
1468
+
record_id: RecordId {
1469
+
did: "did:plc:fdsa".into(),
1470
+
collection: "app.t.c".into(),
1471
+
rkey: "asdf".into(),
1472
+
},
1473
+
links: vec![
1474
+
CollectedLink {
1475
+
target: Link::Uri("a.com".into()),
1476
+
path: ".abc.uri".into(),
1477
+
},
1478
+
CollectedLink {
1479
+
target: Link::Uri("c.com".into()),
1480
+
path: ".def.uri".into(),
1481
+
},
1482
+
],
1483
+
},
1484
+
2,
1485
+
)?;
1486
+
storage.push(
1487
+
&ActionableEvent::CreateLinks {
1488
+
record_id: RecordId {
1489
+
did: "did:plc:fdsa".into(),
1490
+
collection: "app.t.c".into(),
1491
+
rkey: "asdf2".into(),
1492
+
},
1493
+
links: vec![
1494
+
CollectedLink {
1495
+
target: Link::Uri("a.com".into()),
1496
+
path: ".abc.uri".into(),
1497
+
},
1498
+
CollectedLink {
1499
+
target: Link::Uri("c.com".into()),
1500
+
path: ".def.uri".into(),
1501
+
},
1502
+
],
1503
+
},
1504
+
3,
1505
+
)?;
1506
+
assert_eq!(
1507
+
storage.get_many_to_many_counts(
1508
+
"a.com",
1509
+
"app.t.c",
1510
+
".abc.uri",
1511
+
".def.uri",
1512
+
10,
1513
+
None,
1514
+
&HashSet::new(),
1515
+
&HashSet::new(),
1516
+
)?,
1517
+
PagedOrderedCollection {
1518
+
items: vec![("b.com".to_string(), 2, 2), ("c.com".to_string(), 2, 1),],
1519
+
next: None,
1520
+
}
1521
+
);
1522
+
assert_eq!(
1523
+
storage.get_many_to_many_counts(
1524
+
"a.com",
1525
+
"app.t.c",
1526
+
".abc.uri",
1527
+
".def.uri",
1528
+
10,
1529
+
None,
1530
+
&HashSet::from_iter([Did("did:plc:fdsa".to_string())]),
1531
+
&HashSet::new(),
1532
+
)?,
1533
+
PagedOrderedCollection {
1534
+
items: vec![("c.com".to_string(), 2, 1),],
1535
+
next: None,
1536
+
}
1537
+
);
1538
+
assert_eq!(
1539
+
storage.get_many_to_many_counts(
1540
+
"a.com",
1541
+
"app.t.c",
1542
+
".abc.uri",
1543
+
".def.uri",
1544
+
10,
1545
+
None,
1546
+
&HashSet::new(),
1547
+
&HashSet::from_iter(["b.com".to_string()]),
1548
+
)?,
1549
+
PagedOrderedCollection {
1550
+
items: vec![("b.com".to_string(), 2, 2),],
1551
+
next: None,
1552
+
}
1553
+
);
1084
1554
});
1085
1555
}
+361
-41
constellation/src/storage/rocks_store.rs
+361
-41
constellation/src/storage/rocks_store.rs
···
1
-
use super::{ActionableEvent, LinkReader, LinkStorage, PagedAppendingCollection, StorageStats};
1
+
use super::{
2
+
ActionableEvent, LinkReader, LinkStorage, PagedAppendingCollection, PagedOrderedCollection,
3
+
StorageStats,
4
+
};
2
5
use crate::{CountsByCount, Did, RecordId};
3
6
use anyhow::{bail, Result};
4
7
use bincode::Options as BincodeOptions;
···
11
14
MultiThreaded, Options, PrefixRange, ReadOptions, WriteBatch,
12
15
};
13
16
use serde::{Deserialize, Serialize};
14
-
use std::collections::{HashMap, HashSet};
17
+
use std::collections::{BTreeMap, HashMap, HashSet};
15
18
use std::io::Read;
16
19
use std::marker::PhantomData;
17
20
use std::path::{Path, PathBuf};
···
20
23
Arc,
21
24
};
22
25
use std::thread;
23
-
use std::time::{Duration, Instant};
26
+
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
24
27
use tokio_util::sync::CancellationToken;
25
28
26
29
static DID_IDS_CF: &str = "did_ids";
···
29
32
static LINK_TARGETS_CF: &str = "link_targets";
30
33
31
34
static JETSTREAM_CURSOR_KEY: &str = "jetstream_cursor";
35
+
static STARTED_AT_KEY: &str = "jetstream_first_cursor";
36
+
// add reverse mappings for targets if this db was running before that was a thing
37
+
static TARGET_ID_REPAIR_STATE_KEY: &str = "target_id_table_repair_state";
38
+
39
+
static COZY_FIRST_CURSOR: u64 = 1_738_083_600_000_000; // constellation.microcosm.blue started
40
+
41
+
#[derive(Debug, Clone, Serialize, Deserialize)]
42
+
struct TargetIdRepairState {
43
+
/// start time for repair, microseconds timestamp
44
+
current_us_started_at: u64,
45
+
/// id table's latest id when repair started
46
+
id_when_started: u64,
47
+
/// id table id
48
+
latest_repaired_i: u64,
49
+
}
50
+
impl AsRocksValue for TargetIdRepairState {}
51
+
impl ValueFromRocks for TargetIdRepairState {}
32
52
33
53
// todo: actually understand and set these options probably better
34
54
fn rocks_opts_base() -> Options {
···
56
76
#[derive(Debug, Clone)]
57
77
pub struct RocksStorage {
58
78
pub db: Arc<DBWithThreadMode<MultiThreaded>>, // TODO: mov seqs here (concat merge op will be fun)
59
-
did_id_table: IdTable<Did, DidIdValue, true>,
60
-
target_id_table: IdTable<TargetKey, TargetId, false>,
79
+
did_id_table: IdTable<Did, DidIdValue>,
80
+
target_id_table: IdTable<TargetKey, TargetId>,
61
81
is_writer: bool,
62
82
backup_task: Arc<Option<thread::JoinHandle<Result<()>>>>,
63
83
}
···
85
105
fn cf_descriptor(&self) -> ColumnFamilyDescriptor {
86
106
ColumnFamilyDescriptor::new(&self.name, rocks_opts_base())
87
107
}
88
-
fn init<const WITH_REVERSE: bool>(
89
-
self,
90
-
db: &DBWithThreadMode<MultiThreaded>,
91
-
) -> Result<IdTable<Orig, IdVal, WITH_REVERSE>> {
108
+
fn init(self, db: &DBWithThreadMode<MultiThreaded>) -> Result<IdTable<Orig, IdVal>> {
92
109
if db.cf_handle(&self.name).is_none() {
93
110
bail!("failed to get cf handle from db -- was the db open with our .cf_descriptor()?");
94
111
}
···
119
136
}
120
137
}
121
138
#[derive(Debug, Clone)]
122
-
struct IdTable<Orig, IdVal: IdTableValue, const WITH_REVERSE: bool>
139
+
struct IdTable<Orig, IdVal: IdTableValue>
123
140
where
124
141
Orig: KeyFromRocks,
125
142
for<'a> &'a Orig: AsRocksKey,
···
127
144
base: IdTableBase<Orig, IdVal>,
128
145
priv_id_seq: u64,
129
146
}
130
-
impl<Orig: Clone, IdVal: IdTableValue, const WITH_REVERSE: bool> IdTable<Orig, IdVal, WITH_REVERSE>
147
+
impl<Orig: Clone, IdVal: IdTableValue> IdTable<Orig, IdVal>
131
148
where
132
149
Orig: KeyFromRocks,
133
150
for<'v> &'v IdVal: AsRocksValue,
···
139
156
_key_marker: PhantomData,
140
157
_val_marker: PhantomData,
141
158
name: name.into(),
142
-
id_seq: Arc::new(AtomicU64::new(0)), // zero is "uninint", first seq num will be 1
159
+
id_seq: Arc::new(AtomicU64::new(0)), // zero is "uninit", first seq num will be 1
143
160
}
144
161
}
145
162
fn get_id_val(
···
178
195
id_value
179
196
}))
180
197
}
198
+
181
199
fn estimate_count(&self) -> u64 {
182
200
self.base.id_seq.load(Ordering::SeqCst) - 1 // -1 because seq zero is reserved
183
201
}
184
-
}
185
-
impl<Orig: Clone, IdVal: IdTableValue> IdTable<Orig, IdVal, true>
186
-
where
187
-
Orig: KeyFromRocks,
188
-
for<'v> &'v IdVal: AsRocksValue,
189
-
for<'k> &'k Orig: AsRocksKey,
190
-
{
202
+
191
203
fn get_or_create_id_val(
192
204
&mut self,
193
205
db: &DBWithThreadMode<MultiThreaded>,
···
215
227
}
216
228
}
217
229
}
218
-
impl<Orig: Clone, IdVal: IdTableValue> IdTable<Orig, IdVal, false>
219
-
where
220
-
Orig: KeyFromRocks,
221
-
for<'v> &'v IdVal: AsRocksValue,
222
-
for<'k> &'k Orig: AsRocksKey,
223
-
{
224
-
fn get_or_create_id_val(
225
-
&mut self,
226
-
db: &DBWithThreadMode<MultiThreaded>,
227
-
batch: &mut WriteBatch,
228
-
orig: &Orig,
229
-
) -> Result<IdVal> {
230
-
let cf = db.cf_handle(&self.base.name).unwrap();
231
-
self.__get_or_create_id_val(&cf, db, batch, orig)
232
-
}
233
-
}
234
230
235
231
impl IdTableValue for DidIdValue {
236
232
fn new(v: u64) -> Self {
···
249
245
}
250
246
}
251
247
248
+
fn now() -> u64 {
249
+
SystemTime::now()
250
+
.duration_since(UNIX_EPOCH)
251
+
.unwrap()
252
+
.as_micros() as u64
253
+
}
254
+
252
255
impl RocksStorage {
253
256
pub fn new(path: impl AsRef<Path>) -> Result<Self> {
254
257
Self::describe_metrics();
255
-
RocksStorage::open_readmode(path, false)
258
+
let me = RocksStorage::open_readmode(path, false)?;
259
+
me.global_init()?;
260
+
Ok(me)
256
261
}
257
262
258
263
pub fn open_readonly(path: impl AsRef<Path>) -> Result<Self> {
···
260
265
}
261
266
262
267
fn open_readmode(path: impl AsRef<Path>, readonly: bool) -> Result<Self> {
263
-
let did_id_table = IdTable::<_, _, true>::setup(DID_IDS_CF);
264
-
let target_id_table = IdTable::<_, _, false>::setup(TARGET_IDS_CF);
268
+
let did_id_table = IdTable::setup(DID_IDS_CF);
269
+
let target_id_table = IdTable::setup(TARGET_IDS_CF);
265
270
271
+
// note: global stuff like jetstream cursor goes in the default cf
272
+
// these are bonus extra cfs
266
273
let cfs = vec![
267
274
// id reference tables
268
275
did_id_table.cf_descriptor(),
···
296
303
is_writer: !readonly,
297
304
backup_task: None.into(),
298
305
})
306
+
}
307
+
308
+
fn global_init(&self) -> Result<()> {
309
+
let first_run = self.db.get(JETSTREAM_CURSOR_KEY)?.is_some();
310
+
if first_run {
311
+
self.db.put(STARTED_AT_KEY, _rv(now()))?;
312
+
313
+
// hack / temporary: if we're a new db, put in a completed repair
314
+
// state so we don't run repairs (repairs are for old-code dbs)
315
+
let completed = TargetIdRepairState {
316
+
id_when_started: 0,
317
+
current_us_started_at: 0,
318
+
latest_repaired_i: 0,
319
+
};
320
+
self.db.put(TARGET_ID_REPAIR_STATE_KEY, _rv(completed))?;
321
+
}
322
+
Ok(())
323
+
}
324
+
325
+
pub fn run_repair(&self, breather: Duration, stay_alive: CancellationToken) -> Result<bool> {
326
+
let mut state = match self
327
+
.db
328
+
.get(TARGET_ID_REPAIR_STATE_KEY)?
329
+
.map(|s| _vr(&s))
330
+
.transpose()?
331
+
{
332
+
Some(s) => s,
333
+
None => TargetIdRepairState {
334
+
id_when_started: self.did_id_table.priv_id_seq,
335
+
current_us_started_at: now(),
336
+
latest_repaired_i: 0,
337
+
},
338
+
};
339
+
340
+
eprintln!("initial repair state: {state:?}");
341
+
342
+
let cf = self.db.cf_handle(TARGET_IDS_CF).unwrap();
343
+
344
+
let mut iter = self.db.raw_iterator_cf(&cf);
345
+
iter.seek_to_first();
346
+
347
+
eprintln!("repair iterator sent to first key");
348
+
349
+
// skip ahead if we're done some, or take a single first step
350
+
for _ in 0..state.latest_repaired_i {
351
+
iter.next();
352
+
}
353
+
354
+
eprintln!(
355
+
"repair iterator skipped to {}th key",
356
+
state.latest_repaired_i
357
+
);
358
+
359
+
let mut maybe_done = false;
360
+
361
+
let mut write_fast = rocksdb::WriteOptions::default();
362
+
write_fast.set_sync(false);
363
+
write_fast.disable_wal(true);
364
+
365
+
while !stay_alive.is_cancelled() && !maybe_done {
366
+
// let mut batch = WriteBatch::default();
367
+
368
+
let mut any_written = false;
369
+
370
+
for _ in 0..1000 {
371
+
if state.latest_repaired_i % 1_000_000 == 0 {
372
+
eprintln!("target iter at {}", state.latest_repaired_i);
373
+
}
374
+
state.latest_repaired_i += 1;
375
+
376
+
if !iter.valid() {
377
+
eprintln!("invalid iter, are we done repairing?");
378
+
maybe_done = true;
379
+
break;
380
+
};
381
+
382
+
// eprintln!("iterator seems to be valid! getting the key...");
383
+
let raw_key = iter.key().unwrap();
384
+
if raw_key.len() == 8 {
385
+
// eprintln!("found an 8-byte key, skipping it since it's probably an id...");
386
+
iter.next();
387
+
continue;
388
+
}
389
+
let target: TargetKey = _kr::<TargetKey>(raw_key)?;
390
+
let target_id: TargetId = _vr(iter.value().unwrap())?;
391
+
392
+
self.db
393
+
.put_cf_opt(&cf, target_id.id().to_be_bytes(), _rv(&target), &write_fast)?;
394
+
any_written = true;
395
+
iter.next();
396
+
}
397
+
398
+
if any_written {
399
+
self.db
400
+
.put(TARGET_ID_REPAIR_STATE_KEY, _rv(state.clone()))?;
401
+
std::thread::sleep(breather);
402
+
}
403
+
}
404
+
405
+
eprintln!("repair iterator done.");
406
+
407
+
Ok(false)
299
408
}
300
409
301
410
pub fn start_backup(
···
826
935
}
827
936
828
937
impl LinkReader for RocksStorage {
938
+
fn get_many_to_many_counts(
939
+
&self,
940
+
target: &str,
941
+
collection: &str,
942
+
path: &str,
943
+
path_to_other: &str,
944
+
limit: u64,
945
+
after: Option<String>,
946
+
filter_dids: &HashSet<Did>,
947
+
filter_to_targets: &HashSet<String>,
948
+
) -> Result<PagedOrderedCollection<(String, u64, u64), String>> {
949
+
let collection = Collection(collection.to_string());
950
+
let path = RPath(path.to_string());
951
+
952
+
let target_key = TargetKey(Target(target.to_string()), collection.clone(), path.clone());
953
+
954
+
// unfortunately the cursor is a, uh, stringified number.
955
+
// this was easier for the memstore (plain target, not target id), and
956
+
// making it generic is a bit awful.
957
+
// so... parse the number out of a string here :(
958
+
// TODO: this should bubble up to a BAD_REQUEST response
959
+
let after = after.map(|s| s.parse::<u64>().map(TargetId)).transpose()?;
960
+
961
+
let Some(target_id) = self.target_id_table.get_id_val(&self.db, &target_key)? else {
962
+
eprintln!("nothin doin for this target, {target_key:?}");
963
+
return Ok(Default::default());
964
+
};
965
+
966
+
let filter_did_ids: HashMap<DidId, bool> = filter_dids
967
+
.iter()
968
+
.filter_map(|did| self.did_id_table.get_id_val(&self.db, did).transpose())
969
+
.collect::<Result<Vec<DidIdValue>>>()?
970
+
.into_iter()
971
+
.map(|DidIdValue(id, active)| (id, active))
972
+
.collect();
973
+
974
+
// stored targets are keyed by triples of (target, collection, path).
975
+
// target filtering only consideres the target itself, so we actually
976
+
// need to do a prefix iteration of all target ids for this target and
977
+
// keep them all.
978
+
// i *think* the number of keys at a target prefix should usually be
979
+
// pretty small, so this is hopefully fine. but if it turns out to be
980
+
// large, we can push this filtering back into the main links loop and
981
+
// do forward db queries per backlink to get the raw target back out.
982
+
let mut filter_to_target_ids: HashSet<TargetId> = HashSet::new();
983
+
for t in filter_to_targets {
984
+
for (_, target_id) in self.iter_targets_for_target(&Target(t.to_string())) {
985
+
filter_to_target_ids.insert(target_id);
986
+
}
987
+
}
988
+
989
+
let linkers = self.get_target_linkers(&target_id)?;
990
+
991
+
let mut grouped_counts: BTreeMap<TargetId, (u64, HashSet<DidId>)> = BTreeMap::new();
992
+
993
+
for (did_id, rkey) in linkers.0 {
994
+
if did_id.is_empty() {
995
+
continue;
996
+
}
997
+
998
+
if !filter_did_ids.is_empty() && filter_did_ids.get(&did_id) != Some(&true) {
999
+
continue;
1000
+
}
1001
+
1002
+
let record_link_key = RecordLinkKey(did_id, collection.clone(), rkey);
1003
+
let Some(targets) = self.get_record_link_targets(&record_link_key)? else {
1004
+
continue;
1005
+
};
1006
+
1007
+
let Some(fwd_target) = targets
1008
+
.0
1009
+
.into_iter()
1010
+
.filter_map(|RecordLinkTarget(rpath, target_id)| {
1011
+
if rpath.0 == path_to_other
1012
+
&& (filter_to_target_ids.is_empty()
1013
+
|| filter_to_target_ids.contains(&target_id))
1014
+
{
1015
+
Some(target_id)
1016
+
} else {
1017
+
None
1018
+
}
1019
+
})
1020
+
.take(1)
1021
+
.next()
1022
+
else {
1023
+
eprintln!("no forward match");
1024
+
continue;
1025
+
};
1026
+
1027
+
// small relief: we page over target ids, so we can already bail
1028
+
// reprocessing previous pages here
1029
+
if after.as_ref().map(|a| fwd_target <= *a).unwrap_or(false) {
1030
+
continue;
1031
+
}
1032
+
1033
+
// aand we can skip target ids that must be on future pages
1034
+
// (this check continues after the did-lookup, which we have to do)
1035
+
let page_is_full = grouped_counts.len() as u64 >= limit;
1036
+
if page_is_full {
1037
+
let current_max = grouped_counts.keys().next_back().unwrap(); // limit should be non-zero bleh
1038
+
if fwd_target > *current_max {
1039
+
continue;
1040
+
}
1041
+
}
1042
+
1043
+
// bit painful: 2-step lookup to make sure this did is active
1044
+
let Some(did) = self.did_id_table.get_val_from_id(&self.db, did_id.0)? else {
1045
+
eprintln!("failed to look up did from did_id {did_id:?}");
1046
+
continue;
1047
+
};
1048
+
let Some(DidIdValue(_, active)) = self.did_id_table.get_id_val(&self.db, &did)? else {
1049
+
eprintln!("failed to look up did_value from did_id {did_id:?}: {did:?}: data consistency bug?");
1050
+
continue;
1051
+
};
1052
+
if !active {
1053
+
continue;
1054
+
}
1055
+
1056
+
// page-management, continued
1057
+
// if we have a full page, and we're inserting a *new* key less than
1058
+
// the current max, then we can evict the current max
1059
+
let mut should_evict = false;
1060
+
let entry = grouped_counts.entry(fwd_target.clone()).or_insert_with(|| {
1061
+
// this is a *new* key, so kick the max if we're full
1062
+
should_evict = page_is_full;
1063
+
Default::default()
1064
+
});
1065
+
entry.0 += 1;
1066
+
entry.1.insert(did_id);
1067
+
1068
+
if should_evict {
1069
+
grouped_counts.pop_last();
1070
+
}
1071
+
}
1072
+
1073
+
let mut items: Vec<(String, u64, u64)> = Vec::with_capacity(grouped_counts.len());
1074
+
for (target_id, (n, dids)) in &grouped_counts {
1075
+
let Some(target) = self
1076
+
.target_id_table
1077
+
.get_val_from_id(&self.db, target_id.0)?
1078
+
else {
1079
+
eprintln!("failed to look up target from target_id {target_id:?}");
1080
+
continue;
1081
+
};
1082
+
items.push((target.0 .0, *n, dids.len() as u64));
1083
+
}
1084
+
1085
+
let next = if grouped_counts.len() as u64 >= limit {
1086
+
// yeah.... it's a number saved as a string......sorry
1087
+
grouped_counts
1088
+
.keys()
1089
+
.next_back()
1090
+
.map(|k| format!("{}", k.0))
1091
+
} else {
1092
+
None
1093
+
};
1094
+
1095
+
Ok(PagedOrderedCollection { items, next })
1096
+
}
1097
+
829
1098
fn get_count(&self, target: &str, collection: &str, path: &str) -> Result<u64> {
830
1099
let target_key = TargetKey(
831
1100
Target(target.to_string()),
···
860
1129
path: &str,
861
1130
limit: u64,
862
1131
until: Option<u64>,
1132
+
filter_dids: &HashSet<Did>,
863
1133
) -> Result<PagedAppendingCollection<RecordId>> {
864
1134
let target_key = TargetKey(
865
1135
Target(target.to_string()),
···
876
1146
});
877
1147
};
878
1148
879
-
let linkers = self.get_target_linkers(&target_id)?;
1149
+
let mut linkers = self.get_target_linkers(&target_id)?;
1150
+
if !filter_dids.is_empty() {
1151
+
let mut did_filter = HashSet::new();
1152
+
for did in filter_dids {
1153
+
let Some(DidIdValue(did_id, active)) =
1154
+
self.did_id_table.get_id_val(&self.db, did)?
1155
+
else {
1156
+
eprintln!("failed to find a did_id for {did:?}");
1157
+
continue;
1158
+
};
1159
+
if !active {
1160
+
eprintln!("excluding inactive did from filtered results");
1161
+
continue;
1162
+
}
1163
+
did_filter.insert(did_id);
1164
+
}
1165
+
linkers.0.retain(|linker| did_filter.contains(&linker.0));
1166
+
}
880
1167
881
1168
let (alive, gone) = linkers.count();
882
1169
let total = alive + gone;
···
1024
1311
.map(|s| s.parse::<u64>())
1025
1312
.transpose()?
1026
1313
.unwrap_or(0);
1314
+
let started_at = self
1315
+
.db
1316
+
.get(STARTED_AT_KEY)?
1317
+
.map(|c| _vr(&c))
1318
+
.transpose()?
1319
+
.unwrap_or(COZY_FIRST_CURSOR);
1320
+
1321
+
let other_data = self
1322
+
.db
1323
+
.get(TARGET_ID_REPAIR_STATE_KEY)?
1324
+
.map(|s| _vr(&s))
1325
+
.transpose()?
1326
+
.map(
1327
+
|TargetIdRepairState {
1328
+
current_us_started_at,
1329
+
id_when_started,
1330
+
latest_repaired_i,
1331
+
}| {
1332
+
HashMap::from([
1333
+
("current_us_started_at".to_string(), current_us_started_at),
1334
+
("id_when_started".to_string(), id_when_started),
1335
+
("latest_repaired_i".to_string(), latest_repaired_i),
1336
+
])
1337
+
},
1338
+
)
1339
+
.unwrap_or(HashMap::default());
1340
+
1027
1341
Ok(StorageStats {
1028
1342
dids,
1029
1343
targetables,
1030
1344
linking_records,
1345
+
started_at: Some(started_at),
1346
+
other_data,
1031
1347
})
1032
1348
}
1033
1349
}
···
1053
1369
impl AsRocksValue for &TargetId {}
1054
1370
impl KeyFromRocks for TargetKey {}
1055
1371
impl ValueFromRocks for TargetId {}
1372
+
1373
+
// temp?
1374
+
impl KeyFromRocks for TargetId {}
1375
+
impl AsRocksValue for &TargetKey {}
1056
1376
1057
1377
// target_links table
1058
1378
impl AsRocksKey for &TargetId {}
···
1124
1444
}
1125
1445
1126
1446
// target ids
1127
-
#[derive(Debug, Clone, Serialize, Deserialize)]
1447
+
#[derive(Debug, Clone, Serialize, Deserialize, PartialOrd, Ord, PartialEq, Eq, Hash)]
1128
1448
struct TargetId(u64); // key
1129
1449
1130
-
#[derive(Debug, Clone, Serialize, Deserialize)]
1450
+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
1131
1451
pub struct Target(pub String); // the actual target/uri
1132
1452
1133
1453
// targets (uris, dids, etc.): the reverse index
+1
-1
constellation/templates/dids.html.j2
+1
-1
constellation/templates/dids.html.j2
···
27
27
{% for did in linking_dids %}
28
28
<pre style="display: block; margin: 1em 2em" class="code"><strong>DID</strong>: {{ did.0 }}
29
29
-> see <a href="/links/all?target={{ did.0|urlencode }}">links to this DID</a>
30
-
-> browse <a href="https://atproto-browser-plus-links.vercel.app/at/{{ did.0|urlencode }}">this DID record</a></pre>
30
+
-> browse <a href="https://pdsls.dev/at://{{ did.0|urlencode }}">this DID record</a></pre>
31
31
{% endfor %}
32
32
33
33
{% if let Some(c) = cursor %}
+54
constellation/templates/get-backlinks.html.j2
+54
constellation/templates/get-backlinks.html.j2
···
1
+
{% extends "base.html.j2" %}
2
+
{% import "try-it-macros.html.j2" as try_it %}
3
+
4
+
{% block title %}Backlinks{% endblock %}
5
+
{% block description %}All {{ query.source }} records with links to {{ query.subject }}{% endblock %}
6
+
7
+
{% block content %}
8
+
9
+
{% call try_it::get_backlinks(query.subject, query.source, query.did, query.limit) %}
10
+
11
+
<h2>
12
+
Links to <code>{{ query.subject }}</code>
13
+
{% if let Some(browseable_uri) = query.subject|to_browseable %}
14
+
<small style="font-weight: normal; font-size: 1rem"><a href="{{ browseable_uri }}">browse record</a></small>
15
+
{% endif %}
16
+
</h2>
17
+
18
+
<p><strong>{{ total|human_number }} links</strong> from <code>{{ query.source }}</code>.</p>
19
+
20
+
<ul>
21
+
<li>See distinct linking DIDs at <code>/links/distinct-dids</code>: <a href="/links/distinct-dids?target={{ query.subject|urlencode }}&collection={{ collection|urlencode }}&path={{ path|urlencode }}">/links/distinct-dids?target={{ query.subject }}&collection={{ collection }}&path={{ path }}</a></li>
22
+
<li>See all links to this target at <code>/links/all</code>: <a href="/links/all?target={{ query.subject|urlencode }}">/links/all?target={{ query.subject }}</a></li>
23
+
</ul>
24
+
25
+
<h3>Links, most recent first:</h3>
26
+
27
+
{% for record in records %}
28
+
<pre style="display: block; margin: 1em 2em" class="code"><strong>DID</strong>: {{ record.did().0 }} (<a href="/links/all?target={{ record.did().0|urlencode }}">DID links</a>)
29
+
<strong>Collection</strong>: {{ record.collection }}
30
+
<strong>RKey</strong>: {{ record.rkey }}
31
+
-> <a href="https://pdsls.dev/at://{{ record.did().0 }}/{{ record.collection }}/{{ record.rkey }}">browse record</a></pre>
32
+
{% endfor %}
33
+
34
+
{% if let Some(c) = cursor %}
35
+
<form method="get" action="/xrpc/blue.microcosm.links.getBacklinks">
36
+
<input type="hidden" name="subject" value="{{ query.subject }}" />
37
+
<input type="hidden" name="source" value="{{ query.source }}" />
38
+
<input type="hidden" name="limit" value="{{ query.limit }}" />
39
+
{% for did in query.did %}
40
+
<input type="hidden" name="did" value="{{ did }}" />
41
+
{% endfor %}
42
+
<input type="hidden" name="cursor" value={{ c|json|safe }} />
43
+
<button type="submit">next page…</button>
44
+
</form>
45
+
{% else %}
46
+
<button disabled><em>end of results</em></button>
47
+
{% endif %}
48
+
49
+
<details>
50
+
<summary>Raw JSON response</summary>
51
+
<pre class="code">{{ self|tojson }}</pre>
52
+
</details>
53
+
54
+
{% endblock %}
+67
constellation/templates/get-many-to-many-counts.html.j2
+67
constellation/templates/get-many-to-many-counts.html.j2
···
1
+
{% extends "base.html.j2" %}
2
+
{% import "try-it-macros.html.j2" as try_it %}
3
+
4
+
{% block title %}Many to Many counts{% endblock %}
5
+
{% block description %}Counts of many-to-many {{ query.source }} join records with links to {{ query.subject }} and a secondary target at {{ query.path_to_other }}{% endblock %}
6
+
7
+
{% block content %}
8
+
9
+
{% call try_it::get_many_to_many_counts(
10
+
query.subject,
11
+
query.source,
12
+
query.path_to_other,
13
+
query.did,
14
+
query.other_subject,
15
+
query.limit,
16
+
) %}
17
+
18
+
<h2>
19
+
Many-to-many links to <code>{{ query.subject }}</code> joining through <code>{{ query.path_to_other }}</code>
20
+
{% if let Some(browseable_uri) = query.subject|to_browseable %}
21
+
<small style="font-weight: normal; font-size: 1rem"><a href="{{ browseable_uri }}">browse record</a></small>
22
+
{% endif %}
23
+
</h2>
24
+
25
+
<p><strong>{% if cursor.is_some() || query.cursor.is_some() %}more than {% endif %}{{ counts_by_other_subject.len()|to_u64|human_number }} joins</strong> <code>{{ query.source }}→{{ query.path_to_other }}</code></p>
26
+
27
+
<ul>
28
+
<li>See direct backlinks at <code>/xrpc/blue.microcosm.links.getBacklinks</code>: <a href="/xrpc/blue.microcosm.links.getBacklinks?subject={{ query.subject|urlencode }}&source={{ query.source|urlencode }}">/xrpc/blue.microcosm.links.getBacklinks?subject={{ query.subject }}&source={{ query.source }}</a></li>
29
+
<li>See all links to this target at <code>/links/all</code>: <a href="/links/all?target={{ query.subject|urlencode }}">/links/all?target={{ query.subject }}</a></li>
30
+
</ul>
31
+
32
+
<h3>Counts by other subject:</h3>
33
+
34
+
{% for counts in counts_by_other_subject %}
35
+
<pre style="display: block; margin: 1em 2em" class="code"><strong>Joined subject</strong>: {{ counts.subject }}
36
+
<strong>Joining records</strong>: {{ counts.total }}
37
+
<strong>Unique joiner ids</strong>: {{ counts.distinct }}
38
+
-> {% if let Some(browseable_uri) = counts.subject|to_browseable -%}
39
+
<a href="{{ browseable_uri }}">browse record</a>
40
+
{%- endif %}</pre>
41
+
{% endfor %}
42
+
43
+
{% if let Some(c) = cursor %}
44
+
<form method="get" action="/xrpc/blue.microcosm.links.getManyToManyCounts">
45
+
<input type="hidden" name="subject" value="{{ query.subject }}" />
46
+
<input type="hidden" name="source" value="{{ query.source }}" />
47
+
<input type="hidden" name="pathToOther" value="{{ query.path_to_other }}" />
48
+
{% for did in query.did %}
49
+
<input type="hidden" name="did" value="{{ did }}" />
50
+
{% endfor %}
51
+
{% for otherSubject in query.other_subject %}
52
+
<input type="hidden" name="otherSubject" value="{{ otherSubject }}" />
53
+
{% endfor %}
54
+
<input type="hidden" name="limit" value="{{ query.limit }}" />
55
+
<input type="hidden" name="cursor" value={{ c|json|safe }} />
56
+
<button type="submit">next page…</button>
57
+
</form>
58
+
{% else %}
59
+
<button disabled><em>end of results</em></button>
60
+
{% endif %}
61
+
62
+
<details>
63
+
<summary>Raw JSON response</summary>
64
+
<pre class="code">{{ self|tojson }}</pre>
65
+
</details>
66
+
67
+
{% endblock %}
+65
-7
constellation/templates/hello.html.j2
+65
-7
constellation/templates/hello.html.j2
···
19
19
<p>It works by recursively walking <em>all</em> records coming through the firehose, searching for anything that looks like a link. Links are indexed by the target they point at, the collection the record came from, and the JSON path to the link in that record.</p>
20
20
21
21
<p>
22
-
This server has indexed <span class="stat">{{ stats.linking_records|human_number }}</span> links between <span class="stat">{{ stats.targetables|human_number }}</span> targets and sources from <span class="stat">{{ stats.dids|human_number }}</span> identities over <span class="stat">{{ days_indexed|human_number }}</span> days.<br/>
23
-
<small>(indexing new records in real time, backfill still TODO)</small>
22
+
This server has indexed <span class="stat">{{ stats.linking_records|human_number }}</span> links between <span class="stat">{{ stats.targetables|human_number }}</span> targets and sources from <span class="stat">{{ stats.dids|human_number }}</span> identities over <span class="stat">
23
+
{%- if let Some(days) = days_indexed %}
24
+
{{ days|human_number }}
25
+
{% else %}
26
+
???
27
+
{% endif -%}
28
+
</span> days.<br/>
29
+
<small>(indexing new records in real time, backfill coming soon!)</small>
24
30
</p>
25
31
26
-
<p>The API is currently <strong>unstable</strong>. But feel free to use it! If you want to be nice, put your project name and bsky username (or email) in your user-agent header for api requests.</p>
32
+
{# {% for k, v in stats.other_data.iter() %}
33
+
<p><strong>{{ k }}</strong>: {{ v }}</p>
34
+
{% endfor %} #}
35
+
36
+
<p>You're welcome to use this public instance! Please do not build the torment nexus. If you want to be nice, put your project name and bsky username (or email) in your user-agent header for api requests.</p>
27
37
28
38
29
39
<h2>API Endpoints</h2>
30
40
41
+
<h3 class="route"><code>GET /xrpc/blue.microcosm.links.getBacklinks</code></h3>
42
+
43
+
<p>A list of records linking to any record, identity, or uri.</p>
44
+
45
+
<h4>Query parameters:</h4>
46
+
47
+
<ul>
48
+
<li><p><code>subject</code>: required, must url-encode. Example: <code>at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r</code></p></li>
49
+
<li><p><code>source</code>: required. Example: <code>app.bsky.feed.like:subject.uri</code></p></li>
50
+
<li><p><code>did</code>: optional, filter links to those from specific users. Include multiple times to filter by multiple users. Example: <code>did=did:plc:vc7f4oafdgxsihk4cry2xpze&did=did:plc:vc7f4oafdgxsihk4cry2xpze</code></p></li>
51
+
<li><p><code>limit</code>: optional. Default: <code>16</code>. Maximum: <code>100</code></p></li>
52
+
</ul>
53
+
54
+
<p style="margin-bottom: 0"><strong>Try it:</strong></p>
55
+
{% call try_it::get_backlinks("at://did:plc:a4pqq234yw7fqbddawjo7y35/app.bsky.feed.post/3m237ilwc372e", "app.bsky.feed.like:subject.uri", [""], 16) %}
56
+
57
+
58
+
<h3 class="route"><code>GET /xrpc/blue.microcosm.links.getManyToManyCounts</code></h3>
59
+
60
+
<p>TODO: description</p>
61
+
62
+
<h4>Query parameters:</h4>
63
+
64
+
<ul>
65
+
<li><p><code>subject</code>: required, must url-encode. Example: <code>at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r</code></p></li>
66
+
<li><p><code>source</code>: required. Example: <code>app.bsky.feed.like:subject.uri</code></p></li>
67
+
<li><p><code>pathToOther</code>: required. Path to the secondary link in the many-to-many record. Example: <code>otherThing.uri</code></p></li>
68
+
<li><p><code>did</code>: optional, filter links to those from specific users. Include multiple times to filter by multiple users. Example: <code>did=did:plc:vc7f4oafdgxsihk4cry2xpze&did=did:plc:vc7f4oafdgxsihk4cry2xpze</code></p></li>
69
+
<li><p><code>otherSubject</code>: optional, filter secondary links to specific subjects. Include multiple times to filter by multiple users. Example: <code>at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r</code></p></li>
70
+
<li><p><code>limit</code>: optional. Default: <code>16</code>. Maximum: <code>100</code></p></li>
71
+
</ul>
72
+
73
+
<p style="margin-bottom: 0"><strong>Try it:</strong></p>
74
+
{% call try_it::get_many_to_many_counts(
75
+
"at://did:plc:wshs7t2adsemcrrd4snkeqli/sh.tangled.label.definition/good-first-issue",
76
+
"sh.tangled.label.op:add[].key",
77
+
"subject",
78
+
[""],
79
+
[""],
80
+
25,
81
+
) %}
82
+
83
+
31
84
<h3 class="route"><code>GET /links</code></h3>
32
85
33
86
<p>A list of records linking to a target.</p>
34
87
88
+
<p>[DEPRECATED]: use <code>GET /xrpc/blue.microcosm.links.getBacklinks</code>. New apps should avoid it, but this endpoint <strong>will</strong> remain supported for the forseeable future.</p>
89
+
35
90
<h4>Query parameters:</h4>
36
91
37
92
<ul>
38
-
<li><code>target</code>: required, must url-encode. Example: <code>at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r</code></li>
39
-
<li><code>collection</code>: required. Example: <code>app.bsky.feed.like</code></li>
40
-
<li><code>path</code>: required, must url-encode. Example: <code>.subject.uri</code></li>
93
+
<li><p><code>target</code>: required, must url-encode. Example: <code>at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r</code></p></li>
94
+
<li><p><code>collection</code>: required. Example: <code>app.bsky.feed.like</code></p></li>
95
+
<li><p><code>path</code>: required, must url-encode. Example: <code>.subject.uri</code></p></li>
96
+
<li><p><code>did</code>: optional, filter links to those from specific users. Include multiple times to filter by multiple users. Example: <code>did=did:plc:vc7f4oafdgxsihk4cry2xpze&did=did:plc:vc7f4oafdgxsihk4cry2xpze</code></p></li>
97
+
<li><p><code>from_dids</code> [deprecated]: optional. Use <code>did</code> instead. Example: <code>from_dids=did:plc:vc7f4oafdgxsihk4cry2xpze,did:plc:vc7f4oafdgxsihk4cry2xpze</code></p></li>
98
+
<li><p><code>limit</code>: optional. Default: <code>16</code>. Maximum: <code>100</code></p></li>
41
99
</ul>
42
100
43
101
<p style="margin-bottom: 0"><strong>Try it:</strong></p>
44
-
{% call try_it::links("at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r", "app.bsky.feed.like", ".subject.uri") %}
102
+
{% call try_it::links("at://did:plc:a4pqq234yw7fqbddawjo7y35/app.bsky.feed.post/3m237ilwc372e", "app.bsky.feed.like", ".subject.uri", [""], 16) %}
45
103
46
104
47
105
<h3 class="route"><code>GET /links/distinct-dids</code></h3>
+2
-2
constellation/templates/links.html.j2
+2
-2
constellation/templates/links.html.j2
···
6
6
7
7
{% block content %}
8
8
9
-
{% call try_it::links(query.target, query.collection, query.path) %}
9
+
{% call try_it::links(query.target, query.collection, query.path, query.did, query.limit) %}
10
10
11
11
<h2>
12
12
Links to <code>{{ query.target }}</code>
···
28
28
<pre style="display: block; margin: 1em 2em" class="code"><strong>DID</strong>: {{ record.did().0 }} (<a href="/links/all?target={{ record.did().0|urlencode }}">DID links</a>)
29
29
<strong>Collection</strong>: {{ record.collection }}
30
30
<strong>RKey</strong>: {{ record.rkey }}
31
-
-> <a href="https://atproto-browser-plus-links.vercel.app/at/{{ record.did().0|urlencode }}/{{ record.collection }}/{{ record.rkey }}">browse record</a></pre>
31
+
-> <a href="https://pdsls.dev/at://{{ record.did().0 }}/{{ record.collection }}/{{ record.rkey }}">browse record</a></pre>
32
32
{% endfor %}
33
33
34
34
{% if let Some(c) = cursor %}
+88
-3
constellation/templates/try-it-macros.html.j2
+88
-3
constellation/templates/try-it-macros.html.j2
···
1
-
{% macro links(target, collection, path) %}
1
+
{% macro get_backlinks(subject, source, dids, limit) %}
2
+
<form method="get" action="/xrpc/blue.microcosm.links.getBacklinks">
3
+
<pre class="code"><strong>GET</strong> /xrpc/blue.microcosm.links.getBacklinks
4
+
?subject= <input type="text" name="subject" value="{{ subject }}" placeholder="at-uri, did, uri..." />
5
+
&source= <input type="text" name="source" value="{{ source }}" placeholder="app.bsky.feed.like:subject.uri" />
6
+
{%- for did in dids %}{% if !did.is_empty() %}
7
+
&did= <input type="text" name="did" value="{{ did }}" placeholder="did:plc:..." />{% endif %}{% endfor %}
8
+
<span id="did-placeholder"></span> <button id="add-did">+ did filter</button>
9
+
&limit= <input type="number" name="limit" value="{{ limit }}" max="100" placeholder="100" /> <button type="submit">get links</button></pre>
10
+
</form>
11
+
<script>
12
+
const addDidButton = document.getElementById('add-did');
13
+
const didPlaceholder = document.getElementById('did-placeholder');
14
+
addDidButton.addEventListener('click', e => {
15
+
e.preventDefault();
16
+
const i = document.createElement('input');
17
+
i.placeholder = 'did:plc:...';
18
+
i.name = "did"
19
+
const p = addDidButton.parentNode;
20
+
p.insertBefore(document.createTextNode('&did= '), didPlaceholder);
21
+
p.insertBefore(i, didPlaceholder);
22
+
p.insertBefore(document.createTextNode('\n '), didPlaceholder);
23
+
});
24
+
</script>
25
+
{% endmacro %}
26
+
27
+
{% macro get_many_to_many_counts(subject, source, pathToOther, dids, otherSubjects, limit) %}
28
+
<form method="get" action="/xrpc/blue.microcosm.links.getManyToManyCounts">
29
+
<pre class="code"><strong>GET</strong> /xrpc/blue.microcosm.links.getManyToManyCounts
30
+
?subject= <input type="text" name="subject" value="{{ subject }}" placeholder="at-uri, did, uri..." />
31
+
&source= <input type="text" name="source" value="{{ source }}" placeholder="app.bsky.feed.like:subject.uri" />
32
+
&pathToOther= <input type="text" name="pathToOther" value="{{ pathToOther }}" placeholder="otherThing.uri" />
33
+
{%- for did in dids %}{% if !did.is_empty() %}
34
+
&did= <input type="text" name="did" value="{{ did }}" placeholder="did:plc:..." />{% endif %}{% endfor %}
35
+
<span id="m2m-subject-placeholder"></span> <button id="m2m-add-subject">+ other subject filter</button>
36
+
{%- for otherSubject in otherSubjects %}{% if !otherSubject.is_empty() %}
37
+
&otherSubject= <input type="text" name="did" value="{{ otherSubject }}" placeholder="at-uri, did, uri..." />{% endif %}{% endfor %}
38
+
<span id="m2m-did-placeholder"></span> <button id="m2m-add-did">+ did filter</button>
39
+
&limit= <input type="number" name="limit" value="{{ limit }}" max="100" placeholder="100" /> <button type="submit">get links</button></pre>
40
+
</form>
41
+
<script>
42
+
const m2mAddDidButton = document.getElementById('m2m-add-did');
43
+
const m2mDidPlaceholder = document.getElementById('m2m-did-placeholder');
44
+
m2mAddDidButton.addEventListener('click', e => {
45
+
e.preventDefault();
46
+
const i = document.createElement('input');
47
+
i.placeholder = 'did:plc:...';
48
+
i.name = "did"
49
+
const p = m2mAddDidButton.parentNode;
50
+
p.insertBefore(document.createTextNode('&did= '), m2mDidPlaceholder);
51
+
p.insertBefore(i, m2mDidPlaceholder);
52
+
p.insertBefore(document.createTextNode('\n '), m2mDidPlaceholder);
53
+
});
54
+
const m2mAddSubjectButton = document.getElementById('m2m-add-subject');
55
+
const m2mSubjectPlaceholder = document.getElementById('m2m-subject-placeholder');
56
+
m2mAddSubjectButton.addEventListener('click', e => {
57
+
e.preventDefault();
58
+
const i = document.createElement('input');
59
+
i.placeholder = 'at-uri, did, uri...';
60
+
i.name = "otherSubject"
61
+
const p = m2mAddSubjectButton.parentNode;
62
+
p.insertBefore(document.createTextNode('&otherSubject= '), m2mSubjectPlaceholder);
63
+
p.insertBefore(i, m2mSubjectPlaceholder);
64
+
p.insertBefore(document.createTextNode('\n '), m2mSubjectPlaceholder);
65
+
});
66
+
</script>
67
+
{% endmacro %}
68
+
69
+
{% macro links(target, collection, path, dids, limit) %}
2
70
<form method="get" action="/links">
3
71
<pre class="code"><strong>GET</strong> /links
4
72
?target= <input type="text" name="target" value="{{ target }}" placeholder="target" />
5
73
&collection= <input type="text" name="collection" value="{{ collection }}" placeholder="collection" />
6
-
&path= <input type="text" name="path" value="{{ path }}" placeholder="path" /> <button type="submit">get links</button></pre>
74
+
&path= <input type="text" name="path" value="{{ path }}" placeholder="path" />
75
+
{%- for did in dids %}{% if !did.is_empty() %}
76
+
&did= <input type="text" name="did" value="{{ did }}" placeholder="did:plc:..." />{% endif %}{% endfor %}
77
+
<span id="did-placeholder"></span> <button id="add-did">+ did filter</button>
78
+
&limit= <input type="number" name="limit" value="{{ limit }}" max="100" placeholder="100" /> <button type="submit">get links</button></pre>
7
79
</form>
80
+
<script>
81
+
const addDidButton = document.getElementById('add-did');
82
+
const didPlaceholder = document.getElementById('did-placeholder');
83
+
addDidButton.addEventListener('click', e => {
84
+
e.preventDefault();
85
+
const i = document.createElement('input');
86
+
i.placeholder = 'did:plc:...';
87
+
i.name = "did"
88
+
const p = addDidButton.parentNode;
89
+
p.insertBefore(document.createTextNode('&did= '), didPlaceholder);
90
+
p.insertBefore(i, didPlaceholder);
91
+
p.insertBefore(document.createTextNode('\n '), didPlaceholder);
92
+
});
93
+
</script>
8
94
{% endmacro %}
9
-
10
95
11
96
{% macro dids(target, collection, path) %}
12
97
<form method="get" action="/links/distinct-dids">
-496
cozy-setup (move to another repo).md
-496
cozy-setup (move to another repo).md
···
1
-
cozy-ucosm
2
-
3
-
4
-
## gateway
5
-
6
-
- tailscale (exit node enabled)
7
-
-> allow ipv4 and ipv6 forwarding
8
-
- caddy
9
-
10
-
```bash
11
-
apt install golang
12
-
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
13
-
go/bin/xcaddy build \
14
-
--with github.com/caddyserver/cache-handler \
15
-
--with github.com/darkweak/storages/badger/caddy \
16
-
--with github.com/mholt/caddy-ratelimit
17
-
# then https://caddyserver.com/docs/running#manual-installation
18
-
19
-
mkdir /var/cache/caddy-badger
20
-
chown -R caddy:caddy /var/cache/caddy-badger/
21
-
```
22
-
23
-
- `/etc/caddy/Caddyfile`
24
-
25
-
```
26
-
{
27
-
cache {
28
-
badger
29
-
api {
30
-
prometheus
31
-
}
32
-
}
33
-
}
34
-
35
-
links.bsky.bad-example.com {
36
-
reverse_proxy link-aggregator:6789
37
-
38
-
@browser `{header.Origin.startsWith("Mozilla/5.0")`
39
-
rate_limit {
40
-
zone global_burst {
41
-
key {remote_host}
42
-
events 10
43
-
window 1s
44
-
}
45
-
zone global_general {
46
-
key {remote_host}
47
-
events 100
48
-
window 60s
49
-
log_key true
50
-
}
51
-
zone website_harsh_limit {
52
-
key {header.Origin}
53
-
match {
54
-
expression {header.User-Agent}.startsWith("Mozilla/5.0")
55
-
}
56
-
events 1000
57
-
window 30s
58
-
log_key true
59
-
}
60
-
}
61
-
respond /souin-api/metrics "denied" 403 # does not work
62
-
cache {
63
-
ttl 3s
64
-
stale 1h
65
-
default_cache_control public, s-maxage=3
66
-
badger {
67
-
path /var/cache/caddy-badger/links
68
-
}
69
-
}
70
-
}
71
-
72
-
gateway:80 {
73
-
metrics
74
-
cache
75
-
}
76
-
```
77
-
well... the gateway fell over IMMEDIATELY with like 2 req/sec from deletions, with that ^^ config. for now i removed everything except the reverse proxy config + normal caddy metrics and it's running fine on vanilla caddy. i did try reducing the rate-limiting configs to a single, fixed-key global limit but it still ate all the ram and died. maybe badger w/ the cache config was still a problem. maybe it would have been ok on a machine with more than 1GB mem.
78
-
79
-
80
-
alternative proxies:
81
-
82
-
- nginx. i should probably just use this. acme-client is a piece of cake to set up, and i know how to configure it.
83
-
- haproxy. also kind of familiar, it's old and stable. no idea how it handle low-mem (our 1gb) vs nginx.
84
-
- sozu. popular rust thing, fast. doesn't have rate-limiting or cache feature?
85
-
- rpxy. like caddy (auto-tls) but in rust and actually fast? has an "experimental" cache feature. but the cache feature looks good.
86
-
- rama. build-your-own proxy. not sure that it has both cache and limiter in their standard features?
87
-
- pingora. build-your-own cloudflare, so like, probably stable. has tools for cache and limiting. low-mem...?
88
-
- cache stuff in pingora seems a little... hit and miss (byeeeee). only a test impl for Storage for the main cache feature?
89
-
- but the rate-limiter has a guide: https://github.com/cloudflare/pingora/blob/main/docs/user_guide/rate_limiter.md
90
-
91
-
what i want is low-resource reverse proxy with built-in rate-limiting and caching. but maybe cache (and/or ratelimiting) could be external to the reverse proxy
92
-
- varnish is a dedicated cache. has https://github.com/varnish/varnish-modules/blob/master/src/vmod_vsthrottle.vcc
93
-
- apache traffic control has experimental rate-limiting plugins
94
-
95
-
96
-
- victoriametrics
97
-
98
-
```bash
99
-
curl -LO https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.109.1/victoria-metrics-linux-amd64-v1.109.1.tar.gz
100
-
tar xzf victoria-metrics-linux-amd64-v1.109.1.tar.gz
101
-
# and then https://docs.victoriametrics.com/quick-start/#starting-vm-single-from-a-binary
102
-
sudo mkdir /etc/victoria-metrics && sudo chown -R victoriametrics:victoriametrics /etc/victoria-metrics
103
-
104
-
```
105
-
106
-
- `/etc/victoria-metrics/prometheus.yml`
107
-
108
-
```yaml
109
-
global:
110
-
scrape_interval: '15s'
111
-
112
-
scrape_configs:
113
-
- job_name: 'link_aggregator'
114
-
static_configs:
115
-
- targets: ['link-aggregator:8765']
116
-
- job_name: 'gateway:caddy'
117
-
static_configs:
118
-
- targets: ['gateway:80/metrics']
119
-
- job_name: 'gateway:cache'
120
-
static_configs:
121
-
- targets: ['gateway:80/souin-api/metrics']
122
-
```
123
-
124
-
- `ExecStart` in `/etc/systemd/system/victoriametrics.service`:
125
-
126
-
```
127
-
ExecStart=/usr/local/bin/victoria-metrics-prod -storageDataPath=/var/lib/victoria-metrics -retentionPeriod=90d -selfScrapeInterval=1m -promscrape.config=/etc/victoria-metrics/prometheus.yml
128
-
```
129
-
130
-
- grafana
131
-
132
-
followed `https://grafana.com/docs/grafana/latest/setup-grafana/installation/debian/#install-grafana-on-debian-or-ubuntu`
133
-
134
-
something something something then
135
-
136
-
```
137
-
sudo grafana-cli --pluginUrl https://github.com/VictoriaMetrics/victoriametrics-datasource/releases/download/v0.11.1/victoriametrics-datasource-v0.11.1.zip plugins install victoriametrics
138
-
```
139
-
140
-
- raspi node_exporter
141
-
142
-
```bash
143
-
curl -LO https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-armv7.tar.gz
144
-
tar xzf node_exporter-1.8.2.linux-armv7.tar.gz
145
-
sudo cp node_exporter-1.8.2.linux-armv7/node_exporter /usr/local/bin/
146
-
sudo useradd --no-create-home --shell /bin/false node_exporter
147
-
sudo nano /etc/systemd/system/node_exporter.service
148
-
# [Unit]
149
-
# Description=Node Exporter
150
-
# Wants=network-online.target
151
-
# After=network-online.target
152
-
153
-
# [Service]
154
-
# User=node_exporter
155
-
# Group=node_exporter
156
-
# Type=simple
157
-
# ExecStart=/usr/local/bin/node_exporter
158
-
# Restart=always
159
-
# RestartSec=3
160
-
161
-
# [Install]
162
-
# WantedBy=multi-user.target
163
-
sudo systemctl daemon-reload
164
-
sudo systemctl enable node_exporter.service
165
-
sudo systemctl start node_exporter.service
166
-
```
167
-
168
-
todo: get raspi vcgencmd outputs into metrics
169
-
170
-
- nginx on gateway
171
-
172
-
```nginx
173
-
# in http
174
-
175
-
##
176
-
# cozy cache
177
-
##
178
-
proxy_cache_path /var/cache/nginx keys_zone=cozy_zone:10m;
179
-
180
-
##
181
-
# cozy limit
182
-
##
183
-
limit_req_zone $binary_remote_addr zone=cozy_ip_limit:10m rate=50r/s;
184
-
limit_req_zone $server_name zone=cozy_global_limit:10m rate=1000r/s;
185
-
186
-
# in sites-available/constellation.microcosm.blue
187
-
188
-
upstream cozy_link_aggregator {
189
-
server link-aggregator:6789;
190
-
keepalive 16;
191
-
}
192
-
193
-
server {
194
-
listen 8080;
195
-
listen [::]:8080;
196
-
197
-
server_name constellation.microcosm.blue;
198
-
199
-
proxy_cache cozy_zone;
200
-
proxy_cache_background_update on;
201
-
proxy_cache_key "$scheme$proxy_host$uri$is_args$args$http_accept";
202
-
proxy_cache_lock on; # make simlutaneous requests for the same uri wait for it to appear in cache instead of hitting origin
203
-
proxy_cache_lock_age 1s;
204
-
proxy_cache_lock_timeout 2s;
205
-
proxy_cache_valid 10s; # default -- should be explicitly set in the response headers
206
-
proxy_cache_valid any 15s; # non-200s default
207
-
proxy_read_timeout 5s;
208
-
proxy_send_timeout 15s;
209
-
proxy_socket_keepalive on;
210
-
211
-
limit_req zone=cozy_ip_limit nodelay burst=100;
212
-
limit_req zone=cozy_global_limit;
213
-
limit_req_status 429;
214
-
215
-
location / {
216
-
proxy_pass http://cozy_link_aggregator;
217
-
include proxy_params;
218
-
proxy_http_version 1.1;
219
-
proxy_set_header Connection ""; # for keepalive
220
-
}
221
-
}
222
-
```
223
-
224
-
also `systemctl edit nginx` and paste
225
-
226
-
```
227
-
[Service]
228
-
Restart=always
229
-
```
230
-
231
-
—https://serverfault.com/a/1003373
232
-
233
-
now making browsers redirect to the microcosm.blue url:
234
-
235
-
```
236
-
[...]
237
-
server_name links.bsky.bad-example.com;
238
-
239
-
add_header Access-Control-Allow-Origin * always; # bit of hack to have it here but nginx doesn't like it in the `if`
240
-
if ($http_user_agent ~ ^Mozilla/) {
241
-
# for now send *browsers* to the new location, hopefully without impacting api requests
242
-
# (yeah we're doing UA test here and content-negotatiation in the app. whatever.)
243
-
return 301 https://constellation.microcosm.blue$request_uri;
244
-
}
245
-
[...]
246
-
```
247
-
248
-
- nginx metrics
249
-
250
-
- download nginx-prometheus-exporter
251
-
https://github.com/nginx/nginx-prometheus-exporter/releases/download/v1.4.1/nginx-prometheus-exporter_1.4.1_linux_amd64.tar.gz
252
-
253
-
- err actually going to make mistakes and try with snap
254
-
`snap install nginx-prometheus-exporter`
255
-
- so it got a binary for me but no systemd task set up. boooo.
256
-
`snap remove nginx-prometheus-exporter`
257
-
258
-
- ```bash
259
-
curl -LO https://github.com/nginx/nginx-prometheus-exporter/releases/download/v1.4.1/nginx-prometheus-exporter_1.4.1_linux_amd64.tar.gz
260
-
tar xzf nginx-prometheus-exporter_1.4.1_linux_amd64.tar.gz
261
-
mv nginx-prometheus-exporter /usr/local/bin
262
-
useradd --no-create-home --shell /bin/false nginx-prometheus-exporter
263
-
nano /etc/systemd/system/nginx-prometheus-exporter.service
264
-
# [Unit]
265
-
# Description=NGINX Exporter
266
-
# Wants=network-online.target
267
-
# After=network-online.target
268
-
269
-
# [Service]
270
-
# User=nginx-prometheus-exporter
271
-
# Group=nginx-prometheus-exporter
272
-
# Type=simple
273
-
# ExecStart=/usr/local/bin/nginx-prometheus-exporter --nginx.scrape-uri=http://gateway:8080/stub_status --web.listen-address=gateway:9113
274
-
# Restart=always
275
-
# RestartSec=3
276
-
277
-
# [Install]
278
-
# WantedBy=multi-user.target
279
-
systemctl daemon-reload
280
-
systemctl start nginx-prometheus-exporter.service
281
-
systemctl enable nginx-prometheus-exporter.service
282
-
```
283
-
284
-
- nginx `/etc/nginx/sites-available/gateway-nginx-status`
285
-
286
-
```nginx
287
-
server {
288
-
listen 8080;
289
-
listen [::]:8080;
290
-
291
-
server_name gateway;
292
-
293
-
location /stub_status {
294
-
stub_status;
295
-
}
296
-
location / {
297
-
return 404;
298
-
}
299
-
}
300
-
```
301
-
302
-
```bash
303
-
ln -s /etc/nginx/sites-available/gateway-nginx-status /etc/nginx/sites-enabled/
304
-
```
305
-
306
-
307
-
## bootes (pi5)
308
-
309
-
- mount sd card, touch `ssh` file echo `echo "pi:$(echo raspberry | openssl passwd -6 -stdin)" > userconf.txt`
310
-
- raspi-config: enable pcie 3, set hostname, enable ssh
311
-
- put ssh key into `.ssh/authorized_keys`
312
-
- put `PasswordAuthentication no` in `/etc/ssh/sshd_config`
313
-
- `sudo apt update && sudo apt upgrade`
314
-
- `sudo apt install xfsprogs`
315
-
- `sudo mkfs.xfs -L c11n-kv /dev/nvme0n1`
316
-
- `sudo mount /dev/nvme0n1 /mnt`
317
-
- set up tailscale
318
-
- `sudo tailscale up`
319
-
- `git clone https://github.com/atcosm/links.git`
320
-
- tailscale: disable bootes key expiry
321
-
- rustup `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
322
-
- `cd links/constellation`
323
-
- `sudo apt install libssl-dev` needed
324
-
- `sudo apt install clang` needed for bindgen
325
-
- (in tmux) `cargo build --release`
326
-
- `mkdir ~/backup`
327
-
- `sudo mount.cifs "//truenas.local/folks data" /home/pi/backup -o user=phil,uid=pi`
328
-
- `sudo chown pi:pi /mnt/`
329
-
- `RUST_BACKTRACE=full cargo run --bin rocks-restore-from-backup --release -- --from-backup-dir "/home/pi/backup/constellation-index" --to-data-dir /mnt/constellation-index`
330
-
etc
331
-
- follow above `- raspi node_exporter`
332
-
- configure victoriametrics to scrape the new pi
333
-
- configure ulimit before starting! `ulimit -n 16384`
334
-
- `RUST_BACKTRACE=full cargo run --release -- --backend rocks --data /mnt/constellation-index/ --jetstream us-east-2 --backup /home/pi/backup/constellation-index --backup-interval 6 --max-old-backups 20`
335
-
- add server to nginx gateway upstream: ` server 100.123.79.12:6789; # bootes`
336
-
- stop backups from running on the older instance! `RUST_BACKTRACE=full cargo run --release -- --backend rocks --data /mnt/links-2.rocks/ --jetstream us-east-1`
337
-
- stop upstreaming requests to older instance in nginx
338
-
339
-
340
-
- systemd unit for running: `sudo nano /etc/systemd/system/constellation.service`
341
-
342
-
```ini
343
-
[Unit]
344
-
Description=Constellation backlinks index
345
-
After=network.target
346
-
347
-
[Service]
348
-
User=pi
349
-
WorkingDirectory=/home/pi/links/constellation
350
-
ExecStart=/home/pi/links/target/release/main --backend rocks --data /mnt/constellation-index/ --jetstream us-east-2 --backup /home/pi/backup/constellation-index --backup-interval 6 --max-old-backups 20
351
-
LimitNOFILE=16384
352
-
Restart=always
353
-
354
-
[Install]
355
-
WantedBy=multi-user.target
356
-
```
357
-
358
-
359
-
- todo: overlayfs? would need to figure out builds/updates still, also i guess logs are currently written to sd? (oof)
360
-
- todo: cross-compile for raspi?
361
-
362
-
---
363
-
364
-
some todos
365
-
366
-
- [x] tailscale: exit node
367
-
- [!] link_aggregator: use exit node
368
-
-> worked, but reverted for now: tailscale on raspi was consuming ~50% cpu for the jetstream traffic. this might be near its max since it would have been catching up at the time (max jetstream throughput) but it feels a bit too much. we have to trust the jetstream server and link_aggregator doesn't (yet) make any other external connections, so for now the raspi connects directly from my home again.
369
-
- [x] caddy: reverse proxy
370
-
- [x] build with cache and rate-limit plugins
371
-
- [x] configure systemd to keep it alive
372
-
- [x] configure caddy cache
373
-
- [x] configure caddy rate-limit
374
-
- [ ] configure ~caddy~ nginx to use a health check (once it's added)
375
-
- [ ] ~configure caddy to only expose cache metrics to tailnet :/~
376
-
- [x] make some grafana dashboards
377
-
- [ ] raspi: mount /dev/sda on boot
378
-
- [ ] raspi: run link_aggregator via systemd so it starts on startup (and restarts?)
379
-
380
-
- [x] use nginx instead of caddy
381
-
- [x] nginx: enable cache
382
-
- [x] nginx: rate-limit
383
-
- [ ] nginx: get metrics
384
-
385
-
386
-
387
-
388
-
---
389
-
390
-
nginx cors for constellation + small burst bump
391
-
392
-
```nginx
393
-
upstream cozy_constellation {
394
-
server <tailnet ip>:6789; # bootes; ip so that we don't race on reboot with tailscale coming up, which nginx doesn't like
395
-
keepalive 16;
396
-
}
397
-
398
-
server {
399
-
server_name constellation.microcosm.blue;
400
-
401
-
proxy_cache cozy_zone;
402
-
proxy_cache_background_update on;
403
-
proxy_cache_key "$scheme$proxy_host$uri$is_args$args$http_accept";
404
-
proxy_cache_lock on; # make simlutaneous requests for the same uri wait for it to appear in cache instead of hitting origin
405
-
proxy_cache_lock_age 1s;
406
-
proxy_cache_lock_timeout 2s;
407
-
proxy_cache_valid 10s; # default -- should be explicitly set in the response headers
408
-
proxy_cache_valid any 2s; # non-200s default
409
-
proxy_read_timeout 5s;
410
-
proxy_send_timeout 15s;
411
-
proxy_socket_keepalive on;
412
-
413
-
# take over cors responsibility from upsteram. `always` applies it to error responses.
414
-
proxy_hide_header 'Access-Control-Allow-Origin';
415
-
proxy_hide_header 'Access-Control-Allowed-Methods';
416
-
proxy_hide_header 'Access-Control-Allow-Headers';
417
-
add_header 'Access-Control-Allow-Origin' '*' always;
418
-
add_header 'Access-Control-Allow-Methods' 'GET' always;
419
-
add_header 'Access-Control-Allow-Headers' '*' always;
420
-
421
-
422
-
limit_req zone=cozy_ip_limit nodelay burst=150;
423
-
limit_req zone=cozy_global_limit burst=1800;
424
-
limit_req_status 429;
425
-
426
-
location / {
427
-
proxy_pass http://cozy_constellation;
428
-
include proxy_params;
429
-
proxy_http_version 1.1;
430
-
proxy_set_header Connection ""; # for keepalive
431
-
}
432
-
433
-
434
-
listen 443 ssl; # managed by Certbot
435
-
ssl_certificate /etc/letsencrypt/live/constellation.microcosm.blue/fullchain.pem; # managed by Certbot
436
-
ssl_certificate_key /etc/letsencrypt/live/constellation.microcosm.blue/privkey.pem; # managed by Certbot
437
-
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
438
-
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
439
-
440
-
}
441
-
442
-
server {
443
-
if ($host = constellation.microcosm.blue) {
444
-
return 301 https://$host$request_uri;
445
-
} # managed by Certbot
446
-
447
-
448
-
server_name constellation.microcosm.blue;
449
-
listen 80;
450
-
return 404; # managed by Certbot
451
-
}
452
-
```
453
-
454
-
re-reading about `nodelay`, i should probably remove it -- nginx would then queue requests to upstream, but still service them at the configured limit. it's fine for my internet since the global limit isn't nodelay, but probably less "fair" to clients if there's contention around the global limit (earlier requests would get all of theirs serviced before later ones can get in the queue)
455
-
456
-
leaving it for now though.
457
-
458
-
459
-
### nginx logs to prom
460
-
461
-
```bash
462
-
curl -LO https://github.com/martin-helmich/prometheus-nginxlog-exporter/releases/download/v1.11.0/prometheus-nginxlog-exporter_1.11.0_linux_amd64.deb
463
-
apt install ./prometheus-nginxlog-exporter_1.11.0_linux_amd64.deb
464
-
systemctl enable prometheus-nginxlog-exporter.service
465
-
466
-
```
467
-
468
-
have it run as www-data (maybe not the best idea but...)
469
-
file `/usr/lib/systemd/system/prometheus-nginxlog-exporter.service`
470
-
set User under service and remove capabilities bounding
471
-
472
-
```systemd
473
-
User=www-data
474
-
#CapabilityBoundingSet=
475
-
```
476
-
477
-
in `nginx.conf` in `http`:
478
-
479
-
```nginx
480
-
log_format constellation_format "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\"";
481
-
```
482
-
483
-
in `sites-available/constellation.microcosm.blue` in `server`:
484
-
485
-
```nginx
486
-
# log format must match prometheus-nginx-log-exporter
487
-
access_log /var/log/nginx/constellation-access.log constellation_format;
488
-
```
489
-
490
-
config at `/etc/prometheus-nginxlog-exporter.hcl`
491
-
492
-
493
-
494
-
```bash
495
-
systemctl start prometheus-nginxlog-exporter.service
496
-
```
+1
-1
jetstream/Cargo.toml
+1
-1
jetstream/Cargo.toml
···
10
10
11
11
[dependencies]
12
12
async-trait = "0.1.83"
13
-
atrium-api = { git = "https://github.com/uniphil/atrium", branch = "fix/nsid-allow-nonleading-name-digits", default-features = false, features = [
13
+
atrium-api = { git = "https://github.com/uniphil/atrium.git", branch = "fix/resolve-handle-https-accept-whitespace", default-features = false, features = [
14
14
"namespace-appbsky",
15
15
] }
16
16
tokio = { version = "1.44.2", features = ["full", "sync", "time"] }
+496
legacy/cozy-setup (move to another repo).md
+496
legacy/cozy-setup (move to another repo).md
···
1
+
cozy-ucosm
2
+
3
+
4
+
## gateway
5
+
6
+
- tailscale (exit node enabled)
7
+
-> allow ipv4 and ipv6 forwarding
8
+
- caddy
9
+
10
+
```bash
11
+
apt install golang
12
+
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
13
+
go/bin/xcaddy build \
14
+
--with github.com/caddyserver/cache-handler \
15
+
--with github.com/darkweak/storages/badger/caddy \
16
+
--with github.com/mholt/caddy-ratelimit
17
+
# then https://caddyserver.com/docs/running#manual-installation
18
+
19
+
mkdir /var/cache/caddy-badger
20
+
chown -R caddy:caddy /var/cache/caddy-badger/
21
+
```
22
+
23
+
- `/etc/caddy/Caddyfile`
24
+
25
+
```
26
+
{
27
+
cache {
28
+
badger
29
+
api {
30
+
prometheus
31
+
}
32
+
}
33
+
}
34
+
35
+
links.bsky.bad-example.com {
36
+
reverse_proxy link-aggregator:6789
37
+
38
+
@browser `{header.Origin.startsWith("Mozilla/5.0")`
39
+
rate_limit {
40
+
zone global_burst {
41
+
key {remote_host}
42
+
events 10
43
+
window 1s
44
+
}
45
+
zone global_general {
46
+
key {remote_host}
47
+
events 100
48
+
window 60s
49
+
log_key true
50
+
}
51
+
zone website_harsh_limit {
52
+
key {header.Origin}
53
+
match {
54
+
expression {header.User-Agent}.startsWith("Mozilla/5.0")
55
+
}
56
+
events 1000
57
+
window 30s
58
+
log_key true
59
+
}
60
+
}
61
+
respond /souin-api/metrics "denied" 403 # does not work
62
+
cache {
63
+
ttl 3s
64
+
stale 1h
65
+
default_cache_control public, s-maxage=3
66
+
badger {
67
+
path /var/cache/caddy-badger/links
68
+
}
69
+
}
70
+
}
71
+
72
+
gateway:80 {
73
+
metrics
74
+
cache
75
+
}
76
+
```
77
+
well... the gateway fell over IMMEDIATELY with like 2 req/sec from deletions, with that ^^ config. for now i removed everything except the reverse proxy config + normal caddy metrics and it's running fine on vanilla caddy. i did try reducing the rate-limiting configs to a single, fixed-key global limit but it still ate all the ram and died. maybe badger w/ the cache config was still a problem. maybe it would have been ok on a machine with more than 1GB mem.
78
+
79
+
80
+
alternative proxies:
81
+
82
+
- nginx. i should probably just use this. acme-client is a piece of cake to set up, and i know how to configure it.
83
+
- haproxy. also kind of familiar, it's old and stable. no idea how it handle low-mem (our 1gb) vs nginx.
84
+
- sozu. popular rust thing, fast. doesn't have rate-limiting or cache feature?
85
+
- rpxy. like caddy (auto-tls) but in rust and actually fast? has an "experimental" cache feature. but the cache feature looks good.
86
+
- rama. build-your-own proxy. not sure that it has both cache and limiter in their standard features?
87
+
- pingora. build-your-own cloudflare, so like, probably stable. has tools for cache and limiting. low-mem...?
88
+
- cache stuff in pingora seems a little... hit and miss (byeeeee). only a test impl for Storage for the main cache feature?
89
+
- but the rate-limiter has a guide: https://github.com/cloudflare/pingora/blob/main/docs/user_guide/rate_limiter.md
90
+
91
+
what i want is low-resource reverse proxy with built-in rate-limiting and caching. but maybe cache (and/or ratelimiting) could be external to the reverse proxy
92
+
- varnish is a dedicated cache. has https://github.com/varnish/varnish-modules/blob/master/src/vmod_vsthrottle.vcc
93
+
- apache traffic control has experimental rate-limiting plugins
94
+
95
+
96
+
- victoriametrics
97
+
98
+
```bash
99
+
curl -LO https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.109.1/victoria-metrics-linux-amd64-v1.109.1.tar.gz
100
+
tar xzf victoria-metrics-linux-amd64-v1.109.1.tar.gz
101
+
# and then https://docs.victoriametrics.com/quick-start/#starting-vm-single-from-a-binary
102
+
sudo mkdir /etc/victoria-metrics && sudo chown -R victoriametrics:victoriametrics /etc/victoria-metrics
103
+
104
+
```
105
+
106
+
- `/etc/victoria-metrics/prometheus.yml`
107
+
108
+
```yaml
109
+
global:
110
+
scrape_interval: '15s'
111
+
112
+
scrape_configs:
113
+
- job_name: 'link_aggregator'
114
+
static_configs:
115
+
- targets: ['link-aggregator:8765']
116
+
- job_name: 'gateway:caddy'
117
+
static_configs:
118
+
- targets: ['gateway:80/metrics']
119
+
- job_name: 'gateway:cache'
120
+
static_configs:
121
+
- targets: ['gateway:80/souin-api/metrics']
122
+
```
123
+
124
+
- `ExecStart` in `/etc/systemd/system/victoriametrics.service`:
125
+
126
+
```
127
+
ExecStart=/usr/local/bin/victoria-metrics-prod -storageDataPath=/var/lib/victoria-metrics -retentionPeriod=90d -selfScrapeInterval=1m -promscrape.config=/etc/victoria-metrics/prometheus.yml
128
+
```
129
+
130
+
- grafana
131
+
132
+
followed `https://grafana.com/docs/grafana/latest/setup-grafana/installation/debian/#install-grafana-on-debian-or-ubuntu`
133
+
134
+
something something something then
135
+
136
+
```
137
+
sudo grafana-cli --pluginUrl https://github.com/VictoriaMetrics/victoriametrics-datasource/releases/download/v0.11.1/victoriametrics-datasource-v0.11.1.zip plugins install victoriametrics
138
+
```
139
+
140
+
- raspi node_exporter
141
+
142
+
```bash
143
+
curl -LO https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-armv7.tar.gz
144
+
tar xzf node_exporter-1.8.2.linux-armv7.tar.gz
145
+
sudo cp node_exporter-1.8.2.linux-armv7/node_exporter /usr/local/bin/
146
+
sudo useradd --no-create-home --shell /bin/false node_exporter
147
+
sudo nano /etc/systemd/system/node_exporter.service
148
+
# [Unit]
149
+
# Description=Node Exporter
150
+
# Wants=network-online.target
151
+
# After=network-online.target
152
+
153
+
# [Service]
154
+
# User=node_exporter
155
+
# Group=node_exporter
156
+
# Type=simple
157
+
# ExecStart=/usr/local/bin/node_exporter
158
+
# Restart=always
159
+
# RestartSec=3
160
+
161
+
# [Install]
162
+
# WantedBy=multi-user.target
163
+
sudo systemctl daemon-reload
164
+
sudo systemctl enable node_exporter.service
165
+
sudo systemctl start node_exporter.service
166
+
```
167
+
168
+
todo: get raspi vcgencmd outputs into metrics
169
+
170
+
- nginx on gateway
171
+
172
+
```nginx
173
+
# in http
174
+
175
+
##
176
+
# cozy cache
177
+
##
178
+
proxy_cache_path /var/cache/nginx keys_zone=cozy_zone:10m;
179
+
180
+
##
181
+
# cozy limit
182
+
##
183
+
limit_req_zone $binary_remote_addr zone=cozy_ip_limit:10m rate=50r/s;
184
+
limit_req_zone $server_name zone=cozy_global_limit:10m rate=1000r/s;
185
+
186
+
# in sites-available/constellation.microcosm.blue
187
+
188
+
upstream cozy_link_aggregator {
189
+
server link-aggregator:6789;
190
+
keepalive 16;
191
+
}
192
+
193
+
server {
194
+
listen 8080;
195
+
listen [::]:8080;
196
+
197
+
server_name constellation.microcosm.blue;
198
+
199
+
proxy_cache cozy_zone;
200
+
proxy_cache_background_update on;
201
+
proxy_cache_key "$scheme$proxy_host$uri$is_args$args$http_accept";
202
+
proxy_cache_lock on; # make simlutaneous requests for the same uri wait for it to appear in cache instead of hitting origin
203
+
proxy_cache_lock_age 1s;
204
+
proxy_cache_lock_timeout 2s;
205
+
proxy_cache_valid 10s; # default -- should be explicitly set in the response headers
206
+
proxy_cache_valid any 15s; # non-200s default
207
+
proxy_read_timeout 5s;
208
+
proxy_send_timeout 15s;
209
+
proxy_socket_keepalive on;
210
+
211
+
limit_req zone=cozy_ip_limit nodelay burst=100;
212
+
limit_req zone=cozy_global_limit;
213
+
limit_req_status 429;
214
+
215
+
location / {
216
+
proxy_pass http://cozy_link_aggregator;
217
+
include proxy_params;
218
+
proxy_http_version 1.1;
219
+
proxy_set_header Connection ""; # for keepalive
220
+
}
221
+
}
222
+
```
223
+
224
+
also `systemctl edit nginx` and paste
225
+
226
+
```
227
+
[Service]
228
+
Restart=always
229
+
```
230
+
231
+
—https://serverfault.com/a/1003373
232
+
233
+
now making browsers redirect to the microcosm.blue url:
234
+
235
+
```
236
+
[...]
237
+
server_name links.bsky.bad-example.com;
238
+
239
+
add_header Access-Control-Allow-Origin * always; # bit of hack to have it here but nginx doesn't like it in the `if`
240
+
if ($http_user_agent ~ ^Mozilla/) {
241
+
# for now send *browsers* to the new location, hopefully without impacting api requests
242
+
# (yeah we're doing UA test here and content-negotatiation in the app. whatever.)
243
+
return 301 https://constellation.microcosm.blue$request_uri;
244
+
}
245
+
[...]
246
+
```
247
+
248
+
- nginx metrics
249
+
250
+
- download nginx-prometheus-exporter
251
+
https://github.com/nginx/nginx-prometheus-exporter/releases/download/v1.4.1/nginx-prometheus-exporter_1.4.1_linux_amd64.tar.gz
252
+
253
+
- err actually going to make mistakes and try with snap
254
+
`snap install nginx-prometheus-exporter`
255
+
- so it got a binary for me but no systemd task set up. boooo.
256
+
`snap remove nginx-prometheus-exporter`
257
+
258
+
- ```bash
259
+
curl -LO https://github.com/nginx/nginx-prometheus-exporter/releases/download/v1.4.1/nginx-prometheus-exporter_1.4.1_linux_amd64.tar.gz
260
+
tar xzf nginx-prometheus-exporter_1.4.1_linux_amd64.tar.gz
261
+
mv nginx-prometheus-exporter /usr/local/bin
262
+
useradd --no-create-home --shell /bin/false nginx-prometheus-exporter
263
+
nano /etc/systemd/system/nginx-prometheus-exporter.service
264
+
# [Unit]
265
+
# Description=NGINX Exporter
266
+
# Wants=network-online.target
267
+
# After=network-online.target
268
+
269
+
# [Service]
270
+
# User=nginx-prometheus-exporter
271
+
# Group=nginx-prometheus-exporter
272
+
# Type=simple
273
+
# ExecStart=/usr/local/bin/nginx-prometheus-exporter --nginx.scrape-uri=http://gateway:8080/stub_status --web.listen-address=gateway:9113
274
+
# Restart=always
275
+
# RestartSec=3
276
+
277
+
# [Install]
278
+
# WantedBy=multi-user.target
279
+
systemctl daemon-reload
280
+
systemctl start nginx-prometheus-exporter.service
281
+
systemctl enable nginx-prometheus-exporter.service
282
+
```
283
+
284
+
- nginx `/etc/nginx/sites-available/gateway-nginx-status`
285
+
286
+
```nginx
287
+
server {
288
+
listen 8080;
289
+
listen [::]:8080;
290
+
291
+
server_name gateway;
292
+
293
+
location /stub_status {
294
+
stub_status;
295
+
}
296
+
location / {
297
+
return 404;
298
+
}
299
+
}
300
+
```
301
+
302
+
```bash
303
+
ln -s /etc/nginx/sites-available/gateway-nginx-status /etc/nginx/sites-enabled/
304
+
```
305
+
306
+
307
+
## bootes (pi5)
308
+
309
+
- mount sd card, touch `ssh` file echo `echo "pi:$(echo raspberry | openssl passwd -6 -stdin)" > userconf.txt`
310
+
- raspi-config: enable pcie 3, set hostname, enable ssh
311
+
- put ssh key into `.ssh/authorized_keys`
312
+
- put `PasswordAuthentication no` in `/etc/ssh/sshd_config`
313
+
- `sudo apt update && sudo apt upgrade`
314
+
- `sudo apt install xfsprogs`
315
+
- `sudo mkfs.xfs -L c11n-kv /dev/nvme0n1`
316
+
- `sudo mount /dev/nvme0n1 /mnt`
317
+
- set up tailscale
318
+
- `sudo tailscale up`
319
+
- `git clone https://github.com/atcosm/links.git`
320
+
- tailscale: disable bootes key expiry
321
+
- rustup `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
322
+
- `cd links/constellation`
323
+
- `sudo apt install libssl-dev` needed
324
+
- `sudo apt install clang` needed for bindgen
325
+
- (in tmux) `cargo build --release`
326
+
- `mkdir ~/backup`
327
+
- `sudo mount.cifs "//truenas.local/folks data" /home/pi/backup -o user=phil,uid=pi`
328
+
- `sudo chown pi:pi /mnt/`
329
+
- `RUST_BACKTRACE=full cargo run --bin rocks-restore-from-backup --release -- --from-backup-dir "/home/pi/backup/constellation-index" --to-data-dir /mnt/constellation-index`
330
+
etc
331
+
- follow above `- raspi node_exporter`
332
+
- configure victoriametrics to scrape the new pi
333
+
- configure ulimit before starting! `ulimit -n 16384`
334
+
- `RUST_BACKTRACE=full cargo run --release -- --backend rocks --data /mnt/constellation-index/ --jetstream us-east-2 --backup /home/pi/backup/constellation-index --backup-interval 6 --max-old-backups 20`
335
+
- add server to nginx gateway upstream: ` server 100.123.79.12:6789; # bootes`
336
+
- stop backups from running on the older instance! `RUST_BACKTRACE=full cargo run --release -- --backend rocks --data /mnt/links-2.rocks/ --jetstream us-east-1`
337
+
- stop upstreaming requests to older instance in nginx
338
+
339
+
340
+
- systemd unit for running: `sudo nano /etc/systemd/system/constellation.service`
341
+
342
+
```ini
343
+
[Unit]
344
+
Description=Constellation backlinks index
345
+
After=network.target
346
+
347
+
[Service]
348
+
User=pi
349
+
WorkingDirectory=/home/pi/links/constellation
350
+
ExecStart=/home/pi/links/target/release/main --backend rocks --data /mnt/constellation-index/ --jetstream us-east-2 --backup /home/pi/backup/constellation-index --backup-interval 6 --max-old-backups 20
351
+
LimitNOFILE=16384
352
+
Restart=always
353
+
354
+
[Install]
355
+
WantedBy=multi-user.target
356
+
```
357
+
358
+
359
+
- todo: overlayfs? would need to figure out builds/updates still, also i guess logs are currently written to sd? (oof)
360
+
- todo: cross-compile for raspi?
361
+
362
+
---
363
+
364
+
some todos
365
+
366
+
- [x] tailscale: exit node
367
+
- [!] link_aggregator: use exit node
368
+
-> worked, but reverted for now: tailscale on raspi was consuming ~50% cpu for the jetstream traffic. this might be near its max since it would have been catching up at the time (max jetstream throughput) but it feels a bit too much. we have to trust the jetstream server and link_aggregator doesn't (yet) make any other external connections, so for now the raspi connects directly from my home again.
369
+
- [x] caddy: reverse proxy
370
+
- [x] build with cache and rate-limit plugins
371
+
- [x] configure systemd to keep it alive
372
+
- [x] configure caddy cache
373
+
- [x] configure caddy rate-limit
374
+
- [ ] configure ~caddy~ nginx to use a health check (once it's added)
375
+
- [ ] ~configure caddy to only expose cache metrics to tailnet :/~
376
+
- [x] make some grafana dashboards
377
+
- [ ] raspi: mount /dev/sda on boot
378
+
- [ ] raspi: run link_aggregator via systemd so it starts on startup (and restarts?)
379
+
380
+
- [x] use nginx instead of caddy
381
+
- [x] nginx: enable cache
382
+
- [x] nginx: rate-limit
383
+
- [ ] nginx: get metrics
384
+
385
+
386
+
387
+
388
+
---
389
+
390
+
nginx cors for constellation + small burst bump
391
+
392
+
```nginx
393
+
upstream cozy_constellation {
394
+
server <tailnet ip>:6789; # bootes; ip so that we don't race on reboot with tailscale coming up, which nginx doesn't like
395
+
keepalive 16;
396
+
}
397
+
398
+
server {
399
+
server_name constellation.microcosm.blue;
400
+
401
+
proxy_cache cozy_zone;
402
+
proxy_cache_background_update on;
403
+
proxy_cache_key "$scheme$proxy_host$uri$is_args$args$http_accept";
404
+
proxy_cache_lock on; # make simlutaneous requests for the same uri wait for it to appear in cache instead of hitting origin
405
+
proxy_cache_lock_age 1s;
406
+
proxy_cache_lock_timeout 2s;
407
+
proxy_cache_valid 10s; # default -- should be explicitly set in the response headers
408
+
proxy_cache_valid any 2s; # non-200s default
409
+
proxy_read_timeout 5s;
410
+
proxy_send_timeout 15s;
411
+
proxy_socket_keepalive on;
412
+
413
+
# take over cors responsibility from upsteram. `always` applies it to error responses.
414
+
proxy_hide_header 'Access-Control-Allow-Origin';
415
+
proxy_hide_header 'Access-Control-Allowed-Methods';
416
+
proxy_hide_header 'Access-Control-Allow-Headers';
417
+
add_header 'Access-Control-Allow-Origin' '*' always;
418
+
add_header 'Access-Control-Allow-Methods' 'GET' always;
419
+
add_header 'Access-Control-Allow-Headers' '*' always;
420
+
421
+
422
+
limit_req zone=cozy_ip_limit nodelay burst=150;
423
+
limit_req zone=cozy_global_limit burst=1800;
424
+
limit_req_status 429;
425
+
426
+
location / {
427
+
proxy_pass http://cozy_constellation;
428
+
include proxy_params;
429
+
proxy_http_version 1.1;
430
+
proxy_set_header Connection ""; # for keepalive
431
+
}
432
+
433
+
434
+
listen 443 ssl; # managed by Certbot
435
+
ssl_certificate /etc/letsencrypt/live/constellation.microcosm.blue/fullchain.pem; # managed by Certbot
436
+
ssl_certificate_key /etc/letsencrypt/live/constellation.microcosm.blue/privkey.pem; # managed by Certbot
437
+
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
438
+
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
439
+
440
+
}
441
+
442
+
server {
443
+
if ($host = constellation.microcosm.blue) {
444
+
return 301 https://$host$request_uri;
445
+
} # managed by Certbot
446
+
447
+
448
+
server_name constellation.microcosm.blue;
449
+
listen 80;
450
+
return 404; # managed by Certbot
451
+
}
452
+
```
453
+
454
+
re-reading about `nodelay`, i should probably remove it -- nginx would then queue requests to upstream, but still service them at the configured limit. it's fine for my internet since the global limit isn't nodelay, but probably less "fair" to clients if there's contention around the global limit (earlier requests would get all of theirs serviced before later ones can get in the queue)
455
+
456
+
leaving it for now though.
457
+
458
+
459
+
### nginx logs to prom
460
+
461
+
```bash
462
+
curl -LO https://github.com/martin-helmich/prometheus-nginxlog-exporter/releases/download/v1.11.0/prometheus-nginxlog-exporter_1.11.0_linux_amd64.deb
463
+
apt install ./prometheus-nginxlog-exporter_1.11.0_linux_amd64.deb
464
+
systemctl enable prometheus-nginxlog-exporter.service
465
+
466
+
```
467
+
468
+
have it run as www-data (maybe not the best idea but...)
469
+
file `/usr/lib/systemd/system/prometheus-nginxlog-exporter.service`
470
+
set User under service and remove capabilities bounding
471
+
472
+
```systemd
473
+
User=www-data
474
+
#CapabilityBoundingSet=
475
+
```
476
+
477
+
in `nginx.conf` in `http`:
478
+
479
+
```nginx
480
+
log_format constellation_format "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\"";
481
+
```
482
+
483
+
in `sites-available/constellation.microcosm.blue` in `server`:
484
+
485
+
```nginx
486
+
# log format must match prometheus-nginx-log-exporter
487
+
access_log /var/log/nginx/constellation-access.log constellation_format;
488
+
```
489
+
490
+
config at `/etc/prometheus-nginxlog-exporter.hcl`
491
+
492
+
493
+
494
+
```bash
495
+
systemctl start prometheus-nginxlog-exporter.service
496
+
```
+35
legacy/old-readme-details.md
+35
legacy/old-readme-details.md
···
1
+
[Constellation](./constellation/)
2
+
--------------------------------------------
3
+
4
+
A global atproto backlink index ✨
5
+
6
+
- Self hostable: handles the full write throughput of the global atproto firehose on a raspberry pi 4b + single SSD
7
+
- Storage efficient: less than 2GB/day disk consumption indexing all references in all lexicons and all non-atproto URLs
8
+
- Handles record deletion, account de/re-activation, and account deletion, ensuring accurate link counts and respecting users data choices
9
+
- Simple JSON API
10
+
11
+
All social interactions in atproto tend to be represented by links (or references) between PDS records. This index can answer questions like "how many likes does a bsky post have", "who follows an account", "what are all the comments on a [frontpage](https://frontpage.fyi/) post", and more.
12
+
13
+
- **status**: works! api is unstable and likely to change, and no known instances have a full network backfill yet.
14
+
- source: [./constellation/](./constellation/)
15
+
- public instance: [constellation.microcosm.blue](https://constellation.microcosm.blue/)
16
+
17
+
_note: the public instance currently runs on a little raspberry pi in my house, feel free to use it! it comes with only with best-effort uptime, no commitment to not breaking the api for now, and possible rate-limiting. if you want to be nice you can put your project name and bsky username (or email) in your user-agent header for api requests._
18
+
19
+
20
+
App: Spacedust
21
+
--------------
22
+
23
+
A notification subscription service 💫
24
+
25
+
using the same "link source" concept as [constellation](./constellation/), offer webhook notifications for new references created to records
26
+
27
+
- **status**: in design
28
+
29
+
30
+
Library: [links](./links/)
31
+
------------------------------------
32
+
33
+
A rust crate (not published on crates.io yet) for optimistically parsing links out of arbitrary atproto PDS records, and potentially canonicalizing them
34
+
35
+
- **status**: unstable, might remain an internal lib for constellation (and spacedust, soon)
+123
legacy/original-notes.md
+123
legacy/original-notes.md
···
1
+
---
2
+
3
+
4
+
old notes follow, ignore
5
+
------------------------
6
+
7
+
8
+
as far as i can tell, atproto lexicons today don't follow much of a convention for referencing across documents: sometimes it's a StrongRef, sometimes it's a DID, sometimes it's a bare at-uri. lexicon authors choose any old link-sounding key name for the key in their document.
9
+
10
+
it's pretty messy so embrace the mess: atproto wants to be part of the web, so this library will also extract URLs and other URIs if you want it to. all the links.
11
+
12
+
13
+
why
14
+
---
15
+
16
+
the atproto firehose that bluesky sprays at you will contain raw _contents_ from peoples' pdses. these are isolated, decontextualized updates. it's very easy to build some kinds of interesting downstream apps off of this feed.
17
+
18
+
- bluesky posts (firesky, deletions, )
19
+
- blueksy post stats (emojis, )
20
+
- trending keywords ()
21
+
22
+
but bringing almost kind of _context_ into your project requires a big step up in complexity and potentially cost: you're entering "appview" territory. _how many likes does a post have? who follows this account?_
23
+
24
+
you own your atproto data: it's kept in your personal data repository (PDS) and noone else can write to it. when someone likes your post, they create a "like" record in their _own_ pds, and that like belongs to _them_, not to you/your post.
25
+
26
+
in the firehose you'll see a `app.bsky.feed.post` record created, with no details about who has liked it. then you'll see separate `app.bsky.feed.like` records show up for each like that comes in on that post, with no context about the post except a random-looking reference to it. storing these in order to do so is up to you!
27
+
28
+
**so, why**
29
+
30
+
everything is links, and they're a mess, but they all kinda work the same, so maybe some tooling can bring down that big step in complexity from firehose raw-content apps -> apps requiring any social context.
31
+
32
+
everything is links:
33
+
34
+
- likes
35
+
- follows
36
+
- blocks
37
+
- reposts
38
+
- quotes
39
+
40
+
some low-level things you could make from links:
41
+
42
+
- notification streams (part of ucosm)
43
+
- a global reverse index (part of ucosm)
44
+
45
+
i think that making these low-level services as easy to use as jetstream could open up pathways for building more atproto apps that operate at full scale with interesting features for reasonable effort at low cost to operate.
46
+
47
+
48
+
extracting links
49
+
---------------
50
+
51
+
52
+
- low-level: pass a &str of a field value and get a parsed link back
53
+
54
+
- med-level: pass a &str of record in json form and get a list of parsed links + json paths back. (todo: should also handle dag-cbor prob?)
55
+
56
+
- high-ish level: pass the json record and maybe apply some pre-loaded rules based on known lexicons to get the best result.
57
+
58
+
for now, a link is only considered if it matches for the entire value of the record's field -- links embedded in text content are not included. note that urls in bluesky posts _will_ still be extracted, since they are broken out into facets.
59
+
60
+
61
+
resolving / canonicalizing links
62
+
--------------------------------
63
+
64
+
65
+
### at-uris
66
+
67
+
every at-uri has at least two equivalent forms, one with a `DID`, and one with an account handle. the at-uri spec [illustrates this by example](https://atproto.com/specs/at-uri-scheme):
68
+
69
+
- `at://did:plc:44ybard66vv44zksje25o7dz/app.bsky.feed.post/3jwdwj2ctlk26`
70
+
- `at://bnewbold.bsky.team/app.bsky.feed.post/3jwdwj2ctlk26`
71
+
72
+
some applications, like a reverse link index, may wish to canonicalize at-uris to a single form. the `DID`-form is stable as an account changes its handle and probably the right choice to canonicalize to, but maybe some apps would actually perfer to canonicalise to handles?
73
+
74
+
hopefully atrium will make it easy to resolve at-uris.
75
+
76
+
77
+
### urls
78
+
79
+
canonicalizing URLs is more annoying but also a bit more established. lots of details.
80
+
81
+
- do we have to deal with punycode?
82
+
- follow redirects (todo: only permanent ones, or all?)
83
+
- check for rel=canonical http header and possibly follow it
84
+
- check link rel=canonical meta tag and possibly follow it
85
+
- do we need to check site maps??
86
+
- do we have to care at all about AMP?
87
+
- do we want anything to do with url shorteners??
88
+
- how do multilingual sites affect this?
89
+
- do we have to care about `script type="application/ld+json"` ???
90
+
91
+
ugh. is there a crate for this.
92
+
93
+
94
+
### relative uris?
95
+
96
+
links might be relative, in which case they might need to be made absolute before being useful. is that a concern for this library, or up to the user? (seems like we might not have context here to determine its absolute)
97
+
98
+
99
+
### canonicalizing
100
+
101
+
there should be a few async functions available to canonicalize already-parsed links.
102
+
103
+
- what happens if a link can't be resolved?
104
+
105
+
106
+
---
107
+
108
+
- using `tinyjson` because it's nice -- maybe should switch to serde_json to share deps with atrium?
109
+
110
+
- would use atrium for parsing at-uris, but it's not in there. there's a did-only version in the non-lib commands.rs. its identifier parser is strict to did + handle, which makes sense, but for our purposes we might want to allow unknown methods too?
111
+
112
+
- rsky-syntax has an aturi
113
+
- adenosyne also
114
+
- might come back to these
115
+
116
+
117
+
-------
118
+
119
+
rocks
120
+
121
+
```bash
122
+
ROCKSDB_LIB_DIR=/nix/store/z2chn0hsik0clridr8mlprx1cngh1g3c-rocksdb-9.7.3/lib/ cargo build
123
+
```
+196
legacy/ufos ops (move to micro-ops).md
+196
legacy/ufos ops (move to micro-ops).md
···
1
+
ufos ops
2
+
3
+
btrfs snapshots: snapper
4
+
5
+
```bash
6
+
sudo apt install snapper
7
+
sudo snapper -c ufos-db create-config /mnt/ufos-db
8
+
9
+
# edit /etc/snapper/configs/ufos-db
10
+
# change
11
+
TIMELINE_MIN_AGE="1800"
12
+
TIMELINE_LIMIT_HOURLY="10"
13
+
TIMELINE_LIMIT_DAILY="10"
14
+
TIMELINE_LIMIT_WEEKLY="0"
15
+
TIMELINE_LIMIT_MONTHLY="10"
16
+
TIMELINE_LIMIT_YEARLY="10"
17
+
# to
18
+
TIMELINE_MIN_AGE="1800"
19
+
TIMELINE_LIMIT_HOURLY="22"
20
+
TIMELINE_LIMIT_DAILY="4"
21
+
TIMELINE_LIMIT_WEEKLY="0"
22
+
TIMELINE_LIMIT_MONTHLY="0"
23
+
TIMELINE_LIMIT_YEARLY="0"
24
+
```
25
+
26
+
this should be enough?
27
+
28
+
list snapshots:
29
+
30
+
```bash
31
+
sudo snapper -c ufos-db list
32
+
```
33
+
34
+
systemd
35
+
36
+
create file: `/etc/systemd/system/ufos.service`
37
+
38
+
```ini
39
+
[Unit]
40
+
Description=UFOs-API
41
+
After=network.target
42
+
43
+
[Service]
44
+
User=pi
45
+
WorkingDirectory=/home/pi/
46
+
ExecStart=/home/pi/ufos --jetstream us-west-2 --data /mnt/ufos-db/
47
+
Environment="RUST_LOG=info"
48
+
LimitNOFILE=16384
49
+
Restart=always
50
+
51
+
[Install]
52
+
WantedBy=multi-user.target
53
+
```
54
+
55
+
then
56
+
57
+
```bash
58
+
sudo systemctl daemon-reload
59
+
sudo systemctl enable ufos
60
+
sudo systemctl start ufos
61
+
```
62
+
63
+
monitor with
64
+
65
+
```bash
66
+
journalctl -u ufos -f
67
+
```
68
+
69
+
make sure a backup dir exists
70
+
71
+
```bash
72
+
mkdir /home/pi/backup
73
+
```
74
+
75
+
mount the NAS
76
+
77
+
```bash
78
+
sudo mount.cifs "//truenas.local/folks data" /home/pi/backup -o user=phil,uid=pi
79
+
```
80
+
81
+
manual rsync
82
+
83
+
```bash
84
+
sudo rsync -ahP --delete /mnt/ufos-db/.snapshots/1/snapshot/ backup/ufos/
85
+
```
86
+
87
+
backup script sketch
88
+
89
+
```bash
90
+
NUM=$(sudo snapper --csvout -c ufos-db list --type single --columns number | tail -n1)
91
+
sudo rsync -ahP --delete "/mnt/ufos-db/.snapshots/${NUM}/snapshot/" backup/ufos/
92
+
```
93
+
94
+
just crontab it?
95
+
96
+
`sudo crontab -e`
97
+
```bash
98
+
0 1/6 * * * rsync -ahP --delete "/mnt/ufos-db/.snapshots/$(sudo snapper --csvout -c ufos-db list --columns number | tail -n1)/snapshot/" backup/ufos/
99
+
```
100
+
101
+
^^ try once initial backup is done
102
+
103
+
104
+
--columns subvolume,number
105
+
106
+
subvolume
107
+
number
108
+
109
+
110
+
111
+
112
+
gateway: follow constellation for nginx->prom thing
113
+
114
+
config at `/etc/prometheus-nginxlog-exporter.hcl`
115
+
116
+
before: `/etc/prometheus-nginxlog-exporter.hcl`
117
+
118
+
```hcl
119
+
listen {
120
+
port = 4044
121
+
}
122
+
123
+
namespace "nginx" {
124
+
source = {
125
+
files = [
126
+
"/var/log/nginx/constellation-access.log"
127
+
]
128
+
}
129
+
130
+
format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $upstream_cache_status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
131
+
132
+
labels {
133
+
app = "constellation"
134
+
}
135
+
136
+
relabel "cache_status" {
137
+
from = "upstream_cache_status"
138
+
}
139
+
}
140
+
```
141
+
142
+
after:
143
+
144
+
```hcl
145
+
listen {
146
+
port = 4044
147
+
}
148
+
149
+
namespace "constellation" {
150
+
source = {
151
+
files = [
152
+
"/var/log/nginx/constellation-access.log"
153
+
]
154
+
}
155
+
156
+
format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $upstream_cache_status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
157
+
158
+
labels {
159
+
app = "constellation"
160
+
}
161
+
162
+
relabel "cache_status" {
163
+
from = "upstream_cache_status"
164
+
}
165
+
166
+
namespace_label = "vhost"
167
+
metrics_override = { prefix = "nginx" }
168
+
}
169
+
170
+
namespace "ufos" {
171
+
source = {
172
+
files = [
173
+
"/var/log/nginx/ufos-access.log"
174
+
]
175
+
}
176
+
177
+
format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $upstream_cache_status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
178
+
179
+
labels {
180
+
app = "ufos"
181
+
}
182
+
183
+
relabel "cache_status" {
184
+
from = "upstream_cache_status"
185
+
}
186
+
187
+
namespace_label = "vhost"
188
+
metrics_override = { prefix = "nginx" }
189
+
}
190
+
```
191
+
192
+
193
+
```bash
194
+
systemctl start prometheus-nginxlog-exporter.service
195
+
```
196
+
+2
links/Cargo.toml
+2
links/Cargo.toml
+3
-2
links/src/lib.rs
+3
-2
links/src/lib.rs
···
1
1
use fluent_uri::Uri;
2
+
use serde::{Deserialize, Serialize};
2
3
3
4
pub mod at_uri;
4
5
pub mod did;
···
6
7
7
8
pub use record::collect_links;
8
9
9
-
#[derive(Debug, Clone, Ord, Eq, PartialOrd, PartialEq)]
10
+
#[derive(Debug, Clone, Ord, Eq, PartialOrd, PartialEq, Serialize, Deserialize)]
10
11
pub enum Link {
11
12
AtUri(String),
12
13
Uri(String),
···
59
60
}
60
61
}
61
62
62
-
#[derive(Debug, PartialEq)]
63
+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
63
64
pub struct CollectedLink {
64
65
pub path: String,
65
66
pub target: Link,
+41
links/src/record.rs
+41
links/src/record.rs
···
1
+
use dasl::drisl::Value as DrislValue;
1
2
use tinyjson::JsonValue;
2
3
3
4
use crate::{parse_any_link, CollectedLink};
···
36
37
}
37
38
}
38
39
40
+
pub fn walk_drisl(path: &str, v: &DrislValue, found: &mut Vec<CollectedLink>) {
41
+
match v {
42
+
DrislValue::Map(o) => {
43
+
for (key, child) in o {
44
+
walk_drisl(&format!("{path}.{key}"), child, found)
45
+
}
46
+
}
47
+
DrislValue::Array(a) => {
48
+
for child in a {
49
+
let child_p = match child {
50
+
DrislValue::Map(o) => {
51
+
if let Some(DrislValue::Text(t)) = o.get("$type") {
52
+
format!("{path}[{t}]")
53
+
} else {
54
+
format!("{path}[]")
55
+
}
56
+
}
57
+
_ => format!("{path}[]"),
58
+
};
59
+
walk_drisl(&child_p, child, found)
60
+
}
61
+
}
62
+
DrislValue::Text(s) => {
63
+
if let Some(link) = parse_any_link(s) {
64
+
found.push(CollectedLink {
65
+
path: path.to_string(),
66
+
target: link,
67
+
});
68
+
}
69
+
}
70
+
_ => {}
71
+
}
72
+
}
73
+
39
74
pub fn collect_links(v: &JsonValue) -> Vec<CollectedLink> {
40
75
let mut found = vec![];
41
76
walk_record("", v, &mut found);
77
+
found
78
+
}
79
+
80
+
pub fn collect_links_drisl(v: &DrislValue) -> Vec<CollectedLink> {
81
+
let mut found = vec![];
82
+
walk_drisl("", v, &mut found);
42
83
found
43
84
}
44
85
+1
pocket/.gitignore
+1
pocket/.gitignore
···
1
+
prefs.sqlite3*
+19
pocket/Cargo.toml
+19
pocket/Cargo.toml
···
1
+
[package]
2
+
name = "pocket"
3
+
version = "0.1.0"
4
+
edition = "2024"
5
+
6
+
[dependencies]
7
+
atrium-crypto = "0.1.2"
8
+
clap = { version = "4.5.41", features = ["derive"] }
9
+
jwt-compact = { git = "https://github.com/fatfingers23/jwt-compact.git", features = ["es256k"] }
10
+
log = "0.4.27"
11
+
poem = { version = "3.1.12", features = ["acme", "static-files"] }
12
+
poem-openapi = { version = "5.1.16", features = ["scalar"] }
13
+
reqwest = { version = "0.12.22", features = ["json"] }
14
+
rusqlite = "0.37.0"
15
+
serde = { version = "1.0.219", features = ["derive"] }
16
+
serde_json = { version = "1.0.141" }
17
+
thiserror = "2.0.16"
18
+
tokio = { version = "1.47.0", features = ["full"] }
19
+
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
+17
pocket/api-description.md
+17
pocket/api-description.md
···
1
+
_A pocket dimension to stash a bit of non-public user data._
2
+
3
+
4
+
# Pocket: user preference storage
5
+
6
+
This API leverages atproto service proxying to offer a bit of per-user per-app non-public data storage.
7
+
Perfect for things like application preferences that might be better left out of the public PDS data.
8
+
9
+
The intent is to use oauth scopes to isolate storage on a per-application basis, and to allow easy data migration from a community hosted instance to your own if you end up needing that.
10
+
11
+
12
+
### Current status
13
+
14
+
> [!important]
15
+
> Pocket is currently in a **v0, pre-release state**. There is one production instance and you can use it! Expect short downtimes for restarts as development progresses and occaisional data loss until it's stable.
16
+
17
+
ATProto might end up adding a similar feature to [PDSs](https://atproto.com/guides/glossary#pds-personal-data-server). If/when that happens, you should use it instead of this!
+7
pocket/src/lib.rs
+7
pocket/src/lib.rs
+34
pocket/src/main.rs
+34
pocket/src/main.rs
···
1
+
use clap::Parser;
2
+
use pocket::{Storage, serve};
3
+
use std::path::PathBuf;
4
+
5
+
/// Slingshot record edge cache
6
+
#[derive(Parser, Debug, Clone)]
7
+
#[command(version, about, long_about = None)]
8
+
struct Args {
9
+
/// path to the sqlite db file
10
+
#[arg(long)]
11
+
db: Option<PathBuf>,
12
+
/// just initialize the db and exit
13
+
#[arg(long, action)]
14
+
init_db: bool,
15
+
/// the domain for serving a did doc (unused if running behind reflector)
16
+
#[arg(long)]
17
+
domain: Option<String>,
18
+
}
19
+
20
+
#[tokio::main]
21
+
async fn main() {
22
+
tracing_subscriber::fmt::init();
23
+
log::info!("👖 hi");
24
+
let args = Args::parse();
25
+
let domain = args.domain.unwrap_or("bad-example.com".into());
26
+
let db_path = args.db.unwrap_or("prefs.sqlite3".into());
27
+
if args.init_db {
28
+
Storage::init(&db_path).unwrap();
29
+
log::info!("👖 initialized db at {db_path:?}. bye")
30
+
} else {
31
+
let storage = Storage::connect(db_path).unwrap();
32
+
serve(&domain, storage).await
33
+
}
34
+
}
+265
pocket/src/server.rs
+265
pocket/src/server.rs
···
1
+
use crate::{Storage, TokenVerifier};
2
+
use poem::{
3
+
Endpoint, EndpointExt, Route, Server,
4
+
endpoint::{StaticFileEndpoint, make_sync},
5
+
http::Method,
6
+
listener::TcpListener,
7
+
middleware::{CatchPanic, Cors, Tracing},
8
+
};
9
+
use poem_openapi::{
10
+
ApiResponse, ContactObject, ExternalDocumentObject, Object, OpenApi, OpenApiService,
11
+
SecurityScheme, Tags,
12
+
auth::Bearer,
13
+
payload::{Json, PlainText},
14
+
types::Example,
15
+
};
16
+
use serde::Serialize;
17
+
use serde_json::{Value, json};
18
+
use std::sync::{Arc, Mutex};
19
+
20
+
#[derive(Debug, SecurityScheme)]
21
+
#[oai(ty = "bearer")]
22
+
struct XrpcAuth(Bearer);
23
+
24
+
#[derive(Tags)]
25
+
enum ApiTags {
26
+
/// Custom pocket APIs
27
+
#[oai(rename = "Pocket APIs")]
28
+
Pocket,
29
+
}
30
+
31
+
#[derive(Object)]
32
+
#[oai(example = true)]
33
+
struct XrpcErrorResponseObject {
34
+
/// Should correspond an error `name` in the lexicon errors array
35
+
error: String,
36
+
/// Human-readable description and possibly additonal context
37
+
message: String,
38
+
}
39
+
impl Example for XrpcErrorResponseObject {
40
+
fn example() -> Self {
41
+
Self {
42
+
error: "PreferencesNotFound".to_string(),
43
+
message: "No preferences were found for this user".to_string(),
44
+
}
45
+
}
46
+
}
47
+
type XrpcError = Json<XrpcErrorResponseObject>;
48
+
fn xrpc_error(error: impl AsRef<str>, message: impl AsRef<str>) -> XrpcError {
49
+
Json(XrpcErrorResponseObject {
50
+
error: error.as_ref().to_string(),
51
+
message: message.as_ref().to_string(),
52
+
})
53
+
}
54
+
55
+
#[derive(Debug, Object)]
56
+
#[oai(example = true)]
57
+
struct BskyPrefsObject {
58
+
/// at-uri for this record
59
+
preferences: Value,
60
+
}
61
+
impl Example for BskyPrefsObject {
62
+
fn example() -> Self {
63
+
Self {
64
+
preferences: json!({
65
+
"hello": "world",
66
+
}),
67
+
}
68
+
}
69
+
}
70
+
71
+
#[derive(ApiResponse)]
72
+
enum GetBskyPrefsResponse {
73
+
/// Record found
74
+
#[oai(status = 200)]
75
+
Ok(Json<BskyPrefsObject>),
76
+
/// Bad request or no preferences to return
77
+
#[oai(status = 400)]
78
+
BadRequest(XrpcError),
79
+
}
80
+
81
+
#[derive(ApiResponse)]
82
+
enum PutBskyPrefsResponse {
83
+
/// Record found
84
+
#[oai(status = 200)]
85
+
Ok(PlainText<String>),
86
+
/// Bad request or no preferences to return
87
+
#[oai(status = 400)]
88
+
BadRequest(XrpcError),
89
+
// /// Server errors
90
+
// #[oai(status = 500)]
91
+
// ServerError(XrpcError),
92
+
}
93
+
94
+
struct Xrpc {
95
+
verifier: TokenVerifier,
96
+
storage: Arc<Mutex<Storage>>,
97
+
}
98
+
99
+
#[OpenApi]
100
+
impl Xrpc {
101
+
/// com.bad-example.pocket.getPreferences
102
+
///
103
+
/// get stored preferencess
104
+
#[oai(
105
+
path = "/com.bad-example.pocket.getPreferences",
106
+
method = "get",
107
+
tag = "ApiTags::Pocket"
108
+
)]
109
+
async fn pocket_get_prefs(&self, XrpcAuth(auth): XrpcAuth) -> GetBskyPrefsResponse {
110
+
let (did, aud) = match self
111
+
.verifier
112
+
.verify("com.bad-example.pocket.getPreferences", &auth.token)
113
+
.await
114
+
{
115
+
Ok(d) => d,
116
+
Err(e) => return GetBskyPrefsResponse::BadRequest(xrpc_error("boooo", e.to_string())),
117
+
};
118
+
log::info!("verified did: {did}/{aud}");
119
+
120
+
let storage = self.storage.clone();
121
+
122
+
let Ok(Ok(res)) = tokio::task::spawn_blocking(move || {
123
+
storage
124
+
.lock()
125
+
.unwrap()
126
+
.get(&did, &aud)
127
+
.inspect_err(|e| log::error!("failed to get prefs: {e}"))
128
+
})
129
+
.await
130
+
else {
131
+
return GetBskyPrefsResponse::BadRequest(xrpc_error("boooo", "failed to get from db"));
132
+
};
133
+
134
+
let Some(serialized) = res else {
135
+
return GetBskyPrefsResponse::BadRequest(xrpc_error(
136
+
"NotFound",
137
+
"could not find prefs for u",
138
+
));
139
+
};
140
+
141
+
let preferences = match serde_json::from_str(&serialized) {
142
+
Ok(v) => v,
143
+
Err(e) => {
144
+
log::error!("failed to deserialize prefs: {e}");
145
+
return GetBskyPrefsResponse::BadRequest(xrpc_error(
146
+
"boooo",
147
+
"failed to deserialize prefs",
148
+
));
149
+
}
150
+
};
151
+
152
+
GetBskyPrefsResponse::Ok(Json(BskyPrefsObject { preferences }))
153
+
}
154
+
155
+
/// com.bad-example.pocket.putPreferences
156
+
///
157
+
/// store bluesky prefs
158
+
#[oai(
159
+
path = "/com.bad-example.pocket.putPreferences",
160
+
method = "post",
161
+
tag = "ApiTags::Pocket"
162
+
)]
163
+
async fn pocket_put_prefs(
164
+
&self,
165
+
XrpcAuth(auth): XrpcAuth,
166
+
Json(prefs): Json<BskyPrefsObject>,
167
+
) -> PutBskyPrefsResponse {
168
+
let (did, aud) = match self
169
+
.verifier
170
+
.verify("com.bad-example.pocket.putPreferences", &auth.token)
171
+
.await
172
+
{
173
+
Ok(d) => d,
174
+
Err(e) => return PutBskyPrefsResponse::BadRequest(xrpc_error("boooo", e.to_string())),
175
+
};
176
+
log::info!("verified did: {did}/{aud}");
177
+
log::warn!("received prefs: {prefs:?}");
178
+
179
+
let storage = self.storage.clone();
180
+
let serialized = prefs.preferences.to_string();
181
+
182
+
let Ok(Ok(())) = tokio::task::spawn_blocking(move || {
183
+
storage
184
+
.lock()
185
+
.unwrap()
186
+
.put(&did, &aud, &serialized)
187
+
.inspect_err(|e| log::error!("failed to insert prefs: {e}"))
188
+
})
189
+
.await
190
+
else {
191
+
return PutBskyPrefsResponse::BadRequest(xrpc_error("boooo", "failed to put to db"));
192
+
};
193
+
194
+
PutBskyPrefsResponse::Ok(PlainText("saved.".to_string()))
195
+
}
196
+
}
197
+
198
+
#[derive(Debug, Clone, Serialize)]
199
+
#[serde(rename_all = "camelCase")]
200
+
struct AppViewService {
201
+
id: String,
202
+
r#type: String,
203
+
service_endpoint: String,
204
+
}
205
+
#[derive(Debug, Clone, Serialize)]
206
+
struct AppViewDoc {
207
+
id: String,
208
+
service: [AppViewService; 2],
209
+
}
210
+
/// Serve a did document for did:web for this to be an xrpc appview
211
+
fn get_did_doc(domain: &str) -> impl Endpoint + use<> {
212
+
let doc = poem::web::Json(AppViewDoc {
213
+
id: format!("did:web:{domain}"),
214
+
service: [
215
+
AppViewService {
216
+
id: "#pocket_prefs".to_string(),
217
+
r#type: "PocketPreferences".to_string(),
218
+
service_endpoint: format!("https://{domain}"),
219
+
},
220
+
AppViewService {
221
+
id: "#bsky_appview".to_string(),
222
+
r#type: "BlueskyAppview".to_string(),
223
+
service_endpoint: format!("https://{domain}"),
224
+
},
225
+
],
226
+
});
227
+
make_sync(move |_| doc.clone())
228
+
}
229
+
230
+
pub async fn serve(domain: &str, storage: Storage) -> () {
231
+
let verifier = TokenVerifier::default();
232
+
let api_service = OpenApiService::new(
233
+
Xrpc {
234
+
verifier,
235
+
storage: Arc::new(Mutex::new(storage)),
236
+
},
237
+
"Pocket",
238
+
env!("CARGO_PKG_VERSION"),
239
+
)
240
+
.server(domain)
241
+
.url_prefix("/xrpc")
242
+
.contact(
243
+
ContactObject::new()
244
+
.name("@microcosm.blue")
245
+
.url("https://bsky.app/profile/microcosm.blue"),
246
+
)
247
+
.description(include_str!("../api-description.md"))
248
+
.external_document(ExternalDocumentObject::new("https://microcosm.blue/pocket"));
249
+
250
+
let app = Route::new()
251
+
.nest("/openapi", api_service.spec_endpoint())
252
+
.nest("/xrpc/", api_service)
253
+
.at("/.well-known/did.json", get_did_doc(domain))
254
+
.at("/", StaticFileEndpoint::new("./static/index.html"))
255
+
.with(
256
+
Cors::new()
257
+
.allow_method(Method::GET)
258
+
.allow_method(Method::POST),
259
+
)
260
+
.with(CatchPanic::new())
261
+
.with(Tracing);
262
+
263
+
let listener = TcpListener::bind("127.0.0.1:3000");
264
+
Server::new(listener).name("pocket").run(app).await.unwrap();
265
+
}
+50
pocket/src/storage.rs
+50
pocket/src/storage.rs
···
1
+
use rusqlite::{Connection, OptionalExtension, Result};
2
+
use std::path::Path;
3
+
4
+
pub struct Storage {
5
+
con: Connection,
6
+
}
7
+
8
+
impl Storage {
9
+
pub fn connect(path: impl AsRef<Path>) -> Result<Self> {
10
+
let con = Connection::open(path)?;
11
+
con.pragma_update(None, "journal_mode", "WAL")?;
12
+
con.pragma_update(None, "synchronous", "NORMAL")?;
13
+
con.pragma_update(None, "busy_timeout", "100")?;
14
+
con.pragma_update(None, "foreign_keys", "ON")?;
15
+
Ok(Self { con })
16
+
}
17
+
pub fn init(path: impl AsRef<Path>) -> Result<Self> {
18
+
let me = Self::connect(path)?;
19
+
me.con.execute(
20
+
r#"
21
+
create table prefs (
22
+
actor text not null,
23
+
aud text not null,
24
+
pref text not null,
25
+
primary key (actor, aud)
26
+
) strict"#,
27
+
(),
28
+
)?;
29
+
Ok(me)
30
+
}
31
+
pub fn put(&self, actor: &str, aud: &str, pref: &str) -> Result<()> {
32
+
self.con.execute(
33
+
r#"insert into prefs (actor, aud, pref)
34
+
values (?1, ?2, ?3)
35
+
on conflict do update set pref = excluded.pref"#,
36
+
[actor, aud, pref],
37
+
)?;
38
+
Ok(())
39
+
}
40
+
pub fn get(&self, actor: &str, aud: &str) -> Result<Option<String>> {
41
+
self.con
42
+
.query_one(
43
+
r#"select pref from prefs
44
+
where actor = ?1 and aud = ?2"#,
45
+
[actor, aud],
46
+
|row| row.get(0),
47
+
)
48
+
.optional()
49
+
}
50
+
}
+143
pocket/src/token.rs
+143
pocket/src/token.rs
···
1
+
use atrium_crypto::did::parse_multikey;
2
+
use atrium_crypto::verify::Verifier;
3
+
use jwt_compact::UntrustedToken;
4
+
use serde::Deserialize;
5
+
use std::collections::HashMap;
6
+
use std::time::Duration;
7
+
use thiserror::Error;
8
+
9
+
#[derive(Debug, Deserialize)]
10
+
struct MiniDoc {
11
+
signing_key: String,
12
+
did: String,
13
+
}
14
+
15
+
#[derive(Error, Debug)]
16
+
pub enum VerifyError {
17
+
#[error("The cross-service authorization token failed verification: {0}")]
18
+
VerificationFailed(&'static str),
19
+
#[error("Error trying to resolve the DID to a signing key, retry in a moment: {0}")]
20
+
ResolutionFailed(&'static str),
21
+
}
22
+
23
+
pub struct TokenVerifier {
24
+
client: reqwest::Client,
25
+
}
26
+
27
+
impl TokenVerifier {
28
+
pub fn new() -> Self {
29
+
let client = reqwest::Client::builder()
30
+
.user_agent(format!(
31
+
"microcosm pocket v{} (dev: @bad-example.com)",
32
+
env!("CARGO_PKG_VERSION")
33
+
))
34
+
.no_proxy()
35
+
.timeout(Duration::from_secs(12)) // slingshot timeout is 10s
36
+
.build()
37
+
.unwrap();
38
+
Self { client }
39
+
}
40
+
41
+
pub async fn verify(
42
+
&self,
43
+
expected_lxm: &str,
44
+
token: &str,
45
+
) -> Result<(String, String), VerifyError> {
46
+
let untrusted = UntrustedToken::new(token).unwrap();
47
+
48
+
// danger! unfortunately we need to decode the DID from the jwt body before we have a public key to verify the jwt with
49
+
let Ok(untrusted_claims) =
50
+
untrusted.deserialize_claims_unchecked::<HashMap<String, String>>()
51
+
else {
52
+
return Err(VerifyError::VerificationFailed(
53
+
"could not deserialize jtw claims",
54
+
));
55
+
};
56
+
57
+
// get the (untrusted!) claimed DID
58
+
let Some(untrusted_did) = untrusted_claims.custom.get("iss") else {
59
+
return Err(VerifyError::VerificationFailed(
60
+
"jwt must include the user's did in `iss`",
61
+
));
62
+
};
63
+
64
+
// bail if it's not even a user-ish did
65
+
if !untrusted_did.starts_with("did:") {
66
+
return Err(VerifyError::VerificationFailed("iss should be a did"));
67
+
}
68
+
if untrusted_did.contains("#") {
69
+
return Err(VerifyError::VerificationFailed(
70
+
"iss should be a user did without a service identifier",
71
+
));
72
+
}
73
+
74
+
let endpoint =
75
+
"https://slingshot.microcosm.blue/xrpc/com.bad-example.identity.resolveMiniDoc";
76
+
let doc: MiniDoc = self
77
+
.client
78
+
.get(format!("{endpoint}?identifier={untrusted_did}"))
79
+
.send()
80
+
.await
81
+
.map_err(|_| VerifyError::ResolutionFailed("failed to fetch minidoc"))?
82
+
.error_for_status()
83
+
.map_err(|_| VerifyError::ResolutionFailed("non-ok response for minidoc"))?
84
+
.json()
85
+
.await
86
+
.map_err(|_| VerifyError::ResolutionFailed("failed to parse json to minidoc"))?;
87
+
88
+
// sanity check before we go ahead with this signing key
89
+
if doc.did != *untrusted_did {
90
+
return Err(VerifyError::VerificationFailed(
91
+
"wtf, resolveMiniDoc returned a doc for a different DID, slingshot bug",
92
+
));
93
+
}
94
+
95
+
let Ok((alg, public_key)) = parse_multikey(&doc.signing_key) else {
96
+
return Err(VerifyError::VerificationFailed(
97
+
"could not parse signing key form minidoc",
98
+
));
99
+
};
100
+
101
+
// i _guess_ we've successfully bootstrapped the verification of the jwt unless this fails
102
+
if let Err(e) = Verifier::default().verify(
103
+
alg,
104
+
&public_key,
105
+
&untrusted.signed_data,
106
+
untrusted.signature_bytes(),
107
+
) {
108
+
log::warn!("jwt verification failed: {e}");
109
+
return Err(VerifyError::VerificationFailed(
110
+
"jwt signature verification failed",
111
+
));
112
+
}
113
+
114
+
// past this point we're should have established trust. crossing ts and dotting is.
115
+
let did = &untrusted_did;
116
+
let claims = &untrusted_claims;
117
+
118
+
let Some(aud) = claims.custom.get("aud") else {
119
+
return Err(VerifyError::VerificationFailed("missing aud"));
120
+
};
121
+
let Some(mut aud) = aud.strip_prefix("did:web:") else {
122
+
return Err(VerifyError::VerificationFailed("expected a did:web aud"));
123
+
};
124
+
if let Some((aud_without_hash, _)) = aud.split_once("#") {
125
+
log::warn!("aud claim is missing service id fragment: {aud:?}");
126
+
aud = aud_without_hash;
127
+
}
128
+
let Some(lxm) = claims.custom.get("lxm") else {
129
+
return Err(VerifyError::VerificationFailed("missing lxm"));
130
+
};
131
+
if lxm != expected_lxm {
132
+
return Err(VerifyError::VerificationFailed("wrong lxm"));
133
+
}
134
+
135
+
Ok((did.to_string(), aud.to_string()))
136
+
}
137
+
}
138
+
139
+
impl Default for TokenVerifier {
140
+
fn default() -> Self {
141
+
Self::new()
142
+
}
143
+
}
+67
pocket/static/index.html
+67
pocket/static/index.html
···
1
+
<!doctype html>
2
+
<html lang="en">
3
+
<head>
4
+
<meta charset="utf-8" />
5
+
<title>Pocket: atproto user preference storage</title>
6
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7
+
<meta name="description" content="API Documentation for Pocket, a simple user-preference storage system for atproto" />
8
+
<style>
9
+
:root {
10
+
--scalar-small: 13px;
11
+
}
12
+
.scalar-app .markdown .markdown-alert {
13
+
font-size: var(--scalar-small);
14
+
}
15
+
.sidebar-heading-link-title {
16
+
line-height: 1.2;
17
+
}
18
+
.custom-header {
19
+
height: 42px;
20
+
background-color: #221828;
21
+
box-shadow: inset 0 -1px 0 var(--scalar-border-color);
22
+
color: var(--scalar-color-1);
23
+
font-size: var(--scalar-font-size-3);
24
+
font-family: 'Iowan Old Style', 'Palatino Linotype', 'URW Palladio L', P052, serif;
25
+
padding: 0 18px;
26
+
justify-content: space-between;
27
+
}
28
+
.custom-header,
29
+
.custom-header nav {
30
+
display: flex;
31
+
align-items: center;
32
+
gap: 18px;
33
+
}
34
+
.custom-header a:hover {
35
+
color: var(--scalar-color-2);
36
+
}
37
+
38
+
.light-mode .custom-header {
39
+
background-color: thistle;
40
+
}
41
+
</style>
42
+
</head>
43
+
<body>
44
+
<header class="custom-header scalar-app">
45
+
<p>
46
+
TODO: thing
47
+
</p>
48
+
<nav>
49
+
<b>a <a href="https://microcosm.blue">microcosm</a> project</b>
50
+
<a href="https://bsky.app/profile/microcosm.blue">@microcosm.blue</a>
51
+
<a href="https://github.com/at-microcosm">github</a>
52
+
</nav>
53
+
</header>
54
+
55
+
<script id="api-reference" type="application/json" data-url="/openapi"></script>
56
+
57
+
<script>
58
+
var configuration = {
59
+
theme: 'purple',
60
+
hideModels: true,
61
+
}
62
+
document.getElementById('api-reference').dataset.configuration = JSON.stringify(configuration)
63
+
</script>
64
+
65
+
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
66
+
</body>
67
+
</html>
+8
quasar/Cargo.toml
+8
quasar/Cargo.toml
+3
quasar/readme.md
+3
quasar/readme.md
+57
-129
readme.md
+57
-129
readme.md
···
1
-
microcosm: links
2
-
================
3
-
4
-
this repo contains libraries and apps for working with cross-record references in at-protocol.
5
-
1
+
microcosm HTTP APIs + rust crates
2
+
=================================
3
+
[](https://bsky.app/profile/microcosm.blue)
4
+
[](https://discord.gg/tcDfe4PGVB)
5
+
[](https://github.com/sponsors/uniphil/)
6
+
[](https://ko-fi.com/bad_example)
6
7
7
-
App: [Constellation](./constellation/)
8
-
--------------------------------------------
8
+
Welcome! Documentation is under active development. If you like reading API docs, you'll probably hit the ground running!
9
9
10
-
A global atproto backlink index ✨
10
+
Tutorials, how-to guides, and client SDK libraries are all in the works for gentler on-ramps, but are not quite ready yet. But don't let that stop you! Hop in the [microcosm discord](https://discord.gg/tcDfe4PGVB), or post questions and tag [@bad-example.com](https://bsky.app/profile/bad-example.com) on Bluesky if you get stuck anywhere.
11
11
12
-
- Self hostable: handles the full write throughput of the global atproto firehose on a raspberry pi 4b + single SSD
13
-
- Storage efficient: less than 2GB/day disk consumption indexing all references in all lexicons and all non-atproto URLs
14
-
- Handles record deletion, account de/re-activation, and account deletion, ensuring accurate link counts and respecting users data choices
15
-
- Simple JSON API
12
+
> [!tip]
13
+
> This repository's primary home is moving to tangled: [@microcosm.blue/microcosm-rs](https://tangled.sh/@microcosm.blue/microcosm-rs). It will continue to be mirrored on [github](https://github.com/at-microcosm/microcosm-rs) for the forseeable future, and it's fine to open issues or pulls in either place!
16
14
17
-
All social interactions in atproto tend to be represented by links (or references) between PDS records. This index can answer questions like "how many likes does a bsky post have", "who follows an account", "what are all the comments on a [frontpage](https://frontpage.fyi/) post", and more.
18
15
19
-
- **status**: works! api is unstable and likely to change, and no known instances have a full network backfill yet.
20
-
- source: [./constellation/](./constellation/)
21
-
- public instance: [constellation.microcosm.blue](https://constellation.microcosm.blue/)
22
-
23
-
_note: the public instance currently runs on a little raspberry pi in my house, feel free to use it! it comes with only with best-effort uptime, no commitment to not breaking the api for now, and possible rate-limiting. if you want to be nice you can put your project name and bsky username (or email) in your user-agent header for api requests._
24
-
25
-
26
-
App: Spacedust
27
-
--------------
28
-
29
-
A notification subscription service 💫
30
-
31
-
using the same "link source" concept as [constellation](./constellation/), offer webhook notifications for new references created to records
32
-
33
-
- **status**: in design
34
-
35
-
36
-
Library: [links](./links/)
16
+
🌌 [Constellation](./constellation/)
37
17
------------------------------------
38
18
39
-
A rust crate (not published on crates.io yet) for optimistically parsing links out of arbitrary atproto PDS records, and potentially canonicalizing them
40
-
41
-
- **status**: unstable, might remain an internal lib for constellation (and spacedust, soon)
42
-
43
-
44
-
45
-
---
46
-
47
-
48
-
old notes follow, ignore
49
-
------------------------
50
-
51
-
52
-
as far as i can tell, atproto lexicons today don't follow much of a convention for referencing across documents: sometimes it's a StrongRef, sometimes it's a DID, sometimes it's a bare at-uri. lexicon authors choose any old link-sounding key name for the key in their document.
53
-
54
-
it's pretty messy so embrace the mess: atproto wants to be part of the web, so this library will also extract URLs and other URIs if you want it to. all the links.
55
-
56
-
57
-
why
58
-
---
59
-
60
-
the atproto firehose that bluesky sprays at you will contain raw _contents_ from peoples' pdses. these are isolated, decontextualized updates. it's very easy to build some kinds of interesting downstream apps off of this feed.
61
-
62
-
- bluesky posts (firesky, deletions, )
63
-
- blueksy post stats (emojis, )
64
-
- trending keywords ()
65
-
66
-
but bringing almost kind of _context_ into your project requires a big step up in complexity and potentially cost: you're entering "appview" territory. _how many likes does a post have? who follows this account?_
67
-
68
-
you own your atproto data: it's kept in your personal data repository (PDS) and noone else can write to it. when someone likes your post, they create a "like" record in their _own_ pds, and that like belongs to _them_, not to you/your post.
69
-
70
-
in the firehose you'll see a `app.bsky.feed.post` record created, with no details about who has liked it. then you'll see separate `app.bsky.feed.like` records show up for each like that comes in on that post, with no context about the post except a random-looking reference to it. storing these in order to do so is up to you!
71
-
72
-
**so, why**
73
-
74
-
everything is links, and they're a mess, but they all kinda work the same, so maybe some tooling can bring down that big step in complexity from firehose raw-content apps -> apps requiring any social context.
75
-
76
-
everything is links:
77
-
78
-
- likes
79
-
- follows
80
-
- blocks
81
-
- reposts
82
-
- quotes
83
-
84
-
some low-level things you could make from links:
85
-
86
-
- notification streams (part of ucosm)
87
-
- a global reverse index (part of ucosm)
88
-
89
-
i think that making these low-level services as easy to use as jetstream could open up pathways for building more atproto apps that operate at full scale with interesting features for reasonable effort at low cost to operate.
19
+
A global atproto interactions backlink index as a simple JSON API. Works with every lexicon, runs on a raspberry pi, consumes less than 2GiB of disk per day. Handles record deletion, account de/re-activation, and account deletion, ensuring accurate link counts while respecting users' data choices.
90
20
21
+
- Source: [./constellation/](./constellation/)
22
+
- [Public instance/API docs](https://constellation.microcosm.blue/)
23
+
- Status: used in production. APIs will change but backwards compatibility will be maintained as long as needed.
91
24
92
-
extracting links
93
-
---------------
94
25
26
+
🎇 [Spacedust](./spacedust/)
27
+
----------------------------
95
28
96
-
- low-level: pass a &str of a field value and get a parsed link back
29
+
A global atproto interactions firehose. Extracts all at-uris, DIDs, and URLs from every lexicon in the firehose, and exposes them over a websocket modelled after [jetstream](github.com/bluesky-social/jetstream).
97
30
98
-
- med-level: pass a &str of record in json form and get a list of parsed links + json paths back. (todo: should also handle dag-cbor prob?)
31
+
- Source: [./spacedust/](./spacedust/)
32
+
- [Public instance/API docs](https://spacedust.microcosm.blue/)
33
+
- Status: v0: the basics work and the APIs are in place! missing cursor replay, forward link storage, and delete event link hydration.
99
34
100
-
- high-ish level: pass the json record and maybe apply some pre-loaded rules based on known lexicons to get the best result.
35
+
### Demos:
101
36
102
-
for now, a link is only considered if it matches for the entire value of the record's field -- links embedded in text content are not included. note that urls in bluesky posts _will_ still be extracted, since they are broken out into facets.
37
+
- [Spacedust notifications](https://notifications.microcosm.blue/): web push notifications for _every_ atproto app
38
+
- [Zero-Bluesky real-time interaction-updating post embed](https://bsky.bad-example.com/zero-bluesky-realtime-embed/)
103
39
104
40
105
-
resolving / canonicalizing links
106
-
--------------------------------
41
+
🛰️ [Slingshot](./slingshot)
42
+
---------------------------
107
43
44
+
A fast, eager, production-grade edge cache for atproto records and identities. Pre-caches all records from the firehose and maintains a longer-term cache of requested records on disk.
108
45
109
-
### at-uris
46
+
- Source: [./slingshot/](./slingshot/)
47
+
- [Public instance/API docs](https://slingshot.microcosm.blue/)
48
+
- Status: v0: most XRPC APIs are working. cache storage is being reworked.
110
49
111
-
every at-uri has at least two equivalent forms, one with a `DID`, and one with an account handle. the at-uri spec [illustrates this by example](https://atproto.com/specs/at-uri-scheme):
112
50
113
-
- `at://did:plc:44ybard66vv44zksje25o7dz/app.bsky.feed.post/3jwdwj2ctlk26`
114
-
- `at://bnewbold.bsky.team/app.bsky.feed.post/3jwdwj2ctlk26`
51
+
🛸 [UFOs API](./ufos)
52
+
---------------------
115
53
116
-
some applications, like a reverse link index, may wish to canonicalize at-uris to a single form. the `DID`-form is stable as an account changes its handle and probably the right choice to canonicalize to, but maybe some apps would actually perfer to canonicalise to handles?
54
+
Timeseries stats and sample records for every [collection](https://atproto.com/guides/glossary#collection) ever seen in the atproto firehose. Unique users are counted in hyperloglog sketches enabling arbitrary cardinality aggregation across time buckets and/or NSIDs.
117
55
118
-
hopefully atrium will make it easy to resolve at-uris.
56
+
- Source: [./ufos/](./ufos/)
57
+
- [Public instance/API docs](https://ufos-api.microcosm.blue/)
58
+
- Status: Used in production. It has APIs and they work! Needs improvement on indexing; needs more indexes and some more APIs to the data exposed.
119
59
60
+
> [!tip]
61
+
> See also: [UFOs atproto explorer](https://ufos.microcosm.blue/) built on UFOs API. ([source](github.com/at-microcosm/spacedust-utils))
120
62
121
-
### urls
122
63
123
-
canonicalizing URLs is more annoying but also a bit more established. lots of details.
64
+
💫 [Links](./links)
65
+
-------------------
124
66
125
-
- do we have to deal with punycode?
126
-
- follow redirects (todo: only permanent ones, or all?)
127
-
- check for rel=canonical http header and possibly follow it
128
-
- check link rel=canonical meta tag and possibly follow it
129
-
- do we need to check site maps??
130
-
- do we have to care at all about AMP?
131
-
- do we want anything to do with url shorteners??
132
-
- how do multilingual sites affect this?
133
-
- do we have to care about `script type="application/ld+json"` ???
67
+
Rust library for parsing and extracting links (at-uris, DIDs, and URLs) from atproto records.
134
68
135
-
ugh. is there a crate for this.
69
+
- Source: [./links/](./links/)
70
+
- Status: not yet published to crates.io; needs some rework
136
71
137
72
138
-
### relative uris?
139
-
140
-
links might be relative, in which case they might need to be made absolute before being useful. is that a concern for this library, or up to the user? (seems like we might not have context here to determine its absolute)
141
-
142
-
143
-
### canonicalizing
144
-
145
-
there should be a few async functions available to canonicalize already-parsed links.
146
-
147
-
- what happens if a link can't be resolved?
73
+
🛩️ [Jetstream](./jetstream)
74
+
---------------------------
148
75
76
+
A low-overhead jetstream client with cursor handling and automatic reconnect.
149
77
150
-
---
78
+
- Source: [./links/](./links/)
79
+
- Status: used in multiple apps in production, but not yet published to crates.io; some rework planned
151
80
152
-
- using `tinyjson` because it's nice -- maybe should switch to serde_json to share deps with atrium?
81
+
> [!tip]
82
+
> See also: [Rocketman](https://github.com/teal-fm/cadet/tree/main/rocketman), another excellent rust jetstream client which shares some lineage and _is_ published on crates.io.
153
83
154
-
- would use atrium for parsing at-uris, but it's not in there. there's a did-only version in the non-lib commands.rs. its identifier parser is strict to did + handle, which makes sense, but for our purposes we might want to allow unknown methods too?
155
84
156
-
- rsky-syntax has an aturi
157
-
- adenosyne also
158
-
- might come back to these
159
85
86
+
🔭 Deprecated: [Who am I](./who-am-i)
87
+
-------------------------------------
160
88
161
-
-------
89
+
An identity bridge for microcosm demos, that kinda worked. Fixing its problems is about equivalent to reinventing a lot of OIDC, so it's being retired.
162
90
163
-
rocks
91
+
- Source: [./who-am-i/](./who-am-i/)
92
+
- Status: ready for retirement.
164
93
165
-
```bash
166
-
ROCKSDB_LIB_DIR=/nix/store/z2chn0hsik0clridr8mlprx1cngh1g3c-rocksdb-9.7.3/lib/ cargo build
167
-
```
94
+
> [!warning]
95
+
> `who-am-i` is still in use for the Spacedust Notifications demo, but that will hopefully be migrated to use atproto oauth directly instead.
+12
reflector/Cargo.toml
+12
reflector/Cargo.toml
···
1
+
[package]
2
+
name = "reflector"
3
+
version = "0.1.0"
4
+
edition = "2024"
5
+
6
+
[dependencies]
7
+
clap = { version = "4.5.47", features = ["derive"] }
8
+
log = "0.4.28"
9
+
poem = "3.1.12"
10
+
serde = { version = "1.0.219", features = ["derive"] }
11
+
tokio = "1.47.1"
12
+
tracing-subscriber = { version = "0.3.20", features = ["env-filter"] }
+9
reflector/readme.md
+9
reflector/readme.md
···
1
+
# reflector
2
+
3
+
a tiny did:web service server that maps subdomains to a single service endpoint
4
+
5
+
receiving requests from multiple subdomains is left as a problem for the reverse proxy to solve, since acme wildcard certificates (ie. letsencrypt) require the most complicated and involved challenge type (DNS).
6
+
7
+
caddy [has good support for](https://caddyserver.com/docs/caddyfile/patterns#wildcard-certificates) configuring the wildcard DNS challenge with various DNS providers, and also supports [on-demand](https://caddyserver.com/docs/automatic-https#using-on-demand-tls) provisioning via the simpler methods.
8
+
9
+
if you only need a small fixed number of subdomains, you can also use certbot or otherwise individually configure them in your reverse proxy.
+112
reflector/src/main.rs
+112
reflector/src/main.rs
···
1
+
use clap::Parser;
2
+
use poem::{
3
+
EndpointExt, Response, Route, Server, get, handler,
4
+
http::StatusCode,
5
+
listener::TcpListener,
6
+
middleware::{AddData, Tracing},
7
+
web::{Data, Json, Query, TypedHeader, headers::Host},
8
+
};
9
+
use serde::{Deserialize, Serialize};
10
+
11
+
#[handler]
12
+
fn hello() -> String {
13
+
"ɹoʇɔǝʅⅎǝɹ".to_string()
14
+
}
15
+
16
+
#[derive(Debug, Serialize)]
17
+
struct DidDoc {
18
+
id: String,
19
+
service: [DidService; 1],
20
+
}
21
+
22
+
#[derive(Debug, Clone, Serialize)]
23
+
#[serde(rename_all = "camelCase")]
24
+
struct DidService {
25
+
id: String,
26
+
r#type: String,
27
+
service_endpoint: String,
28
+
}
29
+
30
+
#[handler]
31
+
fn did_doc(TypedHeader(host): TypedHeader<Host>, service: Data<&DidService>) -> Json<DidDoc> {
32
+
Json(DidDoc {
33
+
id: format!("did:web:{}", host.hostname()),
34
+
service: [service.clone()],
35
+
})
36
+
}
37
+
38
+
#[derive(Deserialize)]
39
+
struct AskQuery {
40
+
domain: String,
41
+
}
42
+
#[handler]
43
+
fn ask_caddy(
44
+
Data(parent): Data<&Option<String>>,
45
+
Query(AskQuery { domain }): Query<AskQuery>,
46
+
) -> Response {
47
+
if let Some(parent) = parent
48
+
&& let Some(prefix) = domain.strip_suffix(&format!(".{parent}"))
49
+
&& !prefix.contains('.')
50
+
{
51
+
// no sub-sub-domains allowed
52
+
return Response::builder().body("ok");
53
+
};
54
+
Response::builder()
55
+
.status(StatusCode::FORBIDDEN)
56
+
.body("nope")
57
+
}
58
+
59
+
/// Slingshot record edge cache
60
+
#[derive(Parser, Debug, Clone)]
61
+
#[command(version, about, long_about = None)]
62
+
struct Args {
63
+
/// The DID document service ID to serve
64
+
///
65
+
/// must start with a '#', like `#bsky_appview'
66
+
#[arg(long)]
67
+
id: String,
68
+
/// Service type
69
+
///
70
+
/// Not sure exactly what its requirements are. 'BlueskyAppview' for example
71
+
#[arg(long)]
72
+
r#type: String,
73
+
/// The HTTPS endpoint for the service
74
+
#[arg(long)]
75
+
service_endpoint: String,
76
+
/// The parent domain; requests should come from subdomains of this
77
+
#[arg(long)]
78
+
domain: Option<String>,
79
+
}
80
+
81
+
impl From<Args> for DidService {
82
+
fn from(a: Args) -> Self {
83
+
Self {
84
+
id: a.id,
85
+
r#type: a.r#type,
86
+
service_endpoint: a.service_endpoint,
87
+
}
88
+
}
89
+
}
90
+
91
+
#[tokio::main(flavor = "current_thread")]
92
+
async fn main() {
93
+
tracing_subscriber::fmt::init();
94
+
log::info!("ɹoʇɔǝʅⅎǝɹ");
95
+
96
+
let args = Args::parse();
97
+
let domain = args.domain.clone();
98
+
let service: DidService = args.into();
99
+
100
+
Server::new(TcpListener::bind("0.0.0.0:3001"))
101
+
.run(
102
+
Route::new()
103
+
.at("/", get(hello))
104
+
.at("/.well-known/did.json", get(did_doc))
105
+
.at("/ask", get(ask_caddy))
106
+
.with(AddData::new(service))
107
+
.with(AddData::new(domain))
108
+
.with(Tracing),
109
+
)
110
+
.await
111
+
.unwrap()
112
+
}
+1
slingshot/.gitignore
+1
slingshot/.gitignore
···
1
+
foyer
+31
slingshot/Cargo.toml
+31
slingshot/Cargo.toml
···
1
+
[package]
2
+
name = "slingshot"
3
+
version = "0.1.0"
4
+
edition = "2024"
5
+
6
+
[dependencies]
7
+
atrium-api = { git = "https://github.com/uniphil/atrium.git", branch = "fix/resolve-handle-https-accept-whitespace", default-features = false }
8
+
atrium-common = { git = "https://github.com/uniphil/atrium.git", branch = "fix/resolve-handle-https-accept-whitespace" }
9
+
atrium-identity = { git = "https://github.com/uniphil/atrium.git", branch = "fix/resolve-handle-https-accept-whitespace" }
10
+
atrium-oauth = { git = "https://github.com/uniphil/atrium.git", branch = "fix/resolve-handle-https-accept-whitespace" }
11
+
clap = { version = "4.5.41", features = ["derive"] }
12
+
ctrlc = "3.4.7"
13
+
foyer = { version = "0.18.0", features = ["serde"] }
14
+
hickory-resolver = "0.25.2"
15
+
jetstream = { path = "../jetstream", features = ["metrics"] }
16
+
links = { path = "../links" }
17
+
log = "0.4.27"
18
+
metrics = "0.24.2"
19
+
metrics-exporter-prometheus = { version = "0.17.1", features = ["http-listener"] }
20
+
poem = { version = "3.1.12", features = ["acme", "static-files"] }
21
+
poem-openapi = { version = "5.1.16", features = ["scalar"] }
22
+
reqwest = { version = "0.12.22", features = ["json"] }
23
+
rustls = "0.23.31"
24
+
serde = { version = "1.0.219", features = ["derive"] }
25
+
serde_json = { version = "1.0.141", features = ["raw_value"] }
26
+
thiserror = "2.0.12"
27
+
time = { version = "0.3.41", features = ["serde"] }
28
+
tokio = { version = "1.47.0", features = ["full"] }
29
+
tokio-util = "0.7.15"
30
+
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
31
+
url = "2.5.4"
+93
slingshot/api-description.md
+93
slingshot/api-description.md
···
1
+
_A [gravitational slingshot](https://en.wikipedia.org/wiki/Gravity_assist) makes use of the gravity and relative movements of celestial bodies to accelerate a spacecraft and change its trajectory._
2
+
3
+
4
+
# Slingshot: edge record cache
5
+
6
+
Applications in [ATProtocol](https://atproto.com/) store data in users' own [PDS](https://atproto.com/guides/self-hosting) (Personal Data Server), which are distributed across thousands of independently-run servers all over the world. Trying to access this data poses challenges for client applications:
7
+
8
+
- A PDS might be far away with long network latency
9
+
- or may be on an unreliable connection
10
+
- or overloaded when you need it, or offline, or…
11
+
12
+
Large projects like [Bluesky](https://bsky.app/) control their performance and reliability by syncing all app-relevant data from PDSs into first-party databases. But for new apps, building out this additional data infrastructure adds significant effort and complexity up front.
13
+
14
+
**Slingshot is a fast, eager, production-grade cache of data in the [ATmosphere](https://atproto.com/)**, offering performance and reliability without custom infrastructure.
15
+
16
+
17
+
### Current status
18
+
19
+
> [!important]
20
+
> Slingshot is currently in a **v0, pre-release state**. There is one production instance and you can use it! Expect short downtimes for restarts as development progresses and lower cache hit-rates as the internal storage caches are adjusted and reset.
21
+
22
+
The core APIs will not change, since they are standard third-party `com.atproto` query APIs from ATProtocol.
23
+
24
+
25
+
## Eager caching
26
+
27
+
In many cases, Slingshot can cache the data you need *before* first request!
28
+
29
+
Slingshot subscribes to the global [Firehose](https://atproto.com/specs/sync#firehose) of data updates. It keeps a short-term rolling indexed window of *all* data, and automatically promotes content likely to be requested to its longer-term main cache. _(automatic promotion is still a work in progress)_
30
+
31
+
When there is a cache miss, Slingshot can often still accelerate record fetching, since it keeps a large cache of resolved identities: it can usually request from the correct PDS without extra lookups.
32
+
33
+
34
+
## Precise invalidation
35
+
36
+
The fireshose includes **update** and **delete** events, which Slingshot uses to ensure stale and deleted data is removed within a very short window. Additonally, identity and account-level events can trigger rapid cleanup of data for deactivated and deleted accounts. _(some of this is still a work in progress)_
37
+
38
+
39
+
## Low-trust
40
+
41
+
The "AT" in ATProtocol [stands for _Authenticated Transfer_](https://atproto.com/guides/glossary#at-protocol): all data is cryptographically signed, which makes it possible to broadcast data through third parties and trust that it's real _without_ having to directly contact the originating server.
42
+
43
+
Two core standard query APIs are supported to balance convenience and trust. They both fetch [records](https://atproto.com/guides/glossary#record):
44
+
45
+
### [`com.atproto.repo.getRecord`](#tag/comatproto-queries/get/xrpc/com.atproto.repo.getRecord)
46
+
47
+
- convenient `JSON` response format
48
+
- cannot be proven authentic
49
+
50
+
### [`com.atproto.sync.getRecord`](#tag/comatproto-queries/get/xrpc/com.atproto.sync.getRecord)
51
+
52
+
- [`DAG-CBOR`](https://atproto.com/specs/data-model)-encoded response requires extra libraries to decode, but
53
+
- includes a cryptographic proof of authenticity!
54
+
55
+
_(work on this endpoint is in progress)_
56
+
57
+
58
+
## Service proxying
59
+
60
+
Clients can proxy atproto queries through their own PDS with [Service Proxying](https://atproto.com/specs/xrpc#service-proxying), and this is supported by Slingshot. The Slingshot instance must be started the `--domain` argument specified.
61
+
62
+
Service-proxied requests can specify a Slingshot instance via the `atproto-proxy` header:
63
+
64
+
```http
65
+
GET /xrpc/com.bad-example.identity.resolveMiniDoc?identifier=bad-example.com
66
+
Host: <your pds>
67
+
atproto-proxy: did:web:<slingshot domain>#slingshot
68
+
```
69
+
70
+
Where `<your pds>` is the user's own PDS host, and `<slingshot domain>` is the domain that the slingshot instance is deployed at (eg. `slingshot.microcosm.blue`). See the [Service Proxying](https://atproto.com/specs/xrpc#service-proxying) docs for more.
71
+
72
+
> [!tip]
73
+
> Service proxying is supported but completely optional. All APIs are directly accessible over the public internet, and GeoDNS helps route users to the closest instance to them for the lowest possible latency. (_note: deploying multiple slingshot instances with GeoDNS is still TODO_)
74
+
75
+
76
+
## Ergonomic APIs
77
+
78
+
- Slingshot also offers variants of the `getRecord` endpoints that accept a full `at-uri` as a parameter, to save clients from needing to parse and validate all parts of a record location.
79
+
80
+
- Bi-directionally verifying identity endpoints, so you can directly exchange atproto [`handle`](https://atproto.com/guides/glossary#handle)s for [`DID`](https://atproto.com/guides/glossary#did-decentralized-id)s without extra steps, plus a convenient [Mini-Doc](#tag/slingshot-specific-queries/get/xrpc/com.bad-example.identity.resolveMiniDoc) verified identity summary.
81
+
82
+
83
+
## Part of microcosm
84
+
85
+
[Microcosm](https://www.microcosm.blue/) is a collection of services and independent community-run infrastructure for ATProtocol.
86
+
87
+
Slingshot excels when combined with _shallow indexing_ services, which offer fast queries of global data relationships but with only references to the data records. Microcosm has a few!
88
+
89
+
- [🌌 Constellation](https://constellation.microcosm.blue/), a global backlink index (all social interactions in atproto are links!)
90
+
- [🎇 Spacedust](https://spacedust.microcosm.blue/), a firehose of all social interactions
91
+
92
+
> [!success]
93
+
> All microcosm projects are [open source](https://tangled.sh/@bad-example.com/microcosm-links). **You can help sustain Slingshot** and all of microcosm by becoming a [Github sponsor](https://github.com/sponsors/uniphil/) or a [Ko-fi supporter](https://ko-fi.com/bad_example)!
+7
slingshot/readme.md
+7
slingshot/readme.md
+80
slingshot/src/consumer.rs
+80
slingshot/src/consumer.rs
···
1
+
use crate::CachedRecord;
2
+
use crate::error::ConsumerError;
3
+
use foyer::HybridCache;
4
+
use jetstream::{
5
+
DefaultJetstreamEndpoints, JetstreamCompression, JetstreamConfig, JetstreamConnector,
6
+
events::{CommitOp, Cursor, EventKind},
7
+
};
8
+
use tokio_util::sync::CancellationToken;
9
+
10
+
pub async fn consume(
11
+
jetstream_endpoint: String,
12
+
cursor: Option<Cursor>,
13
+
no_zstd: bool,
14
+
shutdown: CancellationToken,
15
+
cache: HybridCache<String, CachedRecord>,
16
+
) -> Result<(), ConsumerError> {
17
+
let endpoint = DefaultJetstreamEndpoints::endpoint_or_shortcut(&jetstream_endpoint);
18
+
if endpoint == jetstream_endpoint {
19
+
log::info!("consumer: connecting jetstream at {endpoint}");
20
+
} else {
21
+
log::info!("consumer: connecting jetstream at {jetstream_endpoint} => {endpoint}");
22
+
}
23
+
let config: JetstreamConfig = JetstreamConfig {
24
+
endpoint,
25
+
compression: if no_zstd {
26
+
JetstreamCompression::None
27
+
} else {
28
+
JetstreamCompression::Zstd
29
+
},
30
+
replay_on_reconnect: true,
31
+
channel_size: 1024, // buffer up to ~1s of jetstream events
32
+
..Default::default()
33
+
};
34
+
let mut receiver = JetstreamConnector::new(config)?
35
+
.connect_cursor(cursor)
36
+
.await?;
37
+
38
+
log::info!("consumer: receiving messages..");
39
+
loop {
40
+
if shutdown.is_cancelled() {
41
+
log::info!("consumer: exiting for shutdown");
42
+
return Ok(());
43
+
}
44
+
let Some(mut event) = receiver.recv().await else {
45
+
log::error!("consumer: could not receive event, bailing");
46
+
break;
47
+
};
48
+
49
+
if event.kind != EventKind::Commit {
50
+
continue;
51
+
}
52
+
let Some(ref mut commit) = event.commit else {
53
+
log::warn!("consumer: commit event missing commit data, ignoring");
54
+
continue;
55
+
};
56
+
57
+
// TODO: something a bit more robust
58
+
let at_uri = format!(
59
+
"at://{}/{}/{}",
60
+
&*event.did, &*commit.collection, &*commit.rkey
61
+
);
62
+
63
+
if commit.operation == CommitOp::Delete {
64
+
cache.insert(at_uri, CachedRecord::Deleted);
65
+
} else {
66
+
let Some(record) = commit.record.take() else {
67
+
log::warn!("consumer: commit insert or update missing record, ignoring");
68
+
continue;
69
+
};
70
+
let Some(cid) = commit.cid.take() else {
71
+
log::warn!("consumer: commit insert or update missing CID, ignoring");
72
+
continue;
73
+
};
74
+
75
+
cache.insert(at_uri, CachedRecord::Found((cid, record).into()));
76
+
}
77
+
}
78
+
79
+
Err(ConsumerError::JetstreamEnded)
80
+
}
+93
slingshot/src/error.rs
+93
slingshot/src/error.rs
···
1
+
use crate::ErrorResponseObject;
2
+
use thiserror::Error;
3
+
4
+
#[derive(Debug, Error)]
5
+
pub enum ConsumerError {
6
+
#[error(transparent)]
7
+
JetstreamConnectionError(#[from] jetstream::error::ConnectionError),
8
+
#[error(transparent)]
9
+
JetstreamConfigValidationError(#[from] jetstream::error::ConfigValidationError),
10
+
#[error("jetstream ended")]
11
+
JetstreamEnded,
12
+
#[error("delay queue output dropped")]
13
+
DelayQueueOutputDropped,
14
+
}
15
+
16
+
#[derive(Debug, Error)]
17
+
pub enum ServerError {
18
+
#[error("server build error: {0}")]
19
+
AcmeBuildError(std::io::Error),
20
+
#[error("server exited: {0}")]
21
+
ServerExited(std::io::Error),
22
+
}
23
+
24
+
#[derive(Debug, Error)]
25
+
pub enum IdentityError {
26
+
#[error("whatever: {0}")]
27
+
WhateverError(String),
28
+
#[error("bad DID: {0}")]
29
+
BadDid(&'static str),
30
+
#[error("identity types got mixed up: {0}")]
31
+
IdentityValTypeMixup(String),
32
+
#[error("foyer error: {0}")]
33
+
FoyerError(#[from] foyer::Error),
34
+
35
+
#[error("failed to resolve: {0}")]
36
+
ResolutionFailed(#[from] atrium_identity::Error),
37
+
// #[error("identity resolved but no handle found for user")]
38
+
// NoHandle,
39
+
#[error("found handle {0:?} but it appears invalid: {1}")]
40
+
InvalidHandle(String, &'static str),
41
+
42
+
#[error("could not convert atrium did doc to partial mini doc: {0}")]
43
+
BadDidDoc(String),
44
+
45
+
#[error("wrong key for clearing refresh queue: {0}")]
46
+
RefreshQueueKeyError(&'static str),
47
+
}
48
+
49
+
#[derive(Debug, Error)]
50
+
pub enum HealthCheckError {
51
+
#[error("failed to send checkin: {0}")]
52
+
HealthCheckError(#[from] reqwest::Error),
53
+
}
54
+
55
+
#[derive(Debug, Error)]
56
+
pub enum MainTaskError {
57
+
#[error(transparent)]
58
+
ConsumerTaskError(#[from] ConsumerError),
59
+
#[error(transparent)]
60
+
ServerTaskError(#[from] ServerError),
61
+
#[error(transparent)]
62
+
IdentityTaskError(#[from] IdentityError),
63
+
#[error(transparent)]
64
+
HealthCheckError(#[from] HealthCheckError),
65
+
#[error("firehose cache failed to close: {0}")]
66
+
FirehoseCacheCloseError(foyer::Error),
67
+
}
68
+
69
+
#[derive(Debug, Error)]
70
+
pub enum RecordError {
71
+
#[error("identity error: {0}")]
72
+
IdentityError(#[from] IdentityError),
73
+
#[error("repo could not be validated as either a DID or an atproto handle")]
74
+
BadRepo,
75
+
#[error("could not get record: {0}")]
76
+
NotFound(&'static str),
77
+
#[error("could nto parse pds url: {0}")]
78
+
UrlParseError(#[from] url::ParseError),
79
+
#[error("reqwest send failed: {0}")]
80
+
SendError(reqwest::Error),
81
+
#[error("reqwest raised for status: {0}")]
82
+
StatusError(reqwest::Error),
83
+
#[error("reqwest failed to parse json: {0}")]
84
+
ParseJsonError(reqwest::Error),
85
+
#[error("upstream getRecord did not include a CID")]
86
+
MissingUpstreamCid,
87
+
#[error("upstream CID was not valid: {0}")]
88
+
BadUpstreamCid(String),
89
+
#[error("upstream atproto-looking bad request")]
90
+
UpstreamBadRequest(ErrorResponseObject),
91
+
#[error("upstream non-atproto bad request")]
92
+
UpstreamBadBadNotGoodRequest(reqwest::Error),
93
+
}
+22
slingshot/src/firehose_cache.rs
+22
slingshot/src/firehose_cache.rs
···
1
+
use crate::CachedRecord;
2
+
use foyer::{DirectFsDeviceOptions, Engine, HybridCache, HybridCacheBuilder};
3
+
use std::path::Path;
4
+
5
+
pub async fn firehose_cache(
6
+
cache_dir: impl AsRef<Path>,
7
+
) -> Result<HybridCache<String, CachedRecord>, String> {
8
+
let cache = HybridCacheBuilder::new()
9
+
.with_name("firehose")
10
+
.memory(64 * 2_usize.pow(20))
11
+
.with_weighter(|k: &String, v| k.len() + std::mem::size_of_val(v))
12
+
.storage(Engine::large())
13
+
.with_device_options(
14
+
DirectFsDeviceOptions::new(cache_dir)
15
+
.with_capacity(2_usize.pow(30)) // TODO: configurable (1GB to have something)
16
+
.with_file_size(16 * 2_usize.pow(20)), // note: this does limit the max cached item size, warning jumbo records
17
+
)
18
+
.build()
19
+
.await
20
+
.map_err(|e| format!("foyer setup error: {e:?}"))?;
21
+
Ok(cache)
22
+
}
+32
slingshot/src/healthcheck.rs
+32
slingshot/src/healthcheck.rs
···
1
+
use crate::error::HealthCheckError;
2
+
use reqwest::Client;
3
+
use std::time::Duration;
4
+
use tokio::time::sleep;
5
+
use tokio_util::sync::CancellationToken;
6
+
7
+
pub async fn healthcheck(
8
+
endpoint: String,
9
+
shutdown: CancellationToken,
10
+
) -> Result<(), HealthCheckError> {
11
+
let client = Client::builder()
12
+
.user_agent(format!(
13
+
"microcosm slingshot v{} (dev: @bad-example.com)",
14
+
env!("CARGO_PKG_VERSION")
15
+
))
16
+
.no_proxy()
17
+
.timeout(Duration::from_secs(10))
18
+
.build()?;
19
+
20
+
loop {
21
+
tokio::select! {
22
+
res = client.get(&endpoint).send() => {
23
+
let _ = res
24
+
.and_then(|r| r.error_for_status())
25
+
.inspect_err(|e| log::error!("failed to send healthcheck: {e}"));
26
+
},
27
+
_ = shutdown.cancelled() => break,
28
+
}
29
+
sleep(Duration::from_secs(51)).await;
30
+
}
31
+
Ok(())
32
+
}
+525
slingshot/src/identity.rs
+525
slingshot/src/identity.rs
···
1
+
use hickory_resolver::{ResolveError, TokioResolver};
2
+
use std::collections::{HashSet, VecDeque};
3
+
use std::path::Path;
4
+
use std::sync::Arc;
5
+
/// for now we're gonna just keep doing more cache
6
+
///
7
+
/// plc.director x foyer, ttl kept with data, refresh deferred to background on fetch
8
+
///
9
+
/// things we need:
10
+
///
11
+
/// 1. handle -> DID resolution: getRecord must accept a handle for `repo` param
12
+
/// 2. DID -> PDS resolution: so we know where to getRecord
13
+
/// 3. DID -> handle resolution: for bidirectional handle validation and in case we want to offer this
14
+
use std::time::Duration;
15
+
use tokio::sync::Mutex;
16
+
use tokio_util::sync::CancellationToken;
17
+
18
+
use crate::error::IdentityError;
19
+
use atrium_api::{
20
+
did_doc::DidDocument,
21
+
types::string::{Did, Handle},
22
+
};
23
+
use atrium_common::resolver::Resolver;
24
+
use atrium_identity::{
25
+
did::{CommonDidResolver, CommonDidResolverConfig, DEFAULT_PLC_DIRECTORY_URL},
26
+
handle::{AtprotoHandleResolver, AtprotoHandleResolverConfig, DnsTxtResolver},
27
+
};
28
+
use atrium_oauth::DefaultHttpClient; // it's probably not worth bringing all of atrium_oauth for this but
29
+
use foyer::{DirectFsDeviceOptions, Engine, HybridCache, HybridCacheBuilder};
30
+
use serde::{Deserialize, Serialize};
31
+
use time::UtcDateTime;
32
+
33
+
/// once we have something resolved, don't re-resolve until after this period
34
+
const MIN_TTL: Duration = Duration::from_secs(4 * 3600); // probably shoudl have a max ttl
35
+
const MIN_NOT_FOUND_TTL: Duration = Duration::from_secs(60);
36
+
37
+
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
38
+
enum IdentityKey {
39
+
Handle(Handle),
40
+
Did(Did),
41
+
}
42
+
43
+
#[derive(Debug, Serialize, Deserialize)]
44
+
struct IdentityVal(UtcDateTime, IdentityData);
45
+
46
+
#[derive(Debug, Serialize, Deserialize)]
47
+
enum IdentityData {
48
+
NotFound,
49
+
Did(Did),
50
+
Doc(PartialMiniDoc),
51
+
}
52
+
53
+
/// partial representation of a com.bad-example.identity mini atproto doc
54
+
///
55
+
/// partial because the handle is not verified
56
+
#[derive(Debug, Clone, Serialize, Deserialize)]
57
+
pub struct PartialMiniDoc {
58
+
/// an atproto handle (**unverified**)
59
+
///
60
+
/// the first valid atproto handle from the did doc's aka
61
+
pub unverified_handle: Handle,
62
+
/// the did's atproto pds url (TODO: type this?)
63
+
///
64
+
/// note: atrium *does* actually parse it into a URI, it just doesn't return
65
+
/// that for some reason
66
+
pub pds: String,
67
+
/// for now we're just pulling this straight from the did doc
68
+
///
69
+
/// would be nice to type and validate it
70
+
///
71
+
/// this is the publicKeyMultibase from the did doc.
72
+
/// legacy key encoding not supported.
73
+
/// `id`, `type`, and `controller` must be checked, but aren't stored.
74
+
pub signing_key: String,
75
+
}
76
+
77
+
impl TryFrom<DidDocument> for PartialMiniDoc {
78
+
type Error = String;
79
+
fn try_from(did_doc: DidDocument) -> Result<Self, Self::Error> {
80
+
// must use the first valid handle
81
+
let mut unverified_handle = None;
82
+
let Some(ref doc_akas) = did_doc.also_known_as else {
83
+
return Err("did doc missing `also_known_as`".to_string());
84
+
};
85
+
for aka in doc_akas {
86
+
let Some(maybe_handle) = aka.strip_prefix("at://") else {
87
+
continue;
88
+
};
89
+
let Ok(valid_handle) = Handle::new(maybe_handle.to_string()) else {
90
+
continue;
91
+
};
92
+
unverified_handle = Some(valid_handle);
93
+
break;
94
+
}
95
+
let Some(unverified_handle) = unverified_handle else {
96
+
return Err("no valid atproto handles in `also_known_as`".to_string());
97
+
};
98
+
99
+
// atrium seems to get service endpoint getters
100
+
let Some(pds) = did_doc.get_pds_endpoint() else {
101
+
return Err("no valid pds service found".to_string());
102
+
};
103
+
104
+
// TODO can't use atrium's get_signing_key() becuase it fails to check type and controller
105
+
// so if we check those and reject it, we might miss a later valid key in the array
106
+
// (todo is to fix atrium)
107
+
// actually: atrium might be flexible for legacy reps. for now we're rejecting legacy rep.
108
+
109
+
// must use the first valid signing key
110
+
let mut signing_key = None;
111
+
let Some(verification_methods) = did_doc.verification_method else {
112
+
return Err("no verification methods found".to_string());
113
+
};
114
+
for method in verification_methods {
115
+
if method.id != format!("{}#atproto", did_doc.id) {
116
+
continue;
117
+
}
118
+
if method.r#type != "Multikey" {
119
+
continue;
120
+
}
121
+
if method.controller != did_doc.id {
122
+
continue;
123
+
}
124
+
let Some(key) = method.public_key_multibase else {
125
+
continue;
126
+
};
127
+
signing_key = Some(key);
128
+
break;
129
+
}
130
+
let Some(signing_key) = signing_key else {
131
+
return Err("no valid atproto signing key found in verification methods".to_string());
132
+
};
133
+
134
+
Ok(PartialMiniDoc {
135
+
unverified_handle,
136
+
pds,
137
+
signing_key,
138
+
})
139
+
}
140
+
}
141
+
142
+
/// multi-producer *single-consumer* queue structures (wrap in arc-mutex plz)
143
+
///
144
+
/// the hashset allows testing for presense of items in the queue.
145
+
/// this has absolutely no support for multiple queue consumers.
146
+
#[derive(Debug, Default)]
147
+
struct RefreshQueue {
148
+
queue: VecDeque<IdentityKey>,
149
+
items: HashSet<IdentityKey>,
150
+
}
151
+
152
+
#[derive(Clone)]
153
+
pub struct Identity {
154
+
handle_resolver: Arc<AtprotoHandleResolver<HickoryDnsTxtResolver, DefaultHttpClient>>,
155
+
did_resolver: Arc<CommonDidResolver<DefaultHttpClient>>,
156
+
cache: HybridCache<IdentityKey, IdentityVal>,
157
+
/// multi-producer *single consumer* queue
158
+
refresh_queue: Arc<Mutex<RefreshQueue>>,
159
+
/// just a lock to ensure only one refresher (queue consumer) is running (to be improved with a better refresher)
160
+
refresher: Arc<Mutex<()>>,
161
+
}
162
+
163
+
impl Identity {
164
+
pub async fn new(cache_dir: impl AsRef<Path>) -> Result<Self, IdentityError> {
165
+
let http_client = Arc::new(DefaultHttpClient::default());
166
+
let handle_resolver = AtprotoHandleResolver::new(AtprotoHandleResolverConfig {
167
+
dns_txt_resolver: HickoryDnsTxtResolver::new().unwrap(),
168
+
http_client: http_client.clone(),
169
+
});
170
+
let did_resolver = CommonDidResolver::new(CommonDidResolverConfig {
171
+
plc_directory_url: DEFAULT_PLC_DIRECTORY_URL.to_string(),
172
+
http_client: http_client.clone(),
173
+
});
174
+
175
+
let cache = HybridCacheBuilder::new()
176
+
.with_name("identity")
177
+
.memory(16 * 2_usize.pow(20))
178
+
.with_weighter(|k, v| std::mem::size_of_val(k) + std::mem::size_of_val(v))
179
+
.storage(Engine::small())
180
+
.with_device_options(
181
+
DirectFsDeviceOptions::new(cache_dir)
182
+
.with_capacity(2_usize.pow(30)) // TODO: configurable (1GB to have something)
183
+
.with_file_size(2_usize.pow(20)), // note: this does limit the max cached item size, warning jumbo records
184
+
)
185
+
.build()
186
+
.await?;
187
+
188
+
Ok(Self {
189
+
handle_resolver: Arc::new(handle_resolver),
190
+
did_resolver: Arc::new(did_resolver),
191
+
cache,
192
+
refresh_queue: Default::default(),
193
+
refresher: Default::default(),
194
+
})
195
+
}
196
+
197
+
/// Resolve (and verify!) an atproto handle to a DID
198
+
///
199
+
/// The result can be stale
200
+
///
201
+
/// `None` if the handle can't be found or verification fails
202
+
pub async fn handle_to_did(&self, handle: Handle) -> Result<Option<Did>, IdentityError> {
203
+
let Some(did) = self.handle_to_unverified_did(&handle).await? else {
204
+
return Ok(None);
205
+
};
206
+
let Some(doc) = self.did_to_partial_mini_doc(&did).await? else {
207
+
return Ok(None);
208
+
};
209
+
if doc.unverified_handle != handle {
210
+
return Ok(None);
211
+
}
212
+
Ok(Some(did))
213
+
}
214
+
215
+
/// Resolve a DID to a pds url
216
+
///
217
+
/// This *also* incidentally resolves and verifies the handle, which might
218
+
/// make it slower than expected
219
+
pub async fn did_to_pds(&self, did: Did) -> Result<Option<String>, IdentityError> {
220
+
let Some(mini_doc) = self.did_to_partial_mini_doc(&did).await? else {
221
+
return Ok(None);
222
+
};
223
+
Ok(Some(mini_doc.pds))
224
+
}
225
+
226
+
/// Resolve (and cache but **not verify**) a handle to a DID
227
+
async fn handle_to_unverified_did(
228
+
&self,
229
+
handle: &Handle,
230
+
) -> Result<Option<Did>, IdentityError> {
231
+
let key = IdentityKey::Handle(handle.clone());
232
+
let entry = self
233
+
.cache
234
+
.fetch(key.clone(), {
235
+
let handle = handle.clone();
236
+
let resolver = self.handle_resolver.clone();
237
+
|| async move {
238
+
match resolver.resolve(&handle).await {
239
+
Ok(did) => Ok(IdentityVal(UtcDateTime::now(), IdentityData::Did(did))),
240
+
Err(atrium_identity::Error::NotFound) => {
241
+
Ok(IdentityVal(UtcDateTime::now(), IdentityData::NotFound))
242
+
}
243
+
Err(other) => Err(foyer::Error::Other(Box::new({
244
+
log::debug!("other error resolving handle: {other:?}");
245
+
IdentityError::ResolutionFailed(other)
246
+
}))),
247
+
}
248
+
}
249
+
})
250
+
.await?;
251
+
252
+
let now = UtcDateTime::now();
253
+
let IdentityVal(last_fetch, data) = entry.value();
254
+
match data {
255
+
IdentityData::Doc(_) => {
256
+
log::error!("identity value mixup: got a doc from a handle key (should be a did)");
257
+
Err(IdentityError::IdentityValTypeMixup(handle.to_string()))
258
+
}
259
+
IdentityData::NotFound => {
260
+
if (now - *last_fetch) >= MIN_NOT_FOUND_TTL {
261
+
self.queue_refresh(key).await;
262
+
}
263
+
Ok(None)
264
+
}
265
+
IdentityData::Did(did) => {
266
+
if (now - *last_fetch) >= MIN_TTL {
267
+
self.queue_refresh(key).await;
268
+
}
269
+
Ok(Some(did.clone()))
270
+
}
271
+
}
272
+
}
273
+
274
+
/// Fetch (and cache) a partial mini doc from a did
275
+
pub async fn did_to_partial_mini_doc(
276
+
&self,
277
+
did: &Did,
278
+
) -> Result<Option<PartialMiniDoc>, IdentityError> {
279
+
let key = IdentityKey::Did(did.clone());
280
+
let entry = self
281
+
.cache
282
+
.fetch(key.clone(), {
283
+
let did = did.clone();
284
+
let resolver = self.did_resolver.clone();
285
+
|| async move {
286
+
match resolver.resolve(&did).await {
287
+
Ok(did_doc) => {
288
+
// TODO: fix in atrium: should verify id is did
289
+
if did_doc.id != did.to_string() {
290
+
return Err(foyer::Error::other(Box::new(
291
+
IdentityError::BadDidDoc(
292
+
"did doc's id did not match did".to_string(),
293
+
),
294
+
)));
295
+
}
296
+
let mini_doc = did_doc.try_into().map_err(|e| {
297
+
foyer::Error::Other(Box::new(IdentityError::BadDidDoc(e)))
298
+
})?;
299
+
Ok(IdentityVal(UtcDateTime::now(), IdentityData::Doc(mini_doc)))
300
+
}
301
+
Err(atrium_identity::Error::NotFound) => {
302
+
Ok(IdentityVal(UtcDateTime::now(), IdentityData::NotFound))
303
+
}
304
+
Err(other) => Err(foyer::Error::Other(Box::new(
305
+
IdentityError::ResolutionFailed(other),
306
+
))),
307
+
}
308
+
}
309
+
})
310
+
.await?;
311
+
312
+
let now = UtcDateTime::now();
313
+
let IdentityVal(last_fetch, data) = entry.value();
314
+
match data {
315
+
IdentityData::Did(_) => {
316
+
log::error!("identity value mixup: got a did from a did key (should be a doc)");
317
+
Err(IdentityError::IdentityValTypeMixup(did.to_string()))
318
+
}
319
+
IdentityData::NotFound => {
320
+
if (now - *last_fetch) >= MIN_NOT_FOUND_TTL {
321
+
self.queue_refresh(key).await;
322
+
}
323
+
Ok(None)
324
+
}
325
+
IdentityData::Doc(mini_did) => {
326
+
if (now - *last_fetch) >= MIN_TTL {
327
+
self.queue_refresh(key).await;
328
+
}
329
+
Ok(Some(mini_did.clone()))
330
+
}
331
+
}
332
+
}
333
+
334
+
/// put a refresh task on the queue
335
+
///
336
+
/// this can be safely called from multiple concurrent tasks
337
+
async fn queue_refresh(&self, key: IdentityKey) {
338
+
// todo: max queue size
339
+
let mut q = self.refresh_queue.lock().await;
340
+
if !q.items.contains(&key) {
341
+
q.items.insert(key.clone());
342
+
q.queue.push_back(key);
343
+
}
344
+
}
345
+
346
+
/// find out what's next in the queue. concurrent consumers are not allowed.
347
+
///
348
+
/// intent is to leave the item in the queue while refreshing, so that a
349
+
/// producer will not re-add it if it's in progress. there's definitely
350
+
/// better ways to do this, but this is ~simple for as far as a single
351
+
/// consumer can take us.
352
+
///
353
+
/// we could take it from the queue but leave it in the set and remove from
354
+
/// set later, but splitting them apart feels more bug-prone.
355
+
async fn peek_refresh(&self) -> Option<IdentityKey> {
356
+
let q = self.refresh_queue.lock().await;
357
+
q.queue.front().cloned()
358
+
}
359
+
360
+
/// call to clear the latest key from the refresh queue. concurrent consumers not allowed.
361
+
///
362
+
/// must provide the last peeked refresh queue item as a small safety check
363
+
async fn complete_refresh(&self, key: &IdentityKey) -> Result<(), IdentityError> {
364
+
let mut q = self.refresh_queue.lock().await;
365
+
366
+
let Some(queue_key) = q.queue.pop_front() else {
367
+
// gone from queue + since we're in an error condition, make sure it's not stuck in items
368
+
// (not toctou because we have the lock)
369
+
// bolder here than below and removing from items because if the queue is *empty*, then we
370
+
// know it hasn't been re-added since losing sync.
371
+
if q.items.remove(key) {
372
+
log::error!("identity refresh: queue de-sync: not in ");
373
+
} else {
374
+
log::warn!(
375
+
"identity refresh: tried to complete with wrong key. are multiple queue consumers running?"
376
+
);
377
+
}
378
+
return Err(IdentityError::RefreshQueueKeyError("no key in queue"));
379
+
};
380
+
381
+
if queue_key != *key {
382
+
// extra weird case here, what's the most defensive behaviour?
383
+
// we have two keys: ours should have been first but isn't. this shouldn't happen, so let's
384
+
// just leave items alone for it. risks unbounded growth but we're in a bad place already.
385
+
// the other key is the one we just popped. we didn't want it, so maybe we should put it
386
+
// back, BUT if we somehow ended up with concurrent consumers, we have bigger problems. take
387
+
// responsibility for taking it instead: remove it from items as well, and just drop it.
388
+
//
389
+
// hope that whoever calls us takes this error seriously.
390
+
if q.items.remove(&queue_key) {
391
+
log::warn!(
392
+
"identity refresh: queue de-sync + dropping a bystander key without refreshing it!"
393
+
);
394
+
} else {
395
+
// you thought things couldn't get weirder? (i mean hopefully they can't)
396
+
log::error!("identity refresh: queue de-sync + bystander key also de-sync!?");
397
+
}
398
+
return Err(IdentityError::RefreshQueueKeyError(
399
+
"wrong key at front of queue",
400
+
));
401
+
}
402
+
403
+
if q.items.remove(key) {
404
+
Ok(())
405
+
} else {
406
+
log::error!("identity refresh: queue de-sync: key not in items");
407
+
Err(IdentityError::RefreshQueueKeyError("key not in items"))
408
+
}
409
+
}
410
+
411
+
/// run the refresh queue consumer
412
+
pub async fn run_refresher(&self, shutdown: CancellationToken) -> Result<(), IdentityError> {
413
+
let _guard = self
414
+
.refresher
415
+
.try_lock()
416
+
.expect("there to only be one refresher running");
417
+
loop {
418
+
if shutdown.is_cancelled() {
419
+
log::info!("identity refresher: exiting for shutdown: closing cache...");
420
+
if let Err(e) = self.cache.close().await {
421
+
log::error!("cache close errored: {e}");
422
+
} else {
423
+
log::info!("identity cache closed.")
424
+
}
425
+
return Ok(());
426
+
}
427
+
let Some(task_key) = self.peek_refresh().await else {
428
+
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
429
+
continue;
430
+
};
431
+
match task_key {
432
+
IdentityKey::Handle(ref handle) => {
433
+
log::trace!("refreshing handle {handle:?}");
434
+
match self.handle_resolver.resolve(handle).await {
435
+
Ok(did) => {
436
+
self.cache.insert(
437
+
task_key.clone(),
438
+
IdentityVal(UtcDateTime::now(), IdentityData::Did(did)),
439
+
);
440
+
}
441
+
Err(atrium_identity::Error::NotFound) => {
442
+
self.cache.insert(
443
+
task_key.clone(),
444
+
IdentityVal(UtcDateTime::now(), IdentityData::NotFound),
445
+
);
446
+
}
447
+
Err(err) => {
448
+
log::warn!(
449
+
"failed to refresh handle: {err:?}. leaving stale (should we eventually do something?)"
450
+
);
451
+
}
452
+
}
453
+
self.complete_refresh(&task_key).await?; // failures are bugs, so break loop
454
+
}
455
+
IdentityKey::Did(ref did) => {
456
+
log::trace!("refreshing did doc: {did:?}");
457
+
458
+
match self.did_resolver.resolve(did).await {
459
+
Ok(did_doc) => {
460
+
// TODO: fix in atrium: should verify id is did
461
+
if did_doc.id != did.to_string() {
462
+
log::warn!(
463
+
"refreshed did doc failed: wrong did doc id. dropping refresh."
464
+
);
465
+
continue;
466
+
}
467
+
let mini_doc = match did_doc.try_into() {
468
+
Ok(md) => md,
469
+
Err(e) => {
470
+
log::warn!(
471
+
"converting mini doc failed: {e:?}. dropping refresh."
472
+
);
473
+
continue;
474
+
}
475
+
};
476
+
self.cache.insert(
477
+
task_key.clone(),
478
+
IdentityVal(UtcDateTime::now(), IdentityData::Doc(mini_doc)),
479
+
);
480
+
}
481
+
Err(atrium_identity::Error::NotFound) => {
482
+
self.cache.insert(
483
+
task_key.clone(),
484
+
IdentityVal(UtcDateTime::now(), IdentityData::NotFound),
485
+
);
486
+
}
487
+
Err(err) => {
488
+
log::warn!(
489
+
"failed to refresh did doc: {err:?}. leaving stale (should we eventually do something?)"
490
+
);
491
+
}
492
+
}
493
+
494
+
self.complete_refresh(&task_key).await?; // failures are bugs, so break loop
495
+
}
496
+
}
497
+
}
498
+
}
499
+
}
500
+
501
+
pub struct HickoryDnsTxtResolver(TokioResolver);
502
+
503
+
impl HickoryDnsTxtResolver {
504
+
fn new() -> Result<Self, ResolveError> {
505
+
Ok(Self(TokioResolver::builder_tokio()?.build()))
506
+
}
507
+
}
508
+
509
+
impl DnsTxtResolver for HickoryDnsTxtResolver {
510
+
async fn resolve(
511
+
&self,
512
+
query: &str,
513
+
) -> core::result::Result<Vec<String>, Box<dyn std::error::Error + Send + Sync>> {
514
+
match self.0.txt_lookup(query).await {
515
+
Ok(r) => {
516
+
metrics::counter!("whoami_resolve_dns_txt", "success" => "true").increment(1);
517
+
Ok(r.iter().map(|r| r.to_string()).collect())
518
+
}
519
+
Err(e) => {
520
+
metrics::counter!("whoami_resolve_dns_txt", "success" => "false").increment(1);
521
+
Err(e.into())
522
+
}
523
+
}
524
+
}
525
+
}
+14
slingshot/src/lib.rs
+14
slingshot/src/lib.rs
···
1
+
mod consumer;
2
+
pub mod error;
3
+
mod firehose_cache;
4
+
mod healthcheck;
5
+
mod identity;
6
+
mod record;
7
+
mod server;
8
+
9
+
pub use consumer::consume;
10
+
pub use firehose_cache::firehose_cache;
11
+
pub use healthcheck::healthcheck;
12
+
pub use identity::Identity;
13
+
pub use record::{CachedRecord, ErrorResponseObject, Repo};
14
+
pub use server::serve;
+194
slingshot/src/main.rs
+194
slingshot/src/main.rs
···
1
+
// use foyer::HybridCache;
2
+
// use foyer::{Engine, DirectFsDeviceOptions, HybridCacheBuilder};
3
+
use metrics_exporter_prometheus::PrometheusBuilder;
4
+
use slingshot::{
5
+
Identity, Repo, consume, error::MainTaskError, firehose_cache, healthcheck, serve,
6
+
};
7
+
use std::path::PathBuf;
8
+
9
+
use clap::Parser;
10
+
use tokio_util::sync::CancellationToken;
11
+
12
+
/// Slingshot record edge cache
13
+
#[derive(Parser, Debug, Clone)]
14
+
#[command(version, about, long_about = None)]
15
+
struct Args {
16
+
/// Jetstream server to connect to (exclusive with --fixture). Provide either a wss:// URL, or a shorhand value:
17
+
/// 'us-east-1', 'us-east-2', 'us-west-1', or 'us-west-2'
18
+
#[arg(long)]
19
+
jetstream: String,
20
+
/// don't request zstd-compressed jetstream events
21
+
///
22
+
/// reduces CPU at the expense of more ingress bandwidth
23
+
#[arg(long, action)]
24
+
jetstream_no_zstd: bool,
25
+
/// where to keep disk caches
26
+
#[arg(long)]
27
+
cache_dir: PathBuf,
28
+
/// the domain pointing to this server
29
+
///
30
+
/// if present:
31
+
/// - a did:web document will be served at /.well-known/did.json
32
+
/// - an HTTPS certs will be automatically configured with Acme/letsencrypt
33
+
/// - TODO: a rate-limiter will be installed
34
+
#[arg(long)]
35
+
domain: Option<String>,
36
+
/// email address for letsencrypt contact
37
+
///
38
+
/// recommended in production, i guess?
39
+
#[arg(long)]
40
+
acme_contact: Option<String>,
41
+
/// a location to cache acme https certs
42
+
///
43
+
/// only used if --host is specified. omitting requires re-requesting certs
44
+
/// on every restart, and letsencrypt has rate limits that are easy to hit.
45
+
///
46
+
/// recommended in production, but mind the file permissions.
47
+
#[arg(long)]
48
+
certs: Option<PathBuf>,
49
+
/// an web address to send healtcheck pings to every ~51s or so
50
+
#[arg(long)]
51
+
healthcheck: Option<String>,
52
+
}
53
+
54
+
#[tokio::main]
55
+
async fn main() -> Result<(), String> {
56
+
tracing_subscriber::fmt::init();
57
+
58
+
let shutdown = CancellationToken::new();
59
+
60
+
let ctrlc_shutdown = shutdown.clone();
61
+
ctrlc::set_handler(move || ctrlc_shutdown.cancel()).expect("failed to set ctrl-c handler");
62
+
63
+
let args = Args::parse();
64
+
65
+
if let Err(e) = install_metrics_server() {
66
+
log::error!("failed to install metrics server: {e:?}");
67
+
} else {
68
+
log::info!("metrics listening at http://0.0.0.0:8765");
69
+
}
70
+
71
+
std::fs::create_dir_all(&args.cache_dir).map_err(|e| {
72
+
format!(
73
+
"failed to ensure cache parent dir: {e:?} (dir: {:?})",
74
+
args.cache_dir
75
+
)
76
+
})?;
77
+
let cache_dir = args.cache_dir.canonicalize().map_err(|e| {
78
+
format!(
79
+
"failed to canonicalize cache_dir: {e:?} (dir: {:?})",
80
+
args.cache_dir
81
+
)
82
+
})?;
83
+
log::info!("cache dir ready at at {cache_dir:?}.");
84
+
85
+
log::info!("setting up firehose cache...");
86
+
let cache = firehose_cache(cache_dir.join("./firehose")).await?;
87
+
log::info!("firehose cache ready.");
88
+
89
+
let mut tasks: tokio::task::JoinSet<Result<(), MainTaskError>> = tokio::task::JoinSet::new();
90
+
91
+
log::info!("starting identity service...");
92
+
let identity = Identity::new(cache_dir.join("./identity"))
93
+
.await
94
+
.map_err(|e| format!("identity setup failed: {e:?}"))?;
95
+
log::info!("identity service ready.");
96
+
let identity_refresher = identity.clone();
97
+
let identity_shutdown = shutdown.clone();
98
+
tasks.spawn(async move {
99
+
identity_refresher.run_refresher(identity_shutdown).await?;
100
+
Ok(())
101
+
});
102
+
103
+
let repo = Repo::new(identity.clone());
104
+
105
+
let server_shutdown = shutdown.clone();
106
+
let server_cache_handle = cache.clone();
107
+
tasks.spawn(async move {
108
+
serve(
109
+
server_cache_handle,
110
+
identity,
111
+
repo,
112
+
args.domain,
113
+
args.acme_contact,
114
+
args.certs,
115
+
server_shutdown,
116
+
)
117
+
.await?;
118
+
Ok(())
119
+
});
120
+
121
+
let consumer_shutdown = shutdown.clone();
122
+
let consumer_cache = cache.clone();
123
+
tasks.spawn(async move {
124
+
consume(
125
+
args.jetstream,
126
+
None,
127
+
args.jetstream_no_zstd,
128
+
consumer_shutdown,
129
+
consumer_cache,
130
+
)
131
+
.await?;
132
+
Ok(())
133
+
});
134
+
135
+
if let Some(hc) = args.healthcheck {
136
+
let healthcheck_shutdown = shutdown.clone();
137
+
tasks.spawn(async move {
138
+
healthcheck(hc, healthcheck_shutdown).await?;
139
+
Ok(())
140
+
});
141
+
}
142
+
143
+
tokio::select! {
144
+
_ = shutdown.cancelled() => log::warn!("shutdown requested"),
145
+
Some(r) = tasks.join_next() => {
146
+
log::warn!("a task exited, shutting down: {r:?}");
147
+
shutdown.cancel();
148
+
}
149
+
}
150
+
151
+
tasks.spawn(async move {
152
+
cache
153
+
.close()
154
+
.await
155
+
.map_err(MainTaskError::FirehoseCacheCloseError)
156
+
});
157
+
158
+
tokio::select! {
159
+
_ = async {
160
+
while let Some(completed) = tasks.join_next().await {
161
+
log::info!("shutdown: task completed: {completed:?}");
162
+
}
163
+
} => {},
164
+
_ = tokio::time::sleep(std::time::Duration::from_secs(30)) => {
165
+
log::info!("shutdown: not all tasks completed on time. aborting...");
166
+
tasks.shutdown().await;
167
+
},
168
+
}
169
+
170
+
log::info!("bye!");
171
+
172
+
Ok(())
173
+
}
174
+
175
+
fn install_metrics_server() -> Result<(), metrics_exporter_prometheus::BuildError> {
176
+
log::info!("installing metrics server...");
177
+
let host = [0, 0, 0, 0];
178
+
let port = 8765;
179
+
PrometheusBuilder::new()
180
+
.set_quantiles(&[0.5, 0.9, 0.99, 1.0])?
181
+
.set_bucket_duration(std::time::Duration::from_secs(300))?
182
+
.set_bucket_count(std::num::NonZero::new(12).unwrap()) // count * duration = 60 mins. stuff doesn't happen that fast here.
183
+
.set_enable_unit_suffix(false) // this seemed buggy for constellation (sometimes wouldn't engage)
184
+
.with_http_listener((host, port))
185
+
.install()?;
186
+
log::info!(
187
+
"metrics server installed! listening on http://{}.{}.{}.{}:{port}",
188
+
host[0],
189
+
host[1],
190
+
host[2],
191
+
host[3]
192
+
);
193
+
Ok(())
194
+
}
+155
slingshot/src/record.rs
+155
slingshot/src/record.rs
···
1
+
//! cached record storage
2
+
3
+
use crate::{Identity, error::RecordError};
4
+
use atrium_api::types::string::{Cid, Did, Nsid, RecordKey};
5
+
use reqwest::{Client, StatusCode};
6
+
use serde::{Deserialize, Serialize};
7
+
use serde_json::value::RawValue;
8
+
use std::str::FromStr;
9
+
use std::time::Duration;
10
+
use url::Url;
11
+
12
+
#[derive(Debug, Serialize, Deserialize)]
13
+
pub struct RawRecord {
14
+
cid: Cid,
15
+
record: String,
16
+
}
17
+
18
+
// TODO: should be able to do typed CID
19
+
impl From<(Cid, Box<RawValue>)> for RawRecord {
20
+
fn from((cid, rv): (Cid, Box<RawValue>)) -> Self {
21
+
Self {
22
+
cid,
23
+
record: rv.get().to_string(),
24
+
}
25
+
}
26
+
}
27
+
28
+
/// only for use with stored (validated) values, not general strings
29
+
impl From<&RawRecord> for (Cid, Box<RawValue>) {
30
+
fn from(RawRecord { cid, record }: &RawRecord) -> Self {
31
+
(
32
+
cid.clone(),
33
+
RawValue::from_string(record.to_string())
34
+
.expect("stored string from RawValue to be valid"),
35
+
)
36
+
}
37
+
}
38
+
39
+
#[derive(Debug, Serialize, Deserialize)]
40
+
pub enum CachedRecord {
41
+
Found(RawRecord),
42
+
Deleted,
43
+
}
44
+
45
+
//////// upstream record fetching
46
+
47
+
#[derive(Deserialize)]
48
+
struct RecordResponseObject {
49
+
#[allow(dead_code)] // expect it to be there but we ignore it
50
+
uri: String,
51
+
/// CID for this exact version of the record
52
+
///
53
+
/// this is optional in the spec and that's potentially TODO for slingshot
54
+
cid: Option<String>,
55
+
/// the record itself as JSON
56
+
value: Box<RawValue>,
57
+
}
58
+
59
+
#[derive(Debug, Deserialize)]
60
+
pub struct ErrorResponseObject {
61
+
pub error: String,
62
+
pub message: String,
63
+
}
64
+
65
+
#[derive(Clone)]
66
+
pub struct Repo {
67
+
identity: Identity,
68
+
client: Client,
69
+
}
70
+
71
+
impl Repo {
72
+
pub fn new(identity: Identity) -> Self {
73
+
let client = Client::builder()
74
+
.user_agent(format!(
75
+
"microcosm slingshot v{} (dev: @bad-example.com)",
76
+
env!("CARGO_PKG_VERSION")
77
+
))
78
+
.no_proxy()
79
+
.timeout(Duration::from_secs(10))
80
+
.build()
81
+
.unwrap();
82
+
Repo { identity, client }
83
+
}
84
+
85
+
pub async fn get_record(
86
+
&self,
87
+
did: &Did,
88
+
collection: &Nsid,
89
+
rkey: &RecordKey,
90
+
cid: &Option<Cid>,
91
+
) -> Result<CachedRecord, RecordError> {
92
+
let Some(pds) = self.identity.did_to_pds(did.clone()).await? else {
93
+
return Err(RecordError::NotFound("could not get pds for DID"));
94
+
};
95
+
96
+
// cid gets set to None for a retry, if it's Some and we got NotFound
97
+
let mut cid = cid;
98
+
99
+
let res = loop {
100
+
// TODO: throttle outgoing requests by host probably, generally guard against outgoing requests
101
+
let mut params = vec![
102
+
("repo", did.to_string()),
103
+
("collection", collection.to_string()),
104
+
("rkey", rkey.to_string()),
105
+
];
106
+
if let Some(cid) = cid {
107
+
params.push(("cid", cid.as_ref().to_string()));
108
+
}
109
+
let mut url = Url::parse_with_params(&pds, ¶ms)?;
110
+
url.set_path("/xrpc/com.atproto.repo.getRecord");
111
+
112
+
let res = self
113
+
.client
114
+
.get(url.clone())
115
+
.send()
116
+
.await
117
+
.map_err(RecordError::SendError)?;
118
+
119
+
if res.status() == StatusCode::BAD_REQUEST {
120
+
// 1. if we're not able to parse json, it's not something we can handle
121
+
let err = res
122
+
.json::<ErrorResponseObject>()
123
+
.await
124
+
.map_err(RecordError::UpstreamBadBadNotGoodRequest)?;
125
+
// 2. if we are, is it a NotFound? and if so, did we try with a CID?
126
+
// if so, retry with no CID (api handler will reject for mismatch but
127
+
// with a nice error + warm cache)
128
+
if err.error == "NotFound" && cid.is_some() {
129
+
cid = &None;
130
+
continue;
131
+
} else {
132
+
return Err(RecordError::UpstreamBadRequest(err));
133
+
}
134
+
}
135
+
break res;
136
+
};
137
+
138
+
let data = res
139
+
.error_for_status()
140
+
.map_err(RecordError::StatusError)? // TODO atproto error handling (think about handling not found)
141
+
.json::<RecordResponseObject>()
142
+
.await
143
+
.map_err(RecordError::ParseJsonError)?; // todo...
144
+
145
+
let Some(cid) = data.cid else {
146
+
return Err(RecordError::MissingUpstreamCid);
147
+
};
148
+
let cid = Cid::from_str(&cid).map_err(|e| RecordError::BadUpstreamCid(e.to_string()))?;
149
+
150
+
Ok(CachedRecord::Found(RawRecord {
151
+
cid,
152
+
record: data.value.to_string(),
153
+
}))
154
+
}
155
+
}
+778
slingshot/src/server.rs
+778
slingshot/src/server.rs
···
1
+
use crate::{
2
+
CachedRecord, ErrorResponseObject, Identity, Repo,
3
+
error::{RecordError, ServerError},
4
+
};
5
+
use atrium_api::types::string::{Cid, Did, Handle, Nsid, RecordKey};
6
+
use foyer::HybridCache;
7
+
use links::at_uri::parse_at_uri as normalize_at_uri;
8
+
use serde::Serialize;
9
+
use std::path::PathBuf;
10
+
use std::str::FromStr;
11
+
use std::sync::Arc;
12
+
use tokio_util::sync::CancellationToken;
13
+
14
+
use poem::{
15
+
Endpoint, EndpointExt, Route, Server,
16
+
endpoint::{StaticFileEndpoint, make_sync},
17
+
http::Method,
18
+
listener::{
19
+
Listener, TcpListener,
20
+
acme::{AutoCert, LETS_ENCRYPT_PRODUCTION},
21
+
},
22
+
middleware::{CatchPanic, Cors, Tracing},
23
+
};
24
+
use poem_openapi::{
25
+
ApiResponse, ContactObject, ExternalDocumentObject, Object, OpenApi, OpenApiService, Tags,
26
+
param::Query, payload::Json, types::Example,
27
+
};
28
+
29
+
fn example_handle() -> String {
30
+
"bad-example.com".to_string()
31
+
}
32
+
fn example_did() -> String {
33
+
"did:plc:hdhoaan3xa3jiuq4fg4mefid".to_string()
34
+
}
35
+
fn example_collection() -> String {
36
+
"app.bsky.feed.like".to_string()
37
+
}
38
+
fn example_rkey() -> String {
39
+
"3lv4ouczo2b2a".to_string()
40
+
}
41
+
fn example_uri() -> String {
42
+
format!(
43
+
"at://{}/{}/{}",
44
+
example_did(),
45
+
example_collection(),
46
+
example_rkey()
47
+
)
48
+
}
49
+
fn example_pds() -> String {
50
+
"https://porcini.us-east.host.bsky.network".to_string()
51
+
}
52
+
fn example_signing_key() -> String {
53
+
"zQ3shpq1g134o7HGDb86CtQFxnHqzx5pZWknrVX2Waum3fF6j".to_string()
54
+
}
55
+
56
+
#[derive(Object)]
57
+
#[oai(example = true)]
58
+
struct XrpcErrorResponseObject {
59
+
/// Should correspond an error `name` in the lexicon errors array
60
+
error: String,
61
+
/// Human-readable description and possibly additonal context
62
+
message: String,
63
+
}
64
+
impl Example for XrpcErrorResponseObject {
65
+
fn example() -> Self {
66
+
Self {
67
+
error: "RecordNotFound".to_string(),
68
+
message: "This record was deleted".to_string(),
69
+
}
70
+
}
71
+
}
72
+
type XrpcError = Json<XrpcErrorResponseObject>;
73
+
fn xrpc_error(error: impl AsRef<str>, message: impl AsRef<str>) -> XrpcError {
74
+
Json(XrpcErrorResponseObject {
75
+
error: error.as_ref().to_string(),
76
+
message: message.as_ref().to_string(),
77
+
})
78
+
}
79
+
80
+
fn bad_request_handler_get_record(err: poem::Error) -> GetRecordResponse {
81
+
GetRecordResponse::BadRequest(Json(XrpcErrorResponseObject {
82
+
error: "InvalidRequest".to_string(),
83
+
message: format!("Bad request, here's some info that maybe should not be exposed: {err}"),
84
+
}))
85
+
}
86
+
87
+
fn bad_request_handler_resolve_mini(err: poem::Error) -> ResolveMiniIDResponse {
88
+
ResolveMiniIDResponse::BadRequest(Json(XrpcErrorResponseObject {
89
+
error: "InvalidRequest".to_string(),
90
+
message: format!("Bad request, here's some info that maybe should not be exposed: {err}"),
91
+
}))
92
+
}
93
+
94
+
fn bad_request_handler_resolve_handle(err: poem::Error) -> JustDidResponse {
95
+
JustDidResponse::BadRequest(Json(XrpcErrorResponseObject {
96
+
error: "InvalidRequest".to_string(),
97
+
message: format!("Bad request, here's some info that maybe should not be exposed: {err}"),
98
+
}))
99
+
}
100
+
101
+
#[derive(Object)]
102
+
#[oai(example = true)]
103
+
struct FoundRecordResponseObject {
104
+
/// at-uri for this record
105
+
uri: String,
106
+
/// CID for this exact version of the record
107
+
///
108
+
/// Slingshot will always return the CID, despite it not being a required
109
+
/// response property in the official lexicon.
110
+
///
111
+
/// TODO: probably actually let it be optional, idk are some pds's weirdly
112
+
/// not returning it?
113
+
cid: Option<String>,
114
+
/// the record itself as JSON
115
+
value: serde_json::Value,
116
+
}
117
+
impl Example for FoundRecordResponseObject {
118
+
fn example() -> Self {
119
+
Self {
120
+
uri: example_uri(),
121
+
cid: Some("bafyreialv3mzvvxaoyrfrwoer3xmabbmdchvrbyhayd7bga47qjbycy74e".to_string()),
122
+
value: serde_json::json!({
123
+
"$type": "app.bsky.feed.like",
124
+
"createdAt": "2025-07-29T18:02:02.327Z",
125
+
"subject": {
126
+
"cid": "bafyreia2gy6eyk5qfetgahvshpq35vtbwy6negpy3gnuulcdi723mi7vxy",
127
+
"uri": "at://did:plc:vwzwgnygau7ed7b7wt5ux7y2/app.bsky.feed.post/3lv4lkb4vgs2k"
128
+
}
129
+
}),
130
+
}
131
+
}
132
+
}
133
+
134
+
#[derive(ApiResponse)]
135
+
#[oai(bad_request_handler = "bad_request_handler_get_record")]
136
+
enum GetRecordResponse {
137
+
/// Record found
138
+
#[oai(status = 200)]
139
+
Ok(Json<FoundRecordResponseObject>),
140
+
/// Bad request or no record to return
141
+
///
142
+
/// The only error name in the repo.getRecord lexicon is `RecordNotFound`,
143
+
/// but the [canonical api docs](https://docs.bsky.app/docs/api/com-atproto-repo-get-record)
144
+
/// also list `InvalidRequest`, `ExpiredToken`, and `InvalidToken`. Of
145
+
/// these, slingshot will only generate `RecordNotFound` or `InvalidRequest`,
146
+
/// but may return any proxied error code from the upstream repo.
147
+
#[oai(status = 400)]
148
+
BadRequest(XrpcError),
149
+
/// Server errors
150
+
#[oai(status = 500)]
151
+
ServerError(XrpcError),
152
+
}
153
+
154
+
#[derive(Object)]
155
+
#[oai(example = true)]
156
+
struct MiniDocResponseObject {
157
+
/// DID, bi-directionally verified if a handle was provided in the query.
158
+
did: String,
159
+
/// The validated handle of the account or `handle.invalid` if the handle
160
+
/// did not bi-directionally match the DID document.
161
+
handle: String,
162
+
/// The identity's PDS URL
163
+
pds: String,
164
+
/// The atproto signing key publicKeyMultibase
165
+
///
166
+
/// Legacy key encoding not supported. the key is returned directly; `id`,
167
+
/// `type`, and `controller` are omitted.
168
+
signing_key: String,
169
+
}
170
+
impl Example for MiniDocResponseObject {
171
+
fn example() -> Self {
172
+
Self {
173
+
did: example_did(),
174
+
handle: example_handle(),
175
+
pds: example_pds(),
176
+
signing_key: example_signing_key(),
177
+
}
178
+
}
179
+
}
180
+
181
+
#[derive(ApiResponse)]
182
+
#[oai(bad_request_handler = "bad_request_handler_resolve_mini")]
183
+
enum ResolveMiniIDResponse {
184
+
/// Identity resolved
185
+
#[oai(status = 200)]
186
+
Ok(Json<MiniDocResponseObject>),
187
+
/// Bad request or identity not resolved
188
+
#[oai(status = 400)]
189
+
BadRequest(XrpcError),
190
+
}
191
+
192
+
#[derive(Object)]
193
+
#[oai(example = true)]
194
+
struct FoundDidResponseObject {
195
+
/// the DID, bi-directionally verified if using Slingshot
196
+
did: String,
197
+
}
198
+
impl Example for FoundDidResponseObject {
199
+
fn example() -> Self {
200
+
Self { did: example_did() }
201
+
}
202
+
}
203
+
204
+
#[derive(ApiResponse)]
205
+
#[oai(bad_request_handler = "bad_request_handler_resolve_handle")]
206
+
enum JustDidResponse {
207
+
/// Resolution succeeded
208
+
#[oai(status = 200)]
209
+
Ok(Json<FoundDidResponseObject>),
210
+
/// Bad request, failed to resolve, or failed to verify
211
+
///
212
+
/// `error` will be one of `InvalidRequest`, `HandleNotFound`.
213
+
#[oai(status = 400)]
214
+
BadRequest(XrpcError),
215
+
/// Something went wrong trying to complete the request
216
+
#[oai(status = 500)]
217
+
ServerError(XrpcError),
218
+
}
219
+
220
+
struct Xrpc {
221
+
cache: HybridCache<String, CachedRecord>,
222
+
identity: Identity,
223
+
repo: Arc<Repo>,
224
+
}
225
+
226
+
#[derive(Tags)]
227
+
enum ApiTags {
228
+
/// Core ATProtocol-compatible APIs.
229
+
///
230
+
/// > [!tip]
231
+
/// > Upstream documentation is available at
232
+
/// > https://docs.bsky.app/docs/category/http-reference
233
+
///
234
+
/// These queries are usually executed directly against the PDS containing
235
+
/// the data being requested. Slingshot offers a caching view of the same
236
+
/// contents with better expected performance and reliability.
237
+
#[oai(rename = "com.atproto.* queries")]
238
+
ComAtproto,
239
+
/// Additional and improved APIs.
240
+
///
241
+
/// These APIs offer small tweaks to the core ATProtocol APIs, with more
242
+
/// more convenient [request parameters](#tag/slingshot-specific-queries/GET/xrpc/com.bad-example.repo.getUriRecord)
243
+
/// or [response formats](#tag/slingshot-specific-queries/GET/xrpc/com.bad-example.identity.resolveMiniDoc).
244
+
///
245
+
/// > [!important]
246
+
/// > At the moment, these are namespaced under the `com.bad-example.*` NSID
247
+
/// > prefix, but as they stabilize they may be migrated to an org namespace
248
+
/// > like `blue.microcosm.*`. Support for asliasing to `com.bad-example.*`
249
+
/// > will be maintained as long as it's in use.
250
+
#[oai(rename = "slingshot-specific queries")]
251
+
Custom,
252
+
}
253
+
254
+
#[OpenApi]
255
+
impl Xrpc {
256
+
/// com.atproto.repo.getRecord
257
+
///
258
+
/// Get a single record from a repository. Does not require auth.
259
+
///
260
+
/// > [!tip]
261
+
/// > See also the [canonical `com.atproto` XRPC documentation](https://docs.bsky.app/docs/api/com-atproto-repo-get-record)
262
+
/// > that this endpoint aims to be compatible with.
263
+
#[oai(
264
+
path = "/com.atproto.repo.getRecord",
265
+
method = "get",
266
+
tag = "ApiTags::ComAtproto"
267
+
)]
268
+
async fn get_record(
269
+
&self,
270
+
/// The DID or handle of the repo
271
+
#[oai(example = "example_did")]
272
+
Query(repo): Query<String>,
273
+
/// The NSID of the record collection
274
+
#[oai(example = "example_collection")]
275
+
Query(collection): Query<String>,
276
+
/// The Record key
277
+
#[oai(example = "example_rkey")]
278
+
Query(rkey): Query<String>,
279
+
/// Optional: the CID of the version of the record.
280
+
///
281
+
/// If not specified, then return the most recent version.
282
+
///
283
+
/// If a stale `CID` is specified and a newer version of the record
284
+
/// exists, Slingshot returns a `NotFound` error. That is: Slingshot
285
+
/// only retains the most recent version of a record.
286
+
Query(cid): Query<Option<String>>,
287
+
) -> GetRecordResponse {
288
+
self.get_record_impl(repo, collection, rkey, cid).await
289
+
}
290
+
291
+
/// com.bad-example.repo.getUriRecord
292
+
///
293
+
/// Ergonomic complement to [`com.atproto.repo.getRecord`](https://docs.bsky.app/docs/api/com-atproto-repo-get-record)
294
+
/// which accepts an `at-uri` instead of individual repo/collection/rkey params
295
+
#[oai(
296
+
path = "/com.bad-example.repo.getUriRecord",
297
+
method = "get",
298
+
tag = "ApiTags::Custom"
299
+
)]
300
+
async fn get_uri_record(
301
+
&self,
302
+
/// The at-uri of the record
303
+
///
304
+
/// The identifier can be a DID or an atproto handle, and the collection
305
+
/// and rkey segments must be present.
306
+
#[oai(example = "example_uri")]
307
+
Query(at_uri): Query<String>,
308
+
/// Optional: the CID of the version of the record.
309
+
///
310
+
/// If not specified, then return the most recent version.
311
+
///
312
+
/// > [!tip]
313
+
/// > If specified and a newer version of the record exists, returns 404 not
314
+
/// > found. That is: slingshot only retains the most recent version of a
315
+
/// > record.
316
+
Query(cid): Query<Option<String>>,
317
+
) -> GetRecordResponse {
318
+
let bad_at_uri = || {
319
+
GetRecordResponse::BadRequest(xrpc_error(
320
+
"InvalidRequest",
321
+
"at-uri does not appear to be valid",
322
+
))
323
+
};
324
+
325
+
let Some(normalized) = normalize_at_uri(&at_uri) else {
326
+
return bad_at_uri();
327
+
};
328
+
329
+
// TODO: move this to links
330
+
let Some(rest) = normalized.strip_prefix("at://") else {
331
+
return bad_at_uri();
332
+
};
333
+
let Some((repo, rest)) = rest.split_once('/') else {
334
+
return bad_at_uri();
335
+
};
336
+
let Some((collection, rest)) = rest.split_once('/') else {
337
+
return bad_at_uri();
338
+
};
339
+
let rkey = if let Some((rkey, _rest)) = rest.split_once('?') {
340
+
rkey
341
+
} else {
342
+
rest
343
+
};
344
+
345
+
self.get_record_impl(
346
+
repo.to_string(),
347
+
collection.to_string(),
348
+
rkey.to_string(),
349
+
cid,
350
+
)
351
+
.await
352
+
}
353
+
354
+
/// com.atproto.identity.resolveHandle
355
+
///
356
+
/// Resolves an atproto [`handle`](https://atproto.com/guides/glossary#handle)
357
+
/// (hostname) to a [`DID`](https://atproto.com/guides/glossary#did-decentralized-id).
358
+
///
359
+
/// > [!tip]
360
+
/// > Compatibility note: Slingshot will **always bi-directionally verify
361
+
/// > against the DID document**, which is optional according to the
362
+
/// > authoritative lexicon.
363
+
///
364
+
/// > [!tip]
365
+
/// > See the [canonical `com.atproto` XRPC documentation](https://docs.bsky.app/docs/api/com-atproto-identity-resolve-handle)
366
+
/// > that this endpoint aims to be compatible with.
367
+
#[oai(
368
+
path = "/com.atproto.identity.resolveHandle",
369
+
method = "get",
370
+
tag = "ApiTags::ComAtproto"
371
+
)]
372
+
async fn resolve_handle(
373
+
&self,
374
+
/// The handle to resolve.
375
+
#[oai(example = "example_handle")]
376
+
Query(handle): Query<String>,
377
+
) -> JustDidResponse {
378
+
let Ok(handle) = Handle::new(handle) else {
379
+
return JustDidResponse::BadRequest(xrpc_error("InvalidRequest", "not a valid handle"));
380
+
};
381
+
382
+
let Ok(alleged_did) = self.identity.handle_to_did(handle.clone()).await else {
383
+
return JustDidResponse::ServerError(xrpc_error("Failed", "Could not resolve handle"));
384
+
};
385
+
386
+
let Some(alleged_did) = alleged_did else {
387
+
return JustDidResponse::BadRequest(xrpc_error(
388
+
"HandleNotFound",
389
+
"Could not resolve handle to a DID",
390
+
));
391
+
};
392
+
393
+
let Ok(partial_doc) = self.identity.did_to_partial_mini_doc(&alleged_did).await else {
394
+
return JustDidResponse::ServerError(xrpc_error("Failed", "Could not fetch DID doc"));
395
+
};
396
+
397
+
let Some(partial_doc) = partial_doc else {
398
+
return JustDidResponse::BadRequest(xrpc_error(
399
+
"HandleNotFound",
400
+
"Resolved handle but could not find DID doc for the DID",
401
+
));
402
+
};
403
+
404
+
if partial_doc.unverified_handle != handle {
405
+
return JustDidResponse::BadRequest(xrpc_error(
406
+
"HandleNotFound",
407
+
"Resolved handle failed bi-directional validation",
408
+
));
409
+
}
410
+
411
+
JustDidResponse::Ok(Json(FoundDidResponseObject {
412
+
did: alleged_did.to_string(),
413
+
}))
414
+
}
415
+
416
+
/// com.bad-example.identity.resolveMiniDoc
417
+
///
418
+
/// Like [com.atproto.identity.resolveIdentity](https://docs.bsky.app/docs/api/com-atproto-identity-resolve-identity)
419
+
/// but instead of the full `didDoc` it returns an atproto-relevant subset.
420
+
#[oai(
421
+
path = "/com.bad-example.identity.resolveMiniDoc",
422
+
method = "get",
423
+
tag = "ApiTags::Custom"
424
+
)]
425
+
async fn resolve_mini_id(
426
+
&self,
427
+
/// Handle or DID to resolve
428
+
#[oai(example = "example_handle")]
429
+
Query(identifier): Query<String>,
430
+
) -> ResolveMiniIDResponse {
431
+
let invalid = |reason: &'static str| {
432
+
ResolveMiniIDResponse::BadRequest(xrpc_error("InvalidRequest", reason))
433
+
};
434
+
435
+
let mut unverified_handle = None;
436
+
let did = match Did::new(identifier.clone()) {
437
+
Ok(did) => did,
438
+
Err(_) => {
439
+
let Ok(alleged_handle) = Handle::new(identifier) else {
440
+
return invalid("identifier was not a valid DID or handle");
441
+
};
442
+
443
+
match self.identity.handle_to_did(alleged_handle.clone()).await {
444
+
Ok(res) => {
445
+
if let Some(did) = res {
446
+
// we did it joe
447
+
unverified_handle = Some(alleged_handle);
448
+
did
449
+
} else {
450
+
return invalid("Could not resolve handle identifier to a DID");
451
+
}
452
+
}
453
+
Err(e) => {
454
+
log::debug!("failed to resolve handle: {e}");
455
+
// TODO: ServerError not BadRequest
456
+
return invalid("errored while trying to resolve handle to DID");
457
+
}
458
+
}
459
+
}
460
+
};
461
+
let Ok(partial_doc) = self.identity.did_to_partial_mini_doc(&did).await else {
462
+
return invalid("failed to get DID doc");
463
+
};
464
+
let Some(partial_doc) = partial_doc else {
465
+
return invalid("failed to find DID doc");
466
+
};
467
+
468
+
// ok so here's where we're at:
469
+
// ✅ we have a DID
470
+
// ✅ we have a partial doc
471
+
// 🔶 if we have a handle, it's from the `identifier` (user-input)
472
+
// -> then we just need to compare to the partial doc to confirm
473
+
// -> else we need to resolve the DID doc's to a handle and check
474
+
let handle = if let Some(h) = unverified_handle {
475
+
if h == partial_doc.unverified_handle {
476
+
h.to_string()
477
+
} else {
478
+
"handle.invalid".to_string()
479
+
}
480
+
} else {
481
+
let Ok(handle_did) = self
482
+
.identity
483
+
.handle_to_did(partial_doc.unverified_handle.clone())
484
+
.await
485
+
else {
486
+
return invalid("failed to get did doc's handle");
487
+
};
488
+
let Some(handle_did) = handle_did else {
489
+
return invalid("failed to resolve did doc's handle");
490
+
};
491
+
if handle_did == did {
492
+
partial_doc.unverified_handle.to_string()
493
+
} else {
494
+
"handle.invalid".to_string()
495
+
}
496
+
};
497
+
498
+
ResolveMiniIDResponse::Ok(Json(MiniDocResponseObject {
499
+
did: did.to_string(),
500
+
handle,
501
+
pds: partial_doc.pds,
502
+
signing_key: partial_doc.signing_key,
503
+
}))
504
+
}
505
+
506
+
async fn get_record_impl(
507
+
&self,
508
+
repo: String,
509
+
collection: String,
510
+
rkey: String,
511
+
cid: Option<String>,
512
+
) -> GetRecordResponse {
513
+
let did = match Did::new(repo.clone()) {
514
+
Ok(did) => did,
515
+
Err(_) => {
516
+
let Ok(handle) = Handle::new(repo) else {
517
+
return GetRecordResponse::BadRequest(xrpc_error(
518
+
"InvalidRequest",
519
+
"repo was not a valid DID or handle",
520
+
));
521
+
};
522
+
match self.identity.handle_to_did(handle).await {
523
+
Ok(res) => {
524
+
if let Some(did) = res {
525
+
did
526
+
} else {
527
+
return GetRecordResponse::BadRequest(xrpc_error(
528
+
"InvalidRequest",
529
+
"Could not resolve handle repo to a DID",
530
+
));
531
+
}
532
+
}
533
+
Err(e) => {
534
+
log::debug!("handle resolution failed: {e}");
535
+
return GetRecordResponse::ServerError(xrpc_error(
536
+
"ResolutionFailed",
537
+
"errored while trying to resolve handle to DID",
538
+
));
539
+
}
540
+
}
541
+
}
542
+
};
543
+
544
+
let Ok(collection) = Nsid::new(collection) else {
545
+
return GetRecordResponse::BadRequest(xrpc_error(
546
+
"InvalidRequest",
547
+
"invalid NSID for collection",
548
+
));
549
+
};
550
+
551
+
let Ok(rkey) = RecordKey::new(rkey) else {
552
+
return GetRecordResponse::BadRequest(xrpc_error("InvalidRequest", "invalid rkey"));
553
+
};
554
+
555
+
let cid: Option<Cid> = if let Some(cid) = cid {
556
+
let Ok(cid) = Cid::from_str(&cid) else {
557
+
return GetRecordResponse::BadRequest(xrpc_error("InvalidRequest", "invalid CID"));
558
+
};
559
+
Some(cid)
560
+
} else {
561
+
None
562
+
};
563
+
564
+
let at_uri = format!("at://{}/{}/{}", &*did, &*collection, &*rkey);
565
+
566
+
let fr = self
567
+
.cache
568
+
.fetch(at_uri.clone(), {
569
+
let cid = cid.clone();
570
+
let repo_api = self.repo.clone();
571
+
|| async move {
572
+
repo_api
573
+
.get_record(&did, &collection, &rkey, &cid)
574
+
.await
575
+
.map_err(|e| foyer::Error::Other(Box::new(e)))
576
+
}
577
+
})
578
+
.await;
579
+
580
+
let entry = match fr {
581
+
Ok(e) => e,
582
+
Err(foyer::Error::Other(e)) => {
583
+
let record_error = match e.downcast::<RecordError>() {
584
+
Ok(e) => e,
585
+
Err(e) => {
586
+
log::error!("error (foyer other) getting cache entry, {e:?}");
587
+
return GetRecordResponse::ServerError(xrpc_error(
588
+
"ServerError",
589
+
"sorry, something went wrong",
590
+
));
591
+
}
592
+
};
593
+
let RecordError::UpstreamBadRequest(ErrorResponseObject { error, message }) =
594
+
*record_error
595
+
else {
596
+
log::error!("RecordError getting cache entry, {record_error:?}");
597
+
return GetRecordResponse::ServerError(xrpc_error(
598
+
"ServerError",
599
+
"sorry, something went wrong",
600
+
));
601
+
};
602
+
603
+
// all of the noise around here is so that we can ultimately reach this:
604
+
// upstream BadRequest extracted from the foyer result which we can proxy back
605
+
return GetRecordResponse::BadRequest(xrpc_error(
606
+
error,
607
+
format!("Upstream bad request: {message}"),
608
+
));
609
+
}
610
+
Err(e) => {
611
+
log::error!("error (foyer) getting cache entry, {e:?}");
612
+
return GetRecordResponse::ServerError(xrpc_error(
613
+
"ServerError",
614
+
"sorry, something went wrong",
615
+
));
616
+
}
617
+
};
618
+
619
+
match *entry {
620
+
CachedRecord::Found(ref raw) => {
621
+
let (found_cid, raw_value) = raw.into();
622
+
if cid.clone().map(|c| c != found_cid).unwrap_or(false) {
623
+
return GetRecordResponse::BadRequest(Json(XrpcErrorResponseObject {
624
+
error: "RecordNotFound".to_string(),
625
+
message: "A record was found but its CID did not match that requested"
626
+
.to_string(),
627
+
}));
628
+
}
629
+
// TODO: thank u stellz: https://gist.github.com/stella3d/51e679e55b264adff89d00a1e58d0272
630
+
let value =
631
+
serde_json::from_str(raw_value.get()).expect("RawValue to be valid json");
632
+
GetRecordResponse::Ok(Json(FoundRecordResponseObject {
633
+
uri: at_uri,
634
+
cid: Some(found_cid.as_ref().to_string()),
635
+
value,
636
+
}))
637
+
}
638
+
CachedRecord::Deleted => GetRecordResponse::BadRequest(Json(XrpcErrorResponseObject {
639
+
error: "RecordNotFound".to_string(),
640
+
message: "This record was deleted".to_string(),
641
+
})),
642
+
}
643
+
}
644
+
645
+
// TODO
646
+
// #[oai(path = "/com.atproto.identity.resolveHandle", method = "get")]
647
+
// #[oai(path = "/com.atproto.identity.resolveDid", method = "get")]
648
+
// but these are both not specified to do bidirectional validation, which is what we want to offer
649
+
// com.atproto.identity.resolveIdentity seems right, but requires returning the full did-doc
650
+
// would be nice if there were two queries:
651
+
// did -> verified handle + pds url
652
+
// handle -> verified did + pds url
653
+
//
654
+
// we could do horrible things and implement resolveIdentity with only a stripped-down fake did doc
655
+
// but this will *definitely* cause problems because eg. we're not currently storing pubkeys and
656
+
// those are a little bit important
657
+
}
658
+
659
+
#[derive(Debug, Clone, Serialize)]
660
+
#[serde(rename_all = "camelCase")]
661
+
struct AppViewService {
662
+
id: String,
663
+
r#type: String,
664
+
service_endpoint: String,
665
+
}
666
+
#[derive(Debug, Clone, Serialize)]
667
+
struct AppViewDoc {
668
+
id: String,
669
+
service: [AppViewService; 1],
670
+
}
671
+
/// Serve a did document for did:web for this to be an xrpc appview
672
+
///
673
+
/// No slingshot endpoints currently require auth, so it's not necessary to do
674
+
/// service proxying, however clients may wish to:
675
+
///
676
+
/// - PDS proxying offers a level of client IP anonymity from slingshot
677
+
/// - slingshot *may* implement more generous per-user rate-limits for proxied requests in the future
678
+
fn get_did_doc(domain: &str) -> impl Endpoint + use<> {
679
+
let doc = poem::web::Json(AppViewDoc {
680
+
id: format!("did:web:{domain}"),
681
+
service: [AppViewService {
682
+
id: "#slingshot".to_string(),
683
+
r#type: "SlingshotRecordProxy".to_string(),
684
+
service_endpoint: format!("https://{domain}"),
685
+
}],
686
+
});
687
+
make_sync(move |_| doc.clone())
688
+
}
689
+
690
+
pub async fn serve(
691
+
cache: HybridCache<String, CachedRecord>,
692
+
identity: Identity,
693
+
repo: Repo,
694
+
domain: Option<String>,
695
+
acme_contact: Option<String>,
696
+
certs: Option<PathBuf>,
697
+
shutdown: CancellationToken,
698
+
) -> Result<(), ServerError> {
699
+
let repo = Arc::new(repo);
700
+
let api_service = OpenApiService::new(
701
+
Xrpc {
702
+
cache,
703
+
identity,
704
+
repo,
705
+
},
706
+
"Slingshot",
707
+
env!("CARGO_PKG_VERSION"),
708
+
)
709
+
.server(if let Some(ref h) = domain {
710
+
format!("https://{h}")
711
+
} else {
712
+
"http://localhost:3000".to_string()
713
+
})
714
+
.url_prefix("/xrpc")
715
+
.contact(
716
+
ContactObject::new()
717
+
.name("@microcosm.blue")
718
+
.url("https://bsky.app/profile/microcosm.blue"),
719
+
)
720
+
.description(include_str!("../api-description.md"))
721
+
.external_document(ExternalDocumentObject::new(
722
+
"https://microcosm.blue/slingshot",
723
+
));
724
+
725
+
let mut app = Route::new()
726
+
.at("/", StaticFileEndpoint::new("./static/index.html"))
727
+
.nest("/openapi", api_service.spec_endpoint())
728
+
.nest("/xrpc/", api_service);
729
+
730
+
if let Some(domain) = domain {
731
+
rustls::crypto::aws_lc_rs::default_provider()
732
+
.install_default()
733
+
.expect("alskfjalksdjf");
734
+
735
+
app = app.at("/.well-known/did.json", get_did_doc(&domain));
736
+
737
+
let mut auto_cert = AutoCert::builder()
738
+
.directory_url(LETS_ENCRYPT_PRODUCTION)
739
+
.domain(&domain);
740
+
if let Some(contact) = acme_contact {
741
+
auto_cert = auto_cert.contact(contact);
742
+
}
743
+
if let Some(certs) = certs {
744
+
auto_cert = auto_cert.cache_path(certs);
745
+
}
746
+
let auto_cert = auto_cert.build().map_err(ServerError::AcmeBuildError)?;
747
+
748
+
run(
749
+
TcpListener::bind("0.0.0.0:443").acme(auto_cert),
750
+
app,
751
+
shutdown,
752
+
)
753
+
.await
754
+
} else {
755
+
run(TcpListener::bind("127.0.0.1:3000"), app, shutdown).await
756
+
}
757
+
}
758
+
759
+
async fn run<L>(listener: L, app: Route, shutdown: CancellationToken) -> Result<(), ServerError>
760
+
where
761
+
L: Listener + 'static,
762
+
{
763
+
let app = app
764
+
.with(
765
+
Cors::new()
766
+
.allow_origin_regex("*")
767
+
.allow_methods([Method::GET])
768
+
.allow_credentials(false),
769
+
)
770
+
.with(CatchPanic::new())
771
+
.with(Tracing);
772
+
Server::new(listener)
773
+
.name("slingshot")
774
+
.run_with_graceful_shutdown(app, shutdown.cancelled(), None)
775
+
.await
776
+
.map_err(ServerError::ServerExited)
777
+
.inspect(|()| log::info!("server ended. goodbye."))
778
+
}
slingshot/static/favicon.ico
slingshot/static/favicon.ico
This is a binary file and will not be displayed.
+67
slingshot/static/index.html
+67
slingshot/static/index.html
···
1
+
<!doctype html>
2
+
<html lang="en">
3
+
<head>
4
+
<meta charset="utf-8" />
5
+
<title>Slingshot: atproto edge record cache</title>
6
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7
+
<meta name="description" content="API Documentation for Slingshot, a firehose-listening atproto edge record and identity cache." />
8
+
<style>
9
+
:root {
10
+
--scalar-small: 13px;
11
+
}
12
+
.scalar-app .markdown .markdown-alert {
13
+
font-size: var(--scalar-small);
14
+
}
15
+
.sidebar-heading-link-title {
16
+
line-height: 1.2;
17
+
}
18
+
.custom-header {
19
+
height: 42px;
20
+
background-color: #221828;
21
+
box-shadow: inset 0 -1px 0 var(--scalar-border-color);
22
+
color: var(--scalar-color-1);
23
+
font-size: var(--scalar-font-size-3);
24
+
font-family: 'Iowan Old Style', 'Palatino Linotype', 'URW Palladio L', P052, serif;
25
+
padding: 0 18px;
26
+
justify-content: space-between;
27
+
}
28
+
.custom-header,
29
+
.custom-header nav {
30
+
display: flex;
31
+
align-items: center;
32
+
gap: 18px;
33
+
}
34
+
.custom-header a:hover {
35
+
color: var(--scalar-color-2);
36
+
}
37
+
38
+
.light-mode .custom-header {
39
+
background-color: thistle;
40
+
}
41
+
</style>
42
+
</head>
43
+
<body>
44
+
<header class="custom-header scalar-app">
45
+
<p>
46
+
TODO: thing
47
+
</p>
48
+
<nav>
49
+
<b>a <a href="https://microcosm.blue">microcosm</a> project</b>
50
+
<a href="https://bsky.app/profile/microcosm.blue">@microcosm.blue</a>
51
+
<a href="https://github.com/at-microcosm">github</a>
52
+
</nav>
53
+
</header>
54
+
55
+
<script id="api-reference" type="application/json" data-url="/openapi"></script>
56
+
57
+
<script>
58
+
var configuration = {
59
+
theme: 'purple',
60
+
hideModels: true,
61
+
}
62
+
document.getElementById('api-reference').dataset.configuration = JSON.stringify(configuration)
63
+
</script>
64
+
65
+
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
66
+
</body>
67
+
</html>
+8
spacedust/Cargo.toml
+8
spacedust/Cargo.toml
···
4
4
edition = "2024"
5
5
6
6
[dependencies]
7
+
anyhow = "1.0.100"
8
+
async-channel = "2.5.0"
7
9
async-trait = "0.1.88"
8
10
clap = { version = "4.5.40", features = ["derive"] }
9
11
ctrlc = "3.4.7"
12
+
dasl = "0.2.0"
10
13
dropshot = "0.16.2"
11
14
env_logger = "0.11.8"
15
+
fjall = "3.0.0-pre.0"
12
16
futures = "0.3.31"
13
17
http = "1.3.1"
18
+
ipld-core = { version = "0.4.2", features = ["serde"] }
14
19
jetstream = { path = "../jetstream", features = ["metrics"] }
15
20
links = { path = "../links" }
16
21
log = "0.4.27"
17
22
metrics = "0.24.2"
18
23
metrics-exporter-prometheus = { version = "0.17.1", features = ["http-listener"] }
19
24
rand = "0.9.1"
25
+
repo-stream = "0.2.2"
26
+
reqwest = { version = "0.12.24", features = ["json", "stream"] }
20
27
schemars = "0.8.22"
21
28
semver = "1.0.26"
22
29
serde = { version = "1.0.219", features = ["derive"] }
30
+
serde_ipld_dagcbor = "0.6.4"
23
31
serde_json = "1.0.140"
24
32
serde_qs = "1.0.0-rc.3"
25
33
thiserror = "2.0.12"
+21
spacedust/src/bin/import_car_file.rs
+21
spacedust/src/bin/import_car_file.rs
···
1
+
use clap::Parser;
2
+
use std::path::PathBuf;
3
+
4
+
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
5
+
6
+
#[derive(Debug, Parser)]
7
+
struct Args {
8
+
#[arg()]
9
+
file: PathBuf,
10
+
}
11
+
12
+
#[tokio::main]
13
+
async fn main() -> Result<()> {
14
+
env_logger::init();
15
+
16
+
let Args { file } = Args::parse();
17
+
18
+
let _reader = tokio::fs::File::open(file).await?;
19
+
20
+
Ok(())
21
+
}
+258
spacedust/src/bin/import_scraped.rs
+258
spacedust/src/bin/import_scraped.rs
···
1
+
use clap::Parser;
2
+
use links::CollectedLink;
3
+
use repo_stream::{
4
+
DiskBuilder, DiskStore, Driver, DriverBuilder, Processable, drive::DriverBuilderWithProcessor,
5
+
drive::NeedDisk,
6
+
};
7
+
use std::path::PathBuf;
8
+
use std::sync::{
9
+
Arc,
10
+
atomic::{AtomicUsize, Ordering},
11
+
};
12
+
use tokio::{io::AsyncRead, task::JoinSet};
13
+
14
+
type Result<T> = anyhow::Result<T>; //std::result::Result<T, Box<dyn std::error::Error>>;
15
+
16
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
17
+
struct CollectedProcessed(CollectedLink);
18
+
19
+
impl Processable for CollectedProcessed {
20
+
fn get_size(&self) -> usize {
21
+
self.0.path.capacity() + self.0.target.as_str().len()
22
+
}
23
+
}
24
+
25
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
26
+
struct ErrString(String);
27
+
28
+
impl Processable for ErrString {
29
+
fn get_size(&self) -> usize {
30
+
self.0.capacity()
31
+
}
32
+
}
33
+
34
+
type Processed = std::result::Result<Vec<CollectedProcessed>, ErrString>;
35
+
36
+
/// hacky for now: put errors in strings 🤷♀️
37
+
fn process(block: Vec<u8>) -> Processed {
38
+
let value: dasl::drisl::Value = dasl::drisl::from_slice(&block)
39
+
.map_err(|e| ErrString(format!("failed to parse block with drisl: {e:?}")))?;
40
+
let links = links::record::collect_links_drisl(&value)
41
+
.into_iter()
42
+
.map(CollectedProcessed)
43
+
.collect();
44
+
Ok(links)
45
+
}
46
+
47
+
#[derive(Debug, Parser)]
48
+
struct Args {
49
+
#[arg(long)]
50
+
cars_folder: PathBuf,
51
+
#[arg(long)]
52
+
mem_workers: usize,
53
+
#[arg(long)]
54
+
disk_workers: usize,
55
+
#[arg(long)]
56
+
disk_folder: PathBuf,
57
+
}
58
+
59
+
async fn get_cars(
60
+
cars_folder: PathBuf,
61
+
tx: async_channel::Sender<tokio::io::BufReader<tokio::fs::File>>,
62
+
) -> Result<()> {
63
+
let mut dir = tokio::fs::read_dir(cars_folder).await?;
64
+
while let Some(entry) = dir.next_entry().await? {
65
+
if !entry.file_type().await?.is_file() {
66
+
continue;
67
+
}
68
+
let reader = tokio::fs::File::open(&entry.path()).await?;
69
+
let reader = tokio::io::BufReader::new(reader);
70
+
tx.send(reader).await?;
71
+
}
72
+
Ok(())
73
+
}
74
+
75
+
async fn drive_mem<R: AsyncRead + Unpin + Send + Sync + 'static>(
76
+
f: R,
77
+
builder: &DriverBuilderWithProcessor<Processed>,
78
+
disk_tx: &async_channel::Sender<NeedDisk<R, Processed>>,
79
+
) -> Result<Option<(usize, usize)>> {
80
+
let mut n = 0;
81
+
let mut n_records = 0;
82
+
match builder.load_car(f).await? {
83
+
Driver::Memory(_commit, mut driver) => {
84
+
while let Some(chunk) = driver.next_chunk(512).await? {
85
+
n_records += chunk.len();
86
+
for (_key, links) in chunk {
87
+
match links {
88
+
Ok(links) => n += links.len(),
89
+
Err(e) => eprintln!("wat: {e:?}"),
90
+
}
91
+
}
92
+
}
93
+
Ok(Some((n, n_records)))
94
+
}
95
+
Driver::Disk(need_disk) => {
96
+
disk_tx.send(need_disk).await?;
97
+
Ok(None)
98
+
}
99
+
}
100
+
}
101
+
102
+
async fn mem_worker<R: AsyncRead + Unpin + Send + Sync + 'static>(
103
+
car_rx: async_channel::Receiver<R>,
104
+
disk_tx: async_channel::Sender<NeedDisk<R, Processed>>,
105
+
n: Arc<AtomicUsize>,
106
+
n_records: Arc<AtomicUsize>,
107
+
) -> Result<()> {
108
+
let builder = DriverBuilder::new()
109
+
.with_block_processor(process) // don't care just counting records
110
+
.with_mem_limit_mb(128);
111
+
while let Ok(f) = car_rx.recv().await {
112
+
let driven = match drive_mem(f, &builder, &disk_tx).await {
113
+
Ok(d) => d,
114
+
Err(e) => {
115
+
eprintln!("failed to drive mem: {e:?}. skipping...");
116
+
continue;
117
+
}
118
+
};
119
+
if let Some((drove, recs)) = driven {
120
+
n.fetch_add(drove, Ordering::Relaxed);
121
+
n_records.fetch_add(recs, Ordering::Relaxed);
122
+
}
123
+
}
124
+
Ok(())
125
+
}
126
+
127
+
async fn drive_disk<R: AsyncRead + Unpin>(
128
+
needed: NeedDisk<R, Processed>,
129
+
store: DiskStore,
130
+
) -> Result<(usize, usize, DiskStore)> {
131
+
let (_commit, mut driver) = needed.finish_loading(store).await?;
132
+
let mut n = 0;
133
+
let mut n_records = 0;
134
+
while let Some(chunk) = driver.next_chunk(512).await? {
135
+
n_records += chunk.len();
136
+
for (_key, links) in chunk {
137
+
match links {
138
+
Ok(links) => n += links.len(),
139
+
Err(e) => eprintln!("wat: {e:?}"),
140
+
}
141
+
}
142
+
}
143
+
let store = driver.reset_store().await?;
144
+
Ok((n, n_records, store))
145
+
}
146
+
147
+
async fn disk_worker<R: AsyncRead + Unpin>(
148
+
worker_id: usize,
149
+
disk_rx: async_channel::Receiver<NeedDisk<R, Processed>>,
150
+
folder: PathBuf,
151
+
n: Arc<AtomicUsize>,
152
+
n_records: Arc<AtomicUsize>,
153
+
disk_workers_active: Arc<AtomicUsize>,
154
+
) -> Result<()> {
155
+
let mut file = folder;
156
+
file.push(format!("disk-worker-{worker_id}.sqlite"));
157
+
let builder = DiskBuilder::new().with_cache_size_mb(128);
158
+
let mut store = builder.open(file.clone()).await?;
159
+
while let Ok(needed) = disk_rx.recv().await {
160
+
let active = disk_workers_active.fetch_add(1, Ordering::AcqRel);
161
+
println!("-> disk workers active: {}", active + 1);
162
+
let (drove, records) = match drive_disk(needed, store).await {
163
+
Ok((d, r, s)) => {
164
+
store = s;
165
+
(d, r)
166
+
}
167
+
Err(e) => {
168
+
eprintln!("failed to drive disk: {e:?}. skipping...");
169
+
store = builder.open(file.clone()).await?;
170
+
continue;
171
+
}
172
+
};
173
+
n.fetch_add(drove, Ordering::Relaxed);
174
+
n_records.fetch_add(records, Ordering::Relaxed);
175
+
let were_active = disk_workers_active.fetch_sub(1, Ordering::AcqRel);
176
+
println!("<- disk workers active: {}", were_active - 1);
177
+
}
178
+
Ok(())
179
+
}
180
+
181
+
#[tokio::main]
182
+
async fn main() -> Result<()> {
183
+
env_logger::init();
184
+
185
+
let Args {
186
+
cars_folder,
187
+
disk_folder,
188
+
disk_workers,
189
+
mem_workers,
190
+
} = Args::parse();
191
+
192
+
let mut set = JoinSet::<Result<()>>::new();
193
+
194
+
let (cars_tx, cars_rx) = async_channel::bounded(2);
195
+
set.spawn(get_cars(cars_folder, cars_tx));
196
+
197
+
let n: Arc<AtomicUsize> = Arc::new(0.into());
198
+
let n_records: Arc<AtomicUsize> = Arc::new(0.into());
199
+
let disk_workers_active: Arc<AtomicUsize> = Arc::new(0.into());
200
+
201
+
set.spawn({
202
+
let n = n.clone();
203
+
let n_records = n_records.clone();
204
+
let mut interval = tokio::time::interval(std::time::Duration::from_secs(10));
205
+
async move {
206
+
let mut last_n = n.load(Ordering::Relaxed);
207
+
let mut last_n_records = n.load(Ordering::Relaxed);
208
+
loop {
209
+
interval.tick().await;
210
+
let n = n.load(Ordering::Relaxed);
211
+
let n_records = n_records.load(Ordering::Relaxed);
212
+
let diff_n = n - last_n;
213
+
let diff_records = n_records - last_n_records;
214
+
println!("rate: {} rec/sec; {} n/sec", diff_records / 10, diff_n / 10);
215
+
if n_records > 0 && diff_records == 0 {
216
+
println!("zero encountered, stopping rate calculation polling.");
217
+
break Ok(());
218
+
}
219
+
last_n = n;
220
+
last_n_records = n_records;
221
+
}
222
+
}
223
+
});
224
+
225
+
let (needs_disk_tx, needs_disk_rx) = async_channel::bounded(disk_workers);
226
+
227
+
for _ in 0..mem_workers {
228
+
set.spawn(mem_worker(
229
+
cars_rx.clone(),
230
+
needs_disk_tx.clone(),
231
+
n.clone(),
232
+
n_records.clone(),
233
+
));
234
+
}
235
+
drop(cars_rx);
236
+
drop(needs_disk_tx);
237
+
238
+
tokio::fs::create_dir_all(disk_folder.clone()).await?;
239
+
for id in 0..disk_workers {
240
+
set.spawn(disk_worker(
241
+
id,
242
+
needs_disk_rx.clone(),
243
+
disk_folder.clone(),
244
+
n.clone(),
245
+
n_records.clone(),
246
+
disk_workers_active.clone(),
247
+
));
248
+
}
249
+
drop(needs_disk_rx);
250
+
251
+
while let Some(res) = set.join_next().await {
252
+
println!("task from set joined: {res:?}");
253
+
}
254
+
255
+
eprintln!("total records processed: {n_records:?}; total n: {n:?}");
256
+
257
+
Ok(())
258
+
}
+137
spacedust/src/bin/scrape_pds.rs
+137
spacedust/src/bin/scrape_pds.rs
···
1
+
use clap::Parser;
2
+
use reqwest::Url;
3
+
use serde::Deserialize;
4
+
use std::path::PathBuf;
5
+
use tokio::io::AsyncWriteExt;
6
+
use tokio::{sync::mpsc, time};
7
+
8
+
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
9
+
10
+
use futures::StreamExt;
11
+
12
+
#[derive(Debug, Parser)]
13
+
struct Args {
14
+
#[arg(long)]
15
+
pds: Url,
16
+
#[arg(long)]
17
+
throttle_ms: u64, // 100ms per pds?
18
+
#[arg(long)]
19
+
folder: PathBuf,
20
+
}
21
+
22
+
async fn download_repo(
23
+
client: &reqwest::Client,
24
+
mut pds: Url,
25
+
did: String,
26
+
mut path: PathBuf,
27
+
) -> Result<()> {
28
+
path.push(format!("{did}.car"));
29
+
let f = tokio::fs::File::create(path).await?;
30
+
let mut w = tokio::io::BufWriter::new(f);
31
+
32
+
pds.set_path("/xrpc/com.atproto.sync.getRepo");
33
+
pds.set_query(Some(&format!("did={did}")));
34
+
let mut byte_stream = client.get(pds).send().await?.bytes_stream();
35
+
36
+
while let Some(stuff) = byte_stream.next().await {
37
+
tokio::io::copy(&mut stuff?.as_ref(), &mut w).await?;
38
+
}
39
+
w.flush().await?;
40
+
41
+
Ok(())
42
+
}
43
+
44
+
#[derive(Debug, Deserialize)]
45
+
struct RepoInfo {
46
+
did: String,
47
+
active: bool,
48
+
}
49
+
50
+
#[derive(Debug, Deserialize)]
51
+
struct ListReposResponse {
52
+
cursor: Option<String>,
53
+
repos: Vec<RepoInfo>,
54
+
}
55
+
56
+
fn get_pds_dids(client: reqwest::Client, mut pds: Url) -> mpsc::Receiver<String> {
57
+
let (tx, rx) = mpsc::channel(2);
58
+
tokio::task::spawn(async move {
59
+
pds.set_path("/xrpc/com.atproto.sync.listRepos");
60
+
let mut cursor = None;
61
+
62
+
loop {
63
+
if let Some(c) = cursor {
64
+
pds.set_query(Some(&format!("cursor={c}")));
65
+
}
66
+
let res: ListReposResponse = client
67
+
.get(pds.clone())
68
+
.send()
69
+
.await
70
+
.expect("to send request")
71
+
.error_for_status()
72
+
.expect("to be ok")
73
+
.json()
74
+
.await
75
+
.expect("json response");
76
+
for repo in res.repos {
77
+
if repo.active {
78
+
tx.send(repo.did)
79
+
.await
80
+
.expect("to be able to send on the channel");
81
+
}
82
+
}
83
+
cursor = res.cursor;
84
+
if cursor.is_none() {
85
+
break;
86
+
}
87
+
}
88
+
});
89
+
rx
90
+
}
91
+
92
+
#[tokio::main]
93
+
async fn main() -> Result<()> {
94
+
env_logger::init();
95
+
96
+
let Args {
97
+
pds,
98
+
throttle_ms,
99
+
folder,
100
+
} = Args::parse();
101
+
102
+
tokio::fs::create_dir_all(folder.clone()).await?;
103
+
104
+
let client = reqwest::Client::builder()
105
+
.user_agent("microcosm/spacedust-testing")
106
+
.build()?;
107
+
108
+
let mut dids = get_pds_dids(client.clone(), pds.clone());
109
+
110
+
let mut interval = time::interval(time::Duration::from_millis(throttle_ms));
111
+
let mut oks = 0;
112
+
let mut single_fails = 0;
113
+
let mut double_fails = 0;
114
+
115
+
while let Some(did) = dids.recv().await {
116
+
interval.tick().await;
117
+
println!("did: {did:?}");
118
+
if let Err(e) = download_repo(&client, pds.clone(), did.clone(), folder.clone()).await {
119
+
single_fails += 1;
120
+
eprintln!("failed to download repo for did: {did:?}: {e:?}. retrying in a moment...");
121
+
tokio::time::sleep(time::Duration::from_secs(3)).await;
122
+
interval.reset();
123
+
if let Err(e) = download_repo(&client, pds.clone(), did.clone(), folder.clone()).await {
124
+
double_fails += 1;
125
+
eprintln!("failed again: {e:?}. moving on in a moment...");
126
+
tokio::time::sleep(time::Duration::from_secs(1)).await;
127
+
continue;
128
+
}
129
+
}
130
+
oks += 1;
131
+
println!(" -> done. did: {did:?}");
132
+
}
133
+
134
+
eprintln!("got {oks} repos. single fails: {single_fails}; doubles: {double_fails}.");
135
+
136
+
Ok(())
137
+
}
+1
spacedust/src/lib.rs
+1
spacedust/src/lib.rs
spacedust/src/storage/car/drive.rs
spacedust/src/storage/car/drive.rs
This is a binary file and will not be displayed.
+1
spacedust/src/storage/car/mod.rs
+1
spacedust/src/storage/car/mod.rs
···
1
+
spacedust/src/storage/car/walk.rs
spacedust/src/storage/car/walk.rs
This is a binary file and will not be displayed.
+9
spacedust/src/storage/fjall/mod.rs
+9
spacedust/src/storage/fjall/mod.rs
+6
spacedust/src/storage/mod.rs
+6
spacedust/src/storage/mod.rs
+5
-5
spacedust/src/subscriber.rs
+5
-5
spacedust/src/subscriber.rs
···
42
42
loop {
43
43
tokio::select! {
44
44
l = receiver.recv() => match l {
45
-
Ok(link) => if self.filter(&link.properties) {
46
-
if let Err(e) = ws_sender.send(link.message.clone()).await {
47
-
log::warn!("failed to send link, dropping subscriber: {e:?}");
48
-
break;
49
-
}
45
+
Ok(link) => if self.filter(&link.properties)
46
+
&& let Err(e) = ws_sender.send(link.message.clone()).await
47
+
{
48
+
log::warn!("failed to send link, dropping subscriber: {e:?}");
49
+
break;
50
50
},
51
51
Err(RecvError::Closed) => self.shutdown.cancel(),
52
52
Err(RecvError::Lagged(n)) => {
+1
-1
ufos/Cargo.toml
+1
-1
ufos/Cargo.toml
···
13
13
clap = { version = "4.5.31", features = ["derive"] }
14
14
dropshot = "0.16.0"
15
15
env_logger = "0.11.7"
16
-
fjall = { version = "2.8.0", features = ["lz4"] }
16
+
fjall = { git = "https://github.com/fjall-rs/fjall.git", features = ["lz4"] }
17
17
getrandom = "0.3.3"
18
18
http = "1.3.1"
19
19
jetstream = { path = "../jetstream", features = ["metrics"] }
+42
-10
ufos/src/main.rs
+42
-10
ufos/src/main.rs
···
4
4
use metrics_exporter_prometheus::PrometheusBuilder;
5
5
use std::path::PathBuf;
6
6
use std::time::{Duration, SystemTime};
7
+
use tokio::task::JoinSet;
7
8
use ufos::consumer;
8
9
use ufos::file_consumer;
9
10
use ufos::server;
···
72
73
Ok(())
73
74
}
74
75
75
-
async fn go<B: StoreBackground>(
76
+
async fn go<B: StoreBackground + 'static>(
76
77
args: Args,
77
78
read_store: impl StoreReader + 'static + Clone,
78
79
mut write_store: impl StoreWriter<B> + 'static,
79
80
cursor: Option<Cursor>,
80
81
sketch_secret: SketchSecretPrefix,
81
82
) -> anyhow::Result<()> {
83
+
let mut whatever_tasks: JoinSet<anyhow::Result<()>> = JoinSet::new();
84
+
let mut consumer_tasks: JoinSet<anyhow::Result<()>> = JoinSet::new();
85
+
82
86
println!("starting server with storage...");
83
87
let serving = server::serve(read_store.clone());
88
+
whatever_tasks.spawn(async move {
89
+
serving.await.map_err(|e| {
90
+
log::warn!("server ended: {e}");
91
+
anyhow::anyhow!(e)
92
+
})
93
+
});
84
94
85
95
if args.pause_writer {
86
96
log::info!("not starting jetstream or the write loop.");
87
-
serving.await.map_err(|e| anyhow::anyhow!(e))?;
97
+
for t in whatever_tasks.join_all().await {
98
+
if let Err(e) = t {
99
+
return Err(anyhow::anyhow!(e));
100
+
}
101
+
}
88
102
return Ok(());
89
103
}
90
104
···
102
116
let rolling = write_store
103
117
.background_tasks(args.reroll)?
104
118
.run(args.backfill);
105
-
let consuming = write_store.receive_batches(batches);
119
+
whatever_tasks.spawn(async move {
120
+
rolling
121
+
.await
122
+
.inspect_err(|e| log::warn!("rollup ended: {e}"))?;
123
+
Ok(())
124
+
});
106
125
107
-
let stating = do_update_stuff(read_store);
126
+
consumer_tasks.spawn(async move {
127
+
write_store
128
+
.receive_batches(batches)
129
+
.await
130
+
.inspect_err(|e| log::warn!("consumer ended: {e}"))?;
131
+
Ok(())
132
+
});
133
+
134
+
whatever_tasks.spawn(async move {
135
+
do_update_stuff(read_store).await;
136
+
log::warn!("status task ended");
137
+
Ok(())
138
+
});
108
139
109
140
install_metrics_server()?;
110
141
111
-
tokio::select! {
112
-
z = serving => log::warn!("serve task ended: {z:?}"),
113
-
z = rolling => log::warn!("rollup task ended: {z:?}"),
114
-
z = consuming => log::warn!("consuming task ended: {z:?}"),
115
-
z = stating => log::warn!("status task ended: {z:?}"),
116
-
};
142
+
for (i, t) in consumer_tasks.join_all().await.iter().enumerate() {
143
+
log::warn!("task {i} done: {t:?}");
144
+
}
145
+
146
+
println!("consumer tasks all completed, killing the others");
147
+
whatever_tasks.shutdown().await;
117
148
118
149
println!("bye!");
119
150
···
162
193
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay);
163
194
loop {
164
195
interval.tick().await;
196
+
read_store.update_metrics();
165
197
match read_store.get_consumer_info().await {
166
198
Err(e) => log::warn!("failed to get jetstream consumer info: {e:?}"),
167
199
Ok(ConsumerInfo::Jetstream {
+11
-1
ufos/src/storage.rs
+11
-1
ufos/src/storage.rs
···
41
41
Unit::Microseconds,
42
42
"batches that took more than 3s to insert"
43
43
);
44
+
describe_histogram!(
45
+
"storage_batch_insert_time",
46
+
Unit::Microseconds,
47
+
"total time to insert one commit batch"
48
+
);
44
49
while let Some(event_batch) = batches.recv().await {
45
50
let token = CancellationToken::new();
46
51
let cancelled = token.clone();
···
69
74
let mut me = self.clone();
70
75
move || {
71
76
let _guard = token.drop_guard();
72
-
me.insert_batch(event_batch)
77
+
let t0 = Instant::now();
78
+
let r = me.insert_batch(event_batch);
79
+
histogram!("storage_batch_insert_time").record(t0.elapsed().as_micros() as f64);
80
+
r
73
81
}
74
82
})
75
83
.await??;
···
103
111
#[async_trait]
104
112
pub trait StoreReader: Send + Sync {
105
113
fn name(&self) -> String;
114
+
115
+
fn update_metrics(&self) {}
106
116
107
117
async fn get_storage_stats(&self) -> StorageResult<serde_json::Value>;
108
118
+104
-20
ufos/src/storage_fjall.rs
+104
-20
ufos/src/storage_fjall.rs
···
23
23
Batch as FjallBatch, Config, Keyspace, PartitionCreateOptions, PartitionHandle, Snapshot,
24
24
};
25
25
use jetstream::events::Cursor;
26
-
use metrics::{counter, describe_counter, describe_histogram, histogram, Unit};
26
+
use lsm_tree::AbstractTree;
27
+
use metrics::{
28
+
counter, describe_counter, describe_gauge, describe_histogram, gauge, histogram, Unit,
29
+
};
27
30
use std::collections::{HashMap, HashSet};
28
31
use std::iter::Peekable;
29
32
use std::ops::Bound;
···
227
230
feeds: feeds.clone(),
228
231
records: records.clone(),
229
232
rollups: rollups.clone(),
233
+
queues: queues.clone(),
230
234
};
235
+
reader.describe_metrics();
231
236
let writer = FjallWriter {
232
237
bg_taken: Arc::new(AtomicBool::new(false)),
233
238
keyspace,
···
237
242
rollups,
238
243
queues,
239
244
};
245
+
writer.describe_metrics();
240
246
Ok((reader, writer, js_cursor, sketch_secret))
241
247
}
242
248
}
···
250
256
feeds: PartitionHandle,
251
257
records: PartitionHandle,
252
258
rollups: PartitionHandle,
259
+
queues: PartitionHandle,
253
260
}
254
261
255
262
/// An iterator that knows how to skip over deleted/invalidated records
···
381
388
type CollectionSerieses = HashMap<Nsid, Vec<CountsValue>>;
382
389
383
390
impl FjallReader {
391
+
fn describe_metrics(&self) {
392
+
describe_gauge!(
393
+
"storage_fjall_l0_run_count",
394
+
Unit::Count,
395
+
"number of L0 runs in a partition"
396
+
);
397
+
describe_gauge!(
398
+
"storage_fjall_keyspace_disk_space",
399
+
Unit::Bytes,
400
+
"total storage used according to fjall"
401
+
);
402
+
describe_gauge!(
403
+
"storage_fjall_journal_count",
404
+
Unit::Count,
405
+
"total keyspace journals according to fjall"
406
+
);
407
+
describe_gauge!(
408
+
"storage_fjall_keyspace_sequence",
409
+
Unit::Count,
410
+
"fjall keyspace sequence"
411
+
);
412
+
}
413
+
384
414
fn get_storage_stats(&self) -> StorageResult<serde_json::Value> {
385
415
let rollup_cursor =
386
416
get_static_neu::<NewRollupCursorKey, NewRollupCursorValue>(&self.global)?
···
1000
1030
fn name(&self) -> String {
1001
1031
"fjall storage v2".into()
1002
1032
}
1033
+
fn update_metrics(&self) {
1034
+
gauge!("storage_fjall_l0_run_count", "partition" => "global")
1035
+
.set(self.global.tree.l0_run_count() as f64);
1036
+
gauge!("storage_fjall_l0_run_count", "partition" => "feeds")
1037
+
.set(self.feeds.tree.l0_run_count() as f64);
1038
+
gauge!("storage_fjall_l0_run_count", "partition" => "records")
1039
+
.set(self.records.tree.l0_run_count() as f64);
1040
+
gauge!("storage_fjall_l0_run_count", "partition" => "rollups")
1041
+
.set(self.rollups.tree.l0_run_count() as f64);
1042
+
gauge!("storage_fjall_l0_run_count", "partition" => "queues")
1043
+
.set(self.queues.tree.l0_run_count() as f64);
1044
+
gauge!("storage_fjall_keyspace_disk_space").set(self.keyspace.disk_space() as f64);
1045
+
gauge!("storage_fjall_journal_count").set(self.keyspace.journal_count() as f64);
1046
+
gauge!("storage_fjall_keyspace_sequence").set(self.keyspace.instant() as f64);
1047
+
}
1003
1048
async fn get_storage_stats(&self) -> StorageResult<serde_json::Value> {
1004
1049
let s = self.clone();
1005
1050
tokio::task::spawn_blocking(move || FjallReader::get_storage_stats(&s)).await?
···
1091
1136
}
1092
1137
1093
1138
impl FjallWriter {
1139
+
fn describe_metrics(&self) {
1140
+
describe_histogram!(
1141
+
"storage_insert_batch_db_batch_items",
1142
+
Unit::Count,
1143
+
"how many items are in the fjall batch for batched inserts"
1144
+
);
1145
+
describe_histogram!(
1146
+
"storage_rollup_counts_db_batch_items",
1147
+
Unit::Count,
1148
+
"how many items are in the fjall batch for a timlies rollup"
1149
+
);
1150
+
describe_counter!(
1151
+
"storage_delete_account_partial_commits",
1152
+
Unit::Count,
1153
+
"fjall checkpoint commits for cleaning up accounts with too many records"
1154
+
);
1155
+
describe_counter!(
1156
+
"storage_delete_account_completions",
1157
+
Unit::Count,
1158
+
"total count of account deletes handled"
1159
+
);
1160
+
describe_counter!(
1161
+
"storage_delete_account_records_deleted",
1162
+
Unit::Count,
1163
+
"total records deleted when handling account deletes"
1164
+
);
1165
+
describe_histogram!(
1166
+
"storage_trim_dirty_nsids",
1167
+
Unit::Count,
1168
+
"number of NSIDs trimmed"
1169
+
);
1170
+
describe_histogram!(
1171
+
"storage_trim_duration",
1172
+
Unit::Microseconds,
1173
+
"how long it took to trim the dirty NSIDs"
1174
+
);
1175
+
describe_counter!(
1176
+
"storage_trim_removed",
1177
+
Unit::Count,
1178
+
"how many records were removed during trim"
1179
+
);
1180
+
}
1094
1181
fn rollup_delete_account(
1095
1182
&mut self,
1096
1183
cursor: Cursor,
···
1222
1309
AllTimeRecordsKey::new(new_creates_count.into(), &nsid).to_db_bytes()?,
1223
1310
),
1224
1311
};
1225
-
batch.remove(&self.rollups, &old_k); // TODO: when fjall gets weak delete, this will hopefully work way better
1312
+
// remove_weak is allowed here because the secondary ranking index only ever inserts once at a key
1313
+
batch.remove_weak(&self.rollups, &old_k);
1226
1314
batch.insert(&self.rollups, &new_k, "");
1227
1315
}
1228
1316
···
1246
1334
AllTimeDidsKey::new(new_dids_estimate.into(), &nsid).to_db_bytes()?,
1247
1335
),
1248
1336
};
1249
-
batch.remove(&self.rollups, &old_k); // TODO: when fjall gets weak delete, this will hopefully work way better
1337
+
// remove_weak is allowed here because the secondary ranking index only ever inserts once at a key
1338
+
batch.remove_weak(&self.rollups, &old_k);
1250
1339
batch.insert(&self.rollups, &new_k, "");
1251
1340
}
1252
1341
···
1256
1345
1257
1346
insert_batch_static_neu::<NewRollupCursorKey>(&mut batch, &self.global, last_cursor)?;
1258
1347
1348
+
histogram!("storage_rollup_counts_db_batch_items").record(batch.len() as f64);
1259
1349
batch.commit()?;
1260
1350
Ok((cursors_advanced, dirty_nsids))
1261
1351
}
···
1266
1356
if self.bg_taken.swap(true, Ordering::SeqCst) {
1267
1357
return Err(StorageError::BackgroundAlreadyStarted);
1268
1358
}
1269
-
describe_histogram!(
1270
-
"storage_trim_dirty_nsids",
1271
-
Unit::Count,
1272
-
"number of NSIDs trimmed"
1273
-
);
1274
-
describe_histogram!(
1275
-
"storage_trim_duration",
1276
-
Unit::Microseconds,
1277
-
"how long it took to trim the dirty NSIDs"
1278
-
);
1279
-
describe_counter!(
1280
-
"storage_trim_removed",
1281
-
Unit::Count,
1282
-
"how many records were removed during trim"
1283
-
);
1284
1359
if reroll {
1285
1360
log::info!("reroll: resetting rollup cursor...");
1286
1361
insert_static_neu::<NewRollupCursorKey>(&self.global, Cursor::from_start())?;
···
1375
1450
latest.to_db_bytes()?,
1376
1451
);
1377
1452
1453
+
histogram!("storage_insert_batch_db_batch_items").record(batch.len() as f64);
1378
1454
batch.commit()?;
1379
1455
Ok(())
1380
1456
}
···
1529
1605
candidate_new_feed_lower_cursor = Some(feed_key.cursor());
1530
1606
}
1531
1607
1532
-
self.feeds.remove(&location_key_bytes)?;
1608
+
self.records.remove(&location_key_bytes)?;
1533
1609
self.feeds.remove(key_bytes)?;
1534
1610
records_deleted += 1;
1535
1611
}
···
1556
1632
batch.remove(&self.records, key_bytes);
1557
1633
records_deleted += 1;
1558
1634
if batch.len() >= MAX_BATCHED_ACCOUNT_DELETE_RECORDS {
1635
+
counter!("storage_delete_account_partial_commits").increment(1);
1559
1636
batch.commit()?;
1560
1637
batch = self.keyspace.batch();
1561
1638
}
1562
1639
}
1640
+
counter!("storage_delete_account_completions").increment(1);
1641
+
counter!("storage_delete_account_records_deleted").increment(records_deleted as u64);
1563
1642
batch.commit()?;
1564
1643
Ok(records_deleted)
1565
1644
}
···
1619
1698
histogram!("storage_trim_dirty_nsids").record(completed.len() as f64);
1620
1699
histogram!("storage_trim_duration").record(dt.as_micros() as f64);
1621
1700
counter!("storage_trim_removed", "dangling" => "true").increment(total_danglers as u64);
1622
-
counter!("storage_trim_removed", "dangling" => "false").increment((total_deleted - total_danglers) as u64);
1701
+
if total_deleted >= total_danglers {
1702
+
counter!("storage_trim_removed", "dangling" => "false").increment((total_deleted - total_danglers) as u64);
1703
+
} else {
1704
+
// TODO: probably think through what's happening here
1705
+
log::warn!("weird trim case: more danglers than deleted? metric will be missing for dangling=false. deleted={total_deleted} danglers={total_danglers}");
1706
+
}
1623
1707
for c in completed {
1624
1708
dirty_nsids.remove(&c);
1625
1709
}
-196
ufos ops (move to micro-ops).md
-196
ufos ops (move to micro-ops).md
···
1
-
ufos ops
2
-
3
-
btrfs snapshots: snapper
4
-
5
-
```bash
6
-
sudo apt install snapper
7
-
sudo snapper -c ufos-db create-config /mnt/ufos-db
8
-
9
-
# edit /etc/snapper/configs/ufos-db
10
-
# change
11
-
TIMELINE_MIN_AGE="1800"
12
-
TIMELINE_LIMIT_HOURLY="10"
13
-
TIMELINE_LIMIT_DAILY="10"
14
-
TIMELINE_LIMIT_WEEKLY="0"
15
-
TIMELINE_LIMIT_MONTHLY="10"
16
-
TIMELINE_LIMIT_YEARLY="10"
17
-
# to
18
-
TIMELINE_MIN_AGE="1800"
19
-
TIMELINE_LIMIT_HOURLY="22"
20
-
TIMELINE_LIMIT_DAILY="4"
21
-
TIMELINE_LIMIT_WEEKLY="0"
22
-
TIMELINE_LIMIT_MONTHLY="0"
23
-
TIMELINE_LIMIT_YEARLY="0"
24
-
```
25
-
26
-
this should be enough?
27
-
28
-
list snapshots:
29
-
30
-
```bash
31
-
sudo snapper -c ufos-db list
32
-
```
33
-
34
-
systemd
35
-
36
-
create file: `/etc/systemd/system/ufos.service`
37
-
38
-
```ini
39
-
[Unit]
40
-
Description=UFOs-API
41
-
After=network.target
42
-
43
-
[Service]
44
-
User=pi
45
-
WorkingDirectory=/home/pi/
46
-
ExecStart=/home/pi/ufos --jetstream us-west-2 --data /mnt/ufos-db/
47
-
Environment="RUST_LOG=info"
48
-
LimitNOFILE=16384
49
-
Restart=always
50
-
51
-
[Install]
52
-
WantedBy=multi-user.target
53
-
```
54
-
55
-
then
56
-
57
-
```bash
58
-
sudo systemctl daemon-reload
59
-
sudo systemctl enable ufos
60
-
sudo systemctl start ufos
61
-
```
62
-
63
-
monitor with
64
-
65
-
```bash
66
-
journalctl -u ufos -f
67
-
```
68
-
69
-
make sure a backup dir exists
70
-
71
-
```bash
72
-
mkdir /home/pi/backup
73
-
```
74
-
75
-
mount the NAS
76
-
77
-
```bash
78
-
sudo mount.cifs "//truenas.local/folks data" /home/pi/backup -o user=phil,uid=pi
79
-
```
80
-
81
-
manual rsync
82
-
83
-
```bash
84
-
sudo rsync -ahP --delete /mnt/ufos-db/.snapshots/1/snapshot/ backup/ufos/
85
-
```
86
-
87
-
backup script sketch
88
-
89
-
```bash
90
-
NUM=$(sudo snapper --csvout -c ufos-db list --type single --columns number | tail -n1)
91
-
sudo rsync -ahP --delete "/mnt/ufos-db/.snapshots/${NUM}/snapshot/" backup/ufos/
92
-
```
93
-
94
-
just crontab it?
95
-
96
-
`sudo crontab -e`
97
-
```bash
98
-
0 1/6 * * * rsync -ahP --delete "/mnt/ufos-db/.snapshots/$(sudo snapper --csvout -c ufos-db list --columns number | tail -n1)/snapshot/" backup/ufos/
99
-
```
100
-
101
-
^^ try once initial backup is done
102
-
103
-
104
-
--columns subvolume,number
105
-
106
-
subvolume
107
-
number
108
-
109
-
110
-
111
-
112
-
gateway: follow constellation for nginx->prom thing
113
-
114
-
config at `/etc/prometheus-nginxlog-exporter.hcl`
115
-
116
-
before: `/etc/prometheus-nginxlog-exporter.hcl`
117
-
118
-
```hcl
119
-
listen {
120
-
port = 4044
121
-
}
122
-
123
-
namespace "nginx" {
124
-
source = {
125
-
files = [
126
-
"/var/log/nginx/constellation-access.log"
127
-
]
128
-
}
129
-
130
-
format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $upstream_cache_status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
131
-
132
-
labels {
133
-
app = "constellation"
134
-
}
135
-
136
-
relabel "cache_status" {
137
-
from = "upstream_cache_status"
138
-
}
139
-
}
140
-
```
141
-
142
-
after:
143
-
144
-
```hcl
145
-
listen {
146
-
port = 4044
147
-
}
148
-
149
-
namespace "constellation" {
150
-
source = {
151
-
files = [
152
-
"/var/log/nginx/constellation-access.log"
153
-
]
154
-
}
155
-
156
-
format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $upstream_cache_status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
157
-
158
-
labels {
159
-
app = "constellation"
160
-
}
161
-
162
-
relabel "cache_status" {
163
-
from = "upstream_cache_status"
164
-
}
165
-
166
-
namespace_label = "vhost"
167
-
metrics_override = { prefix = "nginx" }
168
-
}
169
-
170
-
namespace "ufos" {
171
-
source = {
172
-
files = [
173
-
"/var/log/nginx/ufos-access.log"
174
-
]
175
-
}
176
-
177
-
format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $upstream_cache_status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
178
-
179
-
labels {
180
-
app = "ufos"
181
-
}
182
-
183
-
relabel "cache_status" {
184
-
from = "upstream_cache_status"
185
-
}
186
-
187
-
namespace_label = "vhost"
188
-
metrics_override = { prefix = "nginx" }
189
-
}
190
-
```
191
-
192
-
193
-
```bash
194
-
systemctl start prometheus-nginxlog-exporter.service
195
-
```
196
-
+34
-15
who-am-i/src/jwt.rs
+34
-15
who-am-i/src/jwt.rs
···
1
+
use elliptic_curve::SecretKey;
2
+
use jose_jwk::{Class, Jwk, Key, Parameters};
1
3
use jsonwebtoken::{Algorithm, EncodingKey, Header, encode, errors::Error as JWTError};
4
+
use pkcs8::DecodePrivateKey;
2
5
use serde::Serialize;
3
6
use std::fs;
4
7
use std::io::Error as IOError;
···
27
30
28
31
pub struct Tokens {
29
32
encoding_key: EncodingKey,
30
-
jwks: String,
33
+
jwk: Jwk,
31
34
}
32
35
33
36
impl Tokens {
34
-
pub fn from_files(
35
-
priv_f: impl AsRef<Path>,
36
-
jwks_f: impl AsRef<Path>,
37
-
) -> Result<Self, TokensSetupError> {
37
+
pub fn from_files(priv_f: impl AsRef<Path>) -> Result<Self, TokensSetupError> {
38
38
let private_key_data: Vec<u8> =
39
39
fs::read(priv_f).map_err(TokensSetupError::ReadPrivateKey)?;
40
40
let encoding_key =
41
41
EncodingKey::from_ec_pem(&private_key_data).map_err(TokensSetupError::PrivateKey)?;
42
42
43
-
let jwks_data: Vec<u8> = fs::read(jwks_f).map_err(TokensSetupError::ReadJwks)?;
44
-
let jwks = String::from_utf8(jwks_data).map_err(TokensSetupError::DecodeJwks)?;
43
+
let jwk_key_string = String::from_utf8(private_key_data).unwrap();
44
+
let mut jwk = SecretKey::<p256::NistP256>::from_pkcs8_pem(&jwk_key_string)
45
+
.map(|secret_key| Jwk {
46
+
key: Key::from(&secret_key.into()),
47
+
prm: Parameters {
48
+
kid: Some("who-am-i-00".to_string()),
49
+
cls: Some(Class::Signing),
50
+
..Default::default()
51
+
},
52
+
})
53
+
.expect("to get private key");
54
+
55
+
// CRITICAL: this is what turns the private jwk into a public one: the
56
+
// `d` parameter is the secret for an EC key; a pubkey just has no `d`.
57
+
//
58
+
// this feels baaaadd but hey we're just copying atrium
59
+
// https://github.com/atrium-rs/atrium/blob/b48810f84d83d037ee89b79b8566df9e0f2a6dae/atrium-oauth/src/keyset.rs#L41
60
+
let Key::Ec(ref mut ec) = jwk.key else {
61
+
unimplemented!()
62
+
};
63
+
ec.d = None; // CRITICAL
45
64
46
-
Ok(Self { encoding_key, jwks })
65
+
Ok(Self { encoding_key, jwk })
47
66
}
48
67
49
68
pub fn mint(&self, t: impl ToString) -> Result<String, TokenMintingError> {
···
55
74
let dt_exp = dt_now + Duration::from_secs(30 * 86_400);
56
75
let exp = dt_exp.as_secs();
57
76
58
-
Ok(encode(
59
-
&Header::new(Algorithm::ES256),
60
-
&Claims { sub, exp },
61
-
&self.encoding_key,
62
-
)?)
77
+
let mut header = Header::new(Algorithm::ES256);
78
+
header.kid = Some("who-am-i-00".to_string());
79
+
// todo: consider setting jku?
80
+
81
+
Ok(encode(&header, &Claims { sub, exp }, &self.encoding_key)?)
63
82
}
64
83
65
-
pub fn jwks(&self) -> String {
66
-
self.jwks.clone()
84
+
pub fn jwk(&self) -> Jwk {
85
+
self.jwk.clone()
67
86
}
68
87
}
69
88
+1
-16
who-am-i/src/main.rs
+1
-16
who-am-i/src/main.rs
···
31
31
/// | openssl pkcs8 -topk8 -nocrypt -out <PATH-TO-PRIV-KEY>.pem
32
32
#[arg(long)]
33
33
jwt_private_key: PathBuf,
34
-
/// path to pubkeys file (jwks format)
35
-
///
36
-
/// get pem of pubkey from private key with:
37
-
///
38
-
/// openssl ec -in <PATH-TO-PRIV-KEY>.pem -pubout
39
-
///
40
-
/// then convert to a jwk, probably with something less sketchy than an [online tool](https://jwkset.com/generate)
41
-
///
42
-
/// wrap the jwk in an array, then in an object under "keys":
43
-
///
44
-
/// { "keys": [<JWK obj>] }
45
-
///
46
-
/// TODO: remove this, serve automatically
47
-
#[arg(long)]
48
-
jwks: PathBuf,
49
34
/// this server's client-reachable base url, for oauth redirect + jwt check
50
35
///
51
36
/// required unless running in localhost mode with --dev
···
100
85
println!(" - {host}");
101
86
}
102
87
103
-
let tokens = Tokens::from_files(args.jwt_private_key, args.jwks).unwrap();
88
+
let tokens = Tokens::from_files(args.jwt_private_key).unwrap();
104
89
105
90
if let Err(e) = install_metrics_server() {
106
91
eprintln!("failed to install metrics server: {e:?}");
+1
-1
who-am-i/src/oauth.rs
+1
-1
who-am-i/src/oauth.rs
···
139
139
token_endpoint_auth_method: AuthMethod::PrivateKeyJwt,
140
140
grant_types: vec![GrantType::AuthorizationCode, GrantType::RefreshToken],
141
141
scopes: READONLY_SCOPE.to_vec(),
142
-
jwks_uri: Some(format!("{base}/.well-known/at-jwks.json")),
142
+
jwks_uri: Some(format!("{base}/.well-known/jwks.json")),
143
143
token_endpoint_auth_signing_alg: Some(String::from("ES256")),
144
144
},
145
145
keys: Some(vec![key]),
+96
-30
who-am-i/src/server.rs
+96
-30
who-am-i/src/server.rs
···
5
5
extract::{FromRef, Json as ExtractJson, Query, State},
6
6
http::{
7
7
StatusCode,
8
-
header::{CONTENT_SECURITY_POLICY, CONTENT_TYPE, HeaderMap, REFERER},
8
+
header::{CONTENT_SECURITY_POLICY, CONTENT_TYPE, HeaderMap, ORIGIN, REFERER},
9
9
},
10
10
response::{IntoResponse, Json, Redirect, Response},
11
11
routing::{get, post},
12
12
};
13
-
use axum_extra::extract::cookie::{Cookie, Key, SameSite, SignedCookieJar};
13
+
use axum_extra::extract::cookie::{Cookie, Expiration, Key, SameSite, SignedCookieJar};
14
14
use axum_template::{RenderHtml, engine::Engine};
15
15
use handlebars::{Handlebars, handlebars_helper};
16
16
use jose_jwk::JwkSet;
···
20
20
use serde_json::{Value, json};
21
21
use std::collections::HashSet;
22
22
use std::sync::Arc;
23
-
use std::time::Duration;
23
+
use std::time::{Duration, SystemTime};
24
24
use tokio::net::TcpListener;
25
25
use tokio_util::sync::CancellationToken;
26
26
use url::Url;
···
32
32
const FAVICON: &[u8] = include_bytes!("../static/favicon.ico");
33
33
const STYLE_CSS: &str = include_str!("../static/style.css");
34
34
35
+
const HELLO_COOKIE_KEY: &str = "hello-who-am-i";
35
36
const DID_COOKIE_KEY: &str = "did";
36
37
37
38
const COOKIE_EXPIRATION: Duration = Duration::from_secs(30 * 86_400);
···
99
100
.route("/auth", get(start_oauth))
100
101
.route("/authorized", get(complete_oauth))
101
102
.route("/disconnect", post(disconnect))
102
-
.route("/.well-known/at-jwks.json", get(at_jwks)) // todo combine jwks eps (key id is enough?)
103
103
.route("/.well-known/jwks.json", get(jwks))
104
104
.with_state(state);
105
105
···
114
114
.unwrap();
115
115
}
116
116
117
+
#[derive(Debug, Deserialize)]
118
+
struct HelloQuery {
119
+
auth_reload: Option<String>,
120
+
auth_failed: Option<String>,
121
+
}
117
122
async fn hello(
118
123
State(AppState {
119
124
engine,
···
122
127
oauth,
123
128
..
124
129
}): State<AppState>,
130
+
Query(params): Query<HelloQuery>,
125
131
mut jar: SignedCookieJar,
126
132
) -> Response {
133
+
let is_auth_reload = params.auth_reload.is_some();
134
+
let auth_failed = params.auth_failed.is_some();
135
+
let no_cookie = jar.get(HELLO_COOKIE_KEY).is_none();
136
+
jar = jar.add(hello_cookie());
137
+
127
138
let info = if let Some(did) = jar.get(DID_COOKIE_KEY) {
128
139
if let Ok(did) = Did::new(did.value_trimmed().to_string()) {
129
140
// push cookie expiry
···
139
150
json!({
140
151
"did": did,
141
152
"fetch_key": fetch_key,
153
+
"is_auth_reload": is_auth_reload,
154
+
"auth_failed": auth_failed,
155
+
"no_cookie": no_cookie,
142
156
})
143
157
} else {
144
158
jar = jar.remove(DID_COOKIE_KEY);
145
-
json!({})
159
+
json!({
160
+
"is_auth_reload": is_auth_reload,
161
+
"auth_failed": auth_failed,
162
+
"no_cookie": no_cookie,
163
+
})
146
164
}
147
165
} else {
148
-
json!({})
166
+
json!({
167
+
"is_auth_reload": is_auth_reload,
168
+
"auth_failed": auth_failed,
169
+
"no_cookie": no_cookie,
170
+
})
149
171
};
150
172
let frame_headers = [(CONTENT_SECURITY_POLICY, "frame-ancestors 'none'")];
151
173
(frame_headers, jar, RenderHtml("hello", engine, info)).into_response()
···
163
185
([(CONTENT_TYPE, "image/x-icon")], FAVICON)
164
186
}
165
187
188
+
fn hello_cookie() -> Cookie<'static> {
189
+
Cookie::build((HELLO_COOKIE_KEY, "hiiii"))
190
+
.http_only(true)
191
+
.secure(true)
192
+
.same_site(SameSite::None)
193
+
.expires(Expiration::DateTime(
194
+
(SystemTime::now() + COOKIE_EXPIRATION).into(),
195
+
)) // wtf safari needs this to not be a session cookie??
196
+
.max_age(COOKIE_EXPIRATION.try_into().unwrap())
197
+
.path("/")
198
+
.into()
199
+
}
200
+
166
201
fn cookie(did: &Did) -> Cookie<'static> {
167
202
Cookie::build((DID_COOKIE_KEY, did.to_string()))
168
203
.http_only(true)
169
204
.secure(true)
170
205
.same_site(SameSite::None)
206
+
.expires(Expiration::DateTime(
207
+
(SystemTime::now() + COOKIE_EXPIRATION).into(),
208
+
)) // wtf safari needs this to not be a session cookie??
171
209
.max_age(COOKIE_EXPIRATION.try_into().unwrap())
210
+
.path("/")
172
211
.into()
173
212
}
174
213
214
+
#[derive(Debug, Deserialize)]
215
+
struct PromptQuery {
216
+
// this must *ONLY* be used for the postmessage target origin
217
+
app: Option<String>,
218
+
}
175
219
async fn prompt(
176
220
State(AppState {
177
221
allowed_hosts,
···
182
226
tokens,
183
227
..
184
228
}): State<AppState>,
229
+
Query(params): Query<PromptQuery>,
185
230
jar: SignedCookieJar,
186
231
headers: HeaderMap,
187
232
) -> impl IntoResponse {
188
-
let err = |reason, check_frame| {
233
+
let err = |reason, check_frame, detail| {
189
234
metrics::counter!("whoami_auth_prompt", "ok" => "false", "reason" => reason).increment(1);
190
-
let info = json!({ "reason": reason, "check_frame": check_frame });
235
+
let info = json!({
236
+
"reason": reason,
237
+
"check_frame": check_frame,
238
+
"detail": detail,
239
+
});
191
240
let html = RenderHtml("prompt-error", engine.clone(), info);
192
241
(StatusCode::BAD_REQUEST, html).into_response()
193
242
};
194
243
195
-
let Some(referrer) = headers.get(REFERER) else {
196
-
return err("Missing referer", true);
244
+
let Some(parent) = headers.get(ORIGIN).or_else(|| {
245
+
eprintln!("referrer fallback");
246
+
// TODO: referer should only be used for localhost??
247
+
headers.get(REFERER)
248
+
}) else {
249
+
return err("Missing origin and no referrer for fallback", true, None);
197
250
};
198
-
let Ok(referrer) = referrer.to_str() else {
199
-
return err("Unreadable referer", true);
251
+
let Ok(parent) = parent.to_str() else {
252
+
return err("Unreadable origin or referrer", true, None);
200
253
};
201
-
let Ok(url) = Url::parse(referrer) else {
202
-
return err("Bad referer", true);
254
+
eprintln!(
255
+
"rolling with parent: {parent:?} (from origin? {})",
256
+
headers.get(ORIGIN).is_some()
257
+
);
258
+
let Ok(url) = Url::parse(parent) else {
259
+
return err("Bad origin or referrer", true, None);
203
260
};
204
261
let Some(parent_host) = url.host_str() else {
205
-
return err("Referer missing host", true);
262
+
return err("Origin or referrer missing host", true, None);
206
263
};
207
264
if !allowed_hosts.contains(parent_host) {
208
-
return err("Login is not allowed on this page", false);
265
+
return err(
266
+
"Login is not allowed on this page",
267
+
false,
268
+
Some(parent_host),
269
+
);
270
+
}
271
+
if let Some(ref app) = params.app
272
+
&& !allowed_hosts.contains(app)
273
+
{
274
+
return err("Login is not allowed for this app", false, Some(app));
209
275
}
210
276
let parent_origin = url.origin().ascii_serialization();
211
277
if parent_origin == "null" {
212
-
return err("Referer origin is opaque", true);
278
+
return err("Origin or referrer header value is opaque", true, None);
213
279
}
214
280
215
-
let csp = format!("frame-ancestors {parent_origin}");
281
+
let all_allowed = allowed_hosts
282
+
.iter()
283
+
.map(|h| format!("https://{h}"))
284
+
.collect::<Vec<_>>()
285
+
.join(" ");
286
+
let csp = format!("frame-ancestors 'self' {parent_origin} {all_allowed}");
216
287
let frame_headers = [(CONTENT_SECURITY_POLICY, &csp)];
217
288
218
289
if let Some(did) = jar.get(DID_COOKIE_KEY) {
219
290
let Ok(did) = Did::new(did.value_trimmed().to_string()) else {
220
-
return err("Bad cookie", false);
291
+
return err("Bad cookie", false, None);
221
292
};
222
293
223
294
// push cookie expiry
···
227
298
Ok(t) => t,
228
299
Err(e) => {
229
300
eprintln!("failed to create JWT: {e:?}");
230
-
return err("failed to create JWT", false);
301
+
return err("failed to create JWT", false, None);
231
302
}
232
303
};
233
304
···
247
318
"fetch_key": fetch_key,
248
319
"parent_host": parent_host,
249
320
"parent_origin": parent_origin,
321
+
"parent_target": params.app.map(|h| format!("https://{h}")),
250
322
});
251
323
(frame_headers, jar, RenderHtml("prompt", engine, info)).into_response()
252
324
} else {
···
313
385
State(AppState { oauth, .. }): State<AppState>,
314
386
) -> Json<OAuthClientMetadata> {
315
387
Json(oauth.client_metadata())
316
-
}
317
-
318
-
async fn at_jwks(State(AppState { oauth, .. }): State<AppState>) -> Json<JwkSet> {
319
-
Json(oauth.jwks())
320
388
}
321
389
322
390
#[derive(Debug, Deserialize)]
···
450
518
(jar, Json(json!({ "ok": true })))
451
519
}
452
520
453
-
async fn jwks(State(AppState { tokens, .. }): State<AppState>) -> impl IntoResponse {
454
-
let headers = [
455
-
(CONTENT_TYPE, "application/json"),
456
-
// (CACHE_CONTROL, "") // TODO
457
-
];
458
-
(headers, tokens.jwks())
521
+
async fn jwks(State(AppState { oauth, tokens, .. }): State<AppState>) -> Json<JwkSet> {
522
+
let mut jwks = oauth.jwks();
523
+
jwks.keys.push(tokens.jwk());
524
+
Json(jwks)
459
525
}
+12
-1
who-am-i/static/style.css
+12
-1
who-am-i/static/style.css
···
12
12
overflow: hidden;
13
13
display: flex;
14
14
flex-direction: column;
15
-
height: 100vh;
15
+
min-height: 100vh;
16
16
}
17
17
.wrap.unframed {
18
18
border-radius: 0;
···
165
165
color: #285;
166
166
}
167
167
168
+
#need-storage {
169
+
font-size: 0.8rem;
170
+
}
171
+
.problem {
172
+
color: #a31;
173
+
}
174
+
168
175
#or {
169
176
font-size: 0.8rem;
170
177
text-align: center;
···
182
189
.hidden {
183
190
display: none !important;
184
191
}
192
+
193
+
.hello-connect-plz {
194
+
margin: 1.667rem 0 0.667rem;
195
+
}
+45
-4
who-am-i/templates/hello.hbs
+45
-4
who-am-i/templates/hello.hbs
···
4
4
<div class="mini-content">
5
5
<div class="explain">
6
6
<p>This is a little identity-verifying service for microcosm demos.</p>
7
+
<p>Only <strong>read access to your public data</strong> is required to connect: connecting does not grant any ability to modify your account or data.</p>
7
8
</div>
8
9
9
10
{{#if did}}
···
50
51
} catch (e) {
51
52
err(e, 'failed to clear session, sorry');
52
53
}
53
-
window.location.reload();
54
+
window.location.replace(location.pathname);
55
+
window.location.reload(); // backup, in case there is no query?
54
56
});
55
57
})();
56
58
···
71
73
}
72
74
</script>
73
75
{{else}}
74
-
<p id="prompt" class="detail no">
75
-
No identity connected.
76
-
</p>
76
+
77
+
<p class="hello-connect-plz">Connect your handle</p>
78
+
79
+
{{#if is_auth_reload}}
80
+
{{#if no_cookie}}
81
+
<p id="prompt" class="detail no">
82
+
No identity connected. Your browser may be blocking access for connecting.
83
+
</p>
84
+
{{else}}
85
+
{{#if auth_failed}}
86
+
<p id="prompt" class="detail no">
87
+
No identity connected. Connecting failed or was denied.
88
+
</p>
89
+
{{else}}
90
+
<p id="prompt" class="detail no">
91
+
No identity connected.
92
+
</p>
93
+
{{/if}}
94
+
{{/if}}
95
+
{{/if}}
96
+
97
+
<div id="user-info">
98
+
<form id="form-action" action="/auth" target="_blank" method="GET" class="action {{#if did}}hidden{{/if}}">
99
+
<label>
100
+
@<input id="handle-input" class="handle" name="handle" placeholder="example.bsky.social" />
101
+
</label>
102
+
<button id="connect" type="submit">connect</button>
103
+
</form>
104
+
</div>
77
105
{{/if}}
106
+
78
107
</div>
108
+
<script>
109
+
window.addEventListener('storage', e => {
110
+
console.log('eyyy got storage', e);
111
+
if (e.key !== 'who-am-i') return;
112
+
if (!e.newValue) return;
113
+
if (e.newValue.result === 'success') {
114
+
window.location = '/?auth_reload=1';
115
+
} else {
116
+
window.location = '/?auth_reload=1&auth_failed=1';
117
+
}
118
+
});
119
+
</script>
79
120
{{/inline}}
80
121
81
122
{{#> base-full}}{{/base-full}}
+1
who-am-i/templates/prompt-error.hbs
+1
who-am-i/templates/prompt-error.hbs
···
2
2
<div class="prompt-error">
3
3
<p class="went-wrong">Something went wrong :(</p>
4
4
<p class="reason">{{ reason }}</p>
5
+
<p class="reason detail">{{ detail }}</p>
5
6
<p id="maybe-not-in-iframe" class="hidden">
6
7
Possibly related: this prompt is meant to be shown in an iframe, but it seems like it's not.
7
8
</p>
+46
-7
who-am-i/templates/prompt.hbs
+46
-7
who-am-i/templates/prompt.hbs
···
6
6
<p id="error-message" class="hidden"></p>
7
7
8
8
<p id="prompt" class="detail">
9
-
<span class="parent-host">{{ parent_host }}</span> would like to confirm your handle
9
+
<span class="parent-host">{{ parent_host }}</span> wants to confirm your handle
10
10
</p>
11
11
12
12
<div id="loader" {{#unless did}}class="hidden"{{/unless}}>
···
27
27
</div>
28
28
</div>
29
29
30
+
<div id="need-storage" class="hidden">
31
+
<p class="problem">Sorry, your browser is blocking access.</p>
32
+
<p>
33
+
Try <a href="/" target="_blank">connecting directly</a> first (but no promises).
34
+
Clicking <button id="desperation">this button</button> might also help.
35
+
</p>
36
+
</div>
37
+
30
38
31
39
32
40
<script>
···
39
47
const formEl = document.getElementById('form-action'); // for anon
40
48
const allowEl = document.getElementById('handle-action'); // for known-did
41
49
const connectEl = document.getElementById('connect'); // for anon
50
+
const needStorageEl = document.getElementById('need-storage'); // for safari/frame isolation
51
+
const desperationEl = document.getElementById('desperation');
42
52
43
53
function err(e, msg) {
44
54
loaderEl.classList.add('hidden');
···
66
76
window.open(url, '_blank');
67
77
};
68
78
79
+
// check if we may be partitioned, preventing access after auth completion
80
+
// this should only happen if on a browser that implements storage access api
81
+
if ('hasStorageAccess' in document) {
82
+
document.hasStorageAccess().then((hasAccess) => {
83
+
if (!hasAccess) {
84
+
promptEl.classList.add('hidden');
85
+
infoEl.classList.add('hidden');
86
+
needStorageEl.classList.remove('hidden');
87
+
desperation.addEventListener('click', () => {
88
+
document.requestStorageAccess({
89
+
cookies: true,
90
+
localStorage: true,
91
+
}).then(
92
+
() => {
93
+
desperation.textContent = "(maybe helped?)";
94
+
setTimeout(() => location.reload(), 350);
95
+
},
96
+
() => desperation.textContent = "(doubtful)",
97
+
);
98
+
})
99
+
}
100
+
});
101
+
}
102
+
69
103
window.addEventListener('storage', async e => {
70
104
// here's a fun minor vuln: we can't tell which flow triggers the storage event.
71
105
// so if you have two flows going, it grants for both (or the first responder?) if you grant for either.
···
79
113
console.error("hmm, heard from localstorage but did not get DID", details, e);
80
114
err('sorry, something went wrong getting your details');
81
115
}
82
-
localStorage.removeItem(e.key);
83
116
84
117
let parsed;
85
118
try {
···
127
160
return info.handle;
128
161
}
129
162
163
+
const parentTarget = {{{json parent_target}}} ?? {{{json parent_origin}}};
164
+
130
165
const shareAllow = (handle, token) => {
131
-
top.postMessage(
132
-
{ action: "allow", handle, token },
133
-
{{{json parent_origin}}},
134
-
);
166
+
try {
167
+
top.postMessage(
168
+
{ action: "allow", handle, token },
169
+
parentTarget,
170
+
);
171
+
} catch (e) {
172
+
err(e, 'Identity verified but failed to connect with app');
173
+
};
135
174
promptEl.textContent = '✔️ shared';
136
175
}
137
176
138
177
const shareDeny = reason => {
139
178
top.postMessage(
140
179
{ action: "deny", reason },
141
-
{{{json parent_origin}}},
180
+
parentTarget,
142
181
);
143
182
}
144
183
</script>