(&self)
| 240 | } |
| 241 | |
| 242 | pub fn get_domain(&self) -> Result<String, ProxyError> { |
| 243 | match self { |
| 244 | ProxyScheme::Http { host, .. } | ProxyScheme::Https { host, .. } => { |
| 245 | let domain = host |
| 246 | .split(':') |
| 247 | .next() |
| 248 | .ok_or_else(|| ProxyError::AddressResolutionFailed(host.clone()))?; |
| 249 | Ok(domain.to_string()) |
| 250 | } |
| 251 | ProxyScheme::Socks5 { addr, .. } => match addr { |
| 252 | SocketAddr::V4(addr_v4) => Ok(addr_v4.ip().to_string()), |
| 253 | SocketAddr::V6(addr_v6) => Ok(addr_v6.ip().to_string()), |
| 254 | }, |
| 255 | } |
| 256 | } |
| 257 | pub fn get_host_and_port(&self) -> Result<String, ProxyError> { |
| 258 | match self { |
| 259 | ProxyScheme::Http { host, .. } => Ok(self.append_default_port(host, 80)), |
no test coverage detected