9inline std::string DecodeUrl(
const std::string& encoded) {
13 for (i = 0; i < encoded.length(); i++) {
14 if (encoded[i] ==
'%') {
15 sscanf(encoded.substr(i + 1, 2).c_str(),
"%x", &j);
16 ch =
static_cast<char>(j);
19 }
else if (encoded[i] ==
'+') {
22 decoded += encoded[i];
28inline bool ParseIPAndFamily(std::string addr, std::string& ip,
int& family) {
29 addr = DecodeUrl(addr);
31 std::regex ipv4_regex(R
"(ipv4:([\d\.]+):\d+)");
32 std::regex ipv6_regex(R"(ipv6:\[([0-9a-fA-F:]+)\]:\d+)");
35 if (std::regex_search(addr, match, ipv4_regex)) {
39 }
else if (std::regex_search(addr, match, ipv6_regex)) {