diff options
author | Tobias Markmann <tm@ayena.de> | 2015-12-09 15:24:23 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-01-12 17:42:50 (GMT) |
commit | 13801557b6664426cac26384441ab0b19ff9abb5 (patch) | |
tree | 924c5d47e157612e0492f29806910828fe38871f /Swiften/Network/BoostConnectionServer.cpp | |
parent | e314293415c9691bb98188b514f6b13e33994d86 (diff) | |
download | swift-13801557b6664426cac26384441ab0b19ff9abb5.zip swift-13801557b6664426cac26384441ab0b19ff9abb5.tar.bz2 |
Listen to IPv6 any address instead of only IPv4
This should enable IPv4/IPv6 dual-stack support for Swift(-en)
Jingle file-transfer support.
Add Connection::getRemoteAddress() method.
Test-Information:
Tested IPv6 file-transfer and IPv4 file-transfer between two
Swift instances.
Added integration test verifying IPv4 only, IPv6 only and
IPv4/IPv6 dual-stack support on the running platform.
Additionally added test to verify remote addresses on dual-stack
server.
Change-Id: Ie384a71833eacca554f69e6f12a1c8330d0d747f
Diffstat (limited to 'Swiften/Network/BoostConnectionServer.cpp')
-rw-r--r-- | Swiften/Network/BoostConnectionServer.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/Swiften/Network/BoostConnectionServer.cpp b/Swiften/Network/BoostConnectionServer.cpp index 2a4a51b..48b323d 100644 --- a/Swiften/Network/BoostConnectionServer.cpp +++ b/Swiften/Network/BoostConnectionServer.cpp @@ -1,17 +1,20 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Network/BoostConnectionServer.h> -#include <boost/bind.hpp> -#include <boost/system/system_error.hpp> +#include <boost/asio/ip/v6_only.hpp> #include <boost/asio/placeholders.hpp> +#include <boost/bind.hpp> #include <boost/numeric/conversion/cast.hpp> #include <boost/optional.hpp> +#include <boost/system/error_code.hpp> +#include <boost/system/system_error.hpp> +#include <Swiften/Base/Log.h> #include <Swiften/EventLoop/EventLoop.h> namespace Swift { @@ -32,15 +35,18 @@ void BoostConnectionServer::start() { boost::optional<BoostConnectionServer::Error> BoostConnectionServer::tryStart() { try { assert(!acceptor_); + boost::asio::ip::tcp::endpoint endpoint; if (address_.isValid()) { - acceptor_ = new boost::asio::ip::tcp::acceptor( - *ioService_, - boost::asio::ip::tcp::endpoint(address_.getRawAddress(), boost::numeric_cast<unsigned short>(port_))); + endpoint = boost::asio::ip::tcp::endpoint(address_.getRawAddress(), boost::numeric_cast<unsigned short>(port_)); } else { - acceptor_ = new boost::asio::ip::tcp::acceptor( - *ioService_, - boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), boost::numeric_cast<unsigned short>(port_))); + endpoint = boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v6(), boost::numeric_cast<unsigned short>(port_)); + } + acceptor_ = new boost::asio::ip::tcp::acceptor(*ioService_, endpoint); + 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; } acceptNextConnection(); } |