# HG changeset patch # User František Kučera # Date 1659780766 -7200 # Node ID b9dcb7aa75e1fab05fbbbcfffe2a52d087555056 # Parent 63bb2c2038c723318ad3cfd265c9952a84062a96 support literal IPv6 addresses in connection strings diff -r 63bb2c2038c7 -r b9dcb7aa75e1 src/CLIParser.h --- a/src/CLIParser.h Sat Aug 06 01:05:44 2022 +0200 +++ b/src/CLIParser.h Sat Aug 06 12:12:46 2022 +0200 @@ -85,14 +85,16 @@ // Parse the connection string and convert it to options: if (connectionString.size()) { std::string connectionStringBytes = convertor.to_bytes(connectionString); - std::regex pattern("(tcp|udp|sctp)://([^:]+):([0-9]+)|(uds)://(.*)"); + std::regex pattern("(tcp|udp|sctp)://(([^:]+)|\\[([0-9a-fA-F:]+)\\]):([0-9]+)|(uds)://(.*)"); + // 1 23 4 5 6 7 std::smatch match; if (std::regex_match(connectionStringBytes, match, pattern)) { setIfMissing(c.options, OPTION_PROTOCOL, match[1], false); - setIfMissing(c.options, OPTION_PROTOCOL, match[4], false); - setIfMissing(c.options, OPTION_HOST, match[2], false); - setIfMissing(c.options, OPTION_PORT, match[3], false); - setIfMissing(c.options, OPTION_PATH, match[5], false); + setIfMissing(c.options, OPTION_PROTOCOL, match[6], false); + setIfMissing(c.options, OPTION_HOST, match[3], false); + setIfMissing(c.options, OPTION_HOST, match[4], false); + setIfMissing(c.options, OPTION_PORT, match[5], false); + setIfMissing(c.options, OPTION_PATH, match[7], false); if (match[1] == PROTOCOL_TCP) setIfMissing(c.options, OPTION_MODE, MODE_STREAM); } else { throw relpipe::cli::RelpipeCLIException(L"Invalid connection string: " + connectionString, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);