diff --git a/snix/Cargo.lock b/snix/Cargo.lock index e15738ea1..b1f7dbb1d 100644 --- a/snix/Cargo.lock +++ b/snix/Cargo.lock @@ -4258,13 +4258,10 @@ dependencies = [ "axum-range", "axum-test", "blake3", - "bytes", "clap", - "data-encoding", "mime", "mime_guess", "path-clean", - "prost", "snix-castore", "tokio", "tokio-listener", diff --git a/snix/Cargo.nix b/snix/Cargo.nix index 529cce9e9..1f4220f74 100644 --- a/snix/Cargo.nix +++ b/snix/Cargo.nix @@ -13966,19 +13966,11 @@ rec { name = "axum-range"; packageId = "axum-range"; } - { - name = "bytes"; - packageId = "bytes"; - } { name = "clap"; packageId = "clap"; features = [ "derive" ]; } - { - name = "data-encoding"; - packageId = "data-encoding"; - } { name = "mime"; packageId = "mime"; @@ -13991,10 +13983,6 @@ rec { name = "path-clean"; packageId = "path-clean"; } - { - name = "prost"; - packageId = "prost"; - } { name = "snix-castore"; packageId = "snix-castore"; diff --git a/snix/castore-http/Cargo.toml b/snix/castore-http/Cargo.toml index 62a778bf3..98312e042 100644 --- a/snix/castore-http/Cargo.toml +++ b/snix/castore-http/Cargo.toml @@ -8,13 +8,10 @@ anyhow.workspace = true axum = { workspace = true, features = ["tracing"] } axum-extra.workspace = true axum-range.workspace = true -bytes.workspace = true clap = { workspace = true, features = ["derive"] } -data-encoding.workspace = true mime_guess = "2.0.5" mime = "0.3.17" path-clean.workspace = true -prost.workspace = true tokio = { workspace = true, features = [ "tracing"] } tokio-listener = { workspace = true, features = ["axum07", "clap", "multi-listener", "sd_listen"] } tracing.workspace = true diff --git a/snix/castore-http/src/cli.rs b/snix/castore-http/src/cli.rs index 49572c031..e6c7e54ae 100644 --- a/snix/castore-http/src/cli.rs +++ b/snix/castore-http/src/cli.rs @@ -1,5 +1,5 @@ use clap::Parser; -use snix_castore::utils::ServiceUrlsGrpc; +use snix_castore::{utils::ServiceUrlsGrpc, B3Digest}; #[derive(Parser)] #[command(author, version, about)] @@ -10,13 +10,9 @@ pub struct CliArgs { // The castore services addresses #[clap(flatten)] pub service_addrs: ServiceUrlsGrpc, - /// The castore root node to serve, URL-safe base64-encoded - #[arg( - short, - long, - help = "The castore root node to serve, URL-safe base64-encoded" - )] - pub root_node: String, + /// The root directory digest to serve. + #[arg(short, long, help = "The root directory digest to serve")] + pub root_directory: B3Digest, /// The name of the file to serve if a client requests a directory e.g. index.html index.htm #[arg( short, diff --git a/snix/castore-http/src/main.rs b/snix/castore-http/src/main.rs index 3ab52a31d..6936feca4 100644 --- a/snix/castore-http/src/main.rs +++ b/snix/castore-http/src/main.rs @@ -1,47 +1,23 @@ -use snix_castore_http::cli::CliArgs; - -use anyhow::{bail, Context}; -use bytes::Bytes; use clap::Parser; -use data_encoding::BASE64URL_NOPAD; -use prost::Message; +use snix_castore::Node; +use snix_castore_http::cli::CliArgs; #[tokio::main] async fn main() -> anyhow::Result<()> { tracing_subscriber::fmt().init(); - let CliArgs { - listen_args, - service_addrs, - root_node, - index_names, - auto_index, - }: CliArgs = snix_castore_http::cli::CliArgs::parse(); - - // b64decode the root node passed *by the user* - let root_entry_proto = BASE64URL_NOPAD - .decode(root_node.as_bytes()) - .context("unable to decode root node b64")?; - - // check the proto size to be somewhat reasonable before parsing it. - if root_entry_proto.len() > 4096 { - bail!("rejected, too large root node"); - } - - // parse the proto - let root_entry: snix_castore::proto::Entry = Message::decode(Bytes::from(root_entry_proto)) - .context("unable to decode root node proto")?; - - let root_node = root_entry - .try_into_anonymous_node() - .context("root node validation failed")?; + let args: CliArgs = snix_castore_http::cli::CliArgs::parse(); snix_castore_http::router::gen_router( - listen_args, - service_addrs, - root_node, - &index_names, - auto_index, + args.listen_args, + args.service_addrs, + Node::Directory { + digest: args.root_directory, + // size doesn't really matter here, we're not doing inode allocation. + size: 0, + }, + &args.index_names, + args.auto_index, ) .await }