From 8bd9f7d51dbb8756d7063cc7cb3939ff74104145 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 29 Oct 2014 19:54:24 -0700 Subject: [PATCH] Build fix for UI and mac. --- ZeroTierUI/ZeroTierUI.pro | 62 ++++++++++++++++++++------------------- ZeroTierUI/mainwindow.cpp | 33 ++++++++++++++------- ZeroTierUI/mainwindow.h | 3 +- make-mac.mk | 2 +- 4 files changed, 57 insertions(+), 43 deletions(-) diff --git a/ZeroTierUI/ZeroTierUI.pro b/ZeroTierUI/ZeroTierUI.pro index 355b06155..98e306b51 100644 --- a/ZeroTierUI/ZeroTierUI.pro +++ b/ZeroTierUI/ZeroTierUI.pro @@ -12,53 +12,58 @@ mac:QMAKE_INFO_PLIST = Info.plist mac:LIBS += -framework Cocoa SOURCES += main.cpp \ - mainwindow.cpp \ - aboutwindow.cpp \ - networkwidget.cpp \ - installdialog.cpp \ - licensedialog.cpp \ - onetimedialog.cpp \ + mainwindow.cpp \ + aboutwindow.cpp \ + networkwidget.cpp \ + installdialog.cpp \ + licensedialog.cpp \ + onetimedialog.cpp \ + ../control/IpcConnection.cpp \ + ../control/IpcListener.cpp \ + ../control/NodeControlClient.cpp \ + ../control/NodeControlService.cpp \ ../node/C25519.cpp \ ../node/CertificateOfMembership.cpp \ ../node/Defaults.cpp \ + ../node/Dictionary.cpp \ ../node/HttpClient.cpp \ ../node/Identity.cpp \ + ../node/IncomingPacket.cpp \ ../node/InetAddress.cpp \ - ../node/IpcConnection.cpp \ - ../node/IpcListener.cpp \ ../node/Logger.cpp \ ../node/Multicaster.cpp \ ../node/Network.cpp \ ../node/NetworkConfig.cpp \ ../node/Node.cpp \ ../node/NodeConfig.cpp \ + ../node/OutboundMulticast.cpp \ ../node/Packet.cpp \ - ../node/PacketDecoder.cpp \ ../node/Peer.cpp \ ../node/Poly1305.cpp \ ../node/RoutingTable.cpp \ ../node/Salsa20.cpp \ ../node/Service.cpp \ ../node/SHA512.cpp \ - ../node/SocketManager.cpp \ ../node/SoftwareUpdater.cpp \ ../node/Switch.cpp \ - ../node/TcpSocket.cpp \ ../node/Topology.cpp \ - ../node/UdpSocket.cpp \ ../node/Utils.cpp \ - ../ext/lz4/lz4.c \ - ../node/Dictionary.cpp + ../ext/lz4/lz4.c HEADERS += mainwindow.h \ - aboutwindow.h \ - networkwidget.h \ - installdialog.h \ - mac_doprivileged.h \ - licensedialog.h \ - main.h \ - onetimedialog.h \ + aboutwindow.h \ + networkwidget.h \ + installdialog.h \ + mac_doprivileged.h \ + licensedialog.h \ + main.h \ + onetimedialog.h \ + ../control/IpcConnection.hpp \ + ../control/IpcListener.hpp \ + ../control/NodeControlClient.hpp \ + ../control/NodeControlService.hpp \ ../node/Address.hpp \ + ../node/AntiRecursion.hpp \ ../node/Array.hpp \ ../node/AtomicCounter.hpp \ ../node/BandwidthAccount.hpp \ @@ -69,11 +74,12 @@ HEADERS += mainwindow.h \ ../node/Constants.hpp \ ../node/Defaults.hpp \ ../node/Dictionary.hpp \ + ../node/EthernetTap.hpp \ + ../node/EthernetTapFactory.hpp \ ../node/HttpClient.hpp \ ../node/Identity.hpp \ + ../node/IncomingPacket.hpp \ ../node/InetAddress.hpp \ - ../node/IpcConnection.hpp \ - ../node/IpcListener.hpp \ ../node/Logger.hpp \ ../node/MAC.hpp \ ../node/Multicaster.hpp \ @@ -84,11 +90,12 @@ HEADERS += mainwindow.h \ ../node/Node.hpp \ ../node/NodeConfig.hpp \ ../node/NonCopyable.hpp \ + ../node/OutboundMulticast.hpp \ ../node/Packet.hpp \ - ../node/PacketDecoder.hpp \ ../node/Path.hpp \ ../node/Peer.hpp \ ../node/Poly1305.hpp \ + ../node/RoutingTable.hpp \ ../node/RuntimeEnvironment.hpp \ ../node/Salsa20.hpp \ ../node/Service.hpp \ @@ -98,15 +105,10 @@ HEADERS += mainwindow.h \ ../node/SocketManager.hpp \ ../node/SoftwareUpdater.hpp \ ../node/Switch.hpp \ - ../node/RoutingTable.hpp \ - ../node/TcpSocket.hpp \ ../node/Thread.hpp \ ../node/Topology.hpp \ - ../node/UdpSocket.hpp \ ../node/Utils.hpp \ - ../ext/lz4/lz4.h \ - ../node/EthernetTap.hpp \ - ../node/EthernetTapFactory.hpp + ../ext/lz4/lz4.h FORMS += mainwindow.ui \ aboutwindow.ui \ diff --git a/ZeroTierUI/mainwindow.cpp b/ZeroTierUI/mainwindow.cpp index 46b5e9e04..3b91a6ff7 100644 --- a/ZeroTierUI/mainwindow.cpp +++ b/ZeroTierUI/mainwindow.cpp @@ -62,8 +62,11 @@ #include "mac_doprivileged.h" #endif +#include "../node/Utils.hpp" +#include "../node/Identity.hpp" + // Globally visible -ZeroTier::Node::NodeControlClient *zeroTierClient = (ZeroTier::Node::NodeControlClient *)0; +ZeroTier::NodeControlClient *zeroTierClient = (ZeroTier::NodeControlClient *)0; // Main window instance for app QMainWindow *mainWindow = (MainWindow *)0; @@ -77,6 +80,7 @@ static void handleZTMessage(void *arg,const char *line) ztReplies_m.lock(); if (line) { + //printf("%s\n",line); if ((line[0] == '.')&&(line[1] == (char)0)) { // The message is packed into an event and sent to the main window where // the actual parsing code lives. @@ -136,7 +140,7 @@ MainWindow::~MainWindow() { delete ui; delete zeroTierClient; - zeroTierClient = (ZeroTier::Node::NodeControlClient *)0; + zeroTierClient = (ZeroTier::NodeControlClient *)0; mainWindow = (MainWindow *)0; } @@ -161,7 +165,7 @@ void MainWindow::timerEvent(QTimerEvent *event) // event can be null since code if (!zeroTierClient) { #ifdef __APPLE__ - if ((!QFile::exists(ZeroTier::Node::NodeControlClient::authTokenDefaultUserPath()))&&(QFile::exists("/Library/Application Support/ZeroTier/One/zerotier-one"))) { + if ((!QFile::exists(ZeroTier::NodeControlClient::authTokenDefaultUserPath()))&&(QFile::exists("/Library/Application Support/ZeroTier/One/zerotier-one"))) { // Authorize user by copying auth token into local home directory QMessageBox::information(this,"Authorization Needed","Administrator privileges are required to allow the current user to control ZeroTier One on this computer. (You only have to do this once.)",QMessageBox::Ok,QMessageBox::NoButton); @@ -204,14 +208,21 @@ void MainWindow::timerEvent(QTimerEvent *event) // event can be null since code #endif // __APPLE__ try { - zeroTierClient = new ZeroTier::Node::NodeControlClient((const char *)0,&handleZTMessage,this); - const char *err = zeroTierClient->error(); - if (err) { - delete zeroTierClient; - zeroTierClient = (ZeroTier::Node::NodeControlClient *)0; + std::string buf; + if (ZeroTier::Utils::readFile("/Library/Application Support/ZeroTier/One/identity.public",buf)) { + ZeroTier::Identity id; + if (id.fromString(buf)) { + std::string authToken(ZeroTier::NodeControlClient::getAuthToken(ZeroTier::NodeControlClient::authTokenDefaultUserPath(),false)); + zeroTierClient = new ZeroTier::NodeControlClient((std::string(ZT_IPC_ENDPOINT_BASE) + id.address().toString()).c_str(),authToken.c_str(),&handleZTMessage,this); + const char *err = zeroTierClient->error(); + if (err) { + delete zeroTierClient; + zeroTierClient = (ZeroTier::NodeControlClient *)0; + } + } } } catch ( ... ) { - zeroTierClient = (ZeroTier::Node::NodeControlClient *)0; + zeroTierClient = (ZeroTier::NodeControlClient *)0; } } @@ -237,7 +248,7 @@ void MainWindow::customEvent(QEvent *event) ZTMessageEvent *m = (ZTMessageEvent *)event; // only one custom event type so far if (m->ztMessage.size() == 0) return; - std::vector hdr(ZeroTier::Node::NodeControlClient::splitLine(m->ztMessage[0])); + std::vector hdr(ZeroTier::NodeControlClient::splitLine(m->ztMessage[0])); if (hdr.size() < 2) return; if (hdr[0] != "200") @@ -255,7 +266,7 @@ void MainWindow::customEvent(QEvent *event) } else if (hdr[1] == "listnetworks") { std::map< std::string,std::vector > newNetworks; for(unsigned long i=1;iztMessage.size();++i) { - std::vector l(ZeroTier::Node::NodeControlClient::splitLine(m->ztMessage[i])); + std::vector l(ZeroTier::NodeControlClient::splitLine(m->ztMessage[i])); // 200 listnetworks if ((l.size() == 10)&&(l[2].length() == 16)) newNetworks[l[2]] = l; diff --git a/ZeroTierUI/mainwindow.h b/ZeroTierUI/mainwindow.h index c26661758..1b6f3f794 100644 --- a/ZeroTierUI/mainwindow.h +++ b/ZeroTierUI/mainwindow.h @@ -42,6 +42,7 @@ #include "../node/Constants.hpp" #include "../node/Node.hpp" #include "../node/Utils.hpp" +#include "../control/NodeControlClient.hpp" namespace Ui { class MainWindow; @@ -49,7 +50,7 @@ class MainWindow; // Globally visible instance of local client for communicating with ZT1 // Can be null if not connected, or will point to current -extern ZeroTier::Node::NodeControlClient *zeroTierClient; +extern ZeroTier::NodeControlClient *zeroTierClient; // Globally visible pointer to main app window extern QMainWindow *mainWindow; diff --git a/make-mac.mk b/make-mac.mk index 0ca12c7b2..1e66d0892 100644 --- a/make-mac.mk +++ b/make-mac.mk @@ -68,7 +68,7 @@ mac-ui: FORCE $(CODESIGN) -vvv "build-ZeroTierUI-release/ZeroTier One.app" clean: - rm -rf *.dSYM testnet.o selftest.o build-* $(OBJS) $(TESTNET_OBJS) zerotier-* ZeroTierOneInstaller-* "ZeroTier One.zip" "ZeroTier One.dmg" + rm -rf *.dSYM testnet.o selftest.o build-* *.o $(OBJS) $(TESTNET_OBJS) zerotier-* ZeroTierOneInstaller-* "ZeroTier One.zip" "ZeroTier One.dmg" # For our use -- builds official signed binary, packages in installer and download DMG official: FORCE