[WIP] MTP migration

This commit is contained in:
Alex Emmet 2026-07-03 16:19:12 +02:00
commit 607bf337fe
5 changed files with 210 additions and 118 deletions

219
Cargo.lock generated
View file

@ -50,7 +50,7 @@ dependencies = [
"mime", "mime",
"percent-encoding", "percent-encoding",
"pin-project-lite", "pin-project-lite",
"rand 0.10.1", "rand 0.10.2",
"sha1 0.11.0", "sha1 0.11.0",
"smallvec", "smallvec",
"tokio", "tokio",
@ -222,6 +222,16 @@ dependencies = [
"generic-array", "generic-array",
] ]
[[package]]
name = "aead"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1973cfbc1a2daf9cf550e74e1f088c28e7f7d8c1e1418fb6c9dc5184b7e84c99"
dependencies = [
"crypto-common 0.2.2",
"inout 0.2.2",
]
[[package]] [[package]]
name = "aes" name = "aes"
version = "0.8.4" version = "0.8.4"
@ -229,19 +239,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"cipher", "cipher 0.4.4",
"cpufeatures 0.2.17", "cpufeatures 0.2.17",
] ]
[[package]] [[package]]
name = "aes-gcm" name = "aes"
version = "0.10.3" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" checksum = "f1fc76eaeac4c9164506c466d4ffdd8ec9d0c5bf57ee97177c4d8eceb3a0e138"
dependencies = [ dependencies = [
"aead", "cipher 0.5.2",
"aes", "cpubits",
"cipher", "cpufeatures 0.3.0",
]
[[package]]
name = "aes-gcm"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdf011db2e21ce0d575593d749db5554b47fed37aff429e4dc50bc91ac93a028"
dependencies = [
"aead 0.6.1",
"aes 0.9.1",
"cipher 0.5.2",
"ctr", "ctr",
"ghash", "ghash",
"subtle", "subtle",
@ -313,7 +334,7 @@ dependencies = [
"nom", "nom",
"num-traits", "num-traits",
"rusticata-macros", "rusticata-macros",
"thiserror", "thiserror 2.0.18",
"time", "time",
] ]
@ -505,9 +526,9 @@ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
[[package]] [[package]]
name = "aws-lc-rs" name = "aws-lc-rs"
version = "1.17.0" version = "1.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ec2f1fc3ec205783a5da9a7e6c1509cc69dedf09a1949e412c1e18469326d00" checksum = "4342d8937fc7e5dd9b1c60292261c0670c882a2cd1719cfc11b1af41731e32ad"
dependencies = [ dependencies = [
"aws-lc-sys", "aws-lc-sys",
"untrusted 0.7.1", "untrusted 0.7.1",
@ -516,14 +537,15 @@ dependencies = [
[[package]] [[package]]
name = "aws-lc-sys" name = "aws-lc-sys"
version = "0.41.0" version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a2f9779ce85b93ab6170dd940ad0169b5766ff848247aff13bb788b832fe3f4" checksum = "6d9ceb1da931507a12f4fccea479dccd00da1943e1b4ae72d8e502d707361444"
dependencies = [ dependencies = [
"cc", "cc",
"cmake", "cmake",
"dunce", "dunce",
"fs_extra", "fs_extra",
"pkg-config",
] ]
[[package]] [[package]]
@ -681,7 +703,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"cipher", "cipher 0.4.4",
"cpufeatures 0.2.17", "cpufeatures 0.2.17",
] ]
@ -702,9 +724,9 @@ version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35"
dependencies = [ dependencies = [
"aead", "aead 0.5.2",
"chacha20 0.9.1", "chacha20 0.9.1",
"cipher", "cipher 0.4.4",
"poly1305", "poly1305",
"zeroize", "zeroize",
] ]
@ -716,10 +738,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
dependencies = [ dependencies = [
"crypto-common 0.1.7", "crypto-common 0.1.7",
"inout", "inout 0.1.4",
"zeroize", "zeroize",
] ]
[[package]]
name = "cipher"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c"
dependencies = [
"block-buffer 0.12.1",
"crypto-common 0.2.2",
"inout 0.2.2",
]
[[package]] [[package]]
name = "cmake" name = "cmake"
version = "0.1.58" version = "0.1.58"
@ -818,6 +851,12 @@ version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "cpubits"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae"
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.2.17" version = "0.2.17"
@ -899,11 +938,11 @@ dependencies = [
[[package]] [[package]]
name = "ctr" name = "ctr"
version = "0.9.2" version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" checksum = "baaca1c4b237092596f64d571e9db6ce4109c4ef9742e27590f1709594461f21"
dependencies = [ dependencies = [
"cipher", "cipher 0.5.2",
] ]
[[package]] [[package]]
@ -1441,11 +1480,10 @@ dependencies = [
[[package]] [[package]]
name = "ghash" name = "ghash"
version = "0.5.1" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" checksum = "2eecf2d5dc9b66b732b97707a0210906b1d30523eb773193ab777c0c84b3e8d5"
dependencies = [ dependencies = [
"opaque-debug",
"polyval", "polyval",
] ]
@ -1867,6 +1905,15 @@ dependencies = [
"generic-array", "generic-array",
] ]
[[package]]
name = "inout"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7"
dependencies = [
"hybrid-array",
]
[[package]] [[package]]
name = "instant" name = "instant"
version = "0.1.13" version = "0.1.13"
@ -1911,7 +1958,7 @@ dependencies = [
"jni-sys", "jni-sys",
"log", "log",
"simd_cesu8", "simd_cesu8",
"thiserror", "thiserror 2.0.18",
"walkdir", "walkdir",
"windows-link", "windows-link",
] ]
@ -2038,14 +2085,14 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
[[package]] [[package]]
name = "libredox" name = "libredox"
version = "0.1.17" version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f02ab6bace2054fb888a3c16f990117b579d14a3088e472d63c6011fa185c9d3" checksum = "c943259e342f1e06ff2da7a83eabdfe7f92ce10262688dbf1895ff0b3e6e4652"
dependencies = [ dependencies = [
"bitflags 2.13.0", "bitflags 2.13.0",
"libc", "libc",
"plain", "plain",
"redox_syscall 0.8.1", "redox_syscall 0.9.0",
] ]
[[package]] [[package]]
@ -2233,7 +2280,7 @@ dependencies = [
[[package]] [[package]]
name = "mtp" name = "mtp"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.methanium.net/methanium/mtp#41528ef7178982e70cb5789a437d863a7a35426c" source = "git+https://git.methanium.net/methanium/mtp#8dc8b54b26544554f98d7af32200d6bf9a01d300"
dependencies = [ dependencies = [
"mtp-client", "mtp-client",
"mtp-codec", "mtp-codec",
@ -2247,7 +2294,7 @@ dependencies = [
[[package]] [[package]]
name = "mtp-client" name = "mtp-client"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.methanium.net/methanium/mtp#41528ef7178982e70cb5789a437d863a7a35426c" source = "git+https://git.methanium.net/methanium/mtp#8dc8b54b26544554f98d7af32200d6bf9a01d300"
dependencies = [ dependencies = [
"mtp-codec", "mtp-codec",
"mtp-common", "mtp-common",
@ -2260,7 +2307,7 @@ dependencies = [
[[package]] [[package]]
name = "mtp-codec" name = "mtp-codec"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.methanium.net/methanium/mtp#41528ef7178982e70cb5789a437d863a7a35426c" source = "git+https://git.methanium.net/methanium/mtp#8dc8b54b26544554f98d7af32200d6bf9a01d300"
dependencies = [ dependencies = [
"base64", "base64",
"byteorder", "byteorder",
@ -2273,18 +2320,18 @@ dependencies = [
[[package]] [[package]]
name = "mtp-common" name = "mtp-common"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.methanium.net/methanium/mtp#41528ef7178982e70cb5789a437d863a7a35426c" source = "git+https://git.methanium.net/methanium/mtp#8dc8b54b26544554f98d7af32200d6bf9a01d300"
dependencies = [ dependencies = [
"quinn", "quinn",
"rustls", "rustls",
"thiserror", "thiserror 2.0.18",
"wtransport", "wtransport",
] ]
[[package]] [[package]]
name = "mtp-crypto" name = "mtp-crypto"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.methanium.net/methanium/mtp#41528ef7178982e70cb5789a437d863a7a35426c" source = "git+https://git.methanium.net/methanium/mtp#8dc8b54b26544554f98d7af32200d6bf9a01d300"
dependencies = [ dependencies = [
"chacha20poly1305", "chacha20poly1305",
"ed25519-dalek", "ed25519-dalek",
@ -2295,13 +2342,14 @@ dependencies = [
"rand_core 0.6.4", "rand_core 0.6.4",
"serde", "serde",
"sha2 0.11.0", "sha2 0.11.0",
"thiserror 1.0.69",
"zeroize", "zeroize",
] ]
[[package]] [[package]]
name = "mtp-host" name = "mtp-host"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.methanium.net/methanium/mtp#41528ef7178982e70cb5789a437d863a7a35426c" source = "git+https://git.methanium.net/methanium/mtp#8dc8b54b26544554f98d7af32200d6bf9a01d300"
dependencies = [ dependencies = [
"mtp-codec", "mtp-codec",
"mtp-common", "mtp-common",
@ -2314,7 +2362,7 @@ dependencies = [
[[package]] [[package]]
name = "mtp-transport" name = "mtp-transport"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.methanium.net/methanium/mtp#41528ef7178982e70cb5789a437d863a7a35426c" source = "git+https://git.methanium.net/methanium/mtp#8dc8b54b26544554f98d7af32200d6bf9a01d300"
dependencies = [ dependencies = [
"log", "log",
"mtp-codec", "mtp-codec",
@ -2328,7 +2376,7 @@ dependencies = [
[[package]] [[package]]
name = "mtp-type-map" name = "mtp-type-map"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.methanium.net/methanium/mtp#41528ef7178982e70cb5789a437d863a7a35426c" source = "git+https://git.methanium.net/methanium/mtp#8dc8b54b26544554f98d7af32200d6bf9a01d300"
dependencies = [ dependencies = [
"serde", "serde",
"serde_yaml", "serde_yaml",
@ -2346,9 +2394,9 @@ dependencies = [
[[package]] [[package]]
name = "num-bigint" name = "num-bigint"
version = "0.4.6" version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" checksum = "c863e9ab5e7bf9c99ba75e1050f1e4d624ae87ed3532d6238ffbdc7b585dbbe6"
dependencies = [ dependencies = [
"num-integer", "num-integer",
"num-traits", "num-traits",
@ -2447,7 +2495,7 @@ dependencies = [
"sqlx", "sqlx",
"strum", "strum",
"strum_macros", "strum_macros",
"thiserror", "thiserror 2.0.18",
"tokio", "tokio",
"uuid", "uuid",
"x448", "x448",
@ -2640,19 +2688,18 @@ checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf"
dependencies = [ dependencies = [
"cpufeatures 0.2.17", "cpufeatures 0.2.17",
"opaque-debug", "opaque-debug",
"universal-hash", "universal-hash 0.5.1",
] ]
[[package]] [[package]]
name = "polyval" name = "polyval"
version = "0.6.2" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" checksum = "7dfc63250416fea14f5749b90725916a6c903f599d51cb635aa7a52bfd03eede"
dependencies = [ dependencies = [
"cfg-if", "cpubits",
"cpufeatures 0.2.17", "cpufeatures 0.3.0",
"opaque-debug", "universal-hash 0.6.1",
"universal-hash",
] ]
[[package]] [[package]]
@ -2708,7 +2755,7 @@ dependencies = [
"rustc-hash", "rustc-hash",
"rustls", "rustls",
"socket2 0.6.4", "socket2 0.6.4",
"thiserror", "thiserror 2.0.18",
"tokio", "tokio",
"tracing", "tracing",
"web-time", "web-time",
@ -2730,7 +2777,7 @@ dependencies = [
"rustls", "rustls",
"rustls-pki-types", "rustls-pki-types",
"slab", "slab",
"thiserror", "thiserror 2.0.18",
"tinyvec", "tinyvec",
"tracing", "tracing",
"web-time", "web-time",
@ -2794,9 +2841,9 @@ dependencies = [
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.10.1" version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2e8e8bcc7961af1fdac401278c6a831614941f6164ee3bf4ce61b7edb162207" checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80"
dependencies = [ dependencies = [
"chacha20 0.10.1", "chacha20 0.10.1",
"getrandom 0.4.3", "getrandom 0.4.3",
@ -2877,9 +2924,9 @@ dependencies = [
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.8.1" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b44b894f2a6e36457d665d1e08c3866add6ed5e70050c1b4ba8a8ddedb02ce7" checksum = "c5102a6aaa05aa011a238e178e6bca86d2cb56fc9f586d37cb80f5bca6e07759"
dependencies = [ dependencies = [
"bitflags 2.13.0", "bitflags 2.13.0",
] ]
@ -2993,9 +3040,9 @@ dependencies = [
[[package]] [[package]]
name = "rustc-hash" name = "rustc-hash"
version = "2.1.2" version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
[[package]] [[package]]
name = "rustc_version" name = "rustc_version"
@ -3081,9 +3128,9 @@ dependencies = [
[[package]] [[package]]
name = "rustls-pki-types" name = "rustls-pki-types"
version = "1.14.1" version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30a7197ae7eb376e574fe940d068c30fe0462554a3ddbe4eca7838e049c937a9" checksum = "764899a24af3980067ee14bc143654f297b22eaebfe3c7b6b211920a5a59b046"
dependencies = [ dependencies = [
"web-time", "web-time",
"zeroize", "zeroize",
@ -3506,7 +3553,7 @@ dependencies = [
"serde_json", "serde_json",
"sha2 0.10.9", "sha2 0.10.9",
"smallvec", "smallvec",
"thiserror", "thiserror 2.0.18",
"tracing", "tracing",
"url", "url",
] ]
@ -3586,7 +3633,7 @@ dependencies = [
"smallvec", "smallvec",
"sqlx-core", "sqlx-core",
"stringprep", "stringprep",
"thiserror", "thiserror 2.0.18",
"tracing", "tracing",
"whoami", "whoami",
] ]
@ -3623,7 +3670,7 @@ dependencies = [
"smallvec", "smallvec",
"sqlx-core", "sqlx-core",
"stringprep", "stringprep",
"thiserror", "thiserror 2.0.18",
"tracing", "tracing",
"whoami", "whoami",
] ]
@ -3647,7 +3694,7 @@ dependencies = [
"serde", "serde",
"serde_urlencoded", "serde_urlencoded",
"sqlx-core", "sqlx-core",
"thiserror", "thiserror 2.0.18",
"tracing", "tracing",
"url", "url",
] ]
@ -3745,13 +3792,33 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "thiserror"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
dependencies = [
"thiserror-impl 1.0.69",
]
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "2.0.18" version = "2.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl 2.0.18",
]
[[package]]
name = "thiserror-impl"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
dependencies = [
"proc-macro2",
"quote",
"syn",
] ]
[[package]] [[package]]
@ -3767,9 +3834,9 @@ dependencies = [
[[package]] [[package]]
name = "time" name = "time"
version = "0.3.51" version = "0.3.53"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85c17d80feb7334b40c484e45ed1a5273dfd8bfda537c3be2e74a06a6686f327" checksum = "18dfaaeddcb932337b5e7866ee7d0ce9b76d2fd092997146f187ec09b4558a50"
dependencies = [ dependencies = [
"deranged", "deranged",
"num-conv", "num-conv",
@ -3787,9 +3854,9 @@ checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109"
[[package]] [[package]]
name = "time-macros" name = "time-macros"
version = "0.2.30" version = "0.2.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcef1a61bdb119096e153208ec5cbec23944ce8bca13be5c7f60c634f7403935" checksum = "c431b87111666e491a90baa837f914fb45cd5dc3c268591b0220ff5057f2085f"
dependencies = [ dependencies = [
"num-conv", "num-conv",
"time-core", "time-core",
@ -4009,6 +4076,16 @@ dependencies = [
"subtle", "subtle",
] ]
[[package]]
name = "universal-hash"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4987bdc12753382e0bec4a65c50738ffaabc998b9cdd1f952fb5f39b0048a96"
dependencies = [
"crypto-common 0.2.2",
"ctutils",
]
[[package]] [[package]]
name = "unsafe-libyaml" name = "unsafe-libyaml"
version = "0.2.11" version = "0.2.11"
@ -4529,7 +4606,7 @@ dependencies = [
"rustls-pki-types", "rustls-pki-types",
"sha2 0.11.0", "sha2 0.11.0",
"socket2 0.6.4", "socket2 0.6.4",
"thiserror", "thiserror 2.0.18",
"time", "time",
"tokio", "tokio",
"tracing", "tracing",
@ -4546,7 +4623,7 @@ checksum = "d5867c629e4252f7439d82315923daaf27f4fa442410d51b78ab93ef4c432a11"
dependencies = [ dependencies = [
"httlib-huffman", "httlib-huffman",
"octets", "octets",
"thiserror", "thiserror 2.0.18",
"url", "url",
] ]
@ -4587,7 +4664,7 @@ dependencies = [
"nom", "nom",
"oid-registry", "oid-registry",
"rusticata-macros", "rusticata-macros",
"thiserror", "thiserror 2.0.18",
"time", "time",
] ]
@ -4724,7 +4801,7 @@ version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb2a05c7c36fde6c09b08576c9f7fb4cda705990f73b58fe011abf7dfb24168b" checksum = "eb2a05c7c36fde6c09b08576c9f7fb4cda705990f73b58fe011abf7dfb24168b"
dependencies = [ dependencies = [
"aes", "aes 0.8.4",
"arbitrary", "arbitrary",
"bzip2", "bzip2",
"constant_time_eq", "constant_time_eq",
@ -4747,9 +4824,9 @@ dependencies = [
[[package]] [[package]]
name = "zlib-rs" name = "zlib-rs"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "977347db8caa080403f6b6b7c1cda9479a8e869316f7e13a59b19076a40f94e3" checksum = "5431d5661c32445236631278f27946e444ddafe4684cac70b185272d4f9c52d5"
[[package]] [[package]]
name = "zmij" name = "zmij"

View file

@ -6,7 +6,7 @@ edition = "2024"
[dependencies] [dependencies]
mtp = { git = "https://git.methanium.net/methanium/mtp", features = [ mtp = { git = "https://git.methanium.net/methanium/mtp", features = [
"host", "host",
"crypto", "crypto"
] } ] }
actix-web = { version = "4.12.1", features = ["rustls-0_23"] } actix-web = { version = "4.12.1", features = ["rustls-0_23"] }

View file

@ -26,12 +26,8 @@ fn load_keyring() -> Keyring {
.expect("Invalid KEYRING env var: not valid base64"); .expect("Invalid KEYRING env var: not valid base64");
Keyring::from_bytes(&bytes).expect("Invalid KEYRING env var: failed to deserialize") Keyring::from_bytes(&bytes).expect("Invalid KEYRING env var: failed to deserialize")
} }
pub fn get_keyring() -> &'static Keyring {
static KEYRING: Lazy<Keyring> = Lazy::new(load_keyring);
&KEYRING
}
pub fn get_public_key_bundle() -> PublicKeyBundle { pub fn get_public_key_bundle() -> PublicKeyBundle {
get_keyring().public_key_bundle() load_keyring().public_key_bundle()
} }
#[tokio::main] #[tokio::main]

View file

@ -1,16 +1,13 @@
use crate::get_public_key_bundle; use crate::get_public_key_bundle;
use crate::sql::sql; use crate::sql::sql;
use crate::sql::sql::{get_by_user_id, get_omikron_by_id};
use crate::sql::user_online_tracker::get_iota_primary_omikron_connection; use crate::sql::user_online_tracker::get_iota_primary_omikron_connection;
use crate::transport::omikron_manager::get_random_omikron; use crate::transport::omikron_manager::get_random_omikron;
use crate::util::file_util::get_directory; use crate::util::file_util::get_directory;
use crate::{
sql::sql::{get_by_user_id, get_omikron_by_id},
};
use actix_web::HttpResponse; use actix_web::HttpResponse;
use actix_web::http::{StatusCode, header}; use actix_web::http::{StatusCode, header};
use base64::Engine as _; use base64::Engine as _;
use json::JsonValue; use json::JsonValue;
use mtp_crypto::PublicKeyBundle;
pub async fn handle(path: &str, body_string: Option<String>) -> HttpResponse { pub async fn handle(path: &str, body_string: Option<String>) -> HttpResponse {
if path == "OPTIONS" { if path == "OPTIONS" {
@ -196,7 +193,9 @@ pub async fn handle(path: &str, body_string: Option<String>) -> HttpResponse {
let mut res = JsonValue::new_object(); let mut res = JsonValue::new_object();
res["status"] = "success".into(); res["status"] = "success".into();
let bundle = get_public_key_bundle(); let bundle = get_public_key_bundle();
res["public_key"] = base64::engine::general_purpose::STANDARD.encode(bundle.to_bytes()).into(); res["public_key"] = base64::engine::general_purpose::STANDARD
.encode(bundle.as_bytes())
.into();
(StatusCode::OK, res.dump()) (StatusCode::OK, res.dump())
} }

View file

@ -1,5 +1,5 @@
use crate::{ use crate::{
get_private_key, get_public_key, log, log_cv_in, log_cv_out, log_err, log_in, get_keyring, get_public_key_bundle, log, log_cv_in, log_cv_out, log_err, log_in,
server::short_link::add_short_link, server::short_link::add_short_link,
sql::{ sql::{
connection_status::UserStatus, connection_status::UserStatus,
@ -7,14 +7,14 @@ use crate::{
user_online_tracker::{self}, user_online_tracker::{self},
}, },
transport::omikron_manager, transport::omikron_manager,
util::{crypto_helper::encrypt, file_util::load_file_vec, logger::PrintType}, util::{file_util::load_file_vec, logger::PrintType},
}; };
use base64::{Engine as _, engine::general_purpose::STANDARD}; use base64::{Engine as _, engine::general_purpose::STANDARD};
use dashmap::DashMap; use dashmap::DashMap;
use mtp::codec::{CommunicationType, CommunicationValue, DataType, DataValue}; use mtp::{codec::{CommunicationType, CommunicationValue, DataType, DataValue}, host::{HostConfig, MTPHost}};
use mtp::transport::{Host, Policy, Receiver, SendMode, Sender, host}; use mtp::transport::{Host, Policy, Receiver, SendMode, Sender, host};
use std::net::{IpAddr, Ipv4Addr};
use rand::{Rng, distributions::Alphanumeric}; use rand::{Rng, distributions::Alphanumeric};
use std::net::{IpAddr, Ipv4Addr};
use std::{ use std::{
sync::Arc, sync::Arc,
time::{Duration, Instant}, time::{Duration, Instant},
@ -268,11 +268,12 @@ impl OmikronConnection {
log!("Stored State"); log!("Stored State");
let challenge_clone = challenge.clone(); let challenge_clone: String = challenge.clone();
let private_key = get_private_key(); let private_key = get_keyring();
let public_key_for_encrypt = omikron_pub_key; let public_key_for_encrypt = omikron_pub_key;
let encrypted = tokio::task::spawn_blocking(move || { let encrypted = tokio::task::spawn_blocking(move || {
challenge_clone
encrypt(private_key, public_key_for_encrypt, &challenge_clone) encrypt(private_key, public_key_for_encrypt, &challenge_clone)
.map_err(|_| OmikronError::AuthenticationFailed) .map_err(|_| OmikronError::AuthenticationFailed)
}) })
@ -286,7 +287,7 @@ impl OmikronConnection {
.with_id(cv.get_id()) .with_id(cv.get_id())
.add_typed_default( .add_typed_default(
DataType::PublicKey, DataType::PublicKey,
DataValue::Str(STANDARD.encode(get_public_key().as_bytes())), DataValue::Str(STANDARD.encode(get_public_key_bundle().as_bytes())),
) )
.add_typed_default(DataType::Content, DataValue::Str(encrypted)); .add_typed_default(DataType::Content, DataValue::Str(encrypted));
@ -579,7 +580,10 @@ impl OmikronConnection {
.add_typed_default(DataType::PublicKey, DataValue::Str(public_key)) .add_typed_default(DataType::PublicKey, DataValue::Str(public_key))
.add_typed_default(DataType::UserId, DataValue::SignedNumber(id.into())) .add_typed_default(DataType::UserId, DataValue::SignedNumber(id.into()))
.add_typed_default(DataType::IotaId, DataValue::SignedNumber(iota_id.into())) .add_typed_default(DataType::IotaId, DataValue::SignedNumber(iota_id.into()))
.add_typed_default(DataType::SubLevel, DataValue::SignedNumber(sub_level as i128)) .add_typed_default(
DataType::SubLevel,
DataValue::SignedNumber(sub_level as i128),
)
.add_typed_default(DataType::SubEnd, DataValue::SignedNumber(sub_end.into())); .add_typed_default(DataType::SubEnd, DataValue::SignedNumber(sub_end.into()));
// Display name (fallback to username) // Display name (fallback to username)
@ -594,7 +598,8 @@ impl OmikronConnection {
response = response.add_typed_default(DataType::About, DataValue::Str(a)); response = response.add_typed_default(DataType::About, DataValue::Str(a));
} }
if let Some(av) = avatar { if let Some(av) = avatar {
response = response.add_typed_default(DataType::Avatar, DataValue::Str(STANDARD.encode(av))); response =
response.add_typed_default(DataType::Avatar, DataValue::Str(STANDARD.encode(av)));
} }
// Online status // Online status
@ -612,7 +617,10 @@ impl OmikronConnection {
DataType::OnlineStatus, DataType::OnlineStatus,
DataValue::Str(display_status.to_string()), DataValue::Str(display_status.to_string()),
); );
response = response.add_typed_default(DataType::OmikronId, DataValue::SignedNumber(us.omikron_id.into())); response = response.add_typed_default(
DataType::OmikronId,
DataValue::SignedNumber(us.omikron_id.into()),
);
} else { } else {
response = response.add_typed_default( response = response.add_typed_default(
DataType::OnlineStatus, DataType::OnlineStatus,
@ -706,7 +714,8 @@ impl OmikronConnection {
.add_typed_default(DataType::IotaId, DataValue::SignedNumber(iota_id.into())); .add_typed_default(DataType::IotaId, DataValue::SignedNumber(iota_id.into()));
if let Some(uid) = user_id { if let Some(uid) = user_id {
response = response.add_typed_default(DataType::UserId, DataValue::SignedNumber(uid.into())); response =
response.add_typed_default(DataType::UserId, DataValue::SignedNumber(uid.into()));
} }
if let Some(uname) = username { if let Some(uname) = username {
response = response.add_typed_default(DataType::Username, DataValue::Str(uname)); response = response.add_typed_default(DataType::Username, DataValue::Str(uname));
@ -730,7 +739,10 @@ impl OmikronConnection {
let register_id = sql::get_register_id().await; let register_id = sql::get_register_id().await;
let response = CommunicationValue::new(CommunicationType::GetRegister) let response = CommunicationValue::new(CommunicationType::GetRegister)
.with_id(cv.get_id()) .with_id(cv.get_id())
.add_typed_default(DataType::UserId, DataValue::SignedNumber(register_id as i128)); .add_typed_default(
DataType::UserId,
DataValue::SignedNumber(register_id as i128),
);
self.send(&response).await self.send(&response).await
} }
@ -763,7 +775,10 @@ impl OmikronConnection {
let response = let response =
CommunicationValue::new(CommunicationType::CompleteRegisterIota) CommunicationValue::new(CommunicationType::CompleteRegisterIota)
.with_id(cv.get_id()) .with_id(cv.get_id())
.add_typed_default(DataType::IotaId, DataValue::SignedNumber(new_iota_id.into())); .add_typed_default(
DataType::IotaId,
DataValue::SignedNumber(new_iota_id.into()),
);
self.send(&response).await self.send(&response).await
} }
Err(e) => { Err(e) => {
@ -919,7 +934,10 @@ impl OmikronConnection {
let response = let response =
CommunicationValue::new(CommunicationType::ErrorInternal) CommunicationValue::new(CommunicationType::ErrorInternal)
.with_id(cv.get_id()) .with_id(cv.get_id())
.add_typed_default(DataType::ErrorType, DataValue::Str(error_message)); .add_typed_default(
DataType::ErrorType,
DataValue::Str(error_message),
);
self.send(&response).await self.send(&response).await
} }
} else { } else {
@ -986,8 +1004,14 @@ impl OmikronConnection {
.map(|(sender, amount)| { .map(|(sender, amount)| {
let tm = mtp::type_map::TypeMap::latest(); let tm = mtp::type_map::TypeMap::latest();
DataValue::Container(vec![ DataValue::Container(vec![
(DataType::SenderId.to_id(&tm), DataValue::SignedNumber(sender.into())), (
(DataType::Amount.to_id(&tm), DataValue::SignedNumber(amount.into())), DataType::SenderId.to_id(&tm),
DataValue::SignedNumber(sender.into()),
),
(
DataType::Amount.to_id(&tm),
DataValue::SignedNumber(amount.into()),
),
]) ])
}) })
.collect(), .collect(),
@ -1033,7 +1057,10 @@ impl OmikronConnection {
// Sync with other Omikron clients // Sync with other Omikron clients
let sync_cv = CommunicationValue::new(CommunicationType::ReadNotification) let sync_cv = CommunicationValue::new(CommunicationType::ReadNotification)
.with_receiver(receiver_id as u64) .with_receiver(receiver_id as u64)
.add_typed_default(DataType::SenderId, DataValue::SignedNumber(other_id.into())); .add_typed_default(
DataType::SenderId,
DataValue::SignedNumber(other_id.into()),
);
crate::transport::omikron_manager::send_to_user(receiver_id, &sync_cv).await; crate::transport::omikron_manager::send_to_user(receiver_id, &sync_cv).await;
} }
} }
@ -1070,7 +1097,10 @@ impl OmikronConnection {
// Sync with other Omikron clients // Sync with other Omikron clients
let push_cv = CommunicationValue::new(CommunicationType::PushNotification) let push_cv = CommunicationValue::new(CommunicationType::PushNotification)
.with_receiver(receiver_id as u64) .with_receiver(receiver_id as u64)
.add_typed_default(DataType::SenderId, DataValue::SignedNumber(sender_id.into())); .add_typed_default(
DataType::SenderId,
DataValue::SignedNumber(sender_id.into()),
);
crate::transport::omikron_manager::send_to_user(receiver_id, &push_cv).await; crate::transport::omikron_manager::send_to_user(receiver_id, &push_cv).await;
} }
Ok(()) Ok(())
@ -1099,7 +1129,10 @@ impl OmikronConnection {
}; };
let tm = mtp::type_map::TypeMap::latest(); let tm = mtp::type_map::TypeMap::latest();
let mut map = Vec::new(); let mut map = Vec::new();
map.push((DataType::UserId.to_id(&tm), DataValue::SignedNumber(user_id.into()))); map.push((
DataType::UserId.to_id(&tm),
DataValue::SignedNumber(user_id.into()),
));
map.push((DataType::UserState.to_id(&tm), DataValue::Str(status_str))); map.push((DataType::UserState.to_id(&tm), DataValue::Str(status_str)));
states.push(DataValue::Container(map)); states.push(DataValue::Container(map));
} }
@ -1192,29 +1225,16 @@ pub async fn start(port: u16) -> Result<(), Box<dyn std::error::Error>> {
let key_pem = load_file_vec("certs", "transport_key.pem").expect("Error loading Keyfile"); let key_pem = load_file_vec("certs", "transport_key.pem").expect("Error loading Keyfile");
let mut host: Host = host( let mut host: MTPHost = MTPHost::new(
IpAddr::from(Ipv4Addr::new(0, 0, 0, 0)), HostConfig::new(
IpAddr::from(Ipv4Addr::new(0, 0, 0, 0)),
port, port,
cert_pem, cert_pem,
key_pem, key_pem,
Policy { )
send_mode: SendMode::SingleStreamPerMessage,
max_message_size: 1_000_000_000,
close_frame_len: u32::MAX,
application_close_code: 0,
open_stream_timeout: Duration::from_millis(2_000),
write_timeout: Duration::from_millis(2_000),
accept_stream_timeout: Duration::from_millis(10_000),
read_timeout: Duration::from_millis(30_000),
keep_alive_interval: Some(Duration::from_secs(6)),
max_idle_timeout: Some(Duration::from_secs(30)),
force_close_delay: Duration::from_millis(300),
max_transient_recv_errors: 20,
transient_recv_backoff: Duration::from_millis(100),
receiver_queue_capacity: 1000,
},
) )
.await?; .await?;
log!("OmikronServer listening on port {}", port); log!("OmikronServer listening on port {}", port);
while let Some((sender, mut receiver)) = host.next().await { while let Some((sender, mut receiver)) = host.next().await {