Browse Source

Mac install fixes, remove obsolete stuff, and write local.conf via API for new UI integration.

Adam Ierymenko 3 years ago
parent
commit
5005244d1b

+ 6 - 0
RELEASE-NOTES.md

@@ -1,6 +1,12 @@
 ZeroTier Release Notes
 ZeroTier Release Notes
 ======
 ======
 
 
+# 2021-08-31 -- Version 1.8.0
+
+ * A *completely* rewritten desktop UI for Mac and Windows!
+ * Implement a workaround for one potential source of a "coma" bug, which can occur if buggy NATs/routers stop allowing the service to communicate on a given port. ZeroTier now reassigns a new secondary port if it's offline for a while unless a secondary port is manually specified in local.conf.
+ * Fix for MacOS MTU issue on feth devices.
+
 # 2021-04-13 -- Version 1.6.5
 # 2021-04-13 -- Version 1.6.5
 
 
  * Fix a bug in potential network path filtering that could in some circumstances lead to "software laser" effects.
  * Fix a bug in potential network path filtering that could in some circumstances lead to "software laser" effects.

+ 1 - 0
ext/installfiles/mac/launch.sh

@@ -1,3 +1,4 @@
 #!/bin/bash
 #!/bin/bash
 export PATH="/Library/Application Support/ZeroTier/One:/bin:/usr/bin:/sbin:/usr/sbin"
 export PATH="/Library/Application Support/ZeroTier/One:/bin:/usr/bin:/sbin:/usr/sbin"
+/usr/bin/killall MacEthernetTapAgent >>/dev/null 2>&1
 exec zerotier-one
 exec zerotier-one

+ 15 - 3
ext/installfiles/mac/postinst.sh

@@ -11,6 +11,21 @@ if [ ! -f authtoken.secret ]; then
 	chmod 0600 authtoken.secret
 	chmod 0600 authtoken.secret
 fi
 fi
 
 
+if [ -f zerotier-one.pid ]; then
+	kill `cat zerotier-one.pid`
+	sleep 1
+	killall MacEthernetTapAgent
+	sleep 1
+	killall -9 MacEthernetTapAgent
+	sleep 1
+	if [ -f zerotier-one.pid ]; then
+		kill -9 `cat zerotier-one.pid`
+		rm -f zerotier-one.pid
+	fi
+fi
+launchctl load /Library/LaunchDaemons/com.zerotier.one.plist >>/dev/null 2>&1
+sleep 1
+
 rm -f zerotier-cli zerotier-idtool
 rm -f zerotier-cli zerotier-idtool
 ln -sf zerotier-one zerotier-cli
 ln -sf zerotier-one zerotier-cli
 ln -sf zerotier-one zerotier-idtool
 ln -sf zerotier-one zerotier-idtool
@@ -22,9 +37,6 @@ rm -f zerotier-cli zerotier-idtool
 ln -sf "/Library/Application Support/ZeroTier/One/zerotier-one" zerotier-cli
 ln -sf "/Library/Application Support/ZeroTier/One/zerotier-one" zerotier-cli
 ln -sf "/Library/Application Support/ZeroTier/One/zerotier-one" zerotier-idtool
 ln -sf "/Library/Application Support/ZeroTier/One/zerotier-one" zerotier-idtool
 
 
-launchctl load /Library/LaunchDaemons/com.zerotier.one.plist >>/dev/null 2>&1
-sleep 2
-
 if [ -f /tmp/zt1-gui-restart.tmp ]; then
 if [ -f /tmp/zt1-gui-restart.tmp ]; then
 	for u in `cat /tmp/zt1-gui-restart.tmp`; do
 	for u in `cat /tmp/zt1-gui-restart.tmp`; do
 		if [ -f '/Applications/ZeroTier One.app/Contents/MacOS/ZeroTier One' ]; then
 		if [ -f '/Applications/ZeroTier One.app/Contents/MacOS/ZeroTier One' ]; then

+ 7 - 8
ext/installfiles/mac/preinst.sh

@@ -25,16 +25,15 @@ for i in `ps axuwww | tr -s ' ' ',' | grep -F '/Applications/ZeroTier.app' | gre
 done
 done
 chmod 0600 /tmp/zt1-gui-restart.tmp
 chmod 0600 /tmp/zt1-gui-restart.tmp
 
 
-if [ -f /Library/LaunchDaemons/com.zerotier.one.plist ]; then
-	launchctl unload /Library/LaunchDaemons/com.zerotier.one.plist >>/dev/null 2>&1
-	sleep 5
-fi
-if [ -f '/Library/Application Support/ZeroTier/One/zerotier-one.pid' ]; then
-	kill -9 `cat /Library/Application Support/ZeroTier/One/zerotier-one.pid`
-fi
-
 cd "/Applications"
 cd "/Applications"
 rm -rf "ZeroTier One.app"
 rm -rf "ZeroTier One.app"
 rm -rf "ZeroTier.app"
 rm -rf "ZeroTier.app"
 
 
+if [ -d '/Library/Application Support/ZeroTier/One' ]; then
+	cd '/Library/Application Support/ZeroTier/One'
+	# ensure that file locking doesn't cause issues with replacing the binary
+	rm -f zerotier-one
+	rm -f MacEthernetTapAgent
+fi
+
 exit 0
 exit 0

+ 1 - 3
ext/installfiles/mac/uninstall.sh

@@ -21,12 +21,10 @@ killall -TERM zerotier-one >>/dev/null 2>&1
 sleep 1
 sleep 1
 killall -KILL zerotier-one >>/dev/null 2>&1
 killall -KILL zerotier-one >>/dev/null 2>&1
 
 
-echo "Making sure kext is unloaded..."
-kextunload '/Library/Application Support/ZeroTier/One/tap.kext' >>/dev/null 2>&1
-
 echo "Removing ZeroTier One files..."
 echo "Removing ZeroTier One files..."
 
 
 rm -rf '/Applications/ZeroTier One.app'
 rm -rf '/Applications/ZeroTier One.app'
+rm -rf '/Applications/ZeroTier.app'
 rm -f '/usr/local/bin/zerotier-one' '/usr/local/bin/zerotier-idtool' '/usr/local/bin/zerotier-cli' '/Library/LaunchDaemons/com.zerotier.one.plist'
 rm -f '/usr/local/bin/zerotier-one' '/usr/local/bin/zerotier-idtool' '/usr/local/bin/zerotier-cli' '/Library/LaunchDaemons/com.zerotier.one.plist'
 
 
 cd '/Library/Application Support/ZeroTier/One'
 cd '/Library/Application Support/ZeroTier/One'

+ 40 - 6
service/OneService.cpp

@@ -1028,8 +1028,11 @@ public:
 			}
 			}
 		}
 		}
 
 
+		// Make a copy so lookups don't modify in place;
+		json lc(_localConfig);
+
 		// Get any trusted paths in local.conf (we'll parse the rest of physical[] elsewhere)
 		// Get any trusted paths in local.conf (we'll parse the rest of physical[] elsewhere)
-		json &physical = _localConfig["physical"];
+		json &physical = lc["physical"];
 		if (physical.is_object()) {
 		if (physical.is_object()) {
 			for(json::iterator phy(physical.begin());phy!=physical.end();++phy) {
 			for(json::iterator phy(physical.begin());phy!=physical.end();++phy) {
 				InetAddress net(OSUtils::jsonString(phy.key(),"").c_str());
 				InetAddress net(OSUtils::jsonString(phy.key(),"").c_str());
@@ -1046,7 +1049,7 @@ public:
 			}
 			}
 		}
 		}
 
 
-		json &settings = _localConfig["settings"];
+		json &settings = lc["settings"];
 		if (settings.is_object()) {
 		if (settings.is_object()) {
 			// Allow controller DB path to be put somewhere else
 			// Allow controller DB path to be put somewhere else
 			const std::string cdbp(OSUtils::jsonString(settings["controllerDbPath"],""));
 			const std::string cdbp(OSUtils::jsonString(settings["controllerDbPath"],""));
@@ -1289,8 +1292,11 @@ public:
 					} else {
 					} else {
 						scode = 400; /* bond controller is not enabled */
 						scode = 400; /* bond controller is not enabled */
 					}
 					}
-				}
-				if (ps[0] == "status") {
+				} else if (ps[0] == "config") {
+					Mutex::Lock lc(_localConfig_m);
+					res = _localConfig;
+					scode = 200;
+				} else if (ps[0] == "status") {
 					ZT_NodeStatus status;
 					ZT_NodeStatus status;
 					_node->status(&status);
 					_node->status(&status);
 
 
@@ -1496,8 +1502,35 @@ public:
 					} else {
 					} else {
 						scode = 400; /* bond controller is not enabled */
 						scode = 400; /* bond controller is not enabled */
 					}
 					}
-				}
-				if (ps[0] == "moon") {
+				} else if (ps[0] == "config") {
+					// Right now we only support writing the things the UI supports changing.
+					if (ps.size() == 2) {
+						if (ps[1] == "settings") {
+							try {
+								json j(OSUtils::jsonParse(body));
+								if (j.is_object()) {
+									Mutex::Lock lcl(_localConfig_m);
+									json lc(_localConfig);
+									for(json::const_iterator s(j.begin());s!=j.end();++s) {
+										lc["settings"][s.key()] = s.value();
+									}
+									std::string lcStr = OSUtils::jsonDump(lc, 4);
+									if (OSUtils::writeFile((_homePath + ZT_PATH_SEPARATOR_S "local.conf").c_str(), lcStr)) {
+										_localConfig = lc;
+									}
+								} else {
+									scode = 400;
+								}
+							} catch ( ... ) {
+								scode = 400;
+							}
+						} else {
+							scode = 404;
+						}
+					} else {
+						scode = 404;
+					}
+				} else if (ps[0] == "moon") {
 					if (ps.size() == 2) {
 					if (ps.size() == 2) {
 
 
 						uint64_t seed = 0;
 						uint64_t seed = 0;
@@ -3115,6 +3148,7 @@ public:
 			if (_trialBind(randp))
 			if (_trialBind(randp))
 				break;
 				break;
 		}
 		}
+		return randp;
 	}
 	}
 
 
 	bool _trialBind(unsigned int port)
 	bool _trialBind(unsigned int port)