diff options
author | Adam Ierymenko <adam.ierymenko@zerotier.com> | 2013-08-24 17:10:34 -0400 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@zerotier.com> | 2013-08-24 17:10:34 -0400 |
commit | e0bdc021395fed6a6931d973b1f780c3a0c7de83 (patch) | |
tree | 9934c79a2a5a5114e0c14bc583819f1031fbf6c5 /node | |
parent | 6d7b1c1e5fff7ffd8deed5716a7c9deda63293cb (diff) | |
download | infinitytier-e0bdc021395fed6a6931d973b1f780c3a0c7de83.tar.gz infinitytier-e0bdc021395fed6a6931d973b1f780c3a0c7de83.zip |
Docs, Node picks a default home folder if created with NULL as its home path, and add binary tap drivers (self-signed for now).
Diffstat (limited to 'node')
-rw-r--r-- | node/Defaults.cpp | 36 | ||||
-rw-r--r-- | node/Defaults.hpp | 5 | ||||
-rw-r--r-- | node/Node.cpp | 5 |
3 files changed, 43 insertions, 3 deletions
diff --git a/node/Defaults.cpp b/node/Defaults.cpp index 3e936b2d..293fd465 100644 --- a/node/Defaults.cpp +++ b/node/Defaults.cpp @@ -25,8 +25,18 @@ * LLC. Start here: http://www.zerotier.com/ */ -#include "Defaults.hpp" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "Constants.hpp" +#include "Defaults.hpp" +#include "Utils.hpp" + +#ifdef __WINDOWS__ +#include <WinSock2.h> +#include <Windows.h> +#endif namespace ZeroTier { @@ -66,8 +76,32 @@ static inline std::map< Identity,std::vector<InetAddress> > _mkSupernodeMap() return sn; } +static inline std::string _mkDefaultHomePath() +{ +#ifdef __UNIX_LIKE__ +#ifdef __APPLE__ + return std::string("/Library/Application\ Support/ZeroTier/One"); +#else + return std::string("/var/lib/zerotier-one"); +#endif +#else +#ifdef __WINDOWS__ + OSVERSIONINFO vi; + memset (&vi,0,sizeof(vi)); + vi.dwOSVersionInfoSize = sizeof(vi); + GetVersionEx(&vi); + if (vi.dwMajorVersion < 6) + return std::string("C:\\Documents and Settings\\All Users\\Application Data\\ZeroTier\\One"); + return std::string("C:\\ProgramData\\ZeroTier\\One"); +#else + // unknown platform +#endif +#endif +} + Defaults::Defaults() throw(std::runtime_error) : + defaultHomePath(_mkDefaultHomePath()), supernodes(_mkSupernodeMap()) { } diff --git a/node/Defaults.hpp b/node/Defaults.hpp index 3a350865..fe79d525 100644 --- a/node/Defaults.hpp +++ b/node/Defaults.hpp @@ -52,6 +52,11 @@ public: ~Defaults() {} /** + * Default home path for this platform + */ + const std::string defaultHomePath; + + /** * Supernodes on the ZeroTier network */ const std::map< Identity,std::vector<InetAddress> > supernodes; diff --git a/node/Node.cpp b/node/Node.cpp index bb68cdaf..1884f9ce 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -258,8 +258,9 @@ Node::Node(const char *hp) { _NodeImpl *impl = (_NodeImpl *)_impl; - impl->renv.homePath = hp; - + if (hp) + impl->renv.homePath = hp; + else impl->renv.homePath = ZT_DEFAULTS.defaultHomePath; impl->reasonForTermination = Node::NODE_RUNNING; impl->started = false; impl->running = false; |