(
plugin: &ConfiguredPlugin<PluginState, tokio::io::Stdin, tokio::io::Stdout>,
)
| 304 | } |
| 305 | |
| 306 | async fn check_proxy_config( |
| 307 | plugin: &ConfiguredPlugin<PluginState, tokio::io::Stdin, tokio::io::Stdout>, |
| 308 | ) -> Result<Option<SocketAddr>, anyhow::Error> { |
| 309 | let rpc_path = |
| 310 | Path::new(&plugin.configuration().lightning_dir).join(plugin.configuration().rpc_file); |
| 311 | let mut rpc = ClnRpc::new(rpc_path).await?; |
| 312 | |
| 313 | let listconfigs_val: Value = rpc.call_raw("listconfigs", &json!(["proxy"])).await?; |
| 314 | let configs_val = listconfigs_val |
| 315 | .get("configs") |
| 316 | .ok_or(anyhow!("Missing configs"))?; |
| 317 | let Some(proxy_val) = configs_val.get("proxy") else { |
| 318 | return Ok(None); |
| 319 | }; |
| 320 | let proxy_str = proxy_val |
| 321 | .get("value_str") |
| 322 | .ok_or(anyhow!("proxy missing value_str"))? |
| 323 | .as_str() |
| 324 | .ok_or(anyhow!("proxy value is not a string"))?; |
| 325 | |
| 326 | parse_proxy_addr(proxy_str).map(Some) |
| 327 | } |
| 328 | |
| 329 | fn parse_proxy_addr(proxy_str: &str) -> Result<SocketAddr, anyhow::Error> { |
| 330 | let addr = if let Ok(addr) = SocketAddr::from_str(proxy_str) { |
no test coverage detected