MCPcopy Create free account
hub / github.com/SeismicSystems/summit / parse_ingress

Function parse_ingress

types/src/bootstrap.rs:26–47  ·  view source on GitHub ↗

Parse an address string into an Ingress. Supports both IP:port (e.g., "127.0.0.1:18551") and domain:port (e.g., "node.example.com:18551")

(address: &str)

Source from the content-addressed store, hash-verified

24/// Parse an address string into an Ingress.
25/// Supports both IP:port (e.g., "127.0.0.1:18551") and domain:port (e.g., "node.example.com:18551")
26fn parse_ingress(address: &str) -> Result<Ingress, Box<dyn std::error::Error>> {
27 // Try to parse as a socket address first (IP:port)
28 if let Ok(socket_addr) = address.parse::<SocketAddr>() {
29 return Ok(Ingress::from(socket_addr));
30 }
31
32 // Otherwise, try to parse as hostname:port
33 let (host, port_str) = address
34 .rsplit_once(':')
35 .ok_or_else(|| format!("Invalid address format (expected host:port): {address}"))?;
36
37 let port: u16 = port_str
38 .parse()
39 .map_err(|_| format!("Invalid port number: {port_str}"))?;
40
41 let hostname = Hostname::new(host).map_err(|e| format!("Invalid hostname '{host}': {e}"))?;
42
43 Ok(Ingress::Dns {
44 host: hostname,
45 port,
46 })
47}
48
49impl Bootstrappers {
50 /// Load bootstrappers from a TOML file

Callers 5

to_ingress_listMethod · 0.85
test_parse_ingress_dnsFunction · 0.85

Calls

no outgoing calls

Tested by 4

test_parse_ingress_dnsFunction · 0.68