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 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'node/Defaults.cpp') 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()) { } -- cgit v1.2.3