Parse gateway input into base_domain and gateway URI Input: `base_domain[:port]`, e.g., `example.com` or `example.com:8443` Output: (base_domain, gateway_uri)
(gateway: &str)
| 130 | /// Input: `base_domain[:port]`, e.g., `example.com` or `example.com:8443` |
| 131 | /// Output: (base_domain, gateway_uri) |
| 132 | fn parse_gateway(gateway: &str) -> Result<(String, String)> { |
| 133 | let (base_domain, port) = match gateway.rsplit_once(':') { |
| 134 | Some((domain, port_str)) => { |
| 135 | // Validate port is a number |
| 136 | let _: u16 = port_str.parse().context("invalid port number")?; |
| 137 | (domain.to_string(), Some(port_str.to_string())) |
| 138 | } |
| 139 | None => (gateway.to_string(), None), |
| 140 | }; |
| 141 | |
| 142 | let gateway_uri = match port { |
| 143 | Some(p) => format!("https://gateway.{}:{}", base_domain, p), |
| 144 | None => format!("https://gateway.{}", base_domain), |
| 145 | }; |
| 146 | |
| 147 | Ok((base_domain, gateway_uri)) |
| 148 | } |
| 149 | |
| 150 | /// Compute expected report_data for a public key using zt-cert content type |
| 151 | fn compute_expected_report_data(public_key: &[u8]) -> [u8; 64] { |