MCPcopy Create free account
hub / github.com/XTXMarkets/ternfs / parseRegistryAddress

Function parseRegistryAddress

cpp/core/RegistryClient.cpp:432–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432bool 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}

Callers 1

Calls 3

findMethod · 0.80
beginMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected