mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-23 23:02:23 +00:00
113 lines
3.6 KiB
C++
113 lines
3.6 KiB
C++
/*
|
|
* ZeroTier One - Global Peer to Peer Ethernet
|
|
* Copyright (C) 2012-2013 ZeroTier Networks LLC
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* --
|
|
*
|
|
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
|
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
|
*
|
|
* If you would like to embed ZeroTier into a commercial application or
|
|
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
|
* LLC. Start here: http://www.zerotier.com/
|
|
*/
|
|
|
|
#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 {
|
|
|
|
const Defaults ZT_DEFAULTS;
|
|
|
|
static inline std::map< Identity,std::vector<InetAddress> > _mkSupernodeMap()
|
|
throw(std::runtime_error)
|
|
{
|
|
std::map< Identity,std::vector<InetAddress> > sn;
|
|
Identity id;
|
|
std::vector<InetAddress> addrs;
|
|
|
|
// Nothing special about a supernode... except that they are
|
|
// designated as such and trusted to provide WHOIS lookup.
|
|
|
|
// cthulhu.zerotier.com - New York, New York, USA
|
|
addrs.clear();
|
|
if (!id.fromString("31a633d7fd:0:1f9d24ac00dd6b21c711304f6034001d25678e1a0eb260ed1996dd881c73143af1ff1b84457e013467eb8b780c0ee4a5fdd037ac07f91eb427051b8cbe110446"))
|
|
throw std::runtime_error("invalid identity in Defaults");
|
|
addrs.push_back(InetAddress("198.199.73.93",ZT_DEFAULT_UDP_PORT));
|
|
sn[id] = addrs;
|
|
|
|
// nyarlathotep.zerotier.com - San Francisco, California, USA
|
|
addrs.clear();
|
|
if (!id.fromString("aaf5e8b5eb:0:9aa129e78c564313b07b1d9f739683d6b109a3c83fb7294ef16c221e2f4f5050682febe9715069ba1013542236635a543ed2f44c20d8a01bbb14d5900e4572ae"))
|
|
throw std::runtime_error("invalid identity in Defaults");
|
|
addrs.push_back(InetAddress("198.199.97.220",ZT_DEFAULT_UDP_PORT));
|
|
sn[id] = addrs;
|
|
|
|
// shub-niggurath.zerotier.com - Amsterdam, Netherlands
|
|
addrs.clear();
|
|
if (!id.fromString("c6524a2797:0:f656ead7c1e88ac3255a36ec2919343fbef8876300015a6f0aceccd6af808f5180eda4b4015e2cc27225233873466e89808b3e50b3b0a5a95a6f7bd3fef7eba8"))
|
|
throw std::runtime_error("invalid identity in Defaults");
|
|
addrs.push_back(InetAddress("198.211.127.172",ZT_DEFAULT_UDP_PORT));
|
|
sn[id] = addrs;
|
|
|
|
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) :
|
|
#ifdef ZT_TRACE_MULTICAST
|
|
multicastTraceWatcher(ZT_TRACE_MULTICAST),
|
|
#endif
|
|
defaultHomePath(_mkDefaultHomePath()),
|
|
supernodes(_mkSupernodeMap())
|
|
{
|
|
}
|
|
|
|
} // namespace ZeroTier
|