diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-04-15 19:38:01 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-04-15 19:38:01 -0700 |
commit | 4e5d2d2c72aaa8f405d5c11223af275748733725 (patch) | |
tree | 08e7dbf40184f10db0e331bf4b1cfc38ae13a385 /service | |
parent | 21a7e774bba4832848687dbd8d2e0a1df33650ce (diff) | |
download | infinitytier-4e5d2d2c72aaa8f405d5c11223af275748733725.tar.gz infinitytier-4e5d2d2c72aaa8f405d5c11223af275748733725.zip |
Write a zerotier-one.port file to the home path to make CLI easy to write, and do a backward compatiable CLI in bash instead of as part of the executable.
Diffstat (limited to 'service')
-rw-r--r-- | service/OneService.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/service/OneService.cpp b/service/OneService.cpp index 1ba7a8c5..bb808304 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -131,6 +131,7 @@ class OneServiceImpl : public OneService public: OneServiceImpl(const char *hp,unsigned int port,NetworkController *master,const char *overrideRootTopology) : _homePath((hp) ? hp : "."), + _port(port), _phy(this,true), _master(master), _overrideRootTopology((overrideRootTopology) ? overrideRootTopology : ""), @@ -160,6 +161,10 @@ public: in6.sin6_port = in4.sin_port; _v6UdpSocket = _phy.udpBind((const struct sockaddr *)&in6,this,131072); _v6TcpListenSocket = _phy.tcpListen((const struct sockaddr *)&in6,this); + + char portstr[64]; + Utils::snprintf(portstr,sizeof(portstr),"%u",port); + OSUtils::writeFile((_homePath + ZT_PATH_SEPARATOR_S + "zerotier-one.port").c_str(),std::string(portstr)); } virtual ~OneServiceImpl() @@ -632,6 +637,7 @@ private: } const std::string _homePath; + unsigned int _port; Phy<OneServiceImpl *> _phy; NetworkController *_master; std::string _overrideRootTopology; |