summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-12-09 15:24:23 (GMT)
committerTobias Markmann <tm@ayena.de>2016-01-12 17:42:50 (GMT)
commit13801557b6664426cac26384441ab0b19ff9abb5 (patch)
tree924c5d47e157612e0492f29806910828fe38871f /Swiften/QA/NetworkTest
parente314293415c9691bb98188b514f6b13e33994d86 (diff)
downloadswift-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/QA/NetworkTest')
-rw-r--r--Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp46
1 files changed, 45 insertions, 1 deletions
diff --git a/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp b/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp
index abe2f05..67b4bfa 100644
--- a/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp
+++ b/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp
@@ -26,6 +26,7 @@ class BoostConnectionServerTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testIPv4Server);
CPPUNIT_TEST(testIPv6Server);
CPPUNIT_TEST(testIPv4IPv6DualStackServer);
+ CPPUNIT_TEST(testIPv6DualStackServerPeerAddress);
CPPUNIT_TEST_SUITE_END();
public:
@@ -36,6 +37,7 @@ class BoostConnectionServerTest : public CppUnit::TestFixture {
stoppedError_.reset();
receivedNewConnection_ = false;
connectFinished_ = false;
+ remoteAddress_ = boost::optional<HostAddressPort>();
}
void tearDown() {
@@ -147,13 +149,54 @@ class BoostConnectionServerTest : public CppUnit::TestFixture {
testling->stop();
}
+ void testIPv6DualStackServerPeerAddress() {
+ BoostConnectionServer::ref testling = BoostConnectionServer::create(HostAddress("::"), 9999, boostIOServiceThread_->getIOService(), eventLoop_);
+ testling->onNewConnection.connect(boost::bind(&BoostConnectionServerTest::handleNewConnection, this, _1));
+ testling->start();
+
+ // Test IPv4.
+ BoostConnection::ref clientTestling = BoostConnection::create(boostIOServiceThread_->getIOService(), eventLoop_);
+ clientTestling->onConnectFinished.connect(boost::bind(&BoostConnectionServerTest::handleConnectFinished, this, _1));
+ clientTestling->connect(HostAddressPort(HostAddress("127.0.0.1"), 9999));
+
+ while (!connectFinished_) {
+ Swift::sleep(10);
+ eventLoop_->processEvents();
+ }
+
+ CPPUNIT_ASSERT_EQUAL(true, receivedNewConnection_);
+ // The IPv4 localhost mapped to a IPv6 address is expected here.
+ CPPUNIT_ASSERT(HostAddress("::ffff:127.0.0.1") == remoteAddress_.get().getAddress());
+
+ receivedNewConnection_ = false;
+ connectFinished_ = false;
+ remoteAddress_ = boost::optional<HostAddressPort>();
+
+ // Test IPv6.
+ clientTestling = BoostConnection::create(boostIOServiceThread_->getIOService(), eventLoop_);
+ clientTestling->onConnectFinished.connect(boost::bind(&BoostConnectionServerTest::handleConnectFinished, this, _1));
+ clientTestling->connect(HostAddressPort(HostAddress("::1"), 9999));
+
+ while (!connectFinished_) {
+ Swift::sleep(10);
+ eventLoop_->processEvents();
+ }
+
+ CPPUNIT_ASSERT_EQUAL(true, receivedNewConnection_);
+ // The IPv6 local host is expected here.
+ CPPUNIT_ASSERT(HostAddress("::1") == remoteAddress_.get().getAddress());
+
+ testling->stop();
+ }
+
void handleStopped_(boost::optional<BoostConnectionServer::Error> e) {
stopped_ = true;
stoppedError_ = e;
}
- void handleNewConnection(boost::shared_ptr<Connection> /*connection*/) {
+ void handleNewConnection(boost::shared_ptr<Connection> connection) {
receivedNewConnection_ = true;
+ remoteAddress_ = connection->getRemoteAddress();
}
void handleConnectFinished(bool /*error*/) {
@@ -167,6 +210,7 @@ class BoostConnectionServerTest : public CppUnit::TestFixture {
bool receivedNewConnection_;
bool connectFinished_;
boost::optional<BoostConnectionServer::Error> stoppedError_;
+ boost::optional<HostAddressPort> remoteAddress_;
};
CPPUNIT_TEST_SUITE_REGISTRATION(BoostConnectionServerTest);