diff --git a/Makefile b/Makefile index 9e5228a..3ccd19d 100644 --- a/Makefile +++ b/Makefile @@ -37,9 +37,9 @@ else endif @start-sdk pack -install: -ifeq (,$(wildcard ~/.embassy/config.yaml)) - @echo; echo "You must define \"host: http://server-name.local\" in ~/.embassy/config.yaml config file first"; echo +install: $(PKG_ID).s9pk +ifeq (,$(wildcard ./start9/config.yaml)) + @echo; echo "You must define \"host: http://server-name.local\" in ./start9/config.yaml config file first"; echo else start-cli package install $(PKG_ID).s9pk endif diff --git a/manager/src/main.rs b/manager/src/main.rs index ea177a8..dc1323a 100644 --- a/manager/src/main.rs +++ b/manager/src/main.rs @@ -31,6 +31,13 @@ pub struct ChainInfo { softforks: LinearMap, } +#[derive(Clone, Debug, serde::Deserialize)] +pub struct NetworkInfo { + connections: usize, + connections_in: usize, + connections_out: usize, +} + #[derive(Clone, Debug, serde::Deserialize)] #[serde(tag = "type")] pub enum SoftFork { @@ -372,6 +379,31 @@ fn sidecar(config: &Mapping, addr: &str) -> Result<(), Box> { std::str::from_utf8(&info_res.stderr).unwrap_or("UNKNOWN ERROR") ); } + let info_res = std::process::Command::new("bitcoin-cli") + .arg("-conf=/root/.bitcoin/bitcoin.conf") + .arg("getnetworkinfo") + .output()?; + if info_res.status.success() { + let info: NetworkInfo = serde_json::from_slice(&info_res.stdout)?; + stats.insert( + Cow::from("Connections"), + Stat { + value_type: "string", + value: format!("{} ({} in / {} out)", info.connections, info.connections_in, info.connections_out), + description: Some(Cow::from("The number of peers connected (inbound and outbound)")), + copyable: false, + qr: false, + masked: false, + }, + ); + } else if info_res.status.code() == Some(28) { + return Ok(()); + } else { + eprintln!( + "Error updating network info: {}", + std::str::from_utf8(&info_res.stderr).unwrap_or("UNKNOWN ERROR") + ); + } serde_yaml::to_writer( std::fs::File::create("/root/.bitcoin/start9/.stats.yaml.tmp")?, &Stats {