summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-03-08 15:36:49 (GMT)
committerKevin Smith <kevin.smith@isode.com>2015-05-01 17:14:55 (GMT)
commit794fec2873e69ec047974416768b32b69754dad1 (patch)
treea3cc8cb221e9ee7ad5c40a9de0ccc03e5f9d9562 /Swiften/FileTransfer/SOCKS5BytestreamServerManager.h
parentd7bc3a37f4bb261c8520a8ddedcda2369f97361c (diff)
downloadswift-794fec2873e69ec047974416768b32b69754dad1.zip
swift-794fec2873e69ec047974416768b32b69754dad1.tar.bz2
Add resource management for S5B server and port forwardings
This patchs adds management of the SOCKS5 bytestream server and port forwarding setup to Swiften. The first file-transfer, regardless of incoming or outgoing transfer, will start and initialize the S5B server and if configured try to set up port forwarding. The last file-transfer to finish will will close the server and remove the port forwarding. Test-Information: Tested with upcoming ConcurrentFileTransferTest.cpp and running multiple S5B file-transfers in parallel. Change-Id: Idd09d3d0ef9498fc9435b0aee81f2b1061783342
Diffstat (limited to 'Swiften/FileTransfer/SOCKS5BytestreamServerManager.h')
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerManager.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h
index abb28b0..e8a43f9 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h
@@ -8,6 +8,7 @@
#include <vector>
#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
#include <Swiften/Base/boost_bsignals.h>
#include <Swiften/Network/HostAddressPort.h>
@@ -22,10 +23,14 @@ namespace Swift {
class SOCKS5BytestreamRegistry;
class ConnectionServerFactory;
class ConnectionServer;
- class SOCKS5BytestreamServerInitializeRequest;
class SOCKS5BytestreamServer;
+ class SOCKS5BytestreamServerResourceUser;
+ class SOCKS5BytestreamServerPortForwardingUser;
class SOCKS5BytestreamServerManager {
+ friend class SOCKS5BytestreamServerResourceUser;
+ friend class SOCKS5BytestreamServerPortForwardingUser;
+
public:
SOCKS5BytestreamServerManager(
SOCKS5BytestreamRegistry* bytestreamRegistry,
@@ -34,7 +39,9 @@ namespace Swift {
NATTraverser* natTraverser);
~SOCKS5BytestreamServerManager();
- boost::shared_ptr<SOCKS5BytestreamServerInitializeRequest> createInitializeRequest();
+ boost::shared_ptr<SOCKS5BytestreamServerResourceUser> aquireResourceUser();
+ boost::shared_ptr<SOCKS5BytestreamServerPortForwardingUser> aquirePortForwardingUser();
+
void stop();
std::vector<HostAddressPort> getHostAddressPorts() const;
@@ -47,6 +54,11 @@ namespace Swift {
private:
bool isInitialized() const;
void initialize();
+
+ bool isPortForwardingReady() const;
+ void setupPortForwarding();
+ void removePortForwarding();
+
void checkInitializeFinished();
void handleGetPublicIPResult(boost::optional<HostAddress> address);
@@ -54,7 +66,7 @@ namespace Swift {
void handleUnforwardPortResult(boost::optional<bool> result);
boost::signal<void (bool /* success */)> onInitialized;
-
+ boost::signal<void (bool /* success */)> onPortForwardingSetup;
private:
friend class SOCKS5BytestreamServerInitializeRequest;
@@ -66,11 +78,16 @@ namespace Swift {
SOCKS5BytestreamServer* server;
boost::shared_ptr<ConnectionServer> connectionServer;
int connectionServerPort;
+
boost::shared_ptr<NATTraversalGetPublicIPRequest> getPublicIPRequest;
boost::shared_ptr<NATTraversalForwardPortRequest> forwardPortRequest;
boost::shared_ptr<NATTraversalRemovePortForwardingRequest> unforwardPortRequest;
boost::optional<HostAddress> publicAddress;
boost::optional<NATPortMapping> portMapping;
+ bool attemptedPortMapping_;
+
+ boost::weak_ptr<SOCKS5BytestreamServerResourceUser> s5bServerResourceUser_;
+ boost::weak_ptr<SOCKS5BytestreamServerPortForwardingUser> s5bServerPortForwardingUser_;
};
}