| 430 | } |
| 431 | |
| 432 | bool parseRegistryAddress(const std::string& fullRegistryAddress, std::string& registryHost, uint16_t& registryPort) { |
| 433 | // split host:port |
| 434 | auto colon = fullRegistryAddress.find(":"); |
| 435 | if (colon == fullRegistryAddress.size()) { |
| 436 | std::cerr << "Could not find colon" << std::endl; |
| 437 | return false; |
| 438 | } |
| 439 | // parse port |
| 440 | if (fullRegistryAddress.size() - colon > 6) { |
| 441 | return false; // port too long |
| 442 | } |
| 443 | uint32_t port = 0; |
| 444 | for (int i = colon + 1; i < fullRegistryAddress.size(); i++) { |
| 445 | char ch = fullRegistryAddress[i]; |
| 446 | if ((i == colon + 1 && ch == '0') || ch < '0' || ch > '9') { |
| 447 | return false; |
| 448 | } |
| 449 | port = port*10 + (ch-'0'); |
| 450 | } |
| 451 | if (port == 0 || port > 65535) { |
| 452 | return false; |
| 453 | } |
| 454 | registryPort = port; |
| 455 | registryHost = {fullRegistryAddress.begin(), fullRegistryAddress.begin()+colon}; |
| 456 | return true; |
| 457 | } |
no test coverage detected