From a40ef1a19de1727f5d9599a0071a0896be6e8340 Mon Sep 17 00:00:00 2001 From: Javier Villanueva Date: Thu, 11 Apr 2024 00:11:57 +0100 Subject: [PATCH 1/2] Add default content proxy to env command --- src/subcommand/env.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/subcommand/env.rs b/src/subcommand/env.rs index 9e2a4058f3..b1f786eb6f 100644 --- a/src/subcommand/env.rs +++ b/src/subcommand/env.rs @@ -97,6 +97,7 @@ rpcport={bitcoind_port} .arg("--polling-interval=100ms") .arg("--http-port") .arg(ord_port.to_string()) + .arg("--content-proxy=https://ordinals.com") .spawn()?, ); From 99f449862951b2624f417e1a4e8e38694628e0f6 Mon Sep 17 00:00:00 2001 From: Javier Villanueva Date: Mon, 15 Apr 2024 17:10:05 +0100 Subject: [PATCH 2/2] Add content proxy and decompress args to env --- src/subcommand/env.rs | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/src/subcommand/env.rs b/src/subcommand/env.rs index 57dcbf5d1b..d6382f10da 100644 --- a/src/subcommand/env.rs +++ b/src/subcommand/env.rs @@ -17,6 +17,16 @@ impl Drop for KillOnDrop { pub(crate) struct Env { #[arg(default_value = "env", help = "Create env in .")] directory: PathBuf, + #[arg( + long, + help = "Decompress encoded content. Currently only supports brotli. Be careful using this on production instances. A decompressed inscription may be arbitrarily large, making decompression a DoS vector." + )] + pub(crate) decompress: bool, + #[arg( + long, + help = "Proxy `/content/INSCRIPTION_ID` requests to `/content/INSCRIPTION_ID` if the inscription is not present on current chain." + )] + pub(crate) content_proxy: Option, } #[derive(Serialize)] @@ -91,17 +101,27 @@ rpcport={bitcoind_port} let ord = std::env::current_exe()?; - let _ord = KillOnDrop( - Command::new(&ord) - .arg("--datadir") - .arg(&absolute) - .arg("server") - .arg("--polling-interval=100ms") - .arg("--http-port") - .arg(ord_port.to_string()) - .arg("--content-proxy=https://ordinals.com") - .spawn()?, - ); + let decompress = self.decompress; + let content_proxy = self.content_proxy.map(|url| url.to_string()); + + let mut command = Command::new(&ord); + let ord_server = command + .arg("--datadir") + .arg(&absolute) + .arg("server") + .arg("--polling-interval=100ms") + .arg("--http-port") + .arg(ord_port.to_string()); + + if decompress { + ord_server.arg("--decompress"); + } + + if let Some(content_proxy) = content_proxy { + ord_server.arg("--content-proxy").arg(content_proxy); + } + + let _ord = KillOnDrop(ord_server.spawn()?); thread::sleep(Duration::from_millis(250));