summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-02-05 12:38:37 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-02-05 12:38:37 -0800
commit3f6152806f9f1edc461dd3d6a828a4f69fffc3f7 (patch)
tree5e519e3eaddd0a39e410d17800b7aa16cdf510b6
parent7fdca150a9f2a689ed58dc7fb3c548551e27456f (diff)
downloadinfinitytier-3f6152806f9f1edc461dd3d6a828a4f69fffc3f7.tar.gz
infinitytier-3f6152806f9f1edc461dd3d6a828a4f69fffc3f7.zip
Add security notice the first time a user joins a public network.
-rw-r--r--ZeroTierUI/ZeroTierUI.pro9
-rw-r--r--ZeroTierUI/main.h1
-rw-r--r--ZeroTierUI/mainwindow.cpp2
-rw-r--r--ZeroTierUI/mainwindow.h3
-rw-r--r--ZeroTierUI/networkwidget.cpp15
-rw-r--r--ZeroTierUI/networkwidget.h1
-rw-r--r--ZeroTierUI/onetimedialog.cpp37
-rw-r--r--ZeroTierUI/onetimedialog.h26
-rw-r--r--ZeroTierUI/onetimedialog.ui99
9 files changed, 186 insertions, 7 deletions
diff --git a/ZeroTierUI/ZeroTierUI.pro b/ZeroTierUI/ZeroTierUI.pro
index c379bd0a..c90ede1d 100644
--- a/ZeroTierUI/ZeroTierUI.pro
+++ b/ZeroTierUI/ZeroTierUI.pro
@@ -45,7 +45,8 @@ SOURCES += main.cpp \
../ext/lz4/lz4hc.c \
networkwidget.cpp \
installdialog.cpp \
- licensedialog.cpp
+ licensedialog.cpp \
+ onetimedialog.cpp
HEADERS += mainwindow.h \
aboutwindow.h \
@@ -98,14 +99,16 @@ HEADERS += mainwindow.h \
installdialog.h \
mac_doprivileged.h \
licensedialog.h \
- main.h
+ main.h \
+ onetimedialog.h
FORMS += mainwindow.ui \
aboutwindow.ui \
networkwidget.ui \
installdialog.ui \
licensedialog.ui \
- quickstartdialog.ui
+ quickstartdialog.ui \
+ onetimedialog.ui
RESOURCES += \
resources.qrc
diff --git a/ZeroTierUI/main.h b/ZeroTierUI/main.h
index 9ab950d1..bee0e51b 100644
--- a/ZeroTierUI/main.h
+++ b/ZeroTierUI/main.h
@@ -2,6 +2,7 @@
#define MAIN_H
#include <QSettings>
+#include <QMainWindow>
extern QSettings *settings;
diff --git a/ZeroTierUI/mainwindow.cpp b/ZeroTierUI/mainwindow.cpp
index c03a95d7..d0dd7351 100644
--- a/ZeroTierUI/mainwindow.cpp
+++ b/ZeroTierUI/mainwindow.cpp
@@ -66,7 +66,7 @@
ZeroTier::Node::LocalClient *zeroTierClient = (ZeroTier::Node::LocalClient *)0;
// Main window instance for app
-static MainWindow *mainWindow = (MainWindow *)0;
+QMainWindow *mainWindow = (MainWindow *)0;
// Handles message from ZeroTier One service
static void handleZTMessage(void *arg,unsigned long id,const char *line)
diff --git a/ZeroTierUI/mainwindow.h b/ZeroTierUI/mainwindow.h
index c6244428..679a727e 100644
--- a/ZeroTierUI/mainwindow.h
+++ b/ZeroTierUI/mainwindow.h
@@ -51,6 +51,9 @@ class MainWindow;
// Can be null if not connected, or will point to current
extern ZeroTier::Node::LocalClient *zeroTierClient;
+// Globally visible pointer to main app window
+extern QMainWindow *mainWindow;
+
class MainWindow : public QMainWindow
{
Q_OBJECT
diff --git a/ZeroTierUI/networkwidget.cpp b/ZeroTierUI/networkwidget.cpp
index a99fef1e..0fdaa514 100644
--- a/ZeroTierUI/networkwidget.cpp
+++ b/ZeroTierUI/networkwidget.cpp
@@ -28,6 +28,8 @@
#include "networkwidget.h"
#include "mainwindow.h"
#include "ui_networkwidget.h"
+#include "onetimedialog.h"
+#include "main.h"
#include <QClipboard>
#include <QString>
@@ -43,7 +45,8 @@
NetworkWidget::NetworkWidget(QWidget *parent,const std::string &nwid) :
QWidget(parent),
ui(new Ui::NetworkWidget),
- networkIdStr(nwid)
+ networkIdStr(nwid),
+ publicWarningShown(false)
{
ui->setupUi(this);
ui->networkIdButton->setText(QString(nwid.c_str()));
@@ -98,9 +101,15 @@ void NetworkWidget::setNetworkType(const std::string &type)
ui->networkTypeLabel->setText(QString(type.c_str()));
if (type == "?")
ui->networkTypeLabel->setStatusTip("Waiting for configuration...");
- else if (type == "public")
+ else if (type == "public") {
+ if ((!publicWarningShown)&&(!settings->value("shown_publicWarning",false).toBool())) {
+ publicWarningShown = true;
+ OneTimeDialog *d = new OneTimeDialog(mainWindow,"shown_publicWarning","Security Notice","Security Notice:"ZT_EOL_S""ZT_EOL_S"You have joined a public network. Anyone can join these. We recommend making sure that your system's automatic software updates are enabled and turning off any shared network services that you do not want people to access.");
+ d->setModal(false);
+ d->show();
+ }
ui->networkTypeLabel->setStatusTip("This network can be joined by anyone in the world.");
- else if (type == "private")
+ } else if (type == "private")
ui->networkTypeLabel->setStatusTip("This network is private; only authorized peers can join.");
else ui->networkTypeLabel->setStatusTip("Unknown network type.");
}
diff --git a/ZeroTierUI/networkwidget.h b/ZeroTierUI/networkwidget.h
index 9ff1ef99..6515e17a 100644
--- a/ZeroTierUI/networkwidget.h
+++ b/ZeroTierUI/networkwidget.h
@@ -62,6 +62,7 @@ private slots:
private:
Ui::NetworkWidget *ui;
std::string networkIdStr;
+ bool publicWarningShown;
};
#endif // NETWORK_H
diff --git a/ZeroTierUI/onetimedialog.cpp b/ZeroTierUI/onetimedialog.cpp
new file mode 100644
index 00000000..1c1d983b
--- /dev/null
+++ b/ZeroTierUI/onetimedialog.cpp
@@ -0,0 +1,37 @@
+#include "onetimedialog.h"
+#include "ui_onetimedialog.h"
+#include "main.h"
+
+OneTimeDialog::OneTimeDialog(QWidget *parent,const char *propName,const QString &title,const QString &message) :
+ QDialog(parent),
+ ui(new Ui::OneTimeDialog)
+{
+ ui->setupUi(this);
+
+ ui->label->setText(message);
+ this->setWindowTitle(title);
+ _propName = propName;
+
+#ifdef __WINDOWS__
+ QWidgetList widgets = this->findChildren<QWidget*>();
+ foreach(QWidget *widget, widgets) {
+ QFont font(widget->font());
+ font.setPointSizeF(font.pointSizeF() * 0.75);
+ widget->setFont(font);
+ }
+#endif
+}
+
+OneTimeDialog::~OneTimeDialog()
+{
+ delete ui;
+}
+
+void OneTimeDialog::on_pushButton_clicked()
+{
+ if (_propName) {
+ settings->setValue(_propName,ui->checkBox->isChecked());
+ settings->sync();
+ }
+ this->close();
+}
diff --git a/ZeroTierUI/onetimedialog.h b/ZeroTierUI/onetimedialog.h
new file mode 100644
index 00000000..3e76cd05
--- /dev/null
+++ b/ZeroTierUI/onetimedialog.h
@@ -0,0 +1,26 @@
+#ifndef ONETIMEDIALOG_H
+#define ONETIMEDIALOG_H
+
+#include <QDialog>
+
+namespace Ui {
+class OneTimeDialog;
+}
+
+class OneTimeDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit OneTimeDialog(QWidget *parent = 0,const char *propName = (const char *)0,const QString &title = QString(),const QString &message = QString());
+ ~OneTimeDialog();
+
+private slots:
+ void on_pushButton_clicked();
+
+private:
+ Ui::OneTimeDialog *ui;
+ const char *_propName;
+};
+
+#endif // ONETIMEDIALOG_H
diff --git a/ZeroTierUI/onetimedialog.ui b/ZeroTierUI/onetimedialog.ui
new file mode 100644
index 00000000..227cdc38
--- /dev/null
+++ b/ZeroTierUI/onetimedialog.ui
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>OneTimeDialog</class>
+ <widget class="QDialog" name="OneTimeDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>496</width>
+ <height>197</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ <property name="margin">
+ <number>12</number>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::NoTextInteraction</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QWidget" name="widget" native="true">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="leftMargin">
+ <number>12</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>12</number>
+ </property>
+ <property name="bottomMargin">
+ <number>5</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="checkBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Don't Show This Message Again</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButton">
+ <property name="text">
+ <string>OK</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>