| 217 | } |
| 218 | |
| 219 | Either<String, HostAddressWithPort> HostAddressWithPort::lookupWithPort(String const& address) { |
| 220 | String host = address; |
| 221 | String port = host.rextract(":"); |
| 222 | if (host.beginsWith("[") && host.endsWith("]")) |
| 223 | host = host.substr(1, host.size() - 2); |
| 224 | |
| 225 | auto portNum = maybeLexicalCast<uint16_t>(port); |
| 226 | if (!portNum) |
| 227 | return makeLeft(strf("Could not parse port portion of HostAddressWithPort '{}'", port)); |
| 228 | |
| 229 | auto hostAddress = HostAddress::lookup(host); |
| 230 | if (hostAddress.isLeft()) |
| 231 | return makeLeft(std::move(hostAddress.left())); |
| 232 | |
| 233 | return makeRight(HostAddressWithPort(std::move(hostAddress.right()), *portNum)); |
| 234 | } |
| 235 | |
| 236 | HostAddressWithPort::HostAddressWithPort() : m_port(0) {} |
| 237 |
nothing calls this directly
no test coverage detected