diff options
Diffstat (limited to 'Swiften/Network')
21 files changed, 94 insertions, 93 deletions
diff --git a/Swiften/Network/BOSHConnection.cpp b/Swiften/Network/BOSHConnection.cpp index aaec9f2..1312a3e 100644 --- a/Swiften/Network/BOSHConnection.cpp +++ b/Swiften/Network/BOSHConnection.cpp @@ -74,27 +74,27 @@ void BOSHConnection::cancelConnector() { } void BOSHConnection::handleTLSConnected() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); onConnectFinished(false); } void BOSHConnection::handleTLSApplicationDataRead(const SafeByteArray& data) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); handleDataRead(std::make_shared<SafeByteArray>(data)); } void BOSHConnection::handleTLSNetowrkDataWriteRequest(const SafeByteArray& data) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); connection_->write(data); } void BOSHConnection::handleRawDataRead(std::shared_ptr<SafeByteArray> data) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); tlsLayer_->handleDataRead(*data.get()); } void BOSHConnection::handleTLSError(std::shared_ptr<TLSError> error) { - SWIFT_LOG(debug) << (error ? error->getMessage() : "Unknown TLS error") << std::endl; + SWIFT_LOG(debug) << (error ? error->getMessage() : "Unknown TLS error"); } void BOSHConnection::writeData(const SafeByteArray& data) { @@ -123,7 +123,7 @@ void BOSHConnection::restartStream() { bool BOSHConnection::setClientCertificate(CertificateWithKey::ref cert) { if (tlsLayer_) { - SWIFT_LOG(debug) << "set client certificate" << std::endl; + SWIFT_LOG(debug) << "set client certificate"; return tlsLayer_->setClientCertificate(cert); } else { @@ -211,7 +211,7 @@ void BOSHConnection::write(const SafeByteArray& data, bool streamRestart, bool t writeData(safeHeader); pending_ = true; - SWIFT_LOG(debug) << "write data: " << safeByteArrayToString(safeHeader) << std::endl; + SWIFT_LOG(debug) << "write data: " << safeByteArrayToString(safeHeader); } void BOSHConnection::handleConnectFinished(Connection::ref connection) { @@ -275,7 +275,7 @@ void BOSHConnection::startStream(const std::string& to, unsigned long long rid) SafeByteArray safeHeader = createSafeByteArray(header.str()); onBOSHDataWritten(safeHeader); writeData(safeHeader); - SWIFT_LOG(debug) << "write stream header: " << safeByteArrayToString(safeHeader) << std::endl; + SWIFT_LOG(debug) << "write stream header: " << safeByteArrayToString(safeHeader); } void BOSHConnection::handleDataRead(std::shared_ptr<SafeByteArray> data) { diff --git a/Swiften/Network/BOSHConnection.h b/Swiften/Network/BOSHConnection.h index c492ac4..f0a946a 100644 --- a/Swiften/Network/BOSHConnection.h +++ b/Swiften/Network/BOSHConnection.h @@ -31,7 +31,7 @@ namespace Swift { class XMLParserFactory; class TLSContextFactory; class TLSLayer; - struct TLSOptions; + class TLSOptions; class HighLayer; class SWIFTEN_API BOSHError : public SessionStream::SessionStreamError { diff --git a/Swiften/Network/BOSHConnectionPool.cpp b/Swiften/Network/BOSHConnectionPool.cpp index 8a75e81..3a79a16 100644 --- a/Swiften/Network/BOSHConnectionPool.cpp +++ b/Swiften/Network/BOSHConnectionPool.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -266,7 +266,7 @@ std::shared_ptr<BOSHConnection> BOSHConnectionPool::createConnection() { if (boshURL.getScheme() == "https") { bool success = connection->setClientCertificate(clientCertificate); - SWIFT_LOG(debug) << "setClientCertificate, success: " << success << std::endl; + SWIFT_LOG(debug) << "setClientCertificate, success: " << success; } connection->connect(); diff --git a/Swiften/Network/BoostConnection.cpp b/Swiften/Network/BoostConnection.cpp index 551363d..6ae6bf6 100644 --- a/Swiften/Network/BoostConnection.cpp +++ b/Swiften/Network/BoostConnection.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -107,7 +107,7 @@ void BoostConnection::doWrite(const SafeByteArray& data) { } void BoostConnection::handleConnectFinished(const boost::system::error_code& error) { - SWIFT_LOG(debug) << "Connect finished: " << error << std::endl; + SWIFT_LOG(debug) << "Connect finished: " << error; if (!error) { eventLoop->postEvent(boost::bind(boost::ref(onConnectFinished), false), shared_from_this()); doRead(); @@ -126,7 +126,7 @@ void BoostConnection::doRead() { } void BoostConnection::handleSocketRead(const boost::system::error_code& error, size_t bytesTransferred) { - SWIFT_LOG(debug) << "Socket read " << error << std::endl; + SWIFT_LOG(debug) << "Socket read " << error; if (!error) { readBuffer_->resize(bytesTransferred); eventLoop->postEvent(boost::bind(boost::ref(onDataRead), readBuffer_), shared_from_this()); @@ -141,7 +141,7 @@ void BoostConnection::handleSocketRead(const boost::system::error_code& error, s } void BoostConnection::handleDataWritten(const boost::system::error_code& error) { - SWIFT_LOG(debug) << "Data written " << error << std::endl; + SWIFT_LOG(debug) << "Data written " << error; if (!error) { eventLoop->postEvent(boost::ref(onDataWritten), shared_from_this()); } diff --git a/Swiften/Network/BoostConnectionServer.cpp b/Swiften/Network/BoostConnectionServer.cpp index 8db9656..dc05172 100644 --- a/Swiften/Network/BoostConnectionServer.cpp +++ b/Swiften/Network/BoostConnectionServer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -46,7 +46,7 @@ boost::optional<BoostConnectionServer::Error> BoostConnectionServer::tryStart() if (endpoint.protocol() == boost::asio::ip::tcp::v6()) { boost::system::error_code ec; acceptor_->set_option(boost::asio::ip::v6_only(false), ec); - SWIFT_LOG_ASSERT(ec, warning) << "IPv4/IPv6 dual-stack support is not supported on this platform." << std::endl; + SWIFT_LOG_ASSERT(ec, warning) << "IPv4/IPv6 dual-stack support is not supported on this platform."; } acceptNextConnection(); } diff --git a/Swiften/Network/BoostNetworkFactories.cpp b/Swiften/Network/BoostNetworkFactories.cpp index 9fef73c..13a7960 100644 --- a/Swiften/Network/BoostNetworkFactories.cpp +++ b/Swiften/Network/BoostNetworkFactories.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -44,9 +44,9 @@ BoostNetworkFactories::BoostNetworkFactories(EventLoop* eventLoop, std::shared_p idnConverter = PlatformIDNConverter::create(); #ifdef USE_UNBOUND // TODO: What to do about idnConverter. - domainNameResolver = new UnboundDomainNameResolver(idnConverter, ioServiceThread.getIOService(), eventLoop); + domainNameResolver = new UnboundDomainNameResolver(idnConverter.get(), ioServiceThread.getIOService(), eventLoop); #else - domainNameResolver = new PlatformDomainNameResolver(idnConverter, eventLoop); + domainNameResolver = new PlatformDomainNameResolver(idnConverter.get(), eventLoop); #endif cryptoProvider = PlatformCryptoProvider::create(); } @@ -54,7 +54,6 @@ BoostNetworkFactories::BoostNetworkFactories(EventLoop* eventLoop, std::shared_p BoostNetworkFactories::~BoostNetworkFactories() { delete cryptoProvider; delete domainNameResolver; - delete idnConverter; delete proxyProvider; delete tlsFactories; delete xmlParserFactory; diff --git a/Swiften/Network/BoostNetworkFactories.h b/Swiften/Network/BoostNetworkFactories.h index 2bf8d33..33a3584 100644 --- a/Swiften/Network/BoostNetworkFactories.h +++ b/Swiften/Network/BoostNetworkFactories.h @@ -1,11 +1,13 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once +#include <memory> + #include <Swiften/Base/API.h> #include <Swiften/Network/BoostIOServiceThread.h> #include <Swiften/Network/NetworkFactories.h> @@ -68,7 +70,7 @@ namespace Swift { } virtual IDNConverter* getIDNConverter() const override { - return idnConverter; + return idnConverter.get(); } virtual CryptoProvider* getCryptoProvider() const override { @@ -87,7 +89,7 @@ namespace Swift { PlatformTLSFactories* tlsFactories; ProxyProvider* proxyProvider; EventLoop* eventLoop; - IDNConverter* idnConverter; + std::unique_ptr<IDNConverter> idnConverter; CryptoProvider* cryptoProvider; }; } diff --git a/Swiften/Network/ChainedConnector.cpp b/Swiften/Network/ChainedConnector.cpp index 94899ad..a9210ba 100644 --- a/Swiften/Network/ChainedConnector.cpp +++ b/Swiften/Network/ChainedConnector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2018 Isode Limited. + * Copyright (c) 2011-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -45,7 +45,7 @@ void ChainedConnector::setTimeoutMilliseconds(int milliseconds) { } void ChainedConnector::start() { - SWIFT_LOG(debug) << "Starting queued connector for " << hostname << std::endl; + SWIFT_LOG(debug) << "Starting queued connector for " << hostname; connectionFactoryQueue = std::deque<ConnectionFactory*>(connectionFactories.begin(), connectionFactories.end()); tryNextConnectionFactory(); @@ -63,12 +63,12 @@ void ChainedConnector::stop() { void ChainedConnector::tryNextConnectionFactory() { assert(!currentConnector); if (connectionFactoryQueue.empty()) { - SWIFT_LOG(debug) << "No more connection factories" << std::endl; + SWIFT_LOG(debug) << "No more connection factories"; finish(std::shared_ptr<Connection>(), lastError); } else { ConnectionFactory* connectionFactory = connectionFactoryQueue.front(); - SWIFT_LOG(debug) << "Trying next connection factory: " << typeid(*connectionFactory).name() << std::endl; + SWIFT_LOG(debug) << "Trying next connection factory: " << typeid(*connectionFactory).name(); connectionFactoryQueue.pop_front(); currentConnector = Connector::create(hostname, port, serviceLookupPrefix, resolver, connectionFactory, timerFactory); currentConnector->setTimeoutMilliseconds(timeoutMilliseconds); @@ -78,7 +78,7 @@ void ChainedConnector::tryNextConnectionFactory() { } void ChainedConnector::handleConnectorFinished(std::shared_ptr<Connection> connection, std::shared_ptr<Error> error) { - SWIFT_LOG(debug) << "Connector finished" << std::endl; + SWIFT_LOG(debug) << "Connector finished"; currentConnector->onConnectFinished.disconnect(boost::bind(&ChainedConnector::handleConnectorFinished, this, _1, _2)); lastError = error; currentConnector.reset(); diff --git a/Swiften/Network/Connector.cpp b/Swiften/Network/Connector.cpp index a0e6b23..e27b95d 100644 --- a/Swiften/Network/Connector.cpp +++ b/Swiften/Network/Connector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -25,7 +25,7 @@ void Connector::setTimeoutMilliseconds(int milliseconds) { } void Connector::start() { - SWIFT_LOG(debug) << "Starting connector for " << hostname << std::endl; + SWIFT_LOG(debug) << "Starting connector for " << hostname; assert(!currentConnection); assert(!serviceQuery); assert(!timer); @@ -66,7 +66,7 @@ void Connector::queryAddress(const std::string& hostname) { } void Connector::handleServiceQueryResult(const std::vector<DomainNameServiceQuery::Result>& result) { - SWIFT_LOG(debug) << result.size() << " SRV result(s)" << std::endl; + SWIFT_LOG(debug) << result.size() << " SRV result(s)"; serviceQueryResults = std::deque<DomainNameServiceQuery::Result>(result.begin(), result.end()); serviceQuery.reset(); if (!serviceQueryResults.empty()) { @@ -77,23 +77,23 @@ void Connector::handleServiceQueryResult(const std::vector<DomainNameServiceQuer void Connector::tryNextServiceOrFallback() { if (queriedAllServices) { - SWIFT_LOG(debug) << "Queried all services" << std::endl; + SWIFT_LOG(debug) << "Queried all services"; finish(std::shared_ptr<Connection>()); } else if (serviceQueryResults.empty()) { - SWIFT_LOG(debug) << "Falling back on A resolution" << std::endl; + SWIFT_LOG(debug) << "Falling back on A resolution"; // Fall back on simple address resolving queriedAllServices = true; queryAddress(hostname); } else { - SWIFT_LOG(debug) << "Querying next address" << std::endl; + SWIFT_LOG(debug) << "Querying next address"; queryAddress(serviceQueryResults.front().hostname); } } void Connector::handleAddressQueryResult(const std::vector<HostAddress>& addresses, boost::optional<DomainNameResolveError> error) { - SWIFT_LOG(debug) << addresses.size() << " addresses" << std::endl; + SWIFT_LOG(debug) << addresses.size() << " addresses"; addressQuery.reset(); if (error || addresses.empty()) { if (!serviceQueryResults.empty()) { @@ -110,7 +110,7 @@ void Connector::handleAddressQueryResult(const std::vector<HostAddress>& address void Connector::tryNextAddress() { if (addressQueryResults.empty()) { - SWIFT_LOG(debug) << "Done trying addresses. Moving on." << std::endl; + SWIFT_LOG(debug) << "Done trying addresses. Moving on."; // Done trying all addresses. Move on to the next host. if (!serviceQueryResults.empty()) { serviceQueryResults.pop_front(); @@ -118,7 +118,7 @@ void Connector::tryNextAddress() { tryNextServiceOrFallback(); } else { - SWIFT_LOG(debug) << "Trying next address" << std::endl; + SWIFT_LOG(debug) << "Trying next address"; HostAddress address = addressQueryResults.front(); addressQueryResults.pop_front(); @@ -133,7 +133,7 @@ void Connector::tryNextAddress() { void Connector::tryConnect(const HostAddressPort& target) { assert(!currentConnection); - SWIFT_LOG(debug) << "Trying to connect to " << target.getAddress().toString() << ":" << target.getPort() << std::endl; + SWIFT_LOG(debug) << "Trying to connect to " << target.getAddress().toString() << ":" << target.getPort(); currentConnection = connectionFactory->createConnection(); currentConnection->onConnectFinished.connect(boost::bind(&Connector::handleConnectionConnectFinished, shared_from_this(), _1)); currentConnection->connect(target); @@ -143,7 +143,7 @@ void Connector::tryConnect(const HostAddressPort& target) { } void Connector::handleConnectionConnectFinished(bool error) { - SWIFT_LOG(debug) << "ConnectFinished: " << (error ? "error" : "success") << std::endl; + SWIFT_LOG(debug) << "ConnectFinished: " << (error ? "error" : "success"); if (timer) { timer->stop(); timer.reset(); @@ -195,8 +195,8 @@ void Connector::finish(std::shared_ptr<Connection> connection) { } void Connector::handleTimeout() { - SWIFT_LOG(debug) << "Timeout" << std::endl; - SWIFT_LOG_ASSERT(currentConnection, error) << "Connection not valid but triggered a timeout" <<std::endl; + SWIFT_LOG(debug) << "Timeout"; + SWIFT_LOG_ASSERT(currentConnection, error) << "Connection not valid but triggered a timeout"; handleConnectionConnectFinished(true); } diff --git a/Swiften/Network/EnvironmentProxyProvider.cpp b/Swiften/Network/EnvironmentProxyProvider.cpp index 65cf4ff..6fbf373 100644 --- a/Swiften/Network/EnvironmentProxyProvider.cpp +++ b/Swiften/Network/EnvironmentProxyProvider.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -26,7 +26,7 @@ namespace Swift { EnvironmentProxyProvider::EnvironmentProxyProvider() { socksProxy = getFromEnv("all_proxy", "socks"); httpProxy = getFromEnv("http_proxy", "http"); - SWIFT_LOG(debug) << "Environment: SOCKS5 => " << socksProxy.toString() << "; HTTP Connect => " << httpProxy.toString() << std::endl; + SWIFT_LOG(debug) << "Environment: SOCKS5 => " << socksProxy.toString() << "; HTTP Connect => " << httpProxy.toString(); } HostAddressPort EnvironmentProxyProvider::getHTTPConnectProxy() const { diff --git a/Swiften/Network/GConfProxyProvider.cpp b/Swiften/Network/GConfProxyProvider.cpp index 7c31868..a2f8adc 100644 --- a/Swiften/Network/GConfProxyProvider.cpp +++ b/Swiften/Network/GConfProxyProvider.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2016-2018 Isode Limited. + * Copyright (c) 2016-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -39,7 +39,7 @@ GConfProxyProvider::GConfProxyProvider() { socksProxy = getFromGConf("/system/proxy/socks_host", "/system/proxy/socks_port"); httpProxy = getFromGConf("/system/http_proxy/host", "/system/http_proxy/port"); - SWIFT_LOG(debug) << "GConf: SOCKS5 => " << socksProxy.toString() << "; HTTP Connect => " << httpProxy.toString() << std::endl; + SWIFT_LOG(debug) << "GConf: SOCKS5 => " << socksProxy.toString() << "; HTTP Connect => " << httpProxy.toString(); } HostAddressPort GConfProxyProvider::getHTTPConnectProxy() const { diff --git a/Swiften/Network/HTTPConnectProxiedConnection.cpp b/Swiften/Network/HTTPConnectProxiedConnection.cpp index 8eba49e..e63b8e2 100644 --- a/Swiften/Network/HTTPConnectProxiedConnection.cpp +++ b/Swiften/Network/HTTPConnectProxiedConnection.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2011-2018 Isode Limited. + * Copyright (c) 2011-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -77,7 +77,7 @@ void HTTPConnectProxiedConnection::initializeProxy() { nextHTTPRequestHeaders_.clear(); } append(data, createSafeByteArray("\r\n")); - SWIFT_LOG(debug) << "HTTP Proxy send headers: " << byteArrayToString(ByteArray(data.begin(), data.end())) << std::endl; + SWIFT_LOG(debug) << "HTTP Proxy send headers: " << byteArrayToString(ByteArray(data.begin(), data.end())); write(data); } @@ -111,7 +111,7 @@ void HTTPConnectProxiedConnection::sendHTTPRequest(const std::string& statusLine void HTTPConnectProxiedConnection::handleProxyInitializeData(std::shared_ptr<SafeByteArray> data) { std::string dataString = byteArrayToString(ByteArray(data->begin(), data->end())); - SWIFT_LOG(debug) << data << std::endl; + SWIFT_LOG(debug) << data; httpResponseBuffer_.append(dataString); std::string statusLine; @@ -141,17 +141,17 @@ void HTTPConnectProxiedConnection::handleProxyInitializeData(std::shared_ptr<Saf if (tmp.size() > 1) { try { int status = boost::lexical_cast<int>(tmp[1]); - SWIFT_LOG(debug) << "Proxy Status: " << status << std::endl; + SWIFT_LOG(debug) << "Proxy Status: " << status; if (status / 100 == 2) { // all 2XX states are OK setProxyInitializeFinished(true); } else { - SWIFT_LOG(debug) << "HTTP Proxy returned an error: " << httpResponseBuffer_ << std::endl; + SWIFT_LOG(debug) << "HTTP Proxy returned an error: " << httpResponseBuffer_; setProxyInitializeFinished(false); } } catch (boost::bad_lexical_cast&) { - SWIFT_LOG(warning) << "Unexpected response: " << tmp[1] << std::endl; + SWIFT_LOG(warning) << "Unexpected response: " << tmp[1]; setProxyInitializeFinished(false); } } diff --git a/Swiften/Network/HostAddress.cpp b/Swiften/Network/HostAddress.cpp index 6eca80b..e82f433 100644 --- a/Swiften/Network/HostAddress.cpp +++ b/Swiften/Network/HostAddress.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -43,7 +43,7 @@ std::string HostAddress::toString() const { addressString = address_.to_string(errorCode); if (errorCode) { - SWIFT_LOG(debug) << "error: " << errorCode.message() << std::endl; + SWIFT_LOG(debug) << "error: " << errorCode.message(); } return addressString; diff --git a/Swiften/Network/NATPMPInterface.cpp b/Swiften/Network/NATPMPInterface.cpp index 0c33c1f..e20fecd 100644 --- a/Swiften/Network/NATPMPInterface.cpp +++ b/Swiften/Network/NATPMPInterface.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2014-2018 Isode Limited. + * Copyright (c) 2014-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -42,7 +42,7 @@ bool NATPMPInterface::isAvailable() { boost::optional<HostAddress> NATPMPInterface::getPublicIP() { if (sendpublicaddressrequest(&p->natpmp) < 0) { - SWIFT_LOG(debug) << "Failed to send NAT-PMP public address request!" << std::endl; + SWIFT_LOG(debug) << "Failed to send NAT-PMP public address request!"; return boost::optional<HostAddress>(); } @@ -67,7 +67,7 @@ boost::optional<HostAddress> NATPMPInterface::getPublicIP() { return boost::optional<HostAddress>(HostAddress(reinterpret_cast<const unsigned char*>(&(response.pnu.publicaddress.addr)), 4)); } else { - SWIFT_LOG(debug) << "Inavlid NAT-PMP response." << std::endl; + SWIFT_LOG(debug) << "Inavlid NAT-PMP response."; return boost::optional<HostAddress>(); } } @@ -80,7 +80,7 @@ boost::optional<NATPortMapping> NATPMPInterface::addPortForward(unsigned short l mapping.getLocalPort(), mapping.getPublicPort(), mapping.getLeaseInSeconds()) < 0) { - SWIFT_LOG(debug) << "Failed to send NAT-PMP port forwarding request!" << std::endl; + SWIFT_LOG(debug) << "Failed to send NAT-PMP port forwarding request!"; return boost::optional<NATPortMapping>(); } @@ -106,14 +106,14 @@ boost::optional<NATPortMapping> NATPMPInterface::addPortForward(unsigned short l return result; } else { - SWIFT_LOG(debug) << "Invalid NAT-PMP response." << std::endl; + SWIFT_LOG(debug) << "Invalid NAT-PMP response."; return boost::optional<NATPortMapping>(); } } bool NATPMPInterface::removePortForward(const NATPortMapping& mapping) { if (sendnewportmappingrequest(&p->natpmp, mapping.getProtocol() == NATPortMapping::TCP ? NATPMP_PROTOCOL_TCP : NATPMP_PROTOCOL_UDP, mapping.getLocalPort(), 0, 0) < 0) { - SWIFT_LOG(debug) << "Failed to send NAT-PMP remove forwarding request!" << std::endl; + SWIFT_LOG(debug) << "Failed to send NAT-PMP remove forwarding request!"; return false; } @@ -133,7 +133,7 @@ bool NATPMPInterface::removePortForward(const NATPortMapping& mapping) { return true; } else { - SWIFT_LOG(debug) << "Invalid NAT-PMP response." << std::endl; + SWIFT_LOG(debug) << "Invalid NAT-PMP response."; return false; } } diff --git a/Swiften/Network/PlatformDomainNameServiceQuery.cpp b/Swiften/Network/PlatformDomainNameServiceQuery.cpp index f884500..2ff14e1 100644 --- a/Swiften/Network/PlatformDomainNameServiceQuery.cpp +++ b/Swiften/Network/PlatformDomainNameServiceQuery.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -58,7 +58,7 @@ void PlatformDomainNameServiceQuery::runBlocking() { return; } - SWIFT_LOG(debug) << "Querying " << service << std::endl; + SWIFT_LOG(debug) << "Querying " << service; std::vector<DomainNameServiceQuery::Result> records; @@ -97,7 +97,7 @@ void PlatformDomainNameServiceQuery::runBlocking() { response.resize(NS_PACKETSZ); int responseLength = res_query(const_cast<char*>(service.c_str()), ns_c_in, ns_t_srv, reinterpret_cast<u_char*>(vecptr(response)), response.size()); if (responseLength == -1) { - SWIFT_LOG(debug) << "Error" << std::endl; + SWIFT_LOG(debug) << "Error"; emitError(); return; } diff --git a/Swiften/Network/PlatformNATTraversalWorker.cpp b/Swiften/Network/PlatformNATTraversalWorker.cpp index 041ad2d..5431379 100644 --- a/Swiften/Network/PlatformNATTraversalWorker.cpp +++ b/Swiften/Network/PlatformNATTraversalWorker.cpp @@ -157,7 +157,7 @@ NATTraversalInterface* PlatformNATTraversalWorker::getNATTraversalInterface() co miniUPnPInterface = new MiniUPnPInterface(); miniUPnPSupported = miniUPnPInterface->isAvailable(); } - SWIFT_LOG(debug) << "UPnP NAT traversal supported: " << static_cast<bool>(miniUPnPSupported) << std::endl; + SWIFT_LOG(debug) << "UPnP NAT traversal supported: " << static_cast<bool>(miniUPnPSupported); if (miniUPnPSupported) { return miniUPnPInterface; } @@ -168,7 +168,7 @@ NATTraversalInterface* PlatformNATTraversalWorker::getNATTraversalInterface() co natPMPInterface = new NATPMPInterface(); natPMPSupported = natPMPInterface->isAvailable(); } - SWIFT_LOG(debug) << "NAT-PMP NAT traversal supported: " << static_cast<bool>(natPMPSupported) << std::endl; + SWIFT_LOG(debug) << "NAT-PMP NAT traversal supported: " << static_cast<bool>(natPMPSupported); if (natPMPSupported) { return natPMPInterface; } diff --git a/Swiften/Network/ProxiedConnection.cpp b/Swiften/Network/ProxiedConnection.cpp index 4c97e31..0c5cda6 100644 --- a/Swiften/Network/ProxiedConnection.cpp +++ b/Swiften/Network/ProxiedConnection.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2018 Isode Limited. + * Copyright (c) 2012-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -37,7 +37,7 @@ ProxiedConnection::~ProxiedConnection() { connection_->onDisconnected.disconnect(boost::bind(&ProxiedConnection::handleDisconnected, shared_from_this(), _1)); } if (connected_) { - SWIFT_LOG(warning) << "Connection was still established." << std::endl; + SWIFT_LOG(warning) << "Connection was still established."; } } diff --git a/Swiften/Network/SOCKS5ProxiedConnection.cpp b/Swiften/Network/SOCKS5ProxiedConnection.cpp index d7036f2..c76b6e6 100644 --- a/Swiften/Network/SOCKS5ProxiedConnection.cpp +++ b/Swiften/Network/SOCKS5ProxiedConnection.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2014-2018 Isode Limited. + * Copyright (c) 2014-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -50,7 +50,7 @@ void SOCKS5ProxiedConnection::handleProxyInitializeData(std::shared_ptr<SafeByte assert(rawAddress.is_v4() || rawAddress.is_v6()); if (proxyState_ == ProxyAuthenticating) { - SWIFT_LOG(debug) << "ProxyAuthenticating response received, reply with the connect BYTEs" << std::endl; + SWIFT_LOG(debug) << "ProxyAuthenticating response received, reply with the connect BYTEs"; unsigned char choosenMethod = static_cast<unsigned char> ((*data)[1]); if ((*data)[0] == 0x05 && choosenMethod != 0xFF) { switch(choosenMethod) { // use the correct Method @@ -79,7 +79,7 @@ void SOCKS5ProxiedConnection::handleProxyInitializeData(std::shared_ptr<SafeByte return; } catch(...) { - SWIFT_LOG(error) << "exception caught" << std::endl; + SWIFT_LOG(error) << "exception caught"; } write(socksConnect); break; @@ -92,8 +92,8 @@ void SOCKS5ProxiedConnection::handleProxyInitializeData(std::shared_ptr<SafeByte setProxyInitializeFinished(false); } else if (proxyState_ == ProxyConnecting) { - SWIFT_LOG(debug) << "Connect response received, check if successfully." << std::endl; - SWIFT_LOG(debug) << "Errorbyte: 0x" << std::hex << static_cast<int> ((*data)[1]) << std::dec << std::endl; + SWIFT_LOG(debug) << "Connect response received, check if successfully."; + SWIFT_LOG(debug) << "Errorbyte: 0x" << std::hex << static_cast<int> ((*data)[1]) << std::dec; /* data.at(1) can be one of the following: @@ -109,11 +109,11 @@ void SOCKS5ProxiedConnection::handleProxyInitializeData(std::shared_ptr<SafeByte 0x09 bis 0xFF unassigned */ if ((*data)[0] == 0x05 && (*data)[1] == 0x0) { - SWIFT_LOG(debug) << "Successfully connected the server via the proxy." << std::endl; + SWIFT_LOG(debug) << "Successfully connected the server via the proxy."; setProxyInitializeFinished(true); } else { - SWIFT_LOG(error) << "SOCKS Proxy returned an error: " << std::hex << (*data)[1] << std::endl; + SWIFT_LOG(error) << "SOCKS Proxy returned an error: " << std::hex << (*data)[1]; setProxyInitializeFinished(false); } } diff --git a/Swiften/Network/UnboundDomainNameResolver.cpp b/Swiften/Network/UnboundDomainNameResolver.cpp index 1df6b8f..21bc697 100644 --- a/Swiften/Network/UnboundDomainNameResolver.cpp +++ b/Swiften/Network/UnboundDomainNameResolver.cpp @@ -64,7 +64,7 @@ class UnboundDomainNameServiceQuery : public DomainNameServiceQuery, public Unbo 1 /* CLASS IN (internet) */, helper, UnboundDomainNameResolver::unbound_callback_wrapper, NULL); if(retval != 0) { - SWIFT_LOG(debug) << "resolve error: " << ub_strerror(retval) << std::endl; + SWIFT_LOG(debug) << "resolve error: " << ub_strerror(retval); delete helper; } } @@ -73,7 +73,7 @@ class UnboundDomainNameServiceQuery : public DomainNameServiceQuery, public Unbo std::vector<DomainNameServiceQuery::Result> serviceRecords; if(err != 0) { - SWIFT_LOG(debug) << "resolve error: " << ub_strerror(err) << std::endl; + SWIFT_LOG(debug) << "resolve error: " << ub_strerror(err); } else { if(result->havedata) { ldns_pkt* replyPacket = 0; @@ -105,7 +105,7 @@ class UnboundDomainNameServiceQuery : public DomainNameServiceQuery, public Unbo serviceRecord.hostname = std::string(reinterpret_cast<char*>(ldns_buffer_at(buffer, 0))); serviceRecords.push_back(serviceRecord); - SWIFT_LOG(debug) << "hostname " << serviceRecord.hostname << " added" << std::endl; + SWIFT_LOG(debug) << "hostname " << serviceRecord.hostname << " added"; } } if (replyPacket) ldns_pkt_free(replyPacket); @@ -137,7 +137,7 @@ class UnboundDomainNameAddressQuery : public DomainNameAddressQuery, public Unbo 1 /* CLASS IN (internet) */, helper, UnboundDomainNameResolver::unbound_callback_wrapper, NULL); if(retval != 0) { - SWIFT_LOG(debug) << "resolve error: " << ub_strerror(retval) << std::endl; + SWIFT_LOG(debug) << "resolve error: " << ub_strerror(retval); delete helper; } } @@ -145,10 +145,10 @@ class UnboundDomainNameAddressQuery : public DomainNameAddressQuery, public Unbo void handleResult(int err, struct ub_result* result) { std::vector<HostAddress> addresses; boost::optional<DomainNameResolveError> error; - SWIFT_LOG(debug) << "Result for: " << name << std::endl; + SWIFT_LOG(debug) << "Result for: " << name; if(err != 0) { - SWIFT_LOG(debug) << "resolve error: " << ub_strerror(err) << std::endl; + SWIFT_LOG(debug) << "resolve error: " << ub_strerror(err); error = DomainNameResolveError(); } else { if(result->havedata) { @@ -156,13 +156,13 @@ class UnboundDomainNameAddressQuery : public DomainNameAddressQuery, public Unbo char address[100]; const char* addressStr = 0; if ((addressStr = inet_ntop(AF_INET, result->data[i], address, 100))) { - SWIFT_LOG(debug) << "IPv4 address: " << addressStr << std::endl; + SWIFT_LOG(debug) << "IPv4 address: " << addressStr; addresses.push_back(HostAddress(std::string(addressStr))); } else if ((addressStr = inet_ntop(AF_INET6, result->data[i], address, 100))) { - SWIFT_LOG(debug) << "IPv6 address: " << addressStr << std::endl; + SWIFT_LOG(debug) << "IPv6 address: " << addressStr; addresses.push_back(HostAddress(std::string(addressStr))); } else { - SWIFT_LOG(debug) << "inet_ntop() failed" << std::endl; + SWIFT_LOG(debug) << "inet_ntop() failed"; error = DomainNameResolveError(); } } @@ -182,7 +182,7 @@ class UnboundDomainNameAddressQuery : public DomainNameAddressQuery, public Unbo UnboundDomainNameResolver::UnboundDomainNameResolver(IDNConverter* idnConverter, std::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) : idnConverter(idnConverter), ioService(ioService), ubDescriptior(*ioService), eventLoop(eventLoop) { ubContext = ub_ctx_create(); if(!ubContext) { - SWIFT_LOG(debug) << "could not create unbound context" << std::endl; + SWIFT_LOG(debug) << "could not create unbound context"; } eventOwner = std::make_shared<EventOwner>(); @@ -192,11 +192,11 @@ UnboundDomainNameResolver::UnboundDomainNameResolver(IDNConverter* idnConverter, /* read /etc/resolv.conf for DNS proxy settings (from DHCP) */ if( (ret=ub_ctx_resolvconf(ubContext, const_cast<char*>("/etc/resolv.conf"))) != 0) { - SWIFT_LOG(error) << "error reading resolv.conf: " << ub_strerror(ret) << ". errno says: " << strerror(errno) << std::endl; + SWIFT_LOG(error) << "error reading resolv.conf: " << ub_strerror(ret) << ". errno says: " << strerror(errno); } /* read /etc/hosts for locally supplied host addresses */ if( (ret=ub_ctx_hosts(ubContext, const_cast<char*>("/etc/hosts"))) != 0) { - SWIFT_LOG(error) << "error reading hosts: " << ub_strerror(ret) << ". errno says: " << strerror(errno) << std::endl; + SWIFT_LOG(error) << "error reading hosts: " << ub_strerror(ret) << ". errno says: " << strerror(errno); } ubDescriptior.assign(ub_fd(ubContext)); @@ -231,7 +231,7 @@ void UnboundDomainNameResolver::processData() { if (ub_poll(ubContext)) { int ret = ub_process(ubContext); if(ret != 0) { - SWIFT_LOG(debug) << "resolve error: " << ub_strerror(ret) << std::endl; + SWIFT_LOG(debug) << "resolve error: " << ub_strerror(ret); } } } diff --git a/Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp b/Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp index 065d015..e9268b0 100644 --- a/Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp +++ b/Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -37,7 +37,7 @@ namespace { virtual std::vector<std::pair<std::string, std::string> > filterHTTPResponseHeader(const std::string& /* statusLine */, const std::vector<std::pair<std::string, std::string> >& response) { filterResponses.push_back(response); - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); return filterResponseReturn; } @@ -409,7 +409,7 @@ class HTTPConnectProxiedConnectionTest : public CppUnit::TestFixture { std::shared_ptr<Connection> createConnection() { std::shared_ptr<MockConnection> connection = std::make_shared<MockConnection>(failingPorts, eventLoop); connections.push_back(connection); - SWIFT_LOG(debug) << "new connection created" << std::endl; + SWIFT_LOG(debug) << "new connection created"; return connection; } diff --git a/Swiften/Network/WindowsProxyProvider.cpp b/Swiften/Network/WindowsProxyProvider.cpp index 9a60bb4..13fdb25 100644 --- a/Swiften/Network/WindowsProxyProvider.cpp +++ b/Swiften/Network/WindowsProxyProvider.cpp @@ -52,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); } @@ -86,7 +86,7 @@ HostAddressPort WindowsProxyProvider::getAsHostAddressPort(std::string proxy) { 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; |