MCPcopy Create free account
hub / github.com/ElementsProject/lightning / check_proxy_config

Function check_proxy_config

plugins/currencyrate-plugin/src/main.rs:306–327  ·  view source on GitHub ↗
(
    plugin: &ConfiguredPlugin<PluginState, tokio::io::Stdin, tokio::io::Stdout>,
)

Source from the content-addressed store, hash-verified

304}
305
306async 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
329fn parse_proxy_addr(proxy_str: &str) -> Result<SocketAddr, anyhow::Error> {
330 let addr = if let Ok(addr) = SocketAddr::from_str(proxy_str) {

Callers 1

mainFunction · 0.85

Calls 7

parse_proxy_addrFunction · 0.85
joinMethod · 0.80
configurationMethod · 0.80
call_rawMethod · 0.80
as_strMethod · 0.80
mapMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected