summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-12-19 15:18:20 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-12-19 15:18:20 -0800
commitf60dfe496325bfe5d58b3db75e86387799b72c25 (patch)
treea9e2cb53d5accbca0f7e61efa35a5c53e9fbd9cf
parent536bcf6505e19dc16cad025b32a385325410fb30 (diff)
downloadinfinitytier-f60dfe496325bfe5d58b3db75e86387799b72c25.tar.gz
infinitytier-f60dfe496325bfe5d58b3db75e86387799b72c25.zip
FreeBSD works, and some documentation fixes.
-rw-r--r--BUILDING.md (renamed from BUILDING.txt)14
-rw-r--r--RUNNING.md (renamed from RUNNING.txt)24
-rw-r--r--node/Defaults.cpp10
-rw-r--r--osnet/BSDEthernetTap.cpp16
4 files changed, 49 insertions, 15 deletions
diff --git a/BUILDING.txt b/BUILDING.md
index 9ec53010..7378eb75 100644
--- a/BUILDING.txt
+++ b/BUILDING.md
@@ -1,17 +1,18 @@
-Building ZeroTier One on different platforms:
+Building ZeroTier One From Source
+======
-(See RUNNING.txt for what to do next.)
+(See RUNNING.md for what to do next.)
Developers note: there is currently no management of dependencies on *nix
platforms, so you should make clean ; make if you change a header. Will
do this eventually.
--- Linux
+### Linux and FreeBSD
Just type 'make'. You'll need gcc and g++ installed, but ZeroTier One requires
no other third party libraries beyond the standard libc, libstdc++, and libm.
--- MacOS
+### MacOS
make
@@ -32,6 +33,7 @@ be symbolically linked into "Qt" in the parent directory of the ZeroTier
One source tree. Then you can type "make mac-ui" and the UI should build.
You can also load the UI in Qt Creator and build/test it that way.
--- Windows
+### Windows
-Here be dragons.
+There's a Visual Studio 2012 solution file in windows/ that can be used.
+I've never tried it with MinGW, but theoretically this should be possible.
diff --git a/RUNNING.txt b/RUNNING.md
index b7ef8966..45807144 100644
--- a/RUNNING.txt
+++ b/RUNNING.md
@@ -1,10 +1,13 @@
-This guide is for those building and running from source. See BUILDING.txt
+Running ZeroTier One
+======
+
+This guide is for those building and running from source. See BUILDING.md
first.
The wiki at GitHub contains several pages that are probably also of interest:
https://github.com/zerotier/ZeroTierOne/wiki
---- MacOS
+### MacOS
On Mac, the default ZeroTier home is:
@@ -24,7 +27,7 @@ If run with no options, it will use the default home directory above.
sudo ./zerotier-one &
---- LINUX
+### LINUX
On Linux, the default ZeroTier home is:
@@ -56,11 +59,18 @@ sudo ufw allow 9993/udp
You should now be able to ping and browse earth.zerotier.net
---- WINDOWS
+### FreeBSD
+
+FreeBSD is identical to Linux except that the default home is
+/var/db/zerotier-one instead of /var/lib.
+
+### WINDOWS
-A windows port is in progress.
+Run zerotier-one.exe -h for help. There's a command to install the current
+binary as a service to run it that way, and another option to run it from
+the Windows console.
---- ONCE IT'S RUNNING:
+### Once you're up and running...
To use the command line interface, see this guide:
https://github.com/zerotier/ZeroTierOne/wiki/Command-Line-Interface
@@ -68,7 +78,7 @@ To use the command line interface, see this guide:
If you want to test by joining the Earth network, try:
sudo ./zerotier-cli join 8056c2e21c000001
-An interface called 'zt0' should appear and should get an IP address in
+An interface called 'zt####' should appear and should get an IP address in
the 28.0.0.0/7 range (28.* or 29.*) within a few seconds or so. Then try
pinging earth.zerotier.net or navigating to http://earth.zerotier.net/ in
a web browser.
diff --git a/node/Defaults.cpp b/node/Defaults.cpp
index 177be52b..adcb9963 100644
--- a/node/Defaults.cpp
+++ b/node/Defaults.cpp
@@ -51,14 +51,24 @@ static inline std::string _mkDefaultHomePath()
#ifdef __UNIX_LIKE__
#ifdef __APPLE__
+ // /Library/... on Apple
return std::string("/Library/Application Support/ZeroTier/One");
#else
+
+#ifdef __FreeBSD__
+ // FreeBSD likes /var/db instead of /var/lib
+ return std::string("/var/db/zerotier-one");
+#else
+ // Use /var/lib for Linux and other *nix
return std::string("/var/lib/zerotier-one");
#endif
+#endif
+
#else // not __UNIX_LIKE__
#ifdef __WINDOWS__
+ // Look up app data folder on Windows, e.g. C:\ProgramData\...
char buf[16384];
if (SUCCEEDED(SHGetFolderPathA(NULL,CSIDL_COMMON_APPDATA,NULL,0,buf)))
return (std::string(buf) + "\\ZeroTier\\One");
diff --git a/osnet/BSDEthernetTap.cpp b/osnet/BSDEthernetTap.cpp
index 8b28510d..100fb171 100644
--- a/osnet/BSDEthernetTap.cpp
+++ b/osnet/BSDEthernetTap.cpp
@@ -117,10 +117,11 @@ BSDEthernetTap::BSDEthernetTap(
// On BSD we create taps and they can have high numbers, so use ones starting
// at 9993 to not conflict with other stuff. Then we rename it to zt<base32 of nwid>
- for(int i=9993;i<500;++i) {
+ std::map<std::string,bool> devFiles(Utils::listDirectory("/dev"));
+ for(int i=9993;i<(9993+128);++i) {
Utils::snprintf(tmpdevname,sizeof(tmpdevname),"tap%d",i);
Utils::snprintf(devpath,sizeof(devpath),"/dev/%s",tmpdevname);
- if (stat(devpath,&stattmp)) {
+ if (devFiles.count(std::string(tmpdevname)) == 0) {
long cpid = (long)vfork();
if (cpid == 0) {
::execl("/sbin/ifconfig","/sbin/ifconfig",tmpdevname,"create",(const char *)0);
@@ -146,6 +147,8 @@ BSDEthernetTap::BSDEthernetTap(
if (_fd > 0)
break;
else throw std::runtime_error("unable to open created tap device");
+ } else {
+ throw std::runtime_error("cannot find /dev node for newly created tap device");
}
}
}
@@ -190,6 +193,15 @@ BSDEthernetTap::~BSDEthernetTap()
::close(_fd);
::close(_shutdownSignalPipe[0]);
::close(_shutdownSignalPipe[1]);
+
+ long cpid = (long)vfork();
+ if (cpid == 0) {
+ ::execl("/sbin/ifconfig","/sbin/ifconfig",_dev.c_str(),"destroy",(const char *)0);
+ ::_exit(-1);
+ } else if (cpid > 0) {
+ int exitcode = -1;
+ ::waitpid(cpid,&exitcode,0);
+ }
}
void BSDEthernetTap::setEnabled(bool en)