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

Function check_proxy_config

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

Source from the content-addressed store, hash-verified

306}
307
308async 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}
338fn gather_sources(
339 plugin: &ConfiguredPlugin<PluginState, tokio::io::Stdin, tokio::io::Stdout>,
340 has_proxy: bool,

Callers 1

mainFunction · 0.85

Calls 5

joinMethod · 0.80
configurationMethod · 0.80
call_rawMethod · 0.80
as_strMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected