From 7094d1d9395ad1ad22c21f68bb3d4ff93cc55124 Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Fri, 15 Aug 2025 18:05:52 -0600 Subject: [PATCH] update types --- core/Cargo.lock | 46 ++++++++++----------- core/models/Cargo.toml | 4 +- core/startos/Cargo.toml | 4 +- core/startos/src/db/model/public.rs | 5 ++- core/startos/src/middleware/auth.rs | 6 +-- core/startos/src/net/host/address.rs | 16 +++---- core/startos/src/net/host/mod.rs | 20 ++------- core/startos/src/service/effects/net/ssl.rs | 8 ++-- core/startos/src/version/v0_4_0_alpha_10.rs | 3 +- patch-db | 2 +- 10 files changed, 48 insertions(+), 66 deletions(-) diff --git a/core/Cargo.lock b/core/Cargo.lock index a8a05f3e1..045c919cb 100644 --- a/core/Cargo.lock +++ b/core/Cargo.lock @@ -2,12 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "Inflector" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" - [[package]] name = "addr2line" version = "0.24.2" @@ -3826,8 +3820,7 @@ dependencies = [ [[package]] name = "imbl-value" version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80b000e99a562d9598ae56029f675dbf1104e8aed5a9b074824a752de0a61f39" +source = "git+https://github.com/Start9Labs/imbl-value.git#82b91f973d67139ce5b3f662407f436bc64d2fe9" dependencies = [ "imbl", "serde", @@ -3837,12 +3830,14 @@ dependencies = [ [[package]] name = "imbl-value" -version = "0.4.0" -source = "git+https://github.com/Start9Labs/imbl-value.git#82b91f973d67139ce5b3f662407f436bc64d2fe9" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5a3dc7150969e3a921eeb9790fd9976ce9164148bd26b0c9d7048fb8615ad5" dependencies = [ "imbl", "serde", "serde_json", + "ts-rs", "yasi", ] @@ -4163,7 +4158,7 @@ dependencies = [ name = "json-patch" version = "0.2.7-alpha.0" dependencies = [ - "imbl-value 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "imbl-value 0.4.1", "json-ptr", "serde", ] @@ -4173,7 +4168,7 @@ name = "json-ptr" version = "0.1.0" dependencies = [ "imbl", - "imbl-value 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "imbl-value 0.4.1", "serde", "thiserror 2.0.14", ] @@ -4183,7 +4178,7 @@ name = "jsonpath_lib" version = "0.3.0" source = "git+https://github.com/Start9Labs/jsonpath.git#1cacbd64afa2e1941a21fef06bad14317ba92f30" dependencies = [ - "imbl-value 0.4.0 (git+https://github.com/Start9Labs/imbl-value.git)", + "imbl-value 0.4.0", "log", "serde", "serde_json", @@ -5238,7 +5233,7 @@ dependencies = [ "fd-lock-rs", "futures", "imbl", - "imbl-value 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "imbl-value 0.4.1", "json-patch", "json-ptr", "lazy_static", @@ -6269,7 +6264,7 @@ dependencies = [ "futures", "http", "http-body-util", - "imbl-value 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "imbl-value 0.4.1", "itertools 0.14.0", "lazy_format", "lazy_static", @@ -7345,7 +7340,7 @@ dependencies = [ "hyper-util", "id-pool", "imbl", - "imbl-value 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "imbl-value 0.4.1", "include_dir", "indexmap 2.10.0", "indicatif", @@ -9276,19 +9271,20 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "ts-rs" -version = "8.1.0" -source = "git+https://github.com/dr-bonez/ts-rs.git?branch=feature%2Ftop-level-as#7ae88ade90b5e724159048a663a0bdb04bed27f7" +version = "11.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ef1b7a6d914a34127ed8e1fa927eb7088903787bcded4fa3eef8f85ee1568be" dependencies = [ - "thiserror 1.0.69", + "thiserror 2.0.14", "ts-rs-macros", ] [[package]] name = "ts-rs-macros" -version = "8.1.0" -source = "git+https://github.com/dr-bonez/ts-rs.git?branch=feature%2Ftop-level-as#7ae88ade90b5e724159048a663a0bdb04bed27f7" +version = "11.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9d4ed7b4c18cc150a6a0a1e9ea1ecfa688791220781af6e119f9599a8502a0a" dependencies = [ - "Inflector", "proc-macro2", "quote", "syn 2.0.104", @@ -10312,14 +10308,16 @@ dependencies = [ [[package]] name = "yasi" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f355ab62ebe30b758c1f4ab096a306722c4b7dbfb9d8c07d18c70d71a945588" +checksum = "d7d16d66ba6622e1388f01e378e2543912bf83984c3b90f3b2ccdea919a664a5" dependencies = [ "ahash 0.8.12", "hashbrown 0.13.2", "lazy_static", "serde", + "tinyvec", + "ts-rs", ] [[package]] diff --git a/core/models/Cargo.toml b/core/models/Cargo.toml index e272b11b3..f2903370d 100644 --- a/core/models/Cargo.toml +++ b/core/models/Cargo.toml @@ -31,9 +31,9 @@ rustls = "0.23" serde = { version = "1.0", features = ["derive", "rc"] } serde_json = "1.0" ssh-key = "0.6.2" -ts-rs = { git = "https://github.com/dr-bonez/ts-rs.git", branch = "feature/top-level-as" } # "8" +ts-rs = "11" thiserror = "2.0" tokio = { version = "1", features = ["full"] } tracing = "0.1.39" -yasi = "0.1.5" +yasi = { version = "0.1.6", features = ["serde", "ts-rs"] } zbus = "5" diff --git a/core/startos/Cargo.toml b/core/startos/Cargo.toml index 450a136b4..dc13c19d8 100644 --- a/core/startos/Cargo.toml +++ b/core/startos/Cargo.toml @@ -135,7 +135,7 @@ id-pool = { version = "0.2.2", default-features = false, features = [ "u16", ] } imbl = { version = "6", features = ["serde", "small-chunks"] } -imbl-value = "0.4.0" +imbl-value = { version = "0.4.1", features = ["ts-rs"] } include_dir = { version = "0.7.3", features = ["metadata"] } indexmap = { version = "2.0.2", features = ["serde"] } indicatif = { version = "0.17.7", features = ["tokio"] } @@ -236,7 +236,7 @@ tracing-error = "0.2.0" tracing-futures = "0.2.5" tracing-journald = "0.3.0" tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } -ts-rs = { git = "https://github.com/dr-bonez/ts-rs.git", branch = "feature/top-level-as" } # "8.1.0" +ts-rs = "11.0.1" typed-builder = "0.21.0" unix-named-pipe = "0.2.0" url = { version = "2.4.1", features = ["serde"] } diff --git a/core/startos/src/db/model/public.rs b/core/startos/src/db/model/public.rs index 2330fe96f..79bc20b57 100644 --- a/core/startos/src/db/model/public.rs +++ b/core/startos/src/db/model/public.rs @@ -20,7 +20,7 @@ use crate::db::model::package::AllPackageData; use crate::net::acme::AcmeProvider; use crate::net::forward::START9_BRIDGE_IFACE; use crate::net::host::binding::{AddSslOptions, BindInfo, BindOptions, NetInfo}; -use crate::net::host::{Domains, Host}; +use crate::net::host::Host; use crate::net::utils::ipv6_is_local; use crate::net::vhost::AlpnInfo; use crate::prelude::*; @@ -82,7 +82,8 @@ impl Public { .into_iter() .collect(), onions: account.tor_keys.iter().map(|k| k.onion_address()).collect(), - domains: Domains::default(), + public_domains: BTreeMap::new(), + private_domains: BTreeSet::new(), hostname_info: BTreeMap::new(), }, wifi: WifiInfo { diff --git a/core/startos/src/middleware/auth.rs b/core/startos/src/middleware/auth.rs index cee5af74c..0032b2dc1 100644 --- a/core/startos/src/middleware/auth.rs +++ b/core/startos/src/middleware/auth.rs @@ -88,8 +88,7 @@ impl SignatureAuthContext for RpcContext { .as_server_info() .as_network() .as_host() - .as_domains() - .as_public() + .as_public_domains() .keys() .map(|k| k.into_iter()) .transpose(), @@ -99,8 +98,7 @@ impl SignatureAuthContext for RpcContext { .as_server_info() .as_network() .as_host() - .as_domains() - .as_private() + .as_private_domains() .de() .map(|k| k.into_iter()) .transpose(), diff --git a/core/startos/src/net/host/address.rs b/core/startos/src/net/host/address.rs index 830839e70..3f1d7ffcf 100644 --- a/core/startos/src/net/host/address.rs +++ b/core/startos/src/net/host/address.rs @@ -63,10 +63,10 @@ fn check_duplicates(db: &DatabaseModel) -> Result<(), Error> { for onion in host.as_onions().de()? { check_onion(onion)?; } - for domain in host.as_domains().as_public().keys()? { + for domain in host.as_public_domains().keys()? { check_domain(domain)?; } - for domain in host.as_domains().as_private().de()? { + for domain in host.as_private_domains().de()? { check_domain(domain)?; } } @@ -230,8 +230,7 @@ pub async fn add_public_domain( } Kind::host_for(&inheritance, db)? - .as_domains_mut() - .as_public_mut() + .as_public_domains_mut() .insert(domain, &PublicDomainConfig { acme, gateway })?; check_duplicates(db) }) @@ -255,8 +254,7 @@ pub async fn remove_public_domain( ctx.db .mutate(|db| { Kind::host_for(&inheritance, db)? - .as_domains_mut() - .as_public_mut() + .as_public_domains_mut() .remove(&domain) }) .await @@ -279,8 +277,7 @@ pub async fn add_private_domain( ctx.db .mutate(|db| { Kind::host_for(&inheritance, db)? - .as_domains_mut() - .as_private_mut() + .as_private_domains_mut() .mutate(|d| Ok(d.insert(domain)))?; check_duplicates(db) }) @@ -299,8 +296,7 @@ pub async fn remove_private_domain( ctx.db .mutate(|db| { Kind::host_for(&inheritance, db)? - .as_domains_mut() - .as_private_mut() + .as_private_domains_mut() .mutate(|d| Ok(d.remove(&domain))) }) .await diff --git a/core/startos/src/net/host/mod.rs b/core/startos/src/net/host/mod.rs index db0c20c4d..5b10f3d9c 100644 --- a/core/startos/src/net/host/mod.rs +++ b/core/startos/src/net/host/mod.rs @@ -30,22 +30,12 @@ pub struct Host { pub bindings: BTreeMap, #[ts(type = "string[]")] pub onions: BTreeSet, - pub domains: Domains, + pub public_domains: BTreeMap, + pub private_domains: BTreeSet, /// COMPUTED: NetService::update pub hostname_info: BTreeMap>, // internal port -> Hostnames } -#[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)] -#[serde(rename_all = "camelCase")] -#[model = "Model"] -#[ts(export)] -pub struct Domains { - #[ts(as = "BTreeMap::")] - pub public: BTreeMap, - #[ts(as = "BTreeSet::")] - pub private: BTreeSet, -} - impl AsRef for Host { fn as_ref(&self) -> &Host { self @@ -61,8 +51,7 @@ impl Host { .cloned() .map(|address| HostAddress::Onion { address }) .chain( - self.domains - .public + self.public_domains .iter() .map(|(address, config)| HostAddress::Domain { address: address.clone(), @@ -70,8 +59,7 @@ impl Host { }), ) .chain( - self.domains - .private + self.private_domains .iter() .map(|address| HostAddress::Domain { address: address.clone(), diff --git a/core/startos/src/service/effects/net/ssl.rs b/core/startos/src/service/effects/net/ssl.rs index 7275f1791..8cf278fa4 100644 --- a/core/startos/src/service/effects/net/ssl.rs +++ b/core/startos/src/service/effects/net/ssl.rs @@ -59,8 +59,8 @@ pub async fn get_ssl_certificate( .de()? .iter() .map(InternedString::from_display) - .chain(m.as_domains().as_public().keys()?) - .chain(m.as_domains().as_private().de()?) + .chain(m.as_public_domains().keys()?) + .chain(m.as_private_domains().de()?) .chain( m.as_hostname_info() .de()? @@ -185,8 +185,8 @@ pub async fn get_ssl_key( .de()? .iter() .map(InternedString::from_display) - .chain(m.as_domains().as_public().keys()?) - .chain(m.as_domains().as_private().de()?) + .chain(m.as_public_domains().keys()?) + .chain(m.as_private_domains().de()?) .chain( m.as_hostname_info() .de()? diff --git a/core/startos/src/version/v0_4_0_alpha_10.rs b/core/startos/src/version/v0_4_0_alpha_10.rs index 6c553f312..2fdd1839a 100644 --- a/core/startos/src/version/v0_4_0_alpha_10.rs +++ b/core/startos/src/version/v0_4_0_alpha_10.rs @@ -87,7 +87,8 @@ impl VersionT for Version { } } - host["domains"] = json!({ "public": &public, "private": &private }); + host["publicDomains"] = to_value(&public)?; + host["privateDomains"] = to_value(&private)?; } } let network = &mut db["public"]["serverInfo"]["network"]; diff --git a/patch-db b/patch-db index 223b1af4f..d2f38ef5f 160000 --- a/patch-db +++ b/patch-db @@ -1 +1 @@ -Subproject commit 223b1af4f59d36dc68d7f038ef77d37a8f058d24 +Subproject commit d2f38ef5f711ea73937cd3bca2623b3193b519da