diff options
Diffstat (limited to 'Swiften/Network/WindowsProxyProvider.cpp')
-rw-r--r-- | Swiften/Network/WindowsProxyProvider.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Swiften/Network/WindowsProxyProvider.cpp b/Swiften/Network/WindowsProxyProvider.cpp index 78bd72f..13fdb25 100644 --- a/Swiften/Network/WindowsProxyProvider.cpp +++ b/Swiften/Network/WindowsProxyProvider.cpp @@ -17,6 +17,7 @@ #include <stdlib.h> #include <boost/lexical_cast.hpp> +#include <boost/numeric/conversion/cast.hpp> #include <windows.h> @@ -51,7 +52,7 @@ WindowsProxyProvider::WindowsProxyProvider() for(auto&& proxy : proxies) { if(proxy.find('=') != std::string::npos) { protocolAndProxy = String::getSplittedAtFirst(proxy, '='); - SWIFT_LOG(debug) << "Found proxy: " << protocolAndProxy.first << " => " << protocolAndProxy.second << std::endl; + SWIFT_LOG(debug) << "Found proxy: " << protocolAndProxy.first << " => " << protocolAndProxy.second; if(protocolAndProxy.first.compare("socks") == 0) { socksProxy = getAsHostAddressPort(protocolAndProxy.second); } @@ -77,15 +78,15 @@ HostAddressPort WindowsProxyProvider::getAsHostAddressPort(std::string proxy) { try { std::pair<std::string, std::string> tmp; - int port = 0; + unsigned short port = 0; tmp = String::getSplittedAtFirst(proxy, ':'); // .c_str() is needed as tmp.second can include a \0 char which will end in an exception of the lexical cast. // with .c_str() the \0 will not be part of the string which is to be casted - port = boost::lexical_cast<int> (tmp.second.c_str()); + port = boost::numeric_cast<unsigned short>(boost::lexical_cast<int> (tmp.second.c_str())); ret = HostAddressPort(HostAddress::fromString(tmp.first).get(), port); } catch(...) { - SWIFT_LOG(error) << "Exception occured while parsing windows proxy \"getHostAddressPort\"." << std::endl; + SWIFT_LOG(error) << "Exception occured while parsing windows proxy \"getHostAddressPort\"."; } return ret; |