mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-21 07:57:34 +00:00
Compare commits
28
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf8d6091f1 | ||
|
|
b4f163aacb | ||
|
|
6c1a6099b9 | ||
|
|
97585f872c | ||
|
|
08eef0c00f | ||
|
|
b73eace66f | ||
|
|
fc4ad66af1 | ||
|
|
daabb53092 | ||
|
|
806a63cb29 | ||
|
|
cd51a01fac | ||
|
|
ffa535e0d5 | ||
|
|
4fa966212e | ||
|
|
58026816f2 | ||
|
|
9d2e53af99 | ||
|
|
6d96936d3a | ||
|
|
48e83f6dfa | ||
|
|
4c49a20255 | ||
|
|
330797f4fb | ||
|
|
580fcf2365 | ||
|
|
3d2975209e | ||
|
|
2944026572 | ||
|
|
8004e962c3 | ||
|
|
a4ef1ecfa2 | ||
|
|
6f6e8c4eb5 | ||
|
|
38433deba7 | ||
|
|
67c4111046 | ||
|
|
50665f4726 | ||
|
|
a9728fab80 |
No files matched your search
Generated
+74
-74
@@ -604,9 +604,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.12.1"
|
||||
version = "1.12.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
|
||||
checksum = "776dfebd015e2d8732c684a2c71003674ccb49457b539b9e82151ba38e96dd7c"
|
||||
|
||||
[[package]]
|
||||
name = "bytesize"
|
||||
@@ -764,9 +764,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.6.7"
|
||||
version = "4.6.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946"
|
||||
checksum = "ac230478587d0269d8d6998b82ae69ea51509d55df66d9e92edd1f986904cd4a"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
@@ -784,9 +784,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.6.7"
|
||||
version = "4.6.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9c751b79415d4e559e3d1fcf128e09e720eb673a06d26cf6f392d37d75b66e0"
|
||||
checksum = "895c9d8d2ac2dd8b8a29f3724a14e72aaaa6debcf8c38c82f97305c6a172767a"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
@@ -946,7 +946,7 @@ dependencies = [
|
||||
"hyper",
|
||||
"itertools 0.15.0",
|
||||
"lettre",
|
||||
"rand 0.10.3",
|
||||
"rand 0.10.4",
|
||||
"reqwest 0.13.5",
|
||||
"ruma",
|
||||
"ruminuwuity",
|
||||
@@ -998,7 +998,7 @@ dependencies = [
|
||||
"ipaddress",
|
||||
"lettre",
|
||||
"libc",
|
||||
"libloading 0.9.0",
|
||||
"libloading 0.9.1",
|
||||
"lock_api 0.5.0",
|
||||
"maplit",
|
||||
"nix",
|
||||
@@ -1010,7 +1010,7 @@ dependencies = [
|
||||
"opentelemetry_sdk",
|
||||
"parking_lot",
|
||||
"prometheus",
|
||||
"rand 0.10.3",
|
||||
"rand 0.10.4",
|
||||
"regex",
|
||||
"reqwest 0.13.5",
|
||||
"resolvematrix",
|
||||
@@ -1131,7 +1131,7 @@ dependencies = [
|
||||
"openidconnect",
|
||||
"opentelemetry",
|
||||
"p256 0.14.0",
|
||||
"rand 0.10.3",
|
||||
"rand 0.10.4",
|
||||
"regex",
|
||||
"reqwest 0.12.28",
|
||||
"reqwest 0.13.5",
|
||||
@@ -1525,9 +1525,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ctor"
|
||||
version = "1.0.13"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "914a755b7c2d4af2bdcff7ce1739e2db9a1b81a9b07123d8015786ae03c0980d"
|
||||
checksum = "ea691ed9f36489d087419b8b2ba3ef27d89621380b4178c73e2445a379e4e0f4"
|
||||
dependencies = [
|
||||
"link-section",
|
||||
"linktime-proc-macro",
|
||||
@@ -1784,10 +1784,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dtor"
|
||||
version = "1.0.6"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd3f6c362b2bbd7063090886afd78978f5dbf1f11da7efcc40f81d32c943fac1"
|
||||
checksum = "915e80ae7aca23bef767ded8e4a763d0c912c2faaa8bfec1e66d505ebaceb254"
|
||||
dependencies = [
|
||||
"link-section",
|
||||
"linktime-proc-macro",
|
||||
]
|
||||
|
||||
@@ -1921,9 +1922,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "email-encoding"
|
||||
version = "0.4.2"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "420b9da095f052ea597503e39073b5b3c522f7db933fbac202d91d24492693fd"
|
||||
checksum = "9f690ae2169f2ceb3f45b28b6fcd8fa16839f2f5c8818546774b9425f5f71004"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"memchr",
|
||||
@@ -2317,9 +2318,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "granit-parser"
|
||||
version = "2.1.0"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05f05586d4d4df3d47123207826c40b252728b438a1a07bad3c01ee6bea401df"
|
||||
checksum = "9bd04d0d9c7079b416b458d2317aea4aa964c81938cb7c20f559758c4f422dc8"
|
||||
dependencies = [
|
||||
"arraydeque",
|
||||
"smallvec",
|
||||
@@ -2494,7 +2495,7 @@ dependencies = [
|
||||
"idna",
|
||||
"ipnet",
|
||||
"jni",
|
||||
"rand 0.10.3",
|
||||
"rand 0.10.4",
|
||||
"thiserror 2.0.21",
|
||||
"tinyvec",
|
||||
"tokio",
|
||||
@@ -2514,7 +2515,7 @@ dependencies = [
|
||||
"jni",
|
||||
"once_cell",
|
||||
"prefix-trie",
|
||||
"rand 0.10.3",
|
||||
"rand 0.10.4",
|
||||
"ring",
|
||||
"serde",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2540,7 +2541,7 @@ dependencies = [
|
||||
"ndk-context",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"rand 0.10.3",
|
||||
"rand 0.10.4",
|
||||
"resolv-conf",
|
||||
"serde",
|
||||
"smallvec",
|
||||
@@ -2953,9 +2954,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ipaddress"
|
||||
version = "0.2.11"
|
||||
version = "0.2.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67a97d7409c3ade4304acbff6b33b915af4564c42bf6e383651ced09bd6a2bce"
|
||||
checksum = "e0ae5a9c049476ef23026df39fe92a8d83c1d8b670b975f095cb4d5a3b13d43e"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"libc",
|
||||
@@ -3195,9 +3196,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lettre"
|
||||
version = "0.11.23"
|
||||
version = "0.11.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2c646bd5cc763b1087b15493e29a64be6147ba8f19342004fa52048ee596eae"
|
||||
checksum = "f294f3d7cdb313e578acef7d7727d4e8d897e0fcd0d6d58c19959cec95073f19"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.23.1",
|
||||
@@ -3241,9 +3242,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.9.0"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "754ca22de805bb5744484a5b151a9e1a8e837d5dc232c2d7d8c2e3492edc8b60"
|
||||
checksum = "a1832accd5a4ca2795ace4d05d15c4039be15b62d3b950eff99746a990e3cc10"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-link",
|
||||
@@ -3268,9 +3269,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "link-section"
|
||||
version = "0.19.3"
|
||||
version = "0.19.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39c29a617ce3df32c08497bdc1ab6e2376e0b17948ac166a2fbe5977c5954cd9"
|
||||
checksum = "4d9aae57673c1a235149777a74d152f3210ebd3e3b13346d2cdb6809e566bd3c"
|
||||
|
||||
[[package]]
|
||||
name = "linked-hash-map"
|
||||
@@ -4617,7 +4618,7 @@ dependencies = [
|
||||
"bytes",
|
||||
"getrandom 0.4.3",
|
||||
"lru-slab",
|
||||
"rand 0.10.3",
|
||||
"rand 0.10.4",
|
||||
"rand_pcg",
|
||||
"ring",
|
||||
"rustc-hash",
|
||||
@@ -4694,9 +4695,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.10.3"
|
||||
version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af"
|
||||
checksum = "8f6fa277c67e6ea590466f04c3fe82cb509f0864fe470643e5570de9514a9b11"
|
||||
dependencies = [
|
||||
"chacha20",
|
||||
"getrandom 0.4.3",
|
||||
@@ -4787,9 +4788,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.13.1"
|
||||
version = "1.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
|
||||
checksum = "9807af0e638c12e753aa1b4e601791bf2a8f71274023c8bbeec12fc149950857"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@@ -4799,9 +4800,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.18"
|
||||
version = "0.4.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
|
||||
checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@@ -4810,9 +4811,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.11"
|
||||
version = "0.8.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
||||
checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6"
|
||||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
@@ -5044,7 +5045,7 @@ dependencies = [
|
||||
"js_int",
|
||||
"konst",
|
||||
"percent-encoding",
|
||||
"rand 0.10.3",
|
||||
"rand 0.10.4",
|
||||
"regex",
|
||||
"ruma-identifiers-validation",
|
||||
"ruma-macros",
|
||||
@@ -5094,7 +5095,7 @@ dependencies = [
|
||||
"js_int",
|
||||
"memchr",
|
||||
"mime",
|
||||
"rand 0.10.3",
|
||||
"rand 0.10.4",
|
||||
"ruma-common",
|
||||
"ruma-events",
|
||||
"ruma-signatures",
|
||||
@@ -5150,7 +5151,7 @@ dependencies = [
|
||||
"ed25519-dalek",
|
||||
"memchr",
|
||||
"pkcs8 0.11.0",
|
||||
"rand 0.10.3",
|
||||
"rand 0.10.4",
|
||||
"ruma-common",
|
||||
"ruma-events",
|
||||
"serde_json",
|
||||
@@ -5188,7 +5189,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rust-librocksdb-sys"
|
||||
version = "0.49.0+11.12.0"
|
||||
source = "git+https://forgejo.ellis.link/continuwuation/rust-rocksdb-zaidoon1?rev=6021299f3e0e9455dc3f2e39c65e1dc217be8903#6021299f3e0e9455dc3f2e39c65e1dc217be8903"
|
||||
source = "git+https://forgejo.ellis.link/continuwuation/rust-rocksdb-zaidoon1?rev=85ded20348e3dab902c239967075795e9c6d101b#85ded20348e3dab902c239967075795e9c6d101b"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"bzip2-sys",
|
||||
@@ -5206,7 +5207,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rust-rocksdb"
|
||||
version = "0.54.0"
|
||||
source = "git+https://forgejo.ellis.link/continuwuation/rust-rocksdb-zaidoon1?rev=6021299f3e0e9455dc3f2e39c65e1dc217be8903#6021299f3e0e9455dc3f2e39c65e1dc217be8903"
|
||||
source = "git+https://forgejo.ellis.link/continuwuation/rust-rocksdb-zaidoon1?rev=85ded20348e3dab902c239967075795e9c6d101b#85ded20348e3dab902c239967075795e9c6d101b"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"parking_lot",
|
||||
@@ -5485,9 +5486,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sentry"
|
||||
version = "0.49.5"
|
||||
version = "0.49.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7c2c887f17023c9462a4202176efc33ca7228f9c30c0141c765ab534ab2d36b"
|
||||
checksum = "d7bc7fb14982f395d53924f4feebd48c6cc136399c49ac2160dcf2b260e74b75"
|
||||
dependencies = [
|
||||
"cfg_aliases",
|
||||
"httpdate",
|
||||
@@ -5505,9 +5506,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sentry-backtrace"
|
||||
version = "0.49.5"
|
||||
version = "0.49.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c391d4330f3b37fdddf2b928151244e8c2dc0cfea1740e455cc8942af436f919"
|
||||
checksum = "f68328b53eb7defc20f993ed7cd1f4ce10d06feecefdf914db062ce2523e4b77"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"regex",
|
||||
@@ -5516,9 +5517,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sentry-contexts"
|
||||
version = "0.49.5"
|
||||
version = "0.49.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "654dacb94135c713e1dcbff01314a83d333f0e62f76b91fed5ab87415075530c"
|
||||
checksum = "1d57fb52d1e5d76cc5a7415428004699d9e6d498859a7acc8e05becc57dad81f"
|
||||
dependencies = [
|
||||
"hostname",
|
||||
"libc",
|
||||
@@ -5530,22 +5531,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sentry-core"
|
||||
version = "0.49.5"
|
||||
version = "0.49.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edcb294ca821e5c5624edaf33535eb18b06ef4f8675201d3e4d81ce325741692"
|
||||
checksum = "8367f7f31654b35453e20c8aca06e0ecf5a4d4793e33be139c1581e475a94e6a"
|
||||
dependencies = [
|
||||
"rand 0.10.3",
|
||||
"rand 0.10.4",
|
||||
"sentry-types",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sentry-debug-images"
|
||||
version = "0.49.5"
|
||||
version = "0.49.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74835055f6a57b78c0e13f941b460e39edc1899b05fe31dd47cd02367f70888f"
|
||||
checksum = "386f4ce2364e58f2ca811f388a0427fa13784bbe7aee85f302e901ef4b00fab9"
|
||||
dependencies = [
|
||||
"findshlibs",
|
||||
"sentry-core",
|
||||
@@ -5553,9 +5553,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sentry-log"
|
||||
version = "0.49.5"
|
||||
version = "0.49.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f24141aaeb20c731719b33077f1063a79e07eef63a4954530559c067ba046aad"
|
||||
checksum = "c938358d54c65a79fea165a447ae0eabc5717f23ba482ceee279c5645f0ccad3"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"log",
|
||||
@@ -5564,9 +5564,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sentry-panic"
|
||||
version = "0.49.5"
|
||||
version = "0.49.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f5d28522f81ed90510ec43ed01cb1873a393b329dc719f93335b4c75fbef05d1"
|
||||
checksum = "2ab095af8f107e893941f857d8e204f5d25404247c34af131c7d199e3021679f"
|
||||
dependencies = [
|
||||
"sentry-backtrace",
|
||||
"sentry-core",
|
||||
@@ -5574,9 +5574,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sentry-tower"
|
||||
version = "0.49.5"
|
||||
version = "0.49.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "057730796d82b72f35f57e66fc41c2b9e334eb3edf5030dd18d3b1f88d062c78"
|
||||
checksum = "18f29b19179ae36e6318c71f6ee18d1e0db8bbe8e7b7f213c2aba9e721b650fb"
|
||||
dependencies = [
|
||||
"http",
|
||||
"pin-project",
|
||||
@@ -5588,9 +5588,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sentry-tracing"
|
||||
version = "0.49.5"
|
||||
version = "0.49.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec67c296aadc41d4d41b64738908c51cacddf99edebe7a2b476f9bf40de93ff5"
|
||||
checksum = "a7cae82b121a812e69a1cfaaacb800112f5f261f362fbf5a08e13d1c11ef349e"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"sentry-backtrace",
|
||||
@@ -5601,13 +5601,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sentry-types"
|
||||
version = "0.49.5"
|
||||
version = "0.49.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83d84a36b6bdeeb7813976fb899fca45d94540d2e2b80eac91ba66b4c654d8f0"
|
||||
checksum = "03da7c1f79d001b4f18e277f8207470efb262fb94c761baa195873d2ace8eb8a"
|
||||
dependencies = [
|
||||
"debugid",
|
||||
"hex",
|
||||
"rand 0.10.3",
|
||||
"rand 0.10.4",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror 2.0.21",
|
||||
@@ -5628,12 +5628,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde-saphyr"
|
||||
version = "2.1.1"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d43fb82d550b07e6f929a58d7d0935182602f48ddead875f5ee313c41c8f07fe"
|
||||
checksum = "969cde0349344dbbf58b5f9badbfb8f806db13969364eb8007c057ef687007d9"
|
||||
dependencies = [
|
||||
"annotate-snippets",
|
||||
"base64 0.23.1",
|
||||
"base64 0.22.1",
|
||||
"encoding_rs_io",
|
||||
"granit-parser",
|
||||
"nohash-hasher",
|
||||
@@ -5971,9 +5971,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.16.5"
|
||||
version = "1.16.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46"
|
||||
checksum = "3244542535d5de959d90ec55d1b5ff0fd2bb7b1310223907d5f11932847f7b59"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
@@ -6228,7 +6228,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "tikv-jemalloc-ctl"
|
||||
version = "0.7.0"
|
||||
source = "git+https://forgejo.ellis.link/continuwuation/jemallocator?rev=ac4d4861b335b199f812807996e8c9166961041a#ac4d4861b335b199f812807996e8c9166961041a"
|
||||
source = "git+https://forgejo.ellis.link/continuwuation/jemallocator?rev=46e7821917b06636cdb5b203d312799970eaea92#46e7821917b06636cdb5b203d312799970eaea92"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"tikv-jemalloc-sys",
|
||||
@@ -6237,7 +6237,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "tikv-jemalloc-sys"
|
||||
version = "0.7.0+5.4.0-0-g7a34f18502e7b222724097cdcd499b437d189acc"
|
||||
source = "git+https://forgejo.ellis.link/continuwuation/jemallocator?rev=ac4d4861b335b199f812807996e8c9166961041a#ac4d4861b335b199f812807996e8c9166961041a"
|
||||
source = "git+https://forgejo.ellis.link/continuwuation/jemallocator?rev=46e7821917b06636cdb5b203d312799970eaea92#46e7821917b06636cdb5b203d312799970eaea92"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
@@ -6246,7 +6246,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "tikv-jemallocator"
|
||||
version = "0.7.0"
|
||||
source = "git+https://forgejo.ellis.link/continuwuation/jemallocator?rev=ac4d4861b335b199f812807996e8c9166961041a#ac4d4861b335b199f812807996e8c9166961041a"
|
||||
source = "git+https://forgejo.ellis.link/continuwuation/jemallocator?rev=46e7821917b06636cdb5b203d312799970eaea92#46e7821917b06636cdb5b203d312799970eaea92"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"tikv-jemalloc-sys",
|
||||
|
||||
+5
-4
@@ -395,6 +395,7 @@ features = [
|
||||
"unstable-msc4406",
|
||||
"unstable-msc4439",
|
||||
"unstable-msc4354",
|
||||
"unstable-msc4388",
|
||||
"unstable-msc4480",
|
||||
"unstable-msc4466",
|
||||
"unstable-msc4494",
|
||||
@@ -406,7 +407,7 @@ features = [
|
||||
|
||||
[workspace.dependencies.rust-rocksdb]
|
||||
git = "https://forgejo.ellis.link/continuwuation/rust-rocksdb-zaidoon1"
|
||||
rev = "6021299f3e0e9455dc3f2e39c65e1dc217be8903"
|
||||
rev = "85ded20348e3dab902c239967075795e9c6d101b"
|
||||
default-features = false
|
||||
features = [
|
||||
"multi-threaded-cf",
|
||||
@@ -489,7 +490,7 @@ version = "0.49.5"
|
||||
# jemalloc usage
|
||||
[workspace.dependencies.tikv-jemalloc-sys]
|
||||
git = "https://forgejo.ellis.link/continuwuation/jemallocator"
|
||||
rev = "ac4d4861b335b199f812807996e8c9166961041a"
|
||||
rev = "46e7821917b06636cdb5b203d312799970eaea92"
|
||||
default-features = false
|
||||
features = [
|
||||
"background_threads_runtime_support",
|
||||
@@ -497,7 +498,7 @@ features = [
|
||||
]
|
||||
[workspace.dependencies.tikv-jemallocator]
|
||||
git = "https://forgejo.ellis.link/continuwuation/jemallocator"
|
||||
rev = "ac4d4861b335b199f812807996e8c9166961041a"
|
||||
rev = "46e7821917b06636cdb5b203d312799970eaea92"
|
||||
default-features = false
|
||||
features = [
|
||||
"background_threads_runtime_support",
|
||||
@@ -505,7 +506,7 @@ features = [
|
||||
]
|
||||
[workspace.dependencies.tikv-jemalloc-ctl]
|
||||
git = "https://forgejo.ellis.link/continuwuation/jemallocator"
|
||||
rev = "ac4d4861b335b199f812807996e8c9166961041a"
|
||||
rev = "46e7821917b06636cdb5b203d312799970eaea92"
|
||||
default-features = false
|
||||
features = ["use_std"]
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Added support for MSC4388, allowing compatible Matrix clients to log in to Continuwuity by scanning a QR code on an already logged-in client. Contributed by @ginger.
|
||||
+21
-4
@@ -812,15 +812,32 @@
|
||||
# env: CONTINUWUITY_FORGET_FORCED_UPON_LEAVE
|
||||
#forget_forced_upon_leave = false
|
||||
|
||||
# Set this to true to require authentication on the normally
|
||||
# unauthenticated profile retrieval endpoints (GET)
|
||||
# "/_matrix/client/v3/profile/{userId}".
|
||||
# Set this to true to require authentication when looking up user profiles
|
||||
# through this server.
|
||||
#
|
||||
# This can prevent profile scraping.
|
||||
# By default this is false, allowing tools such as matrix.to to access
|
||||
# profiles of users on this server and on other servers.
|
||||
# Setting this to true will block those tools, and may block automated
|
||||
# crawlers from scraping users' profiles, although it will not block
|
||||
# other homeservers from accessing users' profiles.
|
||||
#
|
||||
# env: CONTINUWUITY_REQUIRE_AUTH_FOR_PROFILE_REQUESTS
|
||||
#require_auth_for_profile_requests = false
|
||||
|
||||
# Set this to true to require authentication to create a rendezvous
|
||||
# session. Rendezvous sessions are used for QR code login.
|
||||
#
|
||||
# For QR code login, the device that shows the QR code is the one that
|
||||
# creates the rendezvous session. Therefore, this must be false to let
|
||||
# a logged-out device show a QR code.
|
||||
#
|
||||
# By default this is false to allow logged-out desktop devices (which may
|
||||
# not have a camera) to show a QR code. Setting this to true will
|
||||
# require logged-out devices to scan the QR code instead.
|
||||
#
|
||||
# env: CONTINUWUITY_REQUIRE_AUTH_FOR_RENDEZVOUS
|
||||
#require_auth_for_rendezvous = false
|
||||
|
||||
# Set this to true to allow your server's public room directory to be
|
||||
# federated. Set this to false to protect against /publicRooms spiders,
|
||||
# but will forbid external users from viewing your server's public room
|
||||
|
||||
@@ -84,8 +84,9 @@ All forked dependencies are maintained under the
|
||||
- [rocksdb][continuwuation-rocksdb] - Fork of [facebook/rocksdb][rocksdb] via
|
||||
[`@zaidoon1`][8] with liburing build fixes and GCC debug build fixes
|
||||
- [jemallocator][continuwuation-jemallocator] - Fork of
|
||||
[tikv/jemallocator][jemallocator] fixing musl builds, suspicious code, and
|
||||
adding support for redzones in Valgrind
|
||||
[tikv/jemallocator][jemallocator] fixing musl builds and using jemalloc's
|
||||
`*x` APIs consistently in `GlobalAlloc` to avoid interposer/Valgrind
|
||||
mismatches
|
||||
- [rustyline-async][continuwuation-rustyline-async] - Fork of
|
||||
[zyansheep/rustyline-async][rustyline-async] with tab completion callback and
|
||||
`CTRL+\` signal quit event for Continuwuity console CLI
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
target:
|
||||
target.fromToolchainName {
|
||||
name = (lib.importTOML "${inputs.self}/rust-toolchain.toml").toolchain.channel;
|
||||
sha256 = "sha256-+xUr6Al1wZSqX8aEsq7DpuFOK4Ve/i+qTl+K5uWQ9GM=";
|
||||
sha256 = "sha256-MFHoWVcPZKjFrLnQnodCXbUsfZcofGfo9tV9fTTvklg=";
|
||||
};
|
||||
in
|
||||
{
|
||||
|
||||
Generated
+13
-13
@@ -431,9 +431,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rspress/core": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.1.2.tgz",
|
||||
"integrity": "sha512-3ghPRkZFwbuO3tr2Rb5cxi6QfSFWOcxoZ5p4pv21lbN5DxAzMduITFlfgBMTArIQbehXrfXw3OUXe1l422b0RA==",
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.1.3.tgz",
|
||||
"integrity": "sha512-qKa5c7zHO8cmhxkReURd3dN/ZRfHYnEztdIQ9hMuolaNzhSYo2A36XErUvLvbMf2EUM2AxfPYRQv+4Crfeq6pw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -441,7 +441,7 @@
|
||||
"@mdx-js/react": "^3.1.1",
|
||||
"@rsbuild/core": "^2.2.14",
|
||||
"@rsbuild/plugin-react": "~2.1.1",
|
||||
"@rspress/shared": "2.1.2",
|
||||
"@rspress/shared": "2.1.3",
|
||||
"@shikijs/rehype": "^4.2.0",
|
||||
"@shikijs/transformers": "^4.2.0",
|
||||
"@types/mdast": "^4.0.4",
|
||||
@@ -485,9 +485,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rspress/plugin-client-redirects": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.1.2.tgz",
|
||||
"integrity": "sha512-kNCC7fffXA277TzTDfKpP+QuCI1X218lJ5JH/2iqYR8PHnLw0Y6ZIwoFmJlE0eKaBdniYyBRGn9zgvT93mCWdg==",
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.1.3.tgz",
|
||||
"integrity": "sha512-iEqJ8qEFuUxGKRVaS/WMyFi8FiJlogdcEHbGK/UjY8+8Hg8r8aSv4YihmNh3Ev/uIW21hrC8aXMEgVo0H51Q+g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -498,9 +498,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rspress/plugin-sitemap": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@rspress/plugin-sitemap/-/plugin-sitemap-2.1.2.tgz",
|
||||
"integrity": "sha512-qF9NDLLJORa7MM8QY/etgMlrXM8hlArNaK5ntiFimqtKRoF1YTJQSKPsAfMq2PvYrpQJyEqsSg6wJ+r+lyjNlw==",
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@rspress/plugin-sitemap/-/plugin-sitemap-2.1.3.tgz",
|
||||
"integrity": "sha512-Fqo7/4PfQK1ecHUFoUDMrR/E+Hcu+kIohxSs8QabflMy3dqk+M3ZqzJDOHpVYB+HLLGwKiqkPLT4BK+W93clkw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -511,9 +511,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rspress/shared": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.1.2.tgz",
|
||||
"integrity": "sha512-W34tT1fdP3PrdbXpZNKqOGZMOw+RYL70Z9vnkbT1HTTbtX4uMIDE+SU7ByihG0S0LYBsT3kPxA2cXj696253Uw==",
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.1.3.tgz",
|
||||
"integrity": "sha512-VwJ7kgsTWVqHzSXQVHIUCsdMparmq9b/IDmTa3a6jMPl1zmm5Qg9M0eP4j8JXWoIS9n19XtCkQcZmMTFOPRy3A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
|
||||
[toolchain]
|
||||
profile = "minimal"
|
||||
channel = "1.99.1"
|
||||
channel = "1.100.0"
|
||||
components = [
|
||||
# For rust-analyzer
|
||||
"rust-src",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#![allow(clippy::wildcard_imports)]
|
||||
#![allow(clippy::enum_glob_use)]
|
||||
#![allow(clippy::too_many_arguments)]
|
||||
#![allow(clippy::large_unopt_stack_frames, reason = "very large Subcommand macro expansions")]
|
||||
|
||||
conduwuit_macros::introspect_crate! {}
|
||||
|
||||
|
||||
@@ -15,8 +15,7 @@ use ruma::{
|
||||
OneTimeKeyAlgorithm, OwnedDeviceId, OwnedUserId, UserId,
|
||||
api::{
|
||||
client::keys::{
|
||||
claim_keys, get_key_changes, get_keys, upload_keys,
|
||||
upload_signatures::{self},
|
||||
claim_keys, get_key_changes, get_keys, upload_keys, upload_signatures,
|
||||
upload_signing_keys,
|
||||
},
|
||||
federation,
|
||||
|
||||
@@ -16,10 +16,7 @@ use futures::{FutureExt, StreamExt};
|
||||
use ruma::{
|
||||
CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, OwnedRoomId, OwnedServerName,
|
||||
OwnedUserId, RoomId, UserId,
|
||||
api::{
|
||||
client::knock::knock_room,
|
||||
federation::{self},
|
||||
},
|
||||
api::{client::knock::knock_room, federation},
|
||||
canonical_json::to_canonical_value,
|
||||
events::{
|
||||
StateEventType,
|
||||
|
||||
@@ -10,10 +10,7 @@ use conduwuit::{
|
||||
use futures::{FutureExt, StreamExt, pin_mut};
|
||||
use ruma::{
|
||||
CanonicalJsonObject, CanonicalJsonValue, OwnedServerName, RoomId, UserId,
|
||||
api::{
|
||||
client::membership::leave_room,
|
||||
federation::{self},
|
||||
},
|
||||
api::{client::membership::leave_room, federation},
|
||||
events::{
|
||||
StateEventType,
|
||||
room::member::{MembershipState, RoomMemberEventContent},
|
||||
|
||||
@@ -9,7 +9,7 @@ use conduwuit::{
|
||||
use futures::{FutureExt, StreamExt, future::join};
|
||||
use ruma::{
|
||||
api::client::membership::{
|
||||
get_member_events::{self},
|
||||
get_member_events,
|
||||
joined_members::{self, v3::RoomMember},
|
||||
},
|
||||
events::{
|
||||
|
||||
@@ -23,6 +23,7 @@ pub(super) mod push;
|
||||
pub(super) mod read_marker;
|
||||
pub(super) mod redact;
|
||||
pub(super) mod relations;
|
||||
pub(super) mod rendezvous;
|
||||
pub(super) mod report;
|
||||
pub(super) mod room;
|
||||
pub(super) mod search;
|
||||
@@ -69,6 +70,7 @@ pub(super) use push::*;
|
||||
pub(super) use read_marker::*;
|
||||
pub(super) use redact::*;
|
||||
pub(super) use relations::*;
|
||||
pub(super) use rendezvous::*;
|
||||
pub(super) use report::*;
|
||||
pub(super) use room::*;
|
||||
pub(super) use search::*;
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
use axum::extract::State;
|
||||
use conduwuit::{Err, Result};
|
||||
use http::HeaderMap;
|
||||
use ruma::api::client::rendezvous::{
|
||||
create_rendezvous_session, delete_rendezvous_session, discover_rendezvous,
|
||||
get_rendezvous_session, update_rendezvous_session,
|
||||
};
|
||||
use service::Services;
|
||||
|
||||
use crate::{Ruma, router::ClientIdentity};
|
||||
|
||||
/// `GET /_matrix/client/msc4388/io.element.msc4388/rendezvous`
|
||||
pub(crate) async fn discover_rendezvous_route(
|
||||
State(services): State<crate::State>,
|
||||
body: Ruma<discover_rendezvous::msc4388::Request>,
|
||||
) -> Result<discover_rendezvous::msc4388::Response> {
|
||||
Ok(discover_rendezvous::msc4388::Response::new(rendezvous_available(
|
||||
&services,
|
||||
body.identity.as_ref(),
|
||||
)))
|
||||
}
|
||||
|
||||
/// `POST /_matrix/client/msc4388/io.element.msc4388/rendezvous/`
|
||||
pub(crate) async fn create_rendezvous_session_route(
|
||||
State(services): State<crate::State>,
|
||||
body: Ruma<create_rendezvous_session::msc4388::Request>,
|
||||
) -> Result<create_rendezvous_session::msc4388::Response> {
|
||||
if !rendezvous_available(&services, body.identity.as_ref()) {
|
||||
return Err!(Request(Forbidden("You are not authorized to create a rendezvous session")));
|
||||
}
|
||||
|
||||
services.rendezvous.create_session(body.data.clone())
|
||||
}
|
||||
|
||||
/// `PUT /_matrix/client/msc4388/io.element.msc4388/rendezvous/{id}/{txn_id}`
|
||||
pub(crate) async fn update_rendezvous_session_route(
|
||||
State(services): State<crate::State>,
|
||||
body: Ruma<update_rendezvous_session::msc4388::Request>,
|
||||
) -> Result<update_rendezvous_session::msc4388::Response> {
|
||||
services.rendezvous.update_session(
|
||||
&body.id,
|
||||
body.txn_id.clone(),
|
||||
body.sequence_token.clone(),
|
||||
body.data.clone(),
|
||||
)
|
||||
}
|
||||
|
||||
/// `GET /_matrix/client/msc4388/io.element.msc4388/rendezvous/{id}`
|
||||
pub(crate) async fn get_rendezvous_session_route(
|
||||
State(services): State<crate::State>,
|
||||
headers: HeaderMap,
|
||||
body: Ruma<get_rendezvous_session::msc4388::Request>,
|
||||
) -> Result<get_rendezvous_session::msc4388::Response> {
|
||||
if let Some(mode) = headers.get("Sec-Fetch-Mode")
|
||||
&& let Ok(mode) = mode.to_str()
|
||||
&& mode == "navigate"
|
||||
{
|
||||
return Err!(Request(Forbidden(
|
||||
"Rendezvous sessions do not accept browser navigation requests."
|
||||
)));
|
||||
}
|
||||
|
||||
services.rendezvous.get_session(&body.id)
|
||||
}
|
||||
|
||||
/// `DELETE /_matrix/client/msc4388/io.element.msc4388/rendezvous/{id}`
|
||||
pub(crate) async fn delete_rendezvous_session_route(
|
||||
State(services): State<crate::State>,
|
||||
body: Ruma<delete_rendezvous_session::msc4388::Request>,
|
||||
) -> Result<delete_rendezvous_session::msc4388::Response> {
|
||||
services.rendezvous.delete_session(&body.id)
|
||||
}
|
||||
|
||||
fn rendezvous_available(services: &Services, identity: Option<&ClientIdentity>) -> bool {
|
||||
!services.config.require_auth_for_rendezvous || identity.is_some()
|
||||
}
|
||||
@@ -77,7 +77,7 @@ struct FullCreationContent {
|
||||
/// - Send events listed in initial state
|
||||
/// - Send events implied by `name` and `topic`
|
||||
/// - Send invite events
|
||||
#[allow(clippy::large_stack_frames)]
|
||||
#[allow(clippy::large_unopt_stack_frames)]
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
pub(crate) async fn create_room_route(
|
||||
State(services): State<crate::State>,
|
||||
|
||||
@@ -94,8 +94,7 @@ pub(crate) async fn room_initial_sync_route(
|
||||
.first()
|
||||
.map(at!(0))
|
||||
.as_ref()
|
||||
.map(ToString::to_string)
|
||||
.unwrap_or_default();
|
||||
.map_or_default(ToString::to_string);
|
||||
let start = events.last().map(at!(0)).as_ref().map(ToString::to_string);
|
||||
|
||||
let chunk = events
|
||||
|
||||
@@ -787,8 +787,7 @@ async fn build_room_summary(
|
||||
|
||||
Ok(Some(assign!(RoomSummary::new(), {
|
||||
heroes: heroes
|
||||
.map(|heroes| heroes.into_iter().collect())
|
||||
.unwrap_or_default(),
|
||||
.map_or_default(|heroes| heroes.into_iter().collect()),
|
||||
joined_member_count: Some(ruma_from_u64(joined_member_count)),
|
||||
invited_member_count: Some(ruma_from_u64(invited_member_count)),
|
||||
})))
|
||||
|
||||
@@ -5,9 +5,7 @@ use conduwuit::{
|
||||
};
|
||||
use futures::{FutureExt, StreamExt, pin_mut};
|
||||
use ruma::{
|
||||
api::client::user_directory::search_users::{self},
|
||||
assign,
|
||||
events::room::join_rules::JoinRule,
|
||||
api::client::user_directory::search_users, assign, events::room::join_rules::JoinRule,
|
||||
};
|
||||
|
||||
use crate::Ruma;
|
||||
|
||||
@@ -189,6 +189,11 @@ pub fn build(router: Router<State>, state: State) -> Router<State> {
|
||||
.ruma_route(&client::well_known_policy_server)
|
||||
.ruma_route(&client::get_rtc_transports)
|
||||
.ruma_route(&client::room_initial_sync_route)
|
||||
.ruma_route(&client::discover_rendezvous_route)
|
||||
.ruma_route(&client::create_rendezvous_session_route)
|
||||
.ruma_route(&client::update_rendezvous_session_route)
|
||||
.ruma_route(&client::get_rendezvous_session_route)
|
||||
.ruma_route(&client::delete_rendezvous_session_route)
|
||||
.ruma_route(&client::get_authorization_server_metadata_route)
|
||||
.merge(client::oauth::router(state))
|
||||
.route("/_continuwuity/server_version", get(client::continuwuity_server_version))
|
||||
|
||||
@@ -69,7 +69,7 @@ pub(crate) async fn create_join_event_template_route(
|
||||
.get_member(&body.room_id, &body.user_id)
|
||||
.await
|
||||
.ok()
|
||||
.map_or_else(|| MembershipState::Leave, |content| content.membership);
|
||||
.map_or(MembershipState::Leave, |content| content.membership);
|
||||
|
||||
let join_authorized_via_users_server: Option<OwnedUserId> = {
|
||||
if matches!(
|
||||
|
||||
+428
-137
@@ -1,9 +1,12 @@
|
||||
//! jemalloc allocator
|
||||
|
||||
use std::{
|
||||
cell::OnceCell,
|
||||
ffi::{CStr, c_char, c_void},
|
||||
any::Any,
|
||||
ffi::{CStr, CString, c_char, c_uint, c_void},
|
||||
fmt::Debug,
|
||||
panic::{self, AssertUnwindSafe},
|
||||
ptr,
|
||||
sync::OnceLock,
|
||||
};
|
||||
|
||||
use arrayvec::ArrayVec;
|
||||
@@ -12,26 +15,61 @@ use tikv_jemalloc_sys as ffi;
|
||||
use tikv_jemallocator as jemalloc;
|
||||
|
||||
use crate::{
|
||||
Result, SyncRwLock, err, is_equal_to, is_nonzero,
|
||||
Result, err, is_equal_to, is_nonzero,
|
||||
utils::{math, math::Tried},
|
||||
};
|
||||
|
||||
#[cfg(feature = "jemalloc_conf")]
|
||||
#[unsafe(no_mangle)]
|
||||
pub static malloc_conf: &[u8] = const_str::concat_bytes!(
|
||||
#[repr(transparent)]
|
||||
struct MallocConf(*const c_char);
|
||||
|
||||
// SAFETY: MallocConf points to static immutable NUL-terminated bytes.
|
||||
#[cfg(feature = "jemalloc_conf")]
|
||||
unsafe impl Sync for MallocConf {}
|
||||
|
||||
#[cfg(feature = "jemalloc_conf")]
|
||||
const MALLOC_CONF_BYTES: &[u8] = const_str::concat_bytes!(
|
||||
"lg_extent_max_active_fit:4",
|
||||
",oversize_threshold:16777216",
|
||||
",tcache_max:2097152",
|
||||
",dirty_decay_ms:16000",
|
||||
",muzzy_decay_ms:144000",
|
||||
",percpu_arena:percpu",
|
||||
",metadata_thp:always",
|
||||
",background_thread:true",
|
||||
",max_background_threads:-1",
|
||||
MALLOC_CONF_PLATFORM,
|
||||
MALLOC_CONF_PROF,
|
||||
0
|
||||
);
|
||||
|
||||
#[cfg(all(feature = "jemalloc_conf", target_os = "linux"))]
|
||||
const MALLOC_CONF_PLATFORM: &str =
|
||||
",percpu_arena:percpu,metadata_thp:always,background_thread:true";
|
||||
#[cfg(all(feature = "jemalloc_conf", not(target_os = "linux")))]
|
||||
const MALLOC_CONF_PLATFORM: &str = "";
|
||||
|
||||
// Targets match `NO_UNPREFIXED_MALLOC_TARGETS` in `tikv-jemalloc-sys` when
|
||||
// `unprefixed_malloc_on_supported_platforms` is enabled.
|
||||
#[cfg(feature = "jemalloc_conf")]
|
||||
#[used]
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[cfg_attr(
|
||||
any(
|
||||
target_vendor = "apple",
|
||||
target_env = "musl",
|
||||
target_os = "android",
|
||||
target_os = "dragonfly",
|
||||
),
|
||||
unsafe(export_name = "_rjem_malloc_conf")
|
||||
)]
|
||||
#[cfg_attr(
|
||||
not(any(
|
||||
target_vendor = "apple",
|
||||
target_env = "musl",
|
||||
target_os = "android",
|
||||
target_os = "dragonfly",
|
||||
)),
|
||||
unsafe(no_mangle)
|
||||
)]
|
||||
static malloc_conf: MallocConf = MallocConf(MALLOC_CONF_BYTES.as_ptr().cast());
|
||||
|
||||
#[cfg(all(feature = "jemalloc_conf", feature = "jemalloc_prof"))]
|
||||
const MALLOC_CONF_PROF: &str = ",prof_active:false";
|
||||
#[cfg(all(feature = "jemalloc_conf", not(feature = "jemalloc_prof")))]
|
||||
@@ -39,28 +77,39 @@ const MALLOC_CONF_PROF: &str = "";
|
||||
|
||||
#[global_allocator]
|
||||
static JEMALLOC: jemalloc::Jemalloc = jemalloc::Jemalloc;
|
||||
static CONTROL: SyncRwLock<()> = SyncRwLock::new(());
|
||||
|
||||
type Name = ArrayVec<u8, NAME_MAX>;
|
||||
type Key = ArrayVec<usize, KEY_SEGS>;
|
||||
|
||||
const NAME_MAX: usize = 128;
|
||||
const KEY_SEGS: usize = 8;
|
||||
const ARENA_LIMIT: usize = 4095;
|
||||
const ARENAS_ALL: usize = 4096;
|
||||
|
||||
#[ctor::ctor(unsafe)]
|
||||
fn _static_initialization() {
|
||||
acq_epoch().expect("pre-initialization of jemalloc failed");
|
||||
acq_epoch().expect("pre-initialization of jemalloc failed");
|
||||
let mut epoch: u64 = 0;
|
||||
let mut len = size_of::<u64>();
|
||||
// SAFETY: Pre-initialize jemalloc before main() without touching Rust TLS
|
||||
// or unwinding across the constructor boundary.
|
||||
unsafe {
|
||||
ffi::mallctl(
|
||||
c"epoch".as_ptr(),
|
||||
ptr::from_mut(&mut epoch).cast::<c_void>(),
|
||||
&raw mut len,
|
||||
ptr::null_mut(),
|
||||
0,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[cfg(feature = "jemalloc_stats")]
|
||||
pub fn memory_usage() -> Option<String> {
|
||||
let mibs = |input: usize| {
|
||||
let kibs = input / 1024;
|
||||
let kibs = u32::try_from(kibs).unwrap_or_default();
|
||||
let kibs = f64::from(kibs);
|
||||
kibs / 1024.0
|
||||
let whole = u32::try_from(input / (1024 * 1024)).unwrap_or(u32::MAX);
|
||||
let rem_kibs = u32::try_from((input / 1024) % 1024).unwrap_or_default();
|
||||
f64::from(whole) + f64::from(rem_kibs) / 1024.0
|
||||
};
|
||||
|
||||
let [allocated, active, mapped, metadata, resident, retained] =
|
||||
@@ -81,8 +130,8 @@ pub fn memory_usage() -> Option<String> { None }
|
||||
pub fn memory_usage_stats() -> Option<[(&'static str, usize); 6]> {
|
||||
use mallctl::stats;
|
||||
|
||||
// Acquire the epoch; ensure latest stats are pulled in
|
||||
acq_epoch().ok()?;
|
||||
// Advance the epoch; ensure latest stats are pulled in
|
||||
inc_epoch().ok()?;
|
||||
|
||||
Some([
|
||||
("allocated", stats::allocated::read().unwrap_or_default()),
|
||||
@@ -98,164 +147,239 @@ pub fn memory_usage_stats() -> Option<[(&'static str, usize); 6]> {
|
||||
#[cfg(not(feature = "jemalloc_stats"))]
|
||||
pub fn memory_usage_stats() -> Option<[(&'static str, usize); 6]> { None }
|
||||
|
||||
struct StatsPrintState {
|
||||
buf: String,
|
||||
max_len: usize,
|
||||
panic: Option<Box<dyn Any + Send>>,
|
||||
}
|
||||
|
||||
pub fn memory_stats(opts: &str) -> Option<String> {
|
||||
const MAX_LENGTH: usize = 1_048_576;
|
||||
|
||||
let mut str = String::new();
|
||||
let opaque = std::ptr::from_mut(&mut str).cast::<c_void>();
|
||||
let opts_p: *const c_char = std::ffi::CString::new(opts)
|
||||
.expect("cstring")
|
||||
.into_raw()
|
||||
.cast_const();
|
||||
let opts = CString::new(opts).ok()?;
|
||||
|
||||
// Acquire the epoch; ensure latest stats are pulled in
|
||||
acq_epoch().ok()?;
|
||||
let mut state = StatsPrintState {
|
||||
buf: String::new(),
|
||||
max_len: MAX_LENGTH,
|
||||
panic: None,
|
||||
};
|
||||
let opaque = ptr::from_mut(&mut state).cast::<c_void>();
|
||||
|
||||
// SAFETY: calls malloc_stats_print() with our string instance which must
|
||||
// remain in this frame. https://docs.rs/tikv-jemalloc-sys/latest/tikv_jemalloc_sys/fn.malloc_stats_print.html
|
||||
unsafe { ffi::malloc_stats_print(Some(malloc_stats_cb), opaque, opts_p) };
|
||||
// SAFETY: `state` and `opts` remain live in this frame for the duration of
|
||||
// `malloc_stats_print()`, which invokes `malloc_stats_cb` synchronously.
|
||||
unsafe { ffi::malloc_stats_print(Some(malloc_stats_cb), opaque, opts.as_ptr()) };
|
||||
|
||||
str.truncate(MAX_LENGTH);
|
||||
if let Some(payload) = state.panic {
|
||||
panic::resume_unwind(payload);
|
||||
}
|
||||
|
||||
Some(str)
|
||||
Some(state.buf)
|
||||
}
|
||||
|
||||
unsafe extern "C" fn malloc_stats_cb(opaque: *mut c_void, msg: *const c_char) {
|
||||
// SAFETY: we have to trust the opaque points to our String
|
||||
let res: &mut String = unsafe {
|
||||
opaque
|
||||
.cast::<String>()
|
||||
.as_mut()
|
||||
.expect("failed to cast void* to &mut String")
|
||||
// SAFETY: `opaque` points to `StatsPrintState` on the caller's stack.
|
||||
let Some(state) = (unsafe { opaque.cast::<StatsPrintState>().as_mut() }) else {
|
||||
return;
|
||||
};
|
||||
|
||||
// SAFETY: we have to trust the string is null terminated.
|
||||
if state.panic.is_some() || msg.is_null() || state.buf.len() >= state.max_len {
|
||||
return;
|
||||
}
|
||||
|
||||
// SAFETY: jemalloc guarantees `msg` is a valid NUL-terminated C string.
|
||||
let msg = unsafe { CStr::from_ptr(msg) };
|
||||
|
||||
let msg = String::from_utf8_lossy(msg.to_bytes());
|
||||
res.push_str(msg.as_ref());
|
||||
if let Err(err) = panic::catch_unwind(AssertUnwindSafe(|| {
|
||||
let msg = String::from_utf8_lossy(msg.to_bytes());
|
||||
let remaining = state.max_len.saturating_sub(state.buf.len());
|
||||
if msg.len() <= remaining {
|
||||
state.buf.push_str(msg.as_ref());
|
||||
} else {
|
||||
if let Some(prefix) = msg.get(..msg.floor_char_boundary(remaining)) {
|
||||
state.buf.push_str(prefix);
|
||||
}
|
||||
state.max_len = state.buf.len();
|
||||
}
|
||||
})) {
|
||||
state.panic = Some(err);
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! mallctl {
|
||||
($name:expr_2021) => {{
|
||||
thread_local! {
|
||||
static KEY: OnceCell<Key> = OnceCell::default();
|
||||
};
|
||||
($name:literal) => {{
|
||||
static KEY: OnceLock<Key> = OnceLock::new();
|
||||
|
||||
KEY.with(|once| {
|
||||
once.get_or_init(move || key($name).expect("failed to translate name into mib key"))
|
||||
.clone()
|
||||
})
|
||||
KEY.get_or_init(|| key($name).expect("failed to translate name into mib key"))
|
||||
}};
|
||||
}
|
||||
|
||||
pub mod this_thread {
|
||||
use super::{Debug, Key, OnceCell, Result, is_nonzero, key, math};
|
||||
|
||||
thread_local! {
|
||||
static ALLOCATED_BYTES: OnceCell<&'static u64> = const { OnceCell::new() };
|
||||
static DEALLOCATED_BYTES: OnceCell<&'static u64> = const { OnceCell::new() };
|
||||
}
|
||||
use super::{Debug, Key, OnceLock, Result, c_uint, is_nonzero, key, math};
|
||||
|
||||
pub fn trim() -> Result { decay().and_then(|()| purge()) }
|
||||
|
||||
pub fn purge() -> Result { notify(mallctl!("arena.0.purge")) }
|
||||
pub fn purge() -> Result {
|
||||
// SAFETY: `arena.<i>.purge` is an `arena.<i>.*` notification ctl.
|
||||
unsafe { notify(mallctl!("arena.0.purge")) }
|
||||
}
|
||||
|
||||
pub fn decay() -> Result { notify(mallctl!("arena.0.decay")) }
|
||||
pub fn decay() -> Result {
|
||||
// SAFETY: `arena.<i>.decay` is an `arena.<i>.*` notification ctl.
|
||||
unsafe { notify(mallctl!("arena.0.decay")) }
|
||||
}
|
||||
|
||||
pub fn idle() -> Result { super::notify(&mallctl!("thread.idle")) }
|
||||
pub fn idle() -> Result {
|
||||
// SAFETY: `thread.idle` is a non-indexed notification ctl.
|
||||
unsafe { super::notify(mallctl!("thread.idle")) }
|
||||
}
|
||||
|
||||
pub fn flush() -> Result { super::notify(&mallctl!("thread.tcache.flush")) }
|
||||
pub fn flush() -> Result {
|
||||
// SAFETY: `thread.tcache.flush` is a non-indexed notification ctl.
|
||||
unsafe { super::notify(mallctl!("thread.tcache.flush")) }
|
||||
}
|
||||
|
||||
pub fn set_muzzy_decay(decay_ms: isize) -> Result<isize> {
|
||||
set(mallctl!("arena.0.muzzy_decay_ms"), decay_ms)
|
||||
// SAFETY: `arena.<i>.muzzy_decay_ms` has C type `ssize_t`.
|
||||
unsafe { set(mallctl!("arena.0.muzzy_decay_ms"), decay_ms) }
|
||||
}
|
||||
|
||||
pub fn get_muzzy_decay() -> Result<isize> { get(mallctl!("arena.0.muzzy_decay_ms")) }
|
||||
pub fn get_muzzy_decay() -> Result<isize> {
|
||||
// SAFETY: `arena.<i>.muzzy_decay_ms` has C type `ssize_t`.
|
||||
unsafe { get(mallctl!("arena.0.muzzy_decay_ms")) }
|
||||
}
|
||||
|
||||
pub fn set_dirty_decay(decay_ms: isize) -> Result<isize> {
|
||||
set(mallctl!("arena.0.dirty_decay_ms"), decay_ms)
|
||||
// SAFETY: `arena.<i>.dirty_decay_ms` has C type `ssize_t`.
|
||||
unsafe { set(mallctl!("arena.0.dirty_decay_ms"), decay_ms) }
|
||||
}
|
||||
|
||||
pub fn get_dirty_decay() -> Result<isize> { get(mallctl!("arena.0.dirty_decay_ms")) }
|
||||
pub fn get_dirty_decay() -> Result<isize> {
|
||||
// SAFETY: `arena.<i>.dirty_decay_ms` has C type `ssize_t`.
|
||||
unsafe { get(mallctl!("arena.0.dirty_decay_ms")) }
|
||||
}
|
||||
|
||||
pub fn cache_enable(enable: bool) -> Result<bool> {
|
||||
super::set::<u8>(&mallctl!("thread.tcache.enabled"), enable.into()).map(is_nonzero!())
|
||||
// SAFETY: `thread.tcache.enabled` has C type `bool` (1 byte on
|
||||
// non-MSVC).
|
||||
unsafe { super::set::<u8>(mallctl!("thread.tcache.enabled"), enable.into()) }
|
||||
.map(is_nonzero!())
|
||||
}
|
||||
|
||||
pub fn is_cache_enabled() -> Result<bool> {
|
||||
super::get::<u8>(&mallctl!("thread.tcache.enabled")).map(is_nonzero!())
|
||||
// SAFETY: `thread.tcache.enabled` has C type `bool` (1 byte on
|
||||
// non-MSVC).
|
||||
unsafe { super::get::<u8>(mallctl!("thread.tcache.enabled")) }.map(is_nonzero!())
|
||||
}
|
||||
|
||||
pub fn set_arena(id: usize) -> Result<usize> {
|
||||
super::set::<u32>(&mallctl!("thread.arena"), id.try_into()?).and_then(math::try_into)
|
||||
// SAFETY: `thread.arena` has C type `unsigned`.
|
||||
unsafe { super::set::<c_uint>(mallctl!("thread.arena"), id.try_into()?) }
|
||||
.and_then(math::try_into)
|
||||
}
|
||||
|
||||
pub fn arena_id() -> Result<usize> {
|
||||
super::get::<u32>(&mallctl!("thread.arena")).and_then(math::try_into)
|
||||
// SAFETY: `thread.arena` has C type `unsigned`.
|
||||
unsafe { super::get::<c_uint>(mallctl!("thread.arena")) }.and_then(math::try_into)
|
||||
}
|
||||
|
||||
pub fn prof_enable(enable: bool) -> Result<bool> {
|
||||
super::set::<u8>(&mallctl!("thread.prof.active"), enable.into()).map(is_nonzero!())
|
||||
// SAFETY: `thread.prof.active` has C type `bool` (1 byte on non-MSVC).
|
||||
unsafe { super::set::<u8>(mallctl!("thread.prof.active"), enable.into()) }
|
||||
.map(is_nonzero!())
|
||||
}
|
||||
|
||||
pub fn is_prof_enabled() -> Result<bool> {
|
||||
super::get::<u8>(&mallctl!("thread.prof.active")).map(is_nonzero!())
|
||||
// SAFETY: `thread.prof.active` has C type `bool` (1 byte on non-MSVC).
|
||||
unsafe { super::get::<u8>(mallctl!("thread.prof.active")) }.map(is_nonzero!())
|
||||
}
|
||||
|
||||
pub fn reset_peak() -> Result { super::notify(&mallctl!("thread.peak.reset")) }
|
||||
pub fn reset_peak() -> Result {
|
||||
// SAFETY: `thread.peak.reset` is a non-indexed notification ctl.
|
||||
unsafe { super::notify(mallctl!("thread.peak.reset")) }
|
||||
}
|
||||
|
||||
pub fn peak() -> Result<u64> { super::get(&mallctl!("thread.peak.read")) }
|
||||
pub fn peak() -> Result<u64> {
|
||||
// SAFETY: `thread.peak.read` has C type `uint64_t`.
|
||||
unsafe { super::get(mallctl!("thread.peak.read")) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn allocated() -> u64 {
|
||||
*ALLOCATED_BYTES.with(|once| init_tls_cell(once, "thread.allocatedp"))
|
||||
// SAFETY: `thread.allocated` has C type `uint64_t`.
|
||||
unsafe { super::get(mallctl!("thread.allocated")) }.unwrap_or_default()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn deallocated() -> u64 {
|
||||
*DEALLOCATED_BYTES.with(|once| init_tls_cell(once, "thread.deallocatedp"))
|
||||
// SAFETY: `thread.deallocated` has C type `uint64_t`.
|
||||
unsafe { super::get(mallctl!("thread.deallocated")) }.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn notify(key: Key) -> Result { super::notify_by_arena(Some(arena_id()?), key) }
|
||||
/// # Safety
|
||||
/// Caller must ensure `key` is an `arena.<i>.*` notification MIB
|
||||
/// (`key.len() >= 2`).
|
||||
unsafe fn notify(key: &Key) -> Result {
|
||||
let mut key = key.clone();
|
||||
// `arena_id()` returns this thread's own valid arena (< narenas <
|
||||
// ARENA_LIMIT), so we skip `validate_arena_id()` to avoid locking
|
||||
// `ctl_mtx` on hot paths like `decay()`.
|
||||
key[1] = arena_id()?;
|
||||
// SAFETY: Caller guarantees `key` is an `arena.<i>.*` notification MIB
|
||||
// and `arena_id()` returns a valid arena index.
|
||||
unsafe { super::notify(&key) }
|
||||
}
|
||||
|
||||
fn set<T>(key: Key, val: T) -> Result<T>
|
||||
/// # Safety
|
||||
/// Caller must ensure `key` is an `arena.<i>.*` MIB and `T` matches its
|
||||
/// exact C type.
|
||||
unsafe fn set<T>(key: &Key, val: T) -> Result<T>
|
||||
where
|
||||
T: Copy + Debug,
|
||||
{
|
||||
super::set_by_arena(Some(arena_id()?), key, val)
|
||||
let mut key = key.clone();
|
||||
// `arena_id()` is already a valid arena index; skip
|
||||
// `validate_arena_id()`.
|
||||
key[1] = arena_id()?;
|
||||
// SAFETY: Caller guarantees `T` matches `key`.
|
||||
unsafe { super::set(&key, val) }
|
||||
}
|
||||
|
||||
fn get<T>(key: Key) -> Result<T>
|
||||
/// # Safety
|
||||
/// Caller must ensure `key` is an `arena.<i>.*` MIB and `T` matches its
|
||||
/// exact C type.
|
||||
unsafe fn get<T>(key: &Key) -> Result<T>
|
||||
where
|
||||
T: Copy + Debug,
|
||||
{
|
||||
super::get_by_arena(Some(arena_id()?), key)
|
||||
}
|
||||
|
||||
fn init_tls_cell(cell: &OnceCell<&'static u64>, name: &str) -> &'static u64 {
|
||||
cell.get_or_init(|| {
|
||||
let ptr: *const u64 = super::get(&mallctl!(name)).expect("failed to obtain pointer");
|
||||
|
||||
// SAFETY: ptr points directly to the internal state of jemalloc for
|
||||
// this thread
|
||||
unsafe { ptr.as_ref() }.expect("pointer must not be null")
|
||||
})
|
||||
let mut key = key.clone();
|
||||
// `arena_id()` is already a valid arena index; skip
|
||||
// `validate_arena_id()`.
|
||||
key[1] = arena_id()?;
|
||||
// SAFETY: Caller guarantees `T` matches `key`.
|
||||
unsafe { super::get(&key) }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn stats_reset() -> Result { notify(&mallctl!("stats.mutexes.reset")) }
|
||||
pub fn stats_reset() -> Result {
|
||||
// SAFETY: `stats.mutexes.reset` is a non-indexed notification ctl.
|
||||
unsafe { notify(mallctl!("stats.mutexes.reset")) }
|
||||
}
|
||||
|
||||
pub fn prof_reset() -> Result { notify(&mallctl!("prof.reset")) }
|
||||
pub fn prof_reset() -> Result {
|
||||
// SAFETY: `prof.reset` is a non-indexed notification ctl.
|
||||
unsafe { notify(mallctl!("prof.reset")) }
|
||||
}
|
||||
|
||||
pub fn prof_enable(enable: bool) -> Result<bool> {
|
||||
set::<u8>(&mallctl!("prof.active"), enable.into()).map(is_nonzero!())
|
||||
// SAFETY: `prof.active` has C type `bool` (1 byte on non-MSVC).
|
||||
unsafe { set::<u8>(mallctl!("prof.active"), enable.into()) }.map(is_nonzero!())
|
||||
}
|
||||
|
||||
pub fn is_prof_enabled() -> Result<bool> {
|
||||
get::<u8>(&mallctl!("prof.active")).map(is_nonzero!())
|
||||
// SAFETY: `prof.active` has C type `bool` (1 byte on non-MSVC).
|
||||
unsafe { get::<u8>(mallctl!("prof.active")) }.map(is_nonzero!())
|
||||
}
|
||||
|
||||
pub fn trim<I: Into<Option<usize>> + Copy>(arena: I) -> Result {
|
||||
@@ -263,31 +387,40 @@ pub fn trim<I: Into<Option<usize>> + Copy>(arena: I) -> Result {
|
||||
}
|
||||
|
||||
pub fn purge<I: Into<Option<usize>>>(arena: I) -> Result {
|
||||
notify_by_arena(arena.into(), mallctl!("arena.4096.purge"))
|
||||
// SAFETY: `arena.<i>.purge` is an `arena.<i>.*` notification ctl.
|
||||
unsafe { notify_by_arena(arena.into(), mallctl!("arena.4096.purge")) }
|
||||
}
|
||||
|
||||
pub fn decay<I: Into<Option<usize>>>(arena: I) -> Result {
|
||||
notify_by_arena(arena.into(), mallctl!("arena.4096.decay"))
|
||||
// SAFETY: `arena.<i>.decay` is an `arena.<i>.*` notification ctl.
|
||||
unsafe { notify_by_arena(arena.into(), mallctl!("arena.4096.decay")) }
|
||||
}
|
||||
|
||||
pub fn set_muzzy_decay<I: Into<Option<usize>>>(arena: I, decay_ms: isize) -> Result<isize> {
|
||||
match arena.into() {
|
||||
| Some(arena) =>
|
||||
set_by_arena(Some(arena), mallctl!("arena.4096.muzzy_decay_ms"), decay_ms),
|
||||
| _ => set(&mallctl!("arenas.muzzy_decay_ms"), decay_ms),
|
||||
// SAFETY: `arena.<i>.muzzy_decay_ms` has C type `ssize_t`.
|
||||
| Some(arena) => unsafe {
|
||||
set_by_arena(arena, mallctl!("arena.0.muzzy_decay_ms"), decay_ms)
|
||||
},
|
||||
// SAFETY: `arenas.muzzy_decay_ms` has C type `ssize_t`.
|
||||
| _ => unsafe { set(mallctl!("arenas.muzzy_decay_ms"), decay_ms) },
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_dirty_decay<I: Into<Option<usize>>>(arena: I, decay_ms: isize) -> Result<isize> {
|
||||
match arena.into() {
|
||||
| Some(arena) =>
|
||||
set_by_arena(Some(arena), mallctl!("arena.4096.dirty_decay_ms"), decay_ms),
|
||||
| _ => set(&mallctl!("arenas.dirty_decay_ms"), decay_ms),
|
||||
// SAFETY: `arena.<i>.dirty_decay_ms` has C type `ssize_t`.
|
||||
| Some(arena) => unsafe {
|
||||
set_by_arena(arena, mallctl!("arena.0.dirty_decay_ms"), decay_ms)
|
||||
},
|
||||
// SAFETY: `arenas.dirty_decay_ms` has C type `ssize_t`.
|
||||
| _ => unsafe { set(mallctl!("arenas.dirty_decay_ms"), decay_ms) },
|
||||
}
|
||||
}
|
||||
|
||||
pub fn background_thread_enable(enable: bool) -> Result<bool> {
|
||||
set::<u8>(&mallctl!("background_thread"), enable.into()).map(is_nonzero!())
|
||||
// SAFETY: `background_thread` has C type `bool` (1 byte on non-MSVC).
|
||||
unsafe { set::<u8>(mallctl!("background_thread"), enable.into()) }.map(is_nonzero!())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -303,83 +436,138 @@ pub fn is_percpu_arena() -> bool { percpu_arenas().is_ok_and(is_equal_to!("percp
|
||||
pub fn is_phycpu_arena() -> bool { percpu_arenas().is_ok_and(is_equal_to!("phycpu")) }
|
||||
|
||||
pub fn percpu_arenas() -> Result<&'static str> {
|
||||
let ptr = get::<*const c_char>(&mallctl!("opt.percpu_arena"))?;
|
||||
//SAFETY: ptr points to a null-terminated string returned for
|
||||
// opt.percpu_arena.
|
||||
// SAFETY: `opt.percpu_arena` has C type `const char *`.
|
||||
let ptr = unsafe { get::<*const c_char>(mallctl!("opt.percpu_arena")) }?;
|
||||
if ptr.is_null() {
|
||||
return Err(err!("mallctl: opt.percpu_arena returned NULL"));
|
||||
}
|
||||
|
||||
// SAFETY: `ptr` is non-null and points to a static NUL-terminated string
|
||||
// returned by jemalloc for `opt.percpu_arena`.
|
||||
let cstr = unsafe { CStr::from_ptr(ptr) };
|
||||
cstr.to_str().map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn arenas() -> Result<usize> {
|
||||
get::<u32>(&mallctl!("arenas.narenas")).and_then(math::try_into)
|
||||
// SAFETY: `arenas.narenas` has C type `unsigned`.
|
||||
unsafe { get::<c_uint>(mallctl!("arenas.narenas")) }.and_then(math::try_into)
|
||||
}
|
||||
|
||||
pub fn inc_epoch() -> Result<u64> { xchg(&mallctl!("epoch"), 1_u64) }
|
||||
|
||||
pub fn acq_epoch() -> Result<u64> { xchg(&mallctl!("epoch"), 0_u64) }
|
||||
|
||||
fn notify_by_arena(id: Option<usize>, mut key: Key) -> Result {
|
||||
key[1] = id.unwrap_or(4096);
|
||||
notify(&key)
|
||||
pub fn inc_epoch() -> Result<u64> {
|
||||
// SAFETY: `epoch` has C type `uint64_t`.
|
||||
unsafe { xchg(mallctl!("epoch"), 1_u64) }
|
||||
}
|
||||
|
||||
fn set_by_arena<T>(id: Option<usize>, mut key: Key, val: T) -> Result<T>
|
||||
pub fn acq_epoch() -> Result<u64> {
|
||||
// SAFETY: `epoch` has C type `uint64_t`.
|
||||
unsafe { get(mallctl!("epoch")) }
|
||||
}
|
||||
|
||||
fn validate_arena_id(id: usize, allow_all: bool) -> Result<usize> {
|
||||
if allow_all && id == ARENAS_ALL {
|
||||
return Ok(id);
|
||||
}
|
||||
|
||||
let narenas = arenas()?.min(ARENA_LIMIT);
|
||||
if id < narenas {
|
||||
Ok(id)
|
||||
} else {
|
||||
Err(err!("mallctl: invalid arena index {id} (narenas: {narenas})"))
|
||||
}
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
/// Caller must ensure `key` is an `arena.<i>.*` notification MIB
|
||||
/// (`key.len() >= 2`).
|
||||
unsafe fn notify_by_arena(id: Option<usize>, key: &Key) -> Result {
|
||||
let mut key = key.clone();
|
||||
key[1] = match id {
|
||||
| Some(id) => validate_arena_id(id, true)?,
|
||||
| None => ARENAS_ALL,
|
||||
};
|
||||
// SAFETY: Caller guarantees `key` is an `arena.<i>.*` notification MIB and
|
||||
// `key[1]` has been validated above.
|
||||
unsafe { notify(&key) }
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
/// Caller must ensure `key` is an `arena.<i>.*` MIB (`key.len() >= 2`) and `T`
|
||||
/// matches its exact C type.
|
||||
unsafe fn set_by_arena<T>(id: usize, key: &Key, val: T) -> Result<T>
|
||||
where
|
||||
T: Copy + Debug,
|
||||
{
|
||||
key[1] = id.unwrap_or(4096);
|
||||
set(&key, val)
|
||||
let mut key = key.clone();
|
||||
key[1] = validate_arena_id(id, false)?;
|
||||
// SAFETY: Caller guarantees `T` matches `key`.
|
||||
unsafe { set(&key, val) }
|
||||
}
|
||||
|
||||
fn get_by_arena<T>(id: Option<usize>, mut key: Key) -> Result<T>
|
||||
/// # Safety
|
||||
/// Caller must ensure `key` is a valid notification MIB and any indexed arena
|
||||
/// component is within bounds.
|
||||
unsafe fn notify(key: &Key) -> Result {
|
||||
// SAFETY: jemalloc notification ctls require `oldp`, `oldlenp`, and `newp`
|
||||
// to be NULL and `newlen` to be 0 (otherwise `EPERM` is returned).
|
||||
let ret = unsafe {
|
||||
ffi::mallctlbymib(
|
||||
key.as_ptr(),
|
||||
key.len(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
0,
|
||||
)
|
||||
};
|
||||
if ret == 0 {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(err!("mallctl: {}", std::io::Error::from_raw_os_error(ret)))
|
||||
}
|
||||
}
|
||||
|
||||
/// Does not advance `epoch`; callers reading cached `stats.*` must call
|
||||
/// `inc_epoch()` explicitly.
|
||||
///
|
||||
/// # Safety
|
||||
/// Caller must ensure `T` matches the exact C type expected by `key`.
|
||||
unsafe fn set<T>(key: &Key, val: T) -> Result<T>
|
||||
where
|
||||
T: Copy + Debug,
|
||||
{
|
||||
key[1] = id.unwrap_or(4096);
|
||||
get(&key)
|
||||
}
|
||||
|
||||
fn notify(key: &Key) -> Result { xchg(key, ()) }
|
||||
|
||||
fn set<T>(key: &Key, val: T) -> Result<T>
|
||||
where
|
||||
T: Copy + Debug,
|
||||
{
|
||||
let _lock = CONTROL.write();
|
||||
let res = xchg(key, val)?;
|
||||
inc_epoch()?;
|
||||
|
||||
Ok(res)
|
||||
// SAFETY: Caller guarantees `T` matches `key`.
|
||||
unsafe { xchg(key, val) }
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
/// Caller must ensure `T` matches the exact C type expected by `key`.
|
||||
#[tracing::instrument(
|
||||
name = "get",
|
||||
level = "trace",
|
||||
skip_all,
|
||||
fields(?key)
|
||||
)]
|
||||
fn get<T>(key: &Key) -> Result<T>
|
||||
unsafe fn get<T>(key: &Key) -> Result<T>
|
||||
where
|
||||
T: Copy + Debug,
|
||||
{
|
||||
acq_epoch()?;
|
||||
acq_epoch()?;
|
||||
|
||||
// SAFETY: T must be perfectly valid to receive value.
|
||||
// SAFETY: Caller guarantees `T` matches the C type returned for `key`.
|
||||
unsafe { mallctl::raw::read_mib(key.as_slice()) }.map_err(map_err)
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
/// Caller must ensure `T` matches the exact C type expected by `key`.
|
||||
#[tracing::instrument(
|
||||
name = "xchg",
|
||||
level = "trace",
|
||||
skip_all,
|
||||
fields(?key, ?val)
|
||||
)]
|
||||
fn xchg<T>(key: &Key, val: T) -> Result<T>
|
||||
unsafe fn xchg<T>(key: &Key, val: T) -> Result<T>
|
||||
where
|
||||
T: Copy + Debug,
|
||||
{
|
||||
// SAFETY: T must be the exact expected type.
|
||||
// SAFETY: Caller guarantees `T` matches the C type expected by `key`.
|
||||
unsafe { mallctl::raw::update_mib(key.as_slice(), val) }.map_err(map_err)
|
||||
}
|
||||
|
||||
@@ -387,6 +575,9 @@ fn key(name: &str) -> Result<Key> {
|
||||
// tikv asserts the output buffer length is tight to the number of required
|
||||
// mibs so we slice that down here.
|
||||
let segs = name.chars().filter(is_equal_to!(&'.')).count().try_add(1)?;
|
||||
if segs > KEY_SEGS {
|
||||
return Err(err!("mallctl: key has too many segments ({segs} > {KEY_SEGS})"));
|
||||
}
|
||||
|
||||
let name = self::name(name)?;
|
||||
let mut buf = [0_usize; KEY_SEGS];
|
||||
@@ -396,6 +587,10 @@ fn key(name: &str) -> Result<Key> {
|
||||
}
|
||||
|
||||
fn name(name: &str) -> Result<Name> {
|
||||
if name.as_bytes().contains(&0) {
|
||||
return Err(err!("mallctl: key contains interior NUL byte"));
|
||||
}
|
||||
|
||||
let mut buf = Name::new();
|
||||
buf.try_extend_from_slice(name.as_bytes())?;
|
||||
buf.try_extend_from_slice(b"\0")?;
|
||||
@@ -406,3 +601,99 @@ fn name(name: &str) -> Result<Name> {
|
||||
fn map_err(error: tikv_jemalloc_ctl::Error) -> crate::Error {
|
||||
err!("mallctl: {}", error.to_string())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn notify_ctls_succeed() {
|
||||
this_thread::flush().expect("thread.tcache.flush");
|
||||
this_thread::decay().expect("arena.<i>.decay");
|
||||
this_thread::purge().expect("arena.<i>.purge");
|
||||
this_thread::trim().expect("this_thread::trim");
|
||||
trim(None).expect("trim(None)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "jemalloc_stats")]
|
||||
fn allocated_and_deallocated_do_not_alias() {
|
||||
let a0 = this_thread::allocated();
|
||||
let d0 = this_thread::deallocated();
|
||||
|
||||
let buf = std::hint::black_box(vec![0_u8; 64 * 1024]);
|
||||
let a1 = this_thread::allocated();
|
||||
assert!(a1 > a0, "expected allocated to increase: {a0} -> {a1}");
|
||||
|
||||
drop(buf);
|
||||
let d1 = this_thread::deallocated();
|
||||
assert!(d1 > d0, "expected deallocated to increase: {d0} -> {d1}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn memory_stats_handles_valid_and_nul_opts() {
|
||||
assert!(memory_stats("invalid\0opts").is_none());
|
||||
let stats = memory_stats("gmal").expect("memory_stats");
|
||||
assert!(!stats.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn key_too_many_segments_returns_err() { key("a.b.c.d.e.f.g.h.i").unwrap_err(); }
|
||||
|
||||
#[test]
|
||||
fn key_interior_nul_returns_err() { key("a.b\0.c").unwrap_err(); }
|
||||
|
||||
#[test]
|
||||
fn arena_index_bounds_rejected() {
|
||||
purge(Some(ARENAS_ALL)).expect("purge(MALLCTL_ARENAS_ALL)");
|
||||
decay(Some(ARENAS_ALL)).expect("decay(MALLCTL_ARENAS_ALL)");
|
||||
|
||||
let narenas = arenas().expect("arenas.narenas");
|
||||
purge(Some(narenas)).unwrap_err();
|
||||
decay(Some(narenas)).unwrap_err();
|
||||
set_dirty_decay(Some(narenas), -1).unwrap_err();
|
||||
set_muzzy_decay(Some(narenas), -1).unwrap_err();
|
||||
|
||||
purge(Some(4097)).unwrap_err();
|
||||
decay(Some(4097)).unwrap_err();
|
||||
trim(Some(4097)).unwrap_err();
|
||||
purge(Some(usize::MAX)).unwrap_err();
|
||||
|
||||
set_dirty_decay(Some(ARENAS_ALL), -1).unwrap_err();
|
||||
set_muzzy_decay(Some(ARENAS_ALL), -1).unwrap_err();
|
||||
set_dirty_decay(Some(4097), -1).unwrap_err();
|
||||
set_muzzy_decay(Some(4097), -1).unwrap_err();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "jemalloc_conf")]
|
||||
fn malloc_conf_is_applied() {
|
||||
if std::env::var_os("MALLOC_CONF").is_some()
|
||||
|| std::env::var_os("_RJEM_MALLOC_CONF").is_some()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// SAFETY: `opt.dirty_decay_ms` and `opt.muzzy_decay_ms` have C type
|
||||
// `ssize_t`.
|
||||
let dirty =
|
||||
unsafe { get::<isize>(mallctl!("opt.dirty_decay_ms")) }.expect("opt.dirty_decay_ms");
|
||||
let muzzy =
|
||||
unsafe { get::<isize>(mallctl!("opt.muzzy_decay_ms")) }.expect("opt.muzzy_decay_ms");
|
||||
assert_eq!(dirty, 16_000, "expected malloc_conf dirty_decay_ms:16000");
|
||||
assert_eq!(muzzy, 144_000, "expected malloc_conf muzzy_decay_ms:144000");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn percpu_arenas_returns_valid_mode() {
|
||||
let mode = percpu_arenas().expect("opt.percpu_arena");
|
||||
assert!(matches!(mode, "disabled" | "percpu" | "phycpu"), "unexpected mode: {mode}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn epoch_read_and_advance() {
|
||||
let e0 = acq_epoch().expect("acq_epoch");
|
||||
let e1 = inc_epoch().expect("inc_epoch");
|
||||
assert!(e1 > e0, "expected inc_epoch to advance epoch: {e0} -> {e1}");
|
||||
}
|
||||
}
|
||||
+24
-4
@@ -919,14 +919,34 @@ pub struct Config {
|
||||
#[serde(default)]
|
||||
pub forget_forced_upon_leave: bool,
|
||||
|
||||
/// Set this to true to require authentication on the normally
|
||||
/// unauthenticated profile retrieval endpoints (GET)
|
||||
/// "/_matrix/client/v3/profile/{userId}".
|
||||
/// Set this to true to require authentication when looking up user profiles
|
||||
/// through this server.
|
||||
///
|
||||
/// This can prevent profile scraping.
|
||||
/// By default this is false, allowing tools such as matrix.to to access
|
||||
/// profiles of users on this server and on other servers.
|
||||
/// Setting this to true will block those tools, and may block automated
|
||||
/// crawlers from scraping users' profiles, although it will not block
|
||||
/// other homeservers from accessing users' profiles.
|
||||
///
|
||||
/// default: false
|
||||
#[serde(default)]
|
||||
pub require_auth_for_profile_requests: bool,
|
||||
|
||||
/// Set this to true to require authentication to create a rendezvous
|
||||
/// session. Rendezvous sessions are used for QR code login.
|
||||
///
|
||||
/// For QR code login, the device that shows the QR code is the one that
|
||||
/// creates the rendezvous session. Therefore, this must be false to let
|
||||
/// a logged-out device show a QR code.
|
||||
///
|
||||
/// By default this is false to allow logged-out desktop devices (which may
|
||||
/// not have a camera) to show a QR code. Setting this to true will
|
||||
/// require logged-out devices to scan the QR code instead.
|
||||
///
|
||||
/// default: false
|
||||
#[serde(default)]
|
||||
pub require_auth_for_rendezvous: bool,
|
||||
|
||||
/// Set this to true to allow your server's public room directory to be
|
||||
/// federated. Set this to false to protect against /publicRooms spiders,
|
||||
/// but will forbid external users from viewing your server's public room
|
||||
|
||||
+2
-1
@@ -37,7 +37,8 @@ pub use error::Error;
|
||||
pub use info::version::*;
|
||||
pub use matrix::{Event, EventTypeExt, Pdu, PduCount, PduEvent, PduId, pdu, state_res};
|
||||
pub use parking_lot::{
|
||||
Mutex as SyncMutex, RwLock as SyncRwLock, RwLockReadGuard as SyncRwLockReadGuard,
|
||||
MappedMutexGuard as SyncMappedMutexGuard, Mutex as SyncMutex, MutexGuard as SyncMutexGuard,
|
||||
RwLock as SyncRwLock, RwLockReadGuard as SyncRwLockReadGuard,
|
||||
RwLockWriteGuard as SyncRwLockWriteGuard,
|
||||
};
|
||||
pub use server::Server;
|
||||
|
||||
@@ -76,8 +76,7 @@ impl super::Engine {
|
||||
.config
|
||||
.database_backup_path
|
||||
.clone()
|
||||
.map(PathBuf::into_os_string)
|
||||
.unwrap_or_default();
|
||||
.map_or_default(PathBuf::into_os_string);
|
||||
|
||||
if path.is_empty() {
|
||||
return Err!(Config("database_backup_path", "Configure path to enable backups"));
|
||||
|
||||
@@ -22,7 +22,7 @@ use hyper_util::{
|
||||
use tokio::{
|
||||
fs,
|
||||
net::{UnixListener, UnixStream, unix::SocketAddr},
|
||||
sync::broadcast::{self},
|
||||
sync::broadcast,
|
||||
task::JoinSet,
|
||||
time::{Duration, sleep},
|
||||
};
|
||||
|
||||
@@ -379,7 +379,7 @@ fn get_dns_resolver(server: &Arc<Server>) -> Result<Arc<TokioResolver>> {
|
||||
info!(?nameservers, "Resolved nameservers for DNS client");
|
||||
|
||||
for sys_conf in nameservers {
|
||||
let mut ns = sys_conf.clone();
|
||||
let mut ns = sys_conf;
|
||||
|
||||
if config.query_over_tcp_only {
|
||||
ns.connections = vec![ConnectionConfig::tcp()];
|
||||
|
||||
@@ -182,26 +182,11 @@ impl Data {
|
||||
let mut value = Vec::<u8>::new();
|
||||
value.extend_from_slice(×tamp.as_secs().to_be_bytes());
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(
|
||||
data.title
|
||||
.as_ref()
|
||||
.map(String::as_bytes)
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
value.extend_from_slice(data.title.as_ref().map_or_default(String::as_bytes));
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(
|
||||
data.description
|
||||
.as_ref()
|
||||
.map(String::as_bytes)
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
value.extend_from_slice(data.description.as_ref().map_or_default(String::as_bytes));
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(
|
||||
data.image
|
||||
.as_ref()
|
||||
.map(String::as_bytes)
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
value.extend_from_slice(data.image.as_ref().map_or_default(String::as_bytes));
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(&data.image_size.unwrap_or(0).to_be_bytes());
|
||||
value.push(0xFF);
|
||||
@@ -209,12 +194,7 @@ impl Data {
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(&data.image_height.unwrap_or(0).to_be_bytes());
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(
|
||||
data.video
|
||||
.as_ref()
|
||||
.map(String::as_bytes)
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
value.extend_from_slice(data.video.as_ref().map_or_default(String::as_bytes));
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(&data.video_size.unwrap_or(0).to_be_bytes());
|
||||
value.push(0xFF);
|
||||
@@ -222,12 +202,7 @@ impl Data {
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(&data.video_height.unwrap_or(0).to_be_bytes());
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(
|
||||
data.audio
|
||||
.as_ref()
|
||||
.map(String::as_bytes)
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
value.extend_from_slice(data.audio.as_ref().map_or_default(String::as_bytes));
|
||||
value.push(0xFF);
|
||||
value.extend_from_slice(&data.audio_size.unwrap_or(0).to_be_bytes());
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
ffi::{OsStr, OsString},
|
||||
fs::{self},
|
||||
fs,
|
||||
path::PathBuf,
|
||||
sync::Arc,
|
||||
time::Instant,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#![type_length_limit = "8192"]
|
||||
#![recursion_limit = "256"]
|
||||
#![allow(refining_impl_trait)]
|
||||
|
||||
extern crate conduwuit_core as conduwuit;
|
||||
@@ -33,6 +34,7 @@ pub mod oidc;
|
||||
pub mod presence;
|
||||
pub mod pusher;
|
||||
pub mod registration_tokens;
|
||||
pub mod rendezvous;
|
||||
pub mod rooms;
|
||||
pub mod sending;
|
||||
pub mod server_keys;
|
||||
|
||||
@@ -106,12 +106,14 @@ impl Display for RequestedScopes {
|
||||
pub struct RawScopes(String);
|
||||
|
||||
impl RawScopes {
|
||||
const MIN_DEVICE_ID_LENGTH: usize = 5;
|
||||
|
||||
#[allow(clippy::trivial_regex)]
|
||||
pub fn to_scopes(&self) -> Result<RequestedScopes, String> {
|
||||
let client_api_token_regex =
|
||||
regex!(r"urn:matrix:(client|org.matrix.msc2967.client):api:\*");
|
||||
let device_token_regex =
|
||||
regex!(r"urn:matrix:(client|org.matrix.msc2967.client):device:([a-zA-Z0-9-._~]{5,})");
|
||||
regex!(r"urn:matrix:(client|org.matrix.msc2967.client):device:(.+)");
|
||||
let server_administration_regex =
|
||||
regex!(r"urn:matrix:client:cc.c10y.msc4484.server_administration");
|
||||
|
||||
@@ -124,10 +126,40 @@ impl RawScopes {
|
||||
} else if server_administration_regex.is_match(token) {
|
||||
scopes.scopes.insert(OAuthClientScope::ServerAdministration)
|
||||
} else if let Some(captures) = device_token_regex.captures(token) {
|
||||
scopes
|
||||
.device_id
|
||||
.replace(captures.get(2).unwrap().as_str().into())
|
||||
.is_none()
|
||||
let device_id = captures.get(2).unwrap().as_str();
|
||||
|
||||
if device_id.len() < Self::MIN_DEVICE_ID_LENGTH {
|
||||
return Err(format!(
|
||||
"Device ID is too short, it must be at least {} characters",
|
||||
Self::MIN_DEVICE_ID_LENGTH
|
||||
));
|
||||
}
|
||||
|
||||
// The Matrix specification has a "suggested" set of
|
||||
// characters to be used in the device
|
||||
// ID scope. In the past we checked against this set, but we
|
||||
// no longer do that; instead we check
|
||||
// against the _required_ set of
|
||||
// characters defined by the OAuth specification.
|
||||
// We do this because we have observed SDKs in the wild
|
||||
// (*cough* matrix-rust-sdk) that will provide device IDs
|
||||
// that are just unpadded base64, which they're allowed to
|
||||
// do, since the spec just says that
|
||||
// clients "SHOULD" only use the suggested character set and
|
||||
// servers "MAY" choose to require that they do.
|
||||
// Of course this actually means that clients will do
|
||||
// whatever the hell they want and
|
||||
// servers can never ever be stricter
|
||||
// than they absolutely have to be. What
|
||||
// a stupid provision.
|
||||
if device_id
|
||||
.chars()
|
||||
.any(|char| !matches!(char, '\x21' | '\x23'..='\x5b' | '\x5d'..='\x7e'))
|
||||
{
|
||||
return Err("Device ID contains disallowed characters".to_owned());
|
||||
}
|
||||
|
||||
scopes.device_id.replace(device_id.into()).is_none()
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
use std::{
|
||||
sync::Arc,
|
||||
time::{Duration, SystemTime},
|
||||
};
|
||||
|
||||
use conduwuit::{Err, Result, SyncMappedMutexGuard, SyncMutex, SyncMutexGuard, at, err, utils};
|
||||
use lru_cache::LruCache;
|
||||
use ruma::{
|
||||
OwnedTransactionId,
|
||||
api::client::rendezvous::{
|
||||
create_rendezvous_session, delete_rendezvous_session, get_rendezvous_session,
|
||||
update_rendezvous_session,
|
||||
},
|
||||
};
|
||||
|
||||
pub struct Service {
|
||||
sessions: SyncMutex<LruCache<String, Session>>,
|
||||
}
|
||||
|
||||
struct Session {
|
||||
data: String,
|
||||
created_at: SystemTime,
|
||||
last_sequence_token: String,
|
||||
transaction_sequences: LruCache<OwnedTransactionId, String>,
|
||||
}
|
||||
|
||||
impl Session {
|
||||
const SAVED_TRANSACTION_SEQUENCES: usize = 256;
|
||||
|
||||
fn new(data: String, sequence_token: String) -> Self {
|
||||
Self {
|
||||
data,
|
||||
created_at: SystemTime::now(),
|
||||
last_sequence_token: sequence_token,
|
||||
transaction_sequences: LruCache::new(Self::SAVED_TRANSACTION_SEQUENCES),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::Service for Service {
|
||||
fn build(_: crate::Args<'_>) -> Result<Arc<Self>> {
|
||||
Ok(Arc::new(Self {
|
||||
sessions: SyncMutex::new(LruCache::new(Self::MAX_SESSIONS)),
|
||||
}))
|
||||
}
|
||||
|
||||
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
|
||||
}
|
||||
|
||||
impl Service {
|
||||
const MAX_DATA_SIZE_BYTES: usize = 4096;
|
||||
const MAX_SESSIONS: usize = 256;
|
||||
const SESSION_MAX_AGE: Duration = Duration::from_secs(300);
|
||||
const TOKEN_LENGTH: usize = 32;
|
||||
|
||||
fn create_token() -> String { utils::random_string(Self::TOKEN_LENGTH) }
|
||||
|
||||
/// Lock and fetch an unexpired rendezvous session.
|
||||
fn lock_session(&self, id: &str) -> Result<SyncMappedMutexGuard<'_, Session>> {
|
||||
// We don't clear out expired sessions manually, the LRU cache will
|
||||
// evict them over time
|
||||
SyncMutexGuard::try_map_or_err(self.sessions.lock(), |sessions| {
|
||||
sessions
|
||||
.get_mut(id)
|
||||
.filter(|session| {
|
||||
SystemTime::now()
|
||||
.duration_since(session.created_at)
|
||||
.is_ok_and(|duration| duration < Self::SESSION_MAX_AGE)
|
||||
})
|
||||
.ok_or_else(|| err!(Request(NotFound("Unknown session"))))
|
||||
})
|
||||
.map_err(at!(1))
|
||||
}
|
||||
|
||||
/// Create a fresh rendezvous session.
|
||||
pub fn create_session(
|
||||
&self,
|
||||
data: String,
|
||||
) -> Result<create_rendezvous_session::msc4388::Response> {
|
||||
if data.len() > Self::MAX_DATA_SIZE_BYTES {
|
||||
return Err!(Request(TooLarge("Data too large")));
|
||||
}
|
||||
|
||||
let id = Self::create_token();
|
||||
let sequence_token = Self::create_token();
|
||||
|
||||
self.sessions
|
||||
.lock()
|
||||
.insert(id.clone(), Session::new(data, sequence_token.clone()));
|
||||
|
||||
Ok(create_rendezvous_session::msc4388::Response::new(
|
||||
id,
|
||||
sequence_token,
|
||||
Self::SESSION_MAX_AGE,
|
||||
))
|
||||
}
|
||||
|
||||
/// Update a rendezvous session with new data.
|
||||
pub fn update_session(
|
||||
&self,
|
||||
id: &str,
|
||||
transaction: OwnedTransactionId,
|
||||
sequence_token: String,
|
||||
data: String,
|
||||
) -> Result<update_rendezvous_session::msc4388::Response> {
|
||||
let mut session = self.lock_session(id)?;
|
||||
|
||||
// If the provided transaction ID was used already, we have to return
|
||||
// the sequence token that we returned last time it was used.
|
||||
// This makes session updates with the same transaction ID idempotent.
|
||||
if let Some(sequence_token) = session.transaction_sequences.get_mut(&transaction) {
|
||||
return Ok(update_rendezvous_session::msc4388::Response::new(
|
||||
sequence_token.to_owned(),
|
||||
));
|
||||
}
|
||||
|
||||
if session.last_sequence_token != sequence_token {
|
||||
return Err!(Request(ConcurrentWrite("Sequence token mismatch")));
|
||||
}
|
||||
|
||||
drop(sequence_token);
|
||||
|
||||
let new_sequence_token = Self::create_token();
|
||||
|
||||
if data.len() > Self::MAX_DATA_SIZE_BYTES {
|
||||
return Err!(Request(TooLarge("Data too large")));
|
||||
}
|
||||
|
||||
session.data = data;
|
||||
session.last_sequence_token.clone_from(&new_sequence_token);
|
||||
session
|
||||
.transaction_sequences
|
||||
.insert(transaction, new_sequence_token.clone());
|
||||
|
||||
Ok(update_rendezvous_session::msc4388::Response::new(new_sequence_token))
|
||||
}
|
||||
|
||||
/// Look up a rendezvous session by ID.
|
||||
pub fn get_session(&self, id: &str) -> Result<get_rendezvous_session::msc4388::Response> {
|
||||
let session = self.lock_session(id)?;
|
||||
|
||||
let session_age = SystemTime::now()
|
||||
.duration_since(session.created_at)
|
||||
.unwrap_or(Duration::MAX);
|
||||
|
||||
let session_time_remaining = Self::SESSION_MAX_AGE.saturating_sub(session_age);
|
||||
|
||||
Ok(get_rendezvous_session::msc4388::Response::new(
|
||||
session.last_sequence_token.clone(),
|
||||
session.data.clone(),
|
||||
session_time_remaining,
|
||||
))
|
||||
}
|
||||
|
||||
/// Delete a rendezvous session.
|
||||
pub fn delete_session(
|
||||
&self,
|
||||
id: &str,
|
||||
) -> Result<delete_rendezvous_session::msc4388::Response> {
|
||||
let mut sessions = self.sessions.lock();
|
||||
|
||||
if sessions.remove(id).is_some() {
|
||||
Ok(delete_rendezvous_session::msc4388::Response::new())
|
||||
} else {
|
||||
Err!(Request(NotFound("Unknown session")))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ impl Service {
|
||||
.get_member(room_id, sender_user)
|
||||
.await
|
||||
.ok()
|
||||
.map_or_else(|| MembershipState::Leave, |content| content.membership)
|
||||
.map_or(MembershipState::Leave, |content| content.membership)
|
||||
} else {
|
||||
MembershipState::Leave
|
||||
};
|
||||
|
||||
@@ -8,10 +8,7 @@ use conduwuit::{
|
||||
utils::{self, IterStream, ReadyExt},
|
||||
};
|
||||
use database::{Deserialized, Get, Map, Qry};
|
||||
use futures::{
|
||||
Stream, StreamExt,
|
||||
stream::{self},
|
||||
};
|
||||
use futures::{Stream, StreamExt, stream};
|
||||
use ruma::{EventId, OwnedEventId, RoomId, events::StateEventType};
|
||||
use serde::Deserialize;
|
||||
|
||||
|
||||
@@ -264,14 +264,11 @@ impl Service {
|
||||
.compress_state_event(shortstatekey, &new_pdu.event_id)
|
||||
.await;
|
||||
|
||||
let replaces = states_parents
|
||||
.last()
|
||||
.map(|info| {
|
||||
info.full_state
|
||||
.iter()
|
||||
.find(|bytes| bytes.starts_with(&shortstatekey.to_be_bytes()))
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let replaces = states_parents.last().map_or_default(|info| {
|
||||
info.full_state
|
||||
.iter()
|
||||
.find(|bytes| bytes.starts_with(&shortstatekey.to_be_bytes()))
|
||||
});
|
||||
|
||||
if Some(&new) == replaces {
|
||||
return Ok(previous_shortstatehash.expect("must exist"));
|
||||
|
||||
@@ -745,7 +745,7 @@ impl Service {
|
||||
.get_member(room_id, querying_user)
|
||||
.await
|
||||
.ok()
|
||||
.map_or_else(|| MembershipState::Leave, |content| content.membership);
|
||||
.map_or(MembershipState::Leave, |content| content.membership);
|
||||
|
||||
if matches!(membership, MembershipState::Join | MembershipState::Invite) {
|
||||
return true;
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
use conduwuit::config::experiments::ToggledExperiment;
|
||||
use conduwuit_core::{
|
||||
Err, Result, err,
|
||||
matrix::event::Event,
|
||||
utils::{self},
|
||||
warn,
|
||||
};
|
||||
use conduwuit_core::{Err, Result, err, matrix::event::Event, utils, warn};
|
||||
use ruma::{EventId, events::room::encrypted::Relation, signatures::content_hash};
|
||||
|
||||
use super::{ExtractBody, ExtractRelatesTo};
|
||||
|
||||
@@ -101,8 +101,7 @@ impl super::Service {
|
||||
.trusted_servers
|
||||
.iter()
|
||||
.find(|n| n.server_name() == notary)
|
||||
.map(|nk| nk.verify_keys().to_owned())
|
||||
.unwrap_or_default();
|
||||
.map_or_default(|nk| nk.verify_keys().to_owned());
|
||||
let keys = self
|
||||
.services
|
||||
.sending
|
||||
|
||||
@@ -11,8 +11,8 @@ use crate::{
|
||||
account_data, admin, announcements, antispam, appservice, client, config, emergency,
|
||||
federation, firstrun, globals, key_backups, mailer,
|
||||
manager::Manager,
|
||||
media, moderation, oauth, oidc, presence, pusher, registration_tokens, rooms, sending,
|
||||
server_keys,
|
||||
media, moderation, oauth, oidc, presence, pusher, registration_tokens, rendezvous, rooms,
|
||||
sending, server_keys,
|
||||
service::{self, Args, Map, Service},
|
||||
sync, threepid, transactions, uiaa, users,
|
||||
};
|
||||
@@ -33,6 +33,7 @@ pub struct Services {
|
||||
pub presence: Arc<presence::Service>,
|
||||
pub pusher: Arc<pusher::Service>,
|
||||
pub registration_tokens: Arc<registration_tokens::Service>,
|
||||
pub rendezvous: Arc<rendezvous::Service>,
|
||||
pub rooms: rooms::Service,
|
||||
pub federation: Arc<federation::Service>,
|
||||
pub firstrun: Arc<firstrun::Service>,
|
||||
@@ -89,6 +90,7 @@ impl Services {
|
||||
presence: build!(presence::Service),
|
||||
pusher: build!(pusher::Service),
|
||||
registration_tokens: build!(registration_tokens::Service),
|
||||
rendezvous: build!(rendezvous::Service),
|
||||
rooms: rooms::Service {
|
||||
alias: build!(rooms::alias::Service),
|
||||
auth_chain: build!(rooms::auth_chain::Service),
|
||||
|
||||
@@ -143,7 +143,7 @@ impl Service {
|
||||
) {
|
||||
let mut key = user_id.as_bytes().to_vec();
|
||||
key.push(0xFF);
|
||||
key.extend_from_slice(device_id.map(DeviceId::as_bytes).unwrap_or_default());
|
||||
key.extend_from_slice(device_id.map_or_default(DeviceId::as_bytes));
|
||||
key.push(0xFF);
|
||||
key.extend_from_slice(txn_id.as_bytes());
|
||||
|
||||
|
||||
@@ -9,10 +9,7 @@ pub(super) mod remote;
|
||||
use std::{mem, sync::Arc};
|
||||
|
||||
pub use account::{AccessTokenStatus, AccountStatus};
|
||||
use conduwuit::{
|
||||
Err, Error, Result, err,
|
||||
utils::{self},
|
||||
};
|
||||
use conduwuit::{Err, Error, Result, err, utils};
|
||||
use database::Map;
|
||||
pub use device::DeviceToken;
|
||||
pub use profile::ProfileFieldChange;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
</div>
|
||||
<div>
|
||||
{% if style != DeviceCardStyle::Detailed %}
|
||||
<a href="{{ crate::ROUTE_PREFIX }}/account/device/{{ device_id }}/">Details</a>
|
||||
<a href="{{ crate::ROUTE_PREFIX }}/account/device/{{ device_id | urlencode_strict }}/">Details</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
Reference in new issue
Block a user