From: Maxim Mamontov Date: Thu, 15 Oct 2015 14:47:26 +0000 (+0300) Subject: Parse TCP port correctly. X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/892d3409f087a2dfb3daafdd5873114c400127a8?ds=inline;hp=418ecfb85b58d140aa9c786d837b27d79d3187ce Parse TCP port correctly. --- diff --git a/projects/stargazer/plugins/other/radius/config.cpp b/projects/stargazer/plugins/other/radius/config.cpp index 6a29f002..6742f811 100644 --- a/projects/stargazer/plugins/other/radius/config.cpp +++ b/projects/stargazer/plugins/other/radius/config.cpp @@ -167,6 +167,14 @@ T toInt(const std::vector& values) return 0; } +uint16_t toPort(const std::string& value) +{ + uint16_t res = 0; + if (str2x(value, res) == 0) + return res; + throw ParserError(0, "'" + value + "' is not a valid port number."); +} + typedef std::map Codes; // One-time call to initialize the list of codes. @@ -229,11 +237,31 @@ std::string parseString(const std::string& paramName, const std::vector