2013-07-04 20:56:19 +00:00
|
|
|
/*
|
|
|
|
* ZeroTier One - Global Peer to Peer Ethernet
|
2014-02-16 20:40:22 +00:00
|
|
|
* Copyright (C) 2011-2014 ZeroTier Networks LLC
|
2013-07-04 20:56:19 +00:00
|
|
|
*
|
|
|
|
* 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/
|
|
|
|
*/
|
|
|
|
|
2013-08-24 21:10:34 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2013-07-04 20:56:19 +00:00
|
|
|
#include "Constants.hpp"
|
2013-08-24 21:10:34 +00:00
|
|
|
#include "Defaults.hpp"
|
|
|
|
#include "Utils.hpp"
|
|
|
|
|
|
|
|
#ifdef __WINDOWS__
|
|
|
|
#include <WinSock2.h>
|
|
|
|
#include <Windows.h>
|
2014-01-21 00:16:01 +00:00
|
|
|
#include <ShlObj.h>
|
2013-08-24 21:10:34 +00:00
|
|
|
#endif
|
2013-07-04 20:56:19 +00:00
|
|
|
|
|
|
|
namespace ZeroTier {
|
|
|
|
|
|
|
|
const Defaults ZT_DEFAULTS;
|
|
|
|
|
2014-03-26 22:35:15 +00:00
|
|
|
static inline std::map< Identity,std::vector< std::pair<InetAddress,bool> > > _mkSupernodeMap()
|
2013-07-04 20:56:19 +00:00
|
|
|
{
|
2014-03-26 22:35:15 +00:00
|
|
|
std::map< Identity,std::vector< std::pair<InetAddress,bool> > > sn;
|
2013-07-04 20:56:19 +00:00
|
|
|
Identity id;
|
2014-03-26 22:35:15 +00:00
|
|
|
std::vector< std::pair<InetAddress,bool> > addrs;
|
2013-07-04 20:56:19 +00:00
|
|
|
|
|
|
|
// Nothing special about a supernode... except that they are
|
2013-09-17 18:47:48 +00:00
|
|
|
// designated as such and trusted to provide WHOIS lookup.
|
2013-07-04 20:56:19 +00:00
|
|
|
|
|
|
|
// cthulhu.zerotier.com - New York, New York, USA
|
|
|
|
addrs.clear();
|
2013-10-20 19:54:32 +00:00
|
|
|
if (!id.fromString("8acf059fe3:0:482f6ee5dfe902319b419de5bdc765209c0ecda38c4d6e4fcf0d33658398b4527dcd22f93112fb9befd02fd78bf7261b333fc105d192a623ca9e50fc60b374a5"))
|
2013-07-04 20:56:19 +00:00
|
|
|
throw std::runtime_error("invalid identity in Defaults");
|
2014-03-28 01:24:57 +00:00
|
|
|
addrs.push_back(std::pair<InetAddress,bool>(InetAddress("162.243.77.111",ZT_DEFAULT_UDP_PORT),false));
|
2014-03-26 22:35:15 +00:00
|
|
|
addrs.push_back(std::pair<InetAddress,bool>(InetAddress("162.243.77.111",443),true));
|
2013-07-04 20:56:19 +00:00
|
|
|
sn[id] = addrs;
|
|
|
|
|
|
|
|
// nyarlathotep.zerotier.com - San Francisco, California, USA
|
|
|
|
addrs.clear();
|
2013-10-20 19:54:32 +00:00
|
|
|
if (!id.fromString("7e19876aba:0:2a6e2b2318930f60eb097f70d0f4b028b2cd6d3d0c63c014b9039ff35390e41181f216fb2e6fa8d95c1ee9667156411905c3dccfea78d8c6dfafba688170b3fa"))
|
2013-07-04 20:56:19 +00:00
|
|
|
throw std::runtime_error("invalid identity in Defaults");
|
2014-03-28 01:24:57 +00:00
|
|
|
addrs.push_back(std::pair<InetAddress,bool>(InetAddress("198.199.97.220",ZT_DEFAULT_UDP_PORT),false));
|
2014-03-28 22:51:19 +00:00
|
|
|
addrs.push_back(std::pair<InetAddress,bool>(InetAddress("198.199.97.220",443),true));
|
2013-07-04 20:56:19 +00:00
|
|
|
sn[id] = addrs;
|
|
|
|
|
|
|
|
// shub-niggurath.zerotier.com - Amsterdam, Netherlands
|
|
|
|
addrs.clear();
|
2013-10-20 19:54:32 +00:00
|
|
|
if (!id.fromString("36f63d6574:0:67a776487a1a99b32f413329f2b67c43fbf6152e42c6b66e89043e69d93e48314c7d709b58a83016bd2612dd89400b856e18c553da94892f7d3ca16bf2c92c24"))
|
2013-07-04 20:56:19 +00:00
|
|
|
throw std::runtime_error("invalid identity in Defaults");
|
2014-03-28 01:24:57 +00:00
|
|
|
addrs.push_back(std::pair<InetAddress,bool>(InetAddress("198.211.127.172",ZT_DEFAULT_UDP_PORT),false));
|
2014-03-28 22:51:19 +00:00
|
|
|
addrs.push_back(std::pair<InetAddress,bool>(InetAddress("198.211.127.172",443),true));
|
2013-07-04 20:56:19 +00:00
|
|
|
sn[id] = addrs;
|
|
|
|
|
2014-04-15 21:37:19 +00:00
|
|
|
// yig.zerotier.com - Sydney, Australia
|
2014-02-11 16:57:25 +00:00
|
|
|
addrs.clear();
|
2014-04-15 21:37:19 +00:00
|
|
|
if (!id.fromString("275f0151f6:0:58716258283f7e14a2f999875d9cc681c1f0ca8403dce38ec354ceaf284a555f36402e79a32d03b8c0963245b7f1af61a1ad3519d90e05bc3ce591034f6a1c9c"))
|
2014-02-11 16:57:25 +00:00
|
|
|
throw std::runtime_error("invalid identity in Defaults");
|
2014-04-15 21:37:19 +00:00
|
|
|
addrs.push_back(std::pair<InetAddress,bool>(InetAddress("108.61.212.61",ZT_DEFAULT_UDP_PORT),false));
|
|
|
|
addrs.push_back(std::pair<InetAddress,bool>(InetAddress("108.61.212.61",443),true));
|
2014-02-11 16:57:25 +00:00
|
|
|
sn[id] = addrs;
|
|
|
|
|
2014-03-05 22:21:23 +00:00
|
|
|
// shoggoth.zerotier.com - Tokyo, Japan
|
|
|
|
addrs.clear();
|
|
|
|
if (!id.fromString("48e8f875cb:0:5ca54f55e1094f65589f3e6d74158b6964d418ddac3570757128f1c6a2498322d92fcdcd47de459f4d1f9b38df2afd0c7b3fc247ba3d773c38ba35288f24988e"))
|
|
|
|
throw std::runtime_error("invalid identity in Defaults");
|
2014-03-28 01:24:57 +00:00
|
|
|
addrs.push_back(std::pair<InetAddress,bool>(InetAddress("108.61.200.101",ZT_DEFAULT_UDP_PORT),false));
|
2014-03-28 22:51:19 +00:00
|
|
|
addrs.push_back(std::pair<InetAddress,bool>(InetAddress("108.61.200.101",443),true));
|
2014-03-05 22:21:23 +00:00
|
|
|
sn[id] = addrs;
|
|
|
|
|
2013-07-04 20:56:19 +00:00
|
|
|
return sn;
|
|
|
|
}
|
|
|
|
|
2013-08-24 21:10:34 +00:00
|
|
|
static inline std::string _mkDefaultHomePath()
|
|
|
|
{
|
|
|
|
#ifdef __UNIX_LIKE__
|
2014-01-21 00:16:01 +00:00
|
|
|
|
2013-08-24 21:10:34 +00:00
|
|
|
#ifdef __APPLE__
|
2013-08-26 21:51:36 +00:00
|
|
|
return std::string("/Library/Application Support/ZeroTier/One");
|
2013-08-24 21:10:34 +00:00
|
|
|
#else
|
|
|
|
return std::string("/var/lib/zerotier-one");
|
|
|
|
#endif
|
2014-01-21 00:16:01 +00:00
|
|
|
|
|
|
|
#else // not __UNIX_LIKE__
|
|
|
|
|
2013-08-24 21:10:34 +00:00
|
|
|
#ifdef __WINDOWS__
|
2014-01-21 00:16:01 +00:00
|
|
|
char buf[16384];
|
|
|
|
if (SUCCEEDED(SHGetFolderPathA(NULL,CSIDL_COMMON_APPDATA,NULL,0,buf)))
|
|
|
|
return (std::string(buf) + "\\ZeroTier\\One");
|
|
|
|
else return std::string("C:\\ZeroTier\\One");
|
2013-08-24 21:10:34 +00:00
|
|
|
#else
|
|
|
|
// unknown platform
|
|
|
|
#endif
|
2014-01-21 00:16:01 +00:00
|
|
|
|
|
|
|
#endif // __UNIX_LIKE__ or not...
|
2013-08-24 21:10:34 +00:00
|
|
|
}
|
|
|
|
|
2013-11-04 22:31:00 +00:00
|
|
|
static inline std::map< Address,Identity > _mkUpdateAuth()
|
|
|
|
{
|
|
|
|
std::map< Address,Identity > ua;
|
|
|
|
|
|
|
|
{ // 0001
|
|
|
|
Identity id("e9bc3707b5:0:c4cef17bde99eadf9748c4fd11b9b06dc5cd8eb429227811d2c336e6b96a8d329e8abd0a4f45e47fe1bcebf878c004c822d952ff77fc2833af4c74e65985c435");
|
|
|
|
ua[id.address()] = id;
|
|
|
|
}
|
|
|
|
{ // 0002
|
|
|
|
Identity id("56520eaf93:0:7d858b47988b34399a9a31136de07b46104d7edb4a98fa1d6da3e583d3a33e48be531532b886f0b12cd16794a66ab9220749ec5112cbe96296b18fe0cc79ca05");
|
|
|
|
ua[id.address()] = id;
|
|
|
|
}
|
|
|
|
{ // 0003
|
|
|
|
Identity id("7c195de2e0:0:9f659071c960f9b0f0b96f9f9ecdaa27c7295feed9c79b7db6eedcc11feb705e6dd85c70fa21655204d24c897865b99eb946b753a2bbcf2be5f5e006ae618c54");
|
|
|
|
ua[id.address()] = id;
|
|
|
|
}
|
|
|
|
{ // 0004
|
|
|
|
Identity id("415f4cfde7:0:54118e87777b0ea5d922c10b337c4f4bd1db7141845bd54004b3255551a6e356ba6b9e1e85357dbfafc45630b8faa2ebf992f31479e9005f0472685f2d8cbd6e");
|
|
|
|
ua[id.address()] = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ua;
|
|
|
|
}
|
|
|
|
|
2013-12-11 00:13:07 +00:00
|
|
|
static inline const char *_mkUpdateUrl()
|
2013-12-10 23:30:53 +00:00
|
|
|
{
|
2013-12-11 00:13:07 +00:00
|
|
|
#if defined(__LINUX__) && ( defined(__i386__) || defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(__i386) )
|
|
|
|
if (sizeof(void *) == 8)
|
2014-01-08 00:37:36 +00:00
|
|
|
return "http://download.zerotier.com/ZeroTierOneInstaller-linux-x64-LATEST.nfo";
|
|
|
|
else return "http://download.zerotier.com/ZeroTierOneInstaller-linux-x86-LATEST.nfo";
|
2013-12-11 00:13:07 +00:00
|
|
|
#define GOT_UPDATE_URL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
2014-01-08 00:37:36 +00:00
|
|
|
return "http://download.zerotier.com/ZeroTierOneInstaller-mac-combined-LATEST.nfo";
|
2013-12-11 00:13:07 +00:00
|
|
|
#define GOT_UPDATE_URL
|
|
|
|
#endif
|
|
|
|
|
2014-02-23 16:01:52 +00:00
|
|
|
#ifdef __WINDOWS__
|
|
|
|
return "http://download.zerotier.com/ZeroTierOneInstaller-windows-intel-LATEST.nfo";
|
|
|
|
#define GOT_UPDATE_URL
|
|
|
|
#endif
|
2013-12-11 00:13:07 +00:00
|
|
|
|
|
|
|
#ifndef GOT_UPDATE_URL
|
|
|
|
return "";
|
|
|
|
#endif
|
2013-12-10 23:30:53 +00:00
|
|
|
}
|
|
|
|
|
2013-10-18 18:16:53 +00:00
|
|
|
Defaults::Defaults() :
|
2013-10-01 20:01:36 +00:00
|
|
|
#ifdef ZT_TRACE_MULTICAST
|
|
|
|
multicastTraceWatcher(ZT_TRACE_MULTICAST),
|
|
|
|
#endif
|
2013-08-24 21:10:34 +00:00
|
|
|
defaultHomePath(_mkDefaultHomePath()),
|
2013-11-04 22:31:00 +00:00
|
|
|
supernodes(_mkSupernodeMap()),
|
2013-12-10 23:30:53 +00:00
|
|
|
updateAuthorities(_mkUpdateAuth()),
|
2014-04-10 23:30:15 +00:00
|
|
|
updateLatestNfoURL(_mkUpdateUrl()),
|
|
|
|
v4Broadcast(((uint32_t)0xffffffff),ZT_DEFAULT_UDP_PORT)
|
2013-07-04 20:56:19 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace ZeroTier
|