From e0bdc021395fed6a6931d973b1f780c3a0c7de83 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Sat, 24 Aug 2013 17:10:34 -0400 Subject: Docs, Node picks a default home folder if created with NULL as its home path, and add binary tap drivers (self-signed for now). --- node/Defaults.cpp | 36 +++++++++++++++++++++++++++++++++++- node/Defaults.hpp | 5 +++++ node/Node.cpp | 5 +++-- 3 files changed, 43 insertions(+), 3 deletions(-) (limited to 'node') 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 +#include +#include + #include "Constants.hpp" +#include "Defaults.hpp" +#include "Utils.hpp" + +#ifdef __WINDOWS__ +#include +#include +#endif namespace ZeroTier { @@ -66,8 +76,32 @@ static inline std::map< Identity,std::vector > _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 @@ -51,6 +51,11 @@ public: throw(std::runtime_error); ~Defaults() {} + /** + * Default home path for this platform + */ + const std::string defaultHomePath; + /** * Supernodes on the ZeroTier network */ 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; -- cgit v1.2.3