Skip to content

Commit

Permalink
Set --disable-json-api with environment variable (#4154)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Dec 26, 2024
1 parent c647df4 commit 1b40956
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ boilerplate = { version = "1.0.0", features = ["axum"] }
brotli = "7.0.0"
chrono = { version = "0.4.19", features = ["serde"] }
ciborium = "0.2.1"
clap = { version = "4.4.2", features = ["derive"] }
clap = { version = "4.4.2", features = ["derive", "env"] }
colored = "2.0.4"
ctrlc = { version = "3.2.1", features = ["termination"] }
dirs = "5.0.0"
Expand Down
3 changes: 1 addition & 2 deletions deploy/ord.service
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ ExecStart=/usr/local/bin/ord \
--acme-contact mailto:[email protected] \
--csp-origin https://${CSP_ORIGIN} \
--http \
--https \
--disable-json-api
--https
Group=ord
LimitNOFILE=65536
MemoryDenyWriteExecute=true
Expand Down
16 changes: 12 additions & 4 deletions deploy/setup
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,17 @@ mkdir -p \
/etc/systemd/system/bitcoind.service.d \
/etc/systemd/system/ord.service.d

printf "[Service]\nEnvironment=CHAIN=%s\nEnvironment=CSP_ORIGIN=%s\n" $CHAIN $CSP_ORIGIN \
| tee /etc/systemd/system/bitcoind.service.d/override.conf \
> /etc/systemd/system/ord.service.d/override.conf
OVERRIDE=/etc/systemd/system/ord.service.d/override.conf

echo '[Service]' > $OVERRIDE
echo "Environment=CHAIN=$CHAIN" >> $OVERRIDE
echo "Environment=CSP_ORIGIN=$CSP_ORIGIN" >> $OVERRIDE

if [[ $CHAIN == main ]]; then
echo Environment=ORD_SERVER_DISABLE_JSON_API=true >> $OVERRIDE
fi

cp $OVERRIDE /etc/systemd/system/bitcoind.service.d/override.conf

sed -i -E 's/#?PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
sshd -t
Expand All @@ -89,7 +97,7 @@ fi

bitcoind --version

chown bitcoin:bitcoin /var/lib/bitcoind/settings.json
rm -f /var/lib/bitcoind/settings.json

if [[ ! -e ~/.cargo/env ]]; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub struct Server {
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 = "Disable JSON API.")]
#[arg(long, env = "ORD_SERVER_DISABLE_JSON_API", help = "Disable JSON API.")]
pub(crate) disable_json_api: bool,
#[arg(
long,
Expand Down

0 comments on commit 1b40956

Please sign in to comment.