diff options
author | Grant Limberg <glimberg@gmail.com> | 2015-07-28 19:18:33 -0700 |
---|---|---|
committer | Grant Limberg <glimberg@gmail.com> | 2015-07-28 19:18:33 -0700 |
commit | 508d31513a0848236258542930cf577d95afda99 (patch) | |
tree | 453b31d874e6ec0dee3105191142efc8a326a30d /service | |
parent | bc0954381ccdca065987512a45d5dd6ace6cca9d (diff) | |
parent | 7578b5629849f6c286c353dce713b0816b1cc4a9 (diff) | |
download | infinitytier-508d31513a0848236258542930cf577d95afda99.tar.gz infinitytier-508d31513a0848236258542930cf577d95afda99.zip |
Merge branch 'adamierymenko-dev' into android-jni
Diffstat (limited to 'service')
-rw-r--r-- | service/OneService.cpp | 21 | ||||
-rw-r--r-- | service/OneService.hpp | 2 |
2 files changed, 18 insertions, 5 deletions
diff --git a/service/OneService.cpp b/service/OneService.cpp index d582a893..06e37a45 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -54,6 +54,7 @@ #include "../osdep/OSUtils.hpp" #include "../osdep/Http.hpp" #include "../osdep/BackgroundResolver.hpp" +#include "../osdep/UPNPClient.hpp" #include "OneService.hpp" #include "ControlPlane.hpp" @@ -404,7 +405,7 @@ public: #ifdef ZT_ENABLE_NETWORK_CONTROLLER _controller((_homePath + ZT_PATH_SEPARATOR_S + ZT1_CONTROLLER_DB_PATH).c_str()), #endif - _phy(this,false), + _phy(this,false,true), _overrideRootTopology((overrideRootTopology) ? overrideRootTopology : ""), _node((Node *)0), _controlPlane((ControlPlane *)0), @@ -415,6 +416,9 @@ public: _tcpFallbackTunnel((TcpConnection *)0), _termReason(ONE_STILL_RUNNING), _port(port), +#ifdef ZT_USE_MINIUPNPC + _upnpClient((int)port), +#endif _run(true) { struct sockaddr_in in4; @@ -511,7 +515,7 @@ public: _lastRestart = clockShouldBe; uint64_t lastTapMulticastGroupCheck = 0; uint64_t lastTcpFallbackResolve = 0; - uint64_t lastLocalInterfaceAddressCheck = 0; + uint64_t lastLocalInterfaceAddressCheck = (OSUtils::now() - ZT1_LOCAL_INTERFACE_CHECK_INTERVAL) + 15000; // do this in 15s to give UPnP time to configure and other things time to settle #ifdef ZT_AUTO_UPDATE uint64_t lastSoftwareUpdateCheck = 0; #endif // ZT_AUTO_UPDATE @@ -576,9 +580,16 @@ public: ztDevices.push_back(t->second->deviceName()); } + _node->clearLocalInterfaceAddresses(); + +#ifdef ZT_USE_MINIUPNPC + std::vector<InetAddress> upnpAddresses(_upnpClient.get()); + for(std::vector<InetAddress>::const_iterator ext(upnpAddresses.begin());ext!=upnpAddresses.end();++ext) + _node->addLocalInterfaceAddress(reinterpret_cast<const struct sockaddr_storage *>(&(*ext)),0,ZT1_LOCAL_INTERFACE_ADDRESS_TRUST_NORMAL); +#endif + struct ifaddrs *ifatbl = (struct ifaddrs *)0; if ((getifaddrs(&ifatbl) == 0)&&(ifatbl)) { - _node->clearLocalInterfaceAddresses(); struct ifaddrs *ifa = ifatbl; while (ifa) { if ((ifa->ifa_name)&&(ifa->ifa_addr)) { @@ -1242,6 +1253,10 @@ private: unsigned int _port; +#ifdef ZT_USE_MINIUPNPC + UPNPClient _upnpClient; +#endif + bool _run; Mutex _run_m; }; diff --git a/service/OneService.hpp b/service/OneService.hpp index 7964958c..7a4f7827 100644 --- a/service/OneService.hpp +++ b/service/OneService.hpp @@ -106,8 +106,6 @@ public: * The terminate() method may be called from a signal handler or another * thread to terminate execution. Otherwise this will not return unless * another condition terminates execution such as a fatal error. - * - * @param */ virtual ReasonForTermination run() = 0; |