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

Function parse_proxy_addr

plugins/currencyrate-plugin/src/main.rs:329–346  ·  view source on GitHub ↗
(proxy_str: &str)

Source from the content-addressed store, hash-verified

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) {
331 addr
332 } else if let Ok(ip) = IpAddr::from_str(proxy_str) {
333 SocketAddr::new(ip, DEFAULT_PROXY_PORT)
334 } else {
335 return Err(anyhow!("Could not parse proxy value: {proxy_str}"));
336 };
337
338 if addr.is_ipv6() {
339 return Err(anyhow!(
340 "IPv6 proxy addresses are not supported by bitreq (got `{proxy_str}`); \
341 use an IPv4 address instead"
342 ));
343 }
344
345 Ok(addr)
346}
347
348#[test]
349fn test_parse_proxy_addr() {

Callers 2

check_proxy_configFunction · 0.85
test_parse_proxy_addrFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_parse_proxy_addrFunction · 0.68