| 306 | } |
| 307 | |
| 308 | async fn check_proxy_config( |
| 309 | plugin: &ConfiguredPlugin<PluginState, tokio::io::Stdin, tokio::io::Stdout>, |
| 310 | ) -> Result<Option<SocketAddr>, anyhow::Error> { |
| 311 | let rpc_path = |
| 312 | Path::new(&plugin.configuration().lightning_dir).join(plugin.configuration().rpc_file); |
| 313 | let mut rpc = ClnRpc::new(rpc_path).await?; |
| 314 | |
| 315 | let listconfigs_val: Value = rpc.call_raw("listconfigs", &json!(["proxy"])).await?; |
| 316 | let configs_val = listconfigs_val |
| 317 | .get("configs") |
| 318 | .ok_or(anyhow!("Missing configs"))?; |
| 319 | let Some(proxy_val) = configs_val.get("proxy") else { |
| 320 | return Ok(None); |
| 321 | }; |
| 322 | let proxy_str = proxy_val |
| 323 | .get("value_str") |
| 324 | .ok_or(anyhow!("proxy missing value_str"))? |
| 325 | .as_str() |
| 326 | .ok_or(anyhow!("proxy value is not a string"))?; |
| 327 | |
| 328 | if let Ok(addr) = SocketAddr::from_str(proxy_str) { |
| 329 | return Ok(Some(addr)); |
| 330 | } |
| 331 | |
| 332 | if let Ok(ip) = IpAddr::from_str(proxy_str) { |
| 333 | return Ok(Some(SocketAddr::new(ip, DEFAULT_PROXY_PORT))); |
| 334 | } |
| 335 | |
| 336 | Err(anyhow!("Could not parse proxy value: {proxy_str}")) |
| 337 | } |
| 338 | fn gather_sources( |
| 339 | plugin: &ConfiguredPlugin<PluginState, tokio::io::Stdin, tokio::io::Stdout>, |
| 340 | has_proxy: bool, |