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/Defaults.cpp | |
| 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/Defaults.cpp')
| -rw-r--r-- | node/Defaults.cpp | 36 |
1 files changed, 35 insertions, 1 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()) { } |
