mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
various qt work
This commit is contained in:
parent
9925e2732a
commit
275da075e0
|
@ -301,5 +301,19 @@ namespace config {
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GetOptionAsAny(const char *name, boost::any& value) {
|
||||
if (!m_Options.count(name))
|
||||
return false;
|
||||
value = m_Options[name];
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetOptionAsAny(const std::string& name, boost::any& value)
|
||||
{
|
||||
return GetOptionAsAny (name.c_str (), value);
|
||||
}
|
||||
|
||||
} // namespace config
|
||||
} // namespace i2p
|
||||
|
||||
|
|
|
@ -84,6 +84,9 @@ namespace config {
|
|||
return GetOption (name.c_str (), value);
|
||||
}
|
||||
|
||||
bool GetOptionAsAny(const char *name, boost::any& value);
|
||||
bool GetOptionAsAny(const std::string& name, boost::any& value);
|
||||
|
||||
/**
|
||||
* @brief Set value of given parameter
|
||||
* @param name Name of settable parameter
|
||||
|
|
22
qt/i2pd_qt/ClientTunnelPane.cpp
Normal file
22
qt/i2pd_qt/ClientTunnelPane.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include "ClientTunnelPane.h"
|
||||
|
||||
ClientTunnelPane::ClientTunnelPane()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ClientTunnelPane::deleteClientTunnelForm(QGridLayout *tunnelsFormGridLayout) {
|
||||
throw "TODO";
|
||||
/*TODO
|
||||
tunnelsFormGridLayout->removeWidget(clientTunnelNameGroupBox);
|
||||
|
||||
clientTunnelNameGroupBox->deleteLater();
|
||||
clientTunnelNameGroupBox=nullptr;
|
||||
|
||||
gridLayoutWidget_2->deleteLater();
|
||||
gridLayoutWidget_2=nullptr;
|
||||
*/
|
||||
}
|
||||
|
||||
ServerTunnelPane* ClientTunnelPane::asServerTunnelPane(){return nullptr;}
|
||||
ClientTunnelPane* ClientTunnelPane::asClientTunnelPane(){return this;}
|
21
qt/i2pd_qt/ClientTunnelPane.h
Normal file
21
qt/i2pd_qt/ClientTunnelPane.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#ifndef CLIENTTUNNELPANE_H
|
||||
#define CLIENTTUNNELPANE_H
|
||||
|
||||
#include "QGridLayout"
|
||||
|
||||
#include "TunnelPane.h"
|
||||
|
||||
class ServerTunnelPane;
|
||||
class TunnelPane;
|
||||
|
||||
class ClientTunnelPane : public TunnelPane {
|
||||
public:
|
||||
ClientTunnelPane();
|
||||
virtual ServerTunnelPane* asServerTunnelPane();
|
||||
virtual ClientTunnelPane* asClientTunnelPane();
|
||||
void deleteClientTunnelForm(QGridLayout *tunnelsFormGridLayout);
|
||||
protected slots:
|
||||
virtual void setGroupBoxTitle(const QString & title){}//TODO
|
||||
};
|
||||
|
||||
#endif // CLIENTTUNNELPANE_H
|
2
qt/i2pd_qt/MainWindowItems.cpp
Normal file
2
qt/i2pd_qt/MainWindowItems.cpp
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "MainWindowItems.h"
|
||||
|
17
qt/i2pd_qt/MainWindowItems.h
Normal file
17
qt/i2pd_qt/MainWindowItems.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef MAINWINDOWITEMS_H
|
||||
#define MAINWINDOWITEMS_H
|
||||
|
||||
#include <QString>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QComboBox>
|
||||
#include <QCheckBox>
|
||||
|
||||
#include <sstream>
|
||||
#include <functional>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
class MainWindow;
|
||||
|
||||
#endif // MAINWINDOWITEMS_H
|
239
qt/i2pd_qt/ServerTunnelPane.cpp
Normal file
239
qt/i2pd_qt/ServerTunnelPane.cpp
Normal file
|
@ -0,0 +1,239 @@
|
|||
#include "ServerTunnelPane.h"
|
||||
#include "../../ClientContext.h"
|
||||
|
||||
ServerTunnelPane::ServerTunnelPane(): TunnelPane() {}
|
||||
|
||||
void ServerTunnelPane::setGroupBoxTitle(const QString & title) {
|
||||
serverTunnelNameGroupBox->setTitle(title);
|
||||
}
|
||||
|
||||
void ServerTunnelPane::appendServerTunnelForm(
|
||||
ServerTunnelConfig* tunnelConfig, QWidget *tunnelsFormGridLayoutWidget, QGridLayout *tunnelsFormGridLayout) {
|
||||
|
||||
tunnelsFormGridLayoutWidget->resize(527, 452);
|
||||
|
||||
ServerTunnelPane& ui = *this;
|
||||
|
||||
serverTunnelNameGroupBox = new QGroupBox(tunnelsFormGridLayoutWidget);
|
||||
serverTunnelNameGroupBox->setObjectName(QStringLiteral("serverTunnelNameGroupBox"));
|
||||
|
||||
//tunnel
|
||||
ui.gridLayoutWidget_2 = new QWidget(serverTunnelNameGroupBox);
|
||||
|
||||
QComboBox *tunnelTypeComboBox = new QComboBox(gridLayoutWidget_2);
|
||||
tunnelTypeComboBox->setObjectName(QStringLiteral("tunnelTypeComboBox"));
|
||||
tunnelTypeComboBox->addItem("Server", i2p::client::I2P_TUNNELS_SECTION_TYPE_SERVER);
|
||||
tunnelTypeComboBox->addItem("HTTP", i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTP);
|
||||
tunnelTypeComboBox->addItem("IRC", i2p::client::I2P_TUNNELS_SECTION_TYPE_IRC);
|
||||
tunnelTypeComboBox->addItem("UDP Server", i2p::client::I2P_TUNNELS_SECTION_TYPE_UDPSERVER);
|
||||
|
||||
gridLayoutWidget_2->setGeometry(QRect(0, 10, 561, 18*40+10));
|
||||
|
||||
setupTunnelPane(tunnelConfig,
|
||||
serverTunnelNameGroupBox,
|
||||
gridLayoutWidget_2, tunnelTypeComboBox,
|
||||
tunnelsFormGridLayoutWidget, tunnelsFormGridLayout);
|
||||
|
||||
{
|
||||
const QString& type = tunnelConfig->getType();
|
||||
int index=0;
|
||||
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_SERVER)tunnelTypeComboBox->setCurrentIndex(index);
|
||||
++index;
|
||||
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTP)tunnelTypeComboBox->setCurrentIndex(index);
|
||||
++index;
|
||||
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_IRC)tunnelTypeComboBox->setCurrentIndex(index);
|
||||
++index;
|
||||
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_UDPSERVER)tunnelTypeComboBox->setCurrentIndex(index);
|
||||
++index;
|
||||
}
|
||||
|
||||
//host
|
||||
ui.horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
ui.hostLabel = new QLabel(gridLayoutWidget_2);
|
||||
hostLabel->setObjectName(QStringLiteral("hostLabel"));
|
||||
horizontalLayout_2->addWidget(hostLabel);
|
||||
ui.hostLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
hostLineEdit->setObjectName(QStringLiteral("hostLineEdit"));
|
||||
hostLineEdit->setText(tunnelConfig->gethost().c_str());
|
||||
horizontalLayout_2->addWidget(hostLineEdit);
|
||||
ui.hostHorizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(hostHorizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, 2, 0, 1, 1);
|
||||
|
||||
int gridIndex = 2;
|
||||
{
|
||||
int port = tunnelConfig->getport();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
ui.portLabel = new QLabel(gridLayoutWidget_2);
|
||||
portLabel->setObjectName(QStringLiteral("portLabel"));
|
||||
horizontalLayout_2->addWidget(portLabel);
|
||||
ui.portLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
portLineEdit->setObjectName(QStringLiteral("portLineEdit"));
|
||||
portLineEdit->setText(QString::number(port));
|
||||
portLineEdit->setMaximumWidth(80);
|
||||
horizontalLayout_2->addWidget(portLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
{
|
||||
std::string keys = tunnelConfig->getkeys();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
ui.keysLabel = new QLabel(gridLayoutWidget_2);
|
||||
keysLabel->setObjectName(QStringLiteral("keysLabel"));
|
||||
horizontalLayout_2->addWidget(keysLabel);
|
||||
ui.keysLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
keysLineEdit->setObjectName(QStringLiteral("keysLineEdit"));
|
||||
keysLineEdit->setText(keys.c_str());
|
||||
horizontalLayout_2->addWidget(keysLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
{
|
||||
int inPort = tunnelConfig->getinPort();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
ui.inPortLabel = new QLabel(gridLayoutWidget_2);
|
||||
inPortLabel->setObjectName(QStringLiteral("inPortLabel"));
|
||||
horizontalLayout_2->addWidget(inPortLabel);
|
||||
ui.inPortLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
inPortLineEdit->setObjectName(QStringLiteral("inPortLineEdit"));
|
||||
inPortLineEdit->setText(QString::number(inPort));
|
||||
inPortLineEdit->setMaximumWidth(80);
|
||||
horizontalLayout_2->addWidget(inPortLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
{
|
||||
std::string accessList = tunnelConfig->getaccessList();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
ui.accessListLabel = new QLabel(gridLayoutWidget_2);
|
||||
accessListLabel->setObjectName(QStringLiteral("accessListLabel"));
|
||||
horizontalLayout_2->addWidget(accessListLabel);
|
||||
ui.accessListLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
accessListLineEdit->setObjectName(QStringLiteral("accessListLineEdit"));
|
||||
accessListLineEdit->setText(accessList.c_str());
|
||||
horizontalLayout_2->addWidget(accessListLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
{
|
||||
std::string hostOverride = tunnelConfig->gethostOverride();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
ui.hostOverrideLabel = new QLabel(gridLayoutWidget_2);
|
||||
hostOverrideLabel->setObjectName(QStringLiteral("hostOverrideLabel"));
|
||||
horizontalLayout_2->addWidget(hostOverrideLabel);
|
||||
ui.hostOverrideLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
hostOverrideLineEdit->setObjectName(QStringLiteral("hostOverrideLineEdit"));
|
||||
hostOverrideLineEdit->setText(hostOverride.c_str());
|
||||
horizontalLayout_2->addWidget(hostOverrideLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
{
|
||||
std::string webIRCPass = tunnelConfig->getwebircpass();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
ui.webIRCPassLabel = new QLabel(gridLayoutWidget_2);
|
||||
webIRCPassLabel->setObjectName(QStringLiteral("webIRCPassLabel"));
|
||||
horizontalLayout_2->addWidget(webIRCPassLabel);
|
||||
ui.webIRCPassLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
webIRCPassLineEdit->setObjectName(QStringLiteral("webIRCPassLineEdit"));
|
||||
webIRCPassLineEdit->setText(webIRCPass.c_str());
|
||||
horizontalLayout_2->addWidget(webIRCPassLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
{
|
||||
bool gzip = tunnelConfig->getgzip();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
ui.gzipCheckBox = new QCheckBox(gridLayoutWidget_2);
|
||||
gzipCheckBox->setObjectName(QStringLiteral("gzipCheckBox"));
|
||||
gzipCheckBox->setChecked(gzip);
|
||||
horizontalLayout_2->addWidget(gzipCheckBox);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
{
|
||||
i2p::data::SigningKeyType sigType = tunnelConfig->getsigType();
|
||||
//combo box
|
||||
//TODO sigtype
|
||||
}
|
||||
{
|
||||
uint32_t maxConns = tunnelConfig->getmaxConns();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
ui.maxConnsLabel = new QLabel(gridLayoutWidget_2);
|
||||
maxConnsLabel->setObjectName(QStringLiteral("maxConnsLabel"));
|
||||
horizontalLayout_2->addWidget(maxConnsLabel);
|
||||
ui.maxConnsLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
maxConnsLineEdit->setObjectName(QStringLiteral("maxConnsLineEdit"));
|
||||
maxConnsLineEdit->setText(QString::number(maxConns));
|
||||
maxConnsLineEdit->setMaximumWidth(80);
|
||||
horizontalLayout_2->addWidget(maxConnsLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
{
|
||||
std::string address = tunnelConfig->getaddress();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
ui.addressLabel = new QLabel(gridLayoutWidget_2);
|
||||
addressLabel->setObjectName(QStringLiteral("addressLabel"));
|
||||
horizontalLayout_2->addWidget(addressLabel);
|
||||
ui.addressLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
addressLineEdit->setObjectName(QStringLiteral("addressLineEdit"));
|
||||
addressLineEdit->setText(address.c_str());
|
||||
horizontalLayout_2->addWidget(addressLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
{
|
||||
bool isUniqueLocal = tunnelConfig->getisUniqueLocal();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
ui.isUniqueLocalCheckBox = new QCheckBox(gridLayoutWidget_2);
|
||||
isUniqueLocalCheckBox->setObjectName(QStringLiteral("isUniqueLocalCheckBox"));
|
||||
isUniqueLocalCheckBox->setChecked(isUniqueLocal);
|
||||
horizontalLayout_2->addWidget(isUniqueLocalCheckBox);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
{
|
||||
I2CPParameters& i2cpParameters = tunnelConfig->getI2cpParameters();
|
||||
appendControlsForI2CPParameters(i2cpParameters, gridIndex);
|
||||
}
|
||||
|
||||
tunnelsFormGridLayout->addWidget(serverTunnelNameGroupBox, 0, 0, 1, 1);
|
||||
|
||||
retranslateServerTunnelForm(ui);
|
||||
}
|
||||
|
||||
void ServerTunnelPane::deleteServerTunnelForm(QGridLayout *tunnelsFormGridLayout) {
|
||||
tunnelsFormGridLayout->removeWidget(tunnelGroupBox);
|
||||
|
||||
tunnelGroupBox->deleteLater();
|
||||
tunnelGroupBox=nullptr;
|
||||
|
||||
gridLayoutWidget_2->deleteLater();
|
||||
gridLayoutWidget_2=nullptr;
|
||||
}
|
||||
|
||||
|
||||
ServerTunnelPane* ServerTunnelPane::asServerTunnelPane(){return this;}
|
||||
ClientTunnelPane* ServerTunnelPane::asClientTunnelPane(){return nullptr;}
|
110
qt/i2pd_qt/ServerTunnelPane.h
Normal file
110
qt/i2pd_qt/ServerTunnelPane.h
Normal file
|
@ -0,0 +1,110 @@
|
|||
#ifndef SERVERTUNNELPANE_H
|
||||
#define SERVERTUNNELPANE_H
|
||||
|
||||
#include "TunnelPane.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtWidgets/QAction>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QButtonGroup>
|
||||
#include <QtWidgets/QComboBox>
|
||||
#include <QtWidgets/QGridLayout>
|
||||
#include <QtWidgets/QGroupBox>
|
||||
#include <QtWidgets/QHBoxLayout>
|
||||
#include <QtWidgets/QHeaderView>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QLineEdit>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QSpacerItem>
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
class ServerTunnelConfig;
|
||||
|
||||
class ClientTunnelPane;
|
||||
|
||||
class ServerTunnelPane : public TunnelPane {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ServerTunnelPane();
|
||||
virtual ~ServerTunnelPane(){}
|
||||
|
||||
virtual ServerTunnelPane* asServerTunnelPane();
|
||||
virtual ClientTunnelPane* asClientTunnelPane();
|
||||
|
||||
void appendServerTunnelForm(ServerTunnelConfig* tunnelConfig, QWidget *tunnelsFormGridLayoutWidget, QGridLayout *tunnelsFormGridLayout);
|
||||
void deleteServerTunnelForm(QGridLayout *tunnelsFormGridLayout);
|
||||
|
||||
private:
|
||||
QGroupBox *serverTunnelNameGroupBox;
|
||||
|
||||
//tunnel
|
||||
QWidget *gridLayoutWidget_2;
|
||||
|
||||
//host
|
||||
QHBoxLayout *horizontalLayout_2;
|
||||
QLabel *hostLabel;
|
||||
QLineEdit *hostLineEdit;
|
||||
QSpacerItem *hostHorizontalSpacer;
|
||||
|
||||
//port
|
||||
QLabel * portLabel;
|
||||
QLineEdit * portLineEdit;
|
||||
|
||||
//keys
|
||||
QLabel * keysLabel;
|
||||
QLineEdit * keysLineEdit;
|
||||
|
||||
//inPort
|
||||
QLabel * inPortLabel;
|
||||
QLineEdit * inPortLineEdit;
|
||||
|
||||
//accessList
|
||||
QLabel * accessListLabel;
|
||||
QLineEdit * accessListLineEdit;
|
||||
|
||||
//hostOverride
|
||||
QLabel * hostOverrideLabel;
|
||||
QLineEdit * hostOverrideLineEdit;
|
||||
|
||||
//webIRCPass
|
||||
QLabel * webIRCPassLabel;
|
||||
QLineEdit * webIRCPassLineEdit;
|
||||
|
||||
//address
|
||||
QLabel * addressLabel;
|
||||
QLineEdit * addressLineEdit;
|
||||
|
||||
//maxConns
|
||||
QLabel * maxConnsLabel;
|
||||
QLineEdit * maxConnsLineEdit;
|
||||
|
||||
//gzip
|
||||
QCheckBox * gzipCheckBox;
|
||||
|
||||
//isUniqueLocal
|
||||
QCheckBox * isUniqueLocalCheckBox;
|
||||
|
||||
protected slots:
|
||||
virtual void setGroupBoxTitle(const QString & title);
|
||||
|
||||
private:
|
||||
void retranslateServerTunnelForm(ServerTunnelPane& /*ui*/) {
|
||||
hostLabel->setText(QApplication::translate("srvTunForm", "Host:", 0));
|
||||
portLabel->setText(QApplication::translate("srvTunForm", "Port:", 0));
|
||||
keysLabel->setText(QApplication::translate("srvTunForm", "Keys:", 0));
|
||||
inPortLabel->setText(QApplication::translate("srvTunForm", "InPort:", 0));
|
||||
accessListLabel->setText(QApplication::translate("srvTunForm", "Access list:", 0));
|
||||
hostOverrideLabel->setText(QApplication::translate("srvTunForm", "Host override:", 0));
|
||||
webIRCPassLabel->setText(QApplication::translate("srvTunForm", "WebIRC password:", 0));
|
||||
addressLabel->setText(QApplication::translate("srvTunForm", "Address:", 0));
|
||||
maxConnsLabel->setText(QApplication::translate("srvTunForm", "Max connections:", 0));
|
||||
|
||||
gzipCheckBox->setText(QApplication::translate("srvTunForm", "GZip", 0));
|
||||
isUniqueLocalCheckBox->setText(QApplication::translate("srvTunForm", "Is unique local", 0));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // SERVERTUNNELPANE_H
|
2
qt/i2pd_qt/TunnelConfig.cpp
Normal file
2
qt/i2pd_qt/TunnelConfig.cpp
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "TunnelConfig.h"
|
||||
|
221
qt/i2pd_qt/TunnelConfig.h
Normal file
221
qt/i2pd_qt/TunnelConfig.h
Normal file
|
@ -0,0 +1,221 @@
|
|||
#ifndef TUNNELCONFIG_H
|
||||
#define TUNNELCONFIG_H
|
||||
|
||||
#include "QString"
|
||||
#include <string>
|
||||
|
||||
#include "../../ClientContext.h"
|
||||
|
||||
|
||||
class I2CPParameters{
|
||||
QString inbound_length;//number of hops of an inbound tunnel. 3 by default; lower value is faster but dangerous
|
||||
QString outbound_length;//number of hops of an outbound tunnel. 3 by default; lower value is faster but dangerous
|
||||
QString inbound_quantity; //number of inbound tunnels. 5 by default
|
||||
QString outbound_quantity; //number of outbound tunnels. 5 by default
|
||||
QString crypto_tagsToSend; //number of ElGamal/AES tags to send. 40 by default; too low value may cause problems with tunnel building
|
||||
QString explicitPeers; //list of comma-separated b64 addresses of peers to use, default: unset
|
||||
public:
|
||||
I2CPParameters(): inbound_length(),
|
||||
outbound_length(),
|
||||
inbound_quantity(),
|
||||
outbound_quantity(),
|
||||
crypto_tagsToSend(),
|
||||
explicitPeers() {}
|
||||
const QString& getInbound_length(){return inbound_length;}
|
||||
const QString& getOutbound_length(){return outbound_length;}
|
||||
const QString& getInbound_quantity(){return inbound_quantity;}
|
||||
const QString& getOutbound_quantity(){return outbound_quantity;}
|
||||
const QString& getCrypto_tagsToSend(){return crypto_tagsToSend;}
|
||||
const QString& getExplicitPeers(){return explicitPeers;}
|
||||
void setInbound_length(QString inbound_length_){inbound_length=inbound_length_;}
|
||||
void setOutbound_length(QString outbound_length_){outbound_length=outbound_length_;}
|
||||
void setInbound_quantity(QString inbound_quantity_){inbound_quantity=inbound_quantity_;}
|
||||
void setOutbound_quantity(QString outbound_quantity_){outbound_quantity=outbound_quantity_;}
|
||||
void setCrypto_tagsToSend(QString crypto_tagsToSend_){crypto_tagsToSend=crypto_tagsToSend_;}
|
||||
void setExplicitPeers(QString explicitPeers_){explicitPeers=explicitPeers_;}
|
||||
};
|
||||
|
||||
|
||||
class ClientTunnelConfig;
|
||||
class ServerTunnelConfig;
|
||||
class TunnelConfig {
|
||||
/*
|
||||
const char I2P_TUNNELS_SECTION_TYPE_CLIENT[] = "client";
|
||||
const char I2P_TUNNELS_SECTION_TYPE_SERVER[] = "server";
|
||||
const char I2P_TUNNELS_SECTION_TYPE_HTTP[] = "http";
|
||||
const char I2P_TUNNELS_SECTION_TYPE_IRC[] = "irc";
|
||||
const char I2P_TUNNELS_SECTION_TYPE_UDPCLIENT[] = "udpclient";
|
||||
const char I2P_TUNNELS_SECTION_TYPE_UDPSERVER[] = "udpserver";
|
||||
const char I2P_TUNNELS_SECTION_TYPE_SOCKS[] = "socks";
|
||||
const char I2P_TUNNELS_SECTION_TYPE_WEBSOCKS[] = "websocks";
|
||||
const char I2P_TUNNELS_SECTION_TYPE_HTTPPROXY[] = "httpproxy";
|
||||
*/
|
||||
QString type;
|
||||
std::string name;
|
||||
public:
|
||||
TunnelConfig(std::string name_, QString& type_, I2CPParameters& i2cpParameters_): type(type_), name(name_), i2cpParameters(i2cpParameters_) {}
|
||||
const QString& getType(){return type;}
|
||||
const std::string& getName(){return name;}
|
||||
void setType(const QString& type_){type=type_;}
|
||||
void setName(const std::string& name_){name=name_;}
|
||||
I2CPParameters& getI2cpParameters(){return i2cpParameters;}
|
||||
virtual ClientTunnelConfig* asClientTunnelConfig()=0;
|
||||
virtual ServerTunnelConfig* asServerTunnelConfig()=0;
|
||||
|
||||
private:
|
||||
I2CPParameters i2cpParameters;
|
||||
};
|
||||
|
||||
/*
|
||||
# mandatory parameters:
|
||||
std::string dest;
|
||||
if (type == I2P_TUNNELS_SECTION_TYPE_CLIENT || type == I2P_TUNNELS_SECTION_TYPE_UDPCLIENT)
|
||||
dest = section.second.get<std::string> (I2P_CLIENT_TUNNEL_DESTINATION);
|
||||
int port = section.second.get<int> (I2P_CLIENT_TUNNEL_PORT);
|
||||
# optional parameters (may be omitted)
|
||||
std::string keys = section.second.get (I2P_CLIENT_TUNNEL_KEYS, "");
|
||||
std::string address = section.second.get (I2P_CLIENT_TUNNEL_ADDRESS, "127.0.0.1");
|
||||
int destinationPort = section.second.get (I2P_CLIENT_TUNNEL_DESTINATION_PORT, 0);
|
||||
i2p::data::SigningKeyType sigType = section.second.get (I2P_CLIENT_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256);
|
||||
# * keys -- our identity, if unset, will be generated on every startup,
|
||||
# if set and file missing, keys will be generated and placed to this file
|
||||
# * address -- local interface to bind
|
||||
# * signaturetype -- signature type for new destination. 0 (DSA/SHA1), 1 (EcDSA/SHA256) or 7 (EdDSA/SHA512)
|
||||
[somelabel]
|
||||
type = client
|
||||
address = 127.0.0.1
|
||||
port = 6668
|
||||
destination = irc.postman.i2p
|
||||
keys = irc-keys.dat
|
||||
*/
|
||||
class ClientTunnelConfig : public TunnelConfig {
|
||||
std::string dest;
|
||||
int port;
|
||||
std::string keys;
|
||||
std::string address;
|
||||
int destinationPort;
|
||||
i2p::data::SigningKeyType sigType;
|
||||
public:
|
||||
ClientTunnelConfig(std::string name_, QString type_, I2CPParameters& i2cpParameters_,
|
||||
std::string dest_,
|
||||
int port_,
|
||||
std::string keys_,
|
||||
std::string address_,
|
||||
int destinationPort_,
|
||||
i2p::data::SigningKeyType sigType_): TunnelConfig(name_, type_, i2cpParameters_),
|
||||
dest(dest_),
|
||||
port(port_),
|
||||
keys(keys_),
|
||||
address(address_),
|
||||
destinationPort(destinationPort_) {}
|
||||
std::string& getdest(){return dest;}
|
||||
int getport(){return port;}
|
||||
std::string & getkeys(){return keys;}
|
||||
std::string & getaddress(){return address;}
|
||||
int getdestinationPort(){return destinationPort;}
|
||||
i2p::data::SigningKeyType getsigType(){return sigType;}
|
||||
void setdest(std::string& dest_){dest=dest_;}
|
||||
void setport(int port_){port=port_;}
|
||||
void setkeys(std::string & keys_){keys=keys_;}
|
||||
void setaddress(std::string & address_){address=address_;}
|
||||
void setdestinationPort(int destinationPort_){destinationPort=destinationPort_;}
|
||||
void setsigType(i2p::data::SigningKeyType sigType_){sigType=sigType_;}
|
||||
virtual ClientTunnelConfig* asClientTunnelConfig(){return this;}
|
||||
virtual ServerTunnelConfig* asServerTunnelConfig(){return nullptr;}
|
||||
};
|
||||
|
||||
/*
|
||||
# mandatory parameters:
|
||||
# * host -- ip address of our service
|
||||
# * port -- port of our service
|
||||
# * keys -- file with LeaseSet of address in i2p
|
||||
std::string host = section.second.get<std::string> (I2P_SERVER_TUNNEL_HOST);
|
||||
int port = section.second.get<int> (I2P_SERVER_TUNNEL_PORT);
|
||||
std::string keys = section.second.get<std::string> (I2P_SERVER_TUNNEL_KEYS);
|
||||
# optional parameters (may be omitted)
|
||||
int inPort = section.second.get (I2P_SERVER_TUNNEL_INPORT, 0);
|
||||
std::string accessList = section.second.get (I2P_SERVER_TUNNEL_ACCESS_LIST, "");
|
||||
std::string hostOverride = section.second.get (I2P_SERVER_TUNNEL_HOST_OVERRIDE, "");
|
||||
std::string webircpass = section.second.get<std::string> (I2P_SERVER_TUNNEL_WEBIRC_PASSWORD, "");
|
||||
bool gzip = section.second.get (I2P_SERVER_TUNNEL_GZIP, true);
|
||||
i2p::data::SigningKeyType sigType = section.second.get (I2P_SERVER_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256);
|
||||
uint32_t maxConns = section.second.get(i2p::stream::I2CP_PARAM_STREAMING_MAX_CONNS_PER_MIN, i2p::stream::DEFAULT_MAX_CONNS_PER_MIN);
|
||||
std::string address = section.second.get<std::string> (I2P_SERVER_TUNNEL_ADDRESS, "127.0.0.1");
|
||||
bool isUniqueLocal = section.second.get(I2P_SERVER_TUNNEL_ENABLE_UNIQUE_LOCAL, true);
|
||||
# * inport -- optional, i2p service port, if unset - the same as 'port'
|
||||
# * accesslist -- comma-separated list of i2p addresses, allowed to connect
|
||||
# every address is b32 without '.b32.i2p' part
|
||||
[somelabel]
|
||||
type = server
|
||||
host = 127.0.0.1
|
||||
port = 6667
|
||||
keys = irc.dat
|
||||
*/
|
||||
class ServerTunnelConfig : public TunnelConfig {
|
||||
std::string host;
|
||||
int port;
|
||||
std::string keys;
|
||||
int inPort;
|
||||
std::string accessList;
|
||||
std::string hostOverride;
|
||||
std::string webircpass;
|
||||
bool gzip;
|
||||
i2p::data::SigningKeyType sigType;
|
||||
uint32_t maxConns;
|
||||
std::string address;
|
||||
bool isUniqueLocal;
|
||||
public:
|
||||
ServerTunnelConfig(std::string name_, QString type_, I2CPParameters& i2cpParameters_,
|
||||
std::string host_,
|
||||
int port_,
|
||||
std::string keys_,
|
||||
int inPort_,
|
||||
std::string accessList_,
|
||||
std::string hostOverride_,
|
||||
std::string webircpass_,
|
||||
bool gzip_,
|
||||
i2p::data::SigningKeyType sigType_,
|
||||
uint32_t maxConns_,
|
||||
std::string address_,
|
||||
bool isUniqueLocal_): TunnelConfig(name_, type_, i2cpParameters_),
|
||||
host(host_),
|
||||
port(port_),
|
||||
keys(keys_),
|
||||
inPort(inPort_),
|
||||
accessList(accessList_),
|
||||
hostOverride(hostOverride_),
|
||||
webircpass(webircpass_),
|
||||
gzip(gzip_),
|
||||
sigType(sigType_),
|
||||
maxConns(maxConns_),
|
||||
address(address_) {}
|
||||
std::string& gethost(){return host;}
|
||||
int getport(){return port;}
|
||||
std::string& getkeys(){return keys;}
|
||||
int getinPort(){return inPort;}
|
||||
std::string& getaccessList(){return accessList;}
|
||||
std::string& gethostOverride(){return hostOverride;}
|
||||
std::string& getwebircpass(){return webircpass;}
|
||||
bool getgzip(){return gzip;}
|
||||
i2p::data::SigningKeyType getsigType(){return sigType;}
|
||||
uint32_t getmaxConns(){return maxConns;}
|
||||
std::string& getaddress(){return address;}
|
||||
bool getisUniqueLocal(){return isUniqueLocal;}
|
||||
void sethost(std::string& host_){host=host_;}
|
||||
void setport(int port_){port=port_;}
|
||||
void setkeys(std::string& keys_){keys=keys_;}
|
||||
void setinPort(int inPort_){inPort=inPort_;}
|
||||
void setaccessList(std::string& accessList_){accessList=accessList_;}
|
||||
void sethostOverride(std::string& hostOverride_){hostOverride=hostOverride_;}
|
||||
void setwebircpass(std::string& webircpass_){webircpass=webircpass_;}
|
||||
void setgzip(bool gzip_){gzip=gzip_;}
|
||||
void setsigType(i2p::data::SigningKeyType sigType_){sigType=sigType_;}
|
||||
void setmaxConns(uint32_t maxConns_){maxConns=maxConns_;}
|
||||
void setaddress(std::string& address_){address=address_;}
|
||||
void setisUniqueLocal(bool isUniqueLocal_){isUniqueLocal=isUniqueLocal_;}
|
||||
virtual ClientTunnelConfig* asClientTunnelConfig(){return nullptr;}
|
||||
virtual ServerTunnelConfig* asServerTunnelConfig(){return this;}
|
||||
};
|
||||
|
||||
|
||||
#endif // TUNNELCONFIG_H
|
149
qt/i2pd_qt/TunnelPane.cpp
Normal file
149
qt/i2pd_qt/TunnelPane.cpp
Normal file
|
@ -0,0 +1,149 @@
|
|||
#include "TunnelPane.h"
|
||||
|
||||
TunnelPane::TunnelPane(): QObject(),gridLayoutWidget_2(nullptr) {
|
||||
}
|
||||
|
||||
void TunnelPane::setupTunnelPane(
|
||||
TunnelConfig* tunnelConfig,
|
||||
QGroupBox *tunnelGroupBox,
|
||||
QWidget* gridLayoutWidget_2, QComboBox * tunnelTypeComboBox,
|
||||
QWidget */*tunnelsFormGridLayoutWidget*/, QGridLayout */*tunnelsFormGridLayout*/) {
|
||||
this->tunnelGroupBox=tunnelGroupBox;
|
||||
gridLayoutWidget_2->setObjectName(QStringLiteral("gridLayoutWidget_2"));
|
||||
this->gridLayoutWidget_2=gridLayoutWidget_2;
|
||||
tunnelGridLayout = new QGridLayout(gridLayoutWidget_2);
|
||||
tunnelGridLayout->setObjectName(QStringLiteral("tunnelGridLayout"));
|
||||
tunnelGridLayout->setContentsMargins(5, 5, 5, 5);
|
||||
tunnelGridLayout->setVerticalSpacing(5);
|
||||
|
||||
//header
|
||||
QHBoxLayout *headerHorizontalLayout = new QHBoxLayout();
|
||||
headerHorizontalLayout->setObjectName(QStringLiteral("headerHorizontalLayout"));
|
||||
|
||||
nameLabel = new QLabel(gridLayoutWidget_2);
|
||||
nameLabel->setObjectName(QStringLiteral("nameLabel"));
|
||||
headerHorizontalLayout->addWidget(nameLabel);
|
||||
nameLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
nameLineEdit->setObjectName(QStringLiteral("nameLineEdit"));
|
||||
const QString& tunnelName=tunnelConfig->getName().c_str();
|
||||
nameLineEdit->setText(tunnelName);
|
||||
setGroupBoxTitle(tunnelName);
|
||||
|
||||
QObject::connect(nameLineEdit, SIGNAL(textChanged(const QString &)),
|
||||
this, SLOT(setGroupBoxTitle(const QString &)));
|
||||
|
||||
headerHorizontalLayout->addWidget(nameLineEdit);
|
||||
headerHorizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
headerHorizontalLayout->addItem(headerHorizontalSpacer);
|
||||
deletePushButton = new QPushButton(gridLayoutWidget_2);//TODO handle it
|
||||
deletePushButton->setObjectName(QStringLiteral("deletePushButton"));
|
||||
headerHorizontalLayout->addWidget(deletePushButton);
|
||||
tunnelGridLayout->addLayout(headerHorizontalLayout, 0, 0, 1, 1);
|
||||
|
||||
//type
|
||||
{
|
||||
const QString& type = tunnelConfig->getType();
|
||||
QHBoxLayout * horizontalLayout_ = new QHBoxLayout();
|
||||
horizontalLayout_->setObjectName(QStringLiteral("horizontalLayout_"));
|
||||
typeLabel = new QLabel(gridLayoutWidget_2);
|
||||
typeLabel->setObjectName(QStringLiteral("typeLabel"));
|
||||
horizontalLayout_->addWidget(typeLabel);
|
||||
horizontalLayout_->addWidget(tunnelTypeComboBox);
|
||||
this->tunnelTypeComboBox=tunnelTypeComboBox;
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_, 1, 0, 1, 1);
|
||||
}
|
||||
|
||||
retranslateTunnelForm(*this);
|
||||
}
|
||||
|
||||
void TunnelPane::appendControlsForI2CPParameters(I2CPParameters& i2cpParameters, int& gridIndex) {
|
||||
{
|
||||
//number of hops of an inbound tunnel
|
||||
const QString& inbound_length=i2cpParameters.getInbound_length();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
inbound_lengthLabel = new QLabel(gridLayoutWidget_2);
|
||||
inbound_lengthLabel->setObjectName(QStringLiteral("inbound_lengthLabel"));
|
||||
horizontalLayout_2->addWidget(inbound_lengthLabel);
|
||||
inbound_lengthLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
inbound_lengthLineEdit->setObjectName(QStringLiteral("inbound_lengthLineEdit"));
|
||||
inbound_lengthLineEdit->setText(inbound_length);
|
||||
inbound_lengthLineEdit->setMaximumWidth(80);
|
||||
horizontalLayout_2->addWidget(inbound_lengthLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
{
|
||||
//number of hops of an outbound tunnel
|
||||
const QString& outbound_length=i2cpParameters.getOutbound_length();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
outbound_lengthLabel = new QLabel(gridLayoutWidget_2);
|
||||
outbound_lengthLabel->setObjectName(QStringLiteral("outbound_lengthLabel"));
|
||||
horizontalLayout_2->addWidget(outbound_lengthLabel);
|
||||
outbound_lengthLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
outbound_lengthLineEdit->setObjectName(QStringLiteral("outbound_lengthLineEdit"));
|
||||
outbound_lengthLineEdit->setText(outbound_length);
|
||||
outbound_lengthLineEdit->setMaximumWidth(80);
|
||||
horizontalLayout_2->addWidget(outbound_lengthLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
{
|
||||
//number of inbound tunnels
|
||||
const QString& inbound_quantity=i2cpParameters.getInbound_quantity();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
inbound_quantityLabel = new QLabel(gridLayoutWidget_2);
|
||||
inbound_quantityLabel->setObjectName(QStringLiteral("inbound_quantityLabel"));
|
||||
horizontalLayout_2->addWidget(inbound_quantityLabel);
|
||||
inbound_quantityLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
inbound_quantityLineEdit->setObjectName(QStringLiteral("inbound_quantityLineEdit"));
|
||||
inbound_quantityLineEdit->setText(inbound_quantity);
|
||||
inbound_quantityLineEdit->setMaximumWidth(80);
|
||||
horizontalLayout_2->addWidget(inbound_quantityLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
{
|
||||
//number of outbound tunnels
|
||||
const QString& outbound_quantity=i2cpParameters.getOutbound_quantity();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
outbound_quantityLabel = new QLabel(gridLayoutWidget_2);
|
||||
outbound_quantityLabel->setObjectName(QStringLiteral("outbound_quantityLabel"));
|
||||
horizontalLayout_2->addWidget(outbound_quantityLabel);
|
||||
outbound_quantityLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
outbound_quantityLineEdit->setObjectName(QStringLiteral("outbound_quantityLineEdit"));
|
||||
outbound_quantityLineEdit->setText(outbound_quantity);
|
||||
outbound_quantityLineEdit->setMaximumWidth(80);
|
||||
horizontalLayout_2->addWidget(outbound_quantityLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
{
|
||||
//number of ElGamal/AES tags to send
|
||||
const QString& crypto_tagsToSend=i2cpParameters.getCrypto_tagsToSend();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
crypto_tagsToSendLabel = new QLabel(gridLayoutWidget_2);
|
||||
crypto_tagsToSendLabel->setObjectName(QStringLiteral("crypto_tagsToSendLabel"));
|
||||
horizontalLayout_2->addWidget(crypto_tagsToSendLabel);
|
||||
crypto_tagsToSendLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
crypto_tagsToSendLineEdit->setObjectName(QStringLiteral("crypto_tagsToSendLineEdit"));
|
||||
crypto_tagsToSendLineEdit->setText(crypto_tagsToSend);
|
||||
crypto_tagsToSendLineEdit->setMaximumWidth(80);
|
||||
horizontalLayout_2->addWidget(crypto_tagsToSendLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
|
||||
retranslateI2CPParameters();
|
||||
}
|
94
qt/i2pd_qt/TunnelPane.h
Normal file
94
qt/i2pd_qt/TunnelPane.h
Normal file
|
@ -0,0 +1,94 @@
|
|||
#ifndef TUNNELPANE_H
|
||||
#define TUNNELPANE_H
|
||||
|
||||
#include "QObject"
|
||||
#include "QWidget"
|
||||
#include "QComboBox"
|
||||
#include "QGridLayout"
|
||||
#include "QLabel"
|
||||
#include "QPushButton"
|
||||
#include "QApplication"
|
||||
#include "QLineEdit"
|
||||
#include "QGroupBox"
|
||||
|
||||
#include "TunnelConfig.h"
|
||||
|
||||
class ServerTunnelPane;
|
||||
class ClientTunnelPane;
|
||||
|
||||
class TunnelConfig;
|
||||
class I2CPParameters;
|
||||
|
||||
class TunnelPane : public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TunnelPane();
|
||||
virtual ~TunnelPane(){}
|
||||
|
||||
virtual ServerTunnelPane* asServerTunnelPane()=0;
|
||||
virtual ClientTunnelPane* asClientTunnelPane()=0;
|
||||
|
||||
protected:
|
||||
QGridLayout *tunnelGridLayout;
|
||||
QGroupBox *tunnelGroupBox;
|
||||
QWidget* gridLayoutWidget_2;
|
||||
|
||||
//header
|
||||
QLabel *nameLabel;
|
||||
QLineEdit *nameLineEdit;
|
||||
QSpacerItem *headerHorizontalSpacer;
|
||||
QPushButton *deletePushButton;
|
||||
|
||||
//type
|
||||
QComboBox *tunnelTypeComboBox;
|
||||
QLabel *typeLabel;
|
||||
|
||||
//i2cp
|
||||
|
||||
QLabel * inbound_lengthLabel;
|
||||
QLineEdit * inbound_lengthLineEdit;
|
||||
|
||||
QLabel * outbound_lengthLabel;
|
||||
QLineEdit * outbound_lengthLineEdit;
|
||||
|
||||
QLabel * inbound_quantityLabel;
|
||||
QLineEdit * inbound_quantityLineEdit;
|
||||
|
||||
QLabel * outbound_quantityLabel;
|
||||
QLineEdit * outbound_quantityLineEdit;
|
||||
|
||||
QLabel * crypto_tagsToSendLabel;
|
||||
QLineEdit * crypto_tagsToSendLineEdit;
|
||||
|
||||
void setupTunnelPane(
|
||||
TunnelConfig* tunnelConfig,
|
||||
QGroupBox *tunnelGroupBox,
|
||||
QWidget* gridLayoutWidget_2, QComboBox * tunnelTypeComboBox,
|
||||
QWidget *tunnelsFormGridLayoutWidget, QGridLayout *tunnelsFormGridLayout);
|
||||
void appendControlsForI2CPParameters(I2CPParameters& i2cpParameters, int& gridIndex);
|
||||
public:
|
||||
int height() {
|
||||
return gridLayoutWidget_2?gridLayoutWidget_2->height():0;
|
||||
}
|
||||
|
||||
protected slots:
|
||||
virtual void setGroupBoxTitle(const QString & title)=0;
|
||||
private:
|
||||
void retranslateTunnelForm(TunnelPane& ui) {
|
||||
ui.deletePushButton->setText(QApplication::translate("tunForm", "Delete Tunnel", 0));
|
||||
ui.nameLabel->setText(QApplication::translate("tunForm", "Tunnel name:", 0));
|
||||
ui.typeLabel->setText(QApplication::translate("tunForm", "Server tunnel type:", 0));
|
||||
}
|
||||
|
||||
void retranslateI2CPParameters() {
|
||||
inbound_lengthLabel->setText(QApplication::translate("tunForm", "Number of hops of an inbound tunnel:", 0));;
|
||||
outbound_lengthLabel->setText(QApplication::translate("tunForm", "Number of hops of an outbound tunnel:", 0));;
|
||||
inbound_quantityLabel->setText(QApplication::translate("tunForm", "Number of inbound tunnels:", 0));;
|
||||
outbound_quantityLabel->setText(QApplication::translate("tunForm", "Number of outbound tunnels:", 0));;
|
||||
crypto_tagsToSendLabel->setText(QApplication::translate("tunForm", "Number of ElGamal/AES tags to send:", 0));;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // TUNNELPANE_H
|
|
@ -42,6 +42,7 @@ SOURCES += DaemonQT.cpp mainwindow.cpp
|
|||
SOURCES += $$files(../../libi2pd/*.cpp)
|
||||
SOURCES += $$files(../../libi2pd_client/*.cpp)
|
||||
SOURCES += $$files(../../daemon/*.cpp)
|
||||
SOURCES += $$files(./*.cpp)
|
||||
|
||||
SOURCES -= ../../daemon/UnixDaemon.cpp
|
||||
|
||||
|
@ -63,8 +64,10 @@ HEADERS += DaemonQT.h mainwindow.h
|
|||
INCLUDEPATH += ../../libi2pd
|
||||
INCLUDEPATH += ../../libi2pd_client
|
||||
INCLUDEPATH += ../../daemon
|
||||
INCLUDEPATH += .
|
||||
|
||||
FORMS += mainwindow.ui
|
||||
FORMS += mainwindow.ui \
|
||||
tunnelform.ui
|
||||
|
||||
CONFIG += mobility
|
||||
|
||||
|
|
|
@ -2,33 +2,52 @@
|
|||
#include "ui_mainwindow.h"
|
||||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
#include "RouterContext.h"
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include "../../RouterContext.h"
|
||||
#include "../../Config.h"
|
||||
#include "../../FS.h"
|
||||
#include "../../Log.h"
|
||||
|
||||
#ifndef ANDROID
|
||||
#include <QtDebug>
|
||||
# include <QtDebug>
|
||||
#endif
|
||||
|
||||
#include <QScrollBar>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
std::string programOptionsWriterCurrentSection;
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
QMainWindow(parent)
|
||||
#ifndef ANDROID
|
||||
,quitting(false)
|
||||
#endif
|
||||
,ui(new Ui::MainWindow)
|
||||
,configItems()
|
||||
,datadir()
|
||||
,confpath()
|
||||
,tunconfpath()
|
||||
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowTitle(QApplication::translate("AppTitle","I2PD"));
|
||||
|
||||
//TODO handle resizes and change the below into resize() call
|
||||
setFixedSize(width(), 480);
|
||||
ui->centralWidget->setMinimumHeight(480);
|
||||
ui->centralWidget->setMaximumHeight(480);
|
||||
onResize();
|
||||
|
||||
ui->stackedWidget->setCurrentIndex(0);
|
||||
ui->settingsScrollArea->resize(ui->settingsContentsGridLayout->sizeHint().width()+10,ui->settingsScrollArea->height());
|
||||
ui->settingsScrollArea->resize(ui->settingsContentsGridLayout->sizeHint().width()+10,380);
|
||||
QScrollBar* const barSett = ui->settingsScrollArea->verticalScrollBar();
|
||||
//QSize szSettContents = ui->settingsContentsGridLayout->minimumSize();
|
||||
int w = 683;
|
||||
int h = 3000;
|
||||
int h = 3060;
|
||||
ui->settingsContents->setFixedSize(w, h);
|
||||
ui->settingsContents->resize(w, h);
|
||||
//ui->settingsContents->resize(w, h);
|
||||
//ui->settingsContents->adjustSize();
|
||||
|
||||
/*
|
||||
|
@ -39,8 +58,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
*/
|
||||
|
||||
//ui->settingsScrollArea->adjustSize();
|
||||
ui->tunnelsScrollAreaWidgetContents->setFixedSize(
|
||||
ui->tunnelsScrollArea->width() - barSett->width(), 0);
|
||||
/*ui->tunnelsScrollAreaWidgetContents->setFixedSize(
|
||||
ui->tunnelsScrollArea->width() - barSett->width(), 0);*/
|
||||
|
||||
#ifndef ANDROID
|
||||
createActions();
|
||||
|
@ -57,91 +76,141 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
QObject::connect(ui->fastQuitPushButton, SIGNAL(released()), this, SLOT(handleQuitButton()));
|
||||
QObject::connect(ui->gracefulQuitPushButton, SIGNAL(released()), this, SLOT(handleGracefulQuitButton()));
|
||||
|
||||
initFileChooser(ui->configFileLineEdit, ui->configFileBrowsePushButton);
|
||||
initFileChooser(ui->tunnelsConfigFileLineEdit, ui->tunnelsConfigFileBrowsePushButton);
|
||||
initFileChooser(ui->pidFileLineEdit, ui->pidFileBrowsePushButton);
|
||||
initFileChooser(ui->logFileLineEdit, ui->logFileBrowsePushButton);
|
||||
initFileChooser(ui->httpProxyKeyFileLineEdit, ui->httpProxyKeyFilePushButton);
|
||||
initFileChooser(ui->socksProxyKeyFileLineEdit, ui->socksProxyKeyFilePushButton);
|
||||
initFileChooser(ui->i2pControlCertFileLineEdit, ui->i2pControlCertFileBrowsePushButton);
|
||||
initFileChooser(ui->i2pControlKeyFileLineEdit, ui->i2pControlKeyFileBrowsePushButton);
|
||||
initFileChooser(ui->reseedFileLineEdit, ui->reseedFileBrowsePushButton);
|
||||
# define OPTION(section,option,defaultValueGetter) ConfigOption(QString(section),QString(option))
|
||||
|
||||
initFolderChooser(ui->dataFolderLineEdit, ui->dataFolderBrowsePushButton);
|
||||
initFileChooser( OPTION("","conf",[](){return "";}), ui->configFileLineEdit, ui->configFileBrowsePushButton);
|
||||
initFolderChooser( OPTION("","datadir",[]{return "";}), ui->dataFolderLineEdit, ui->dataFolderBrowsePushButton);
|
||||
initFileChooser( OPTION("","tunconf",[](){return "";}), ui->tunnelsConfigFileLineEdit, ui->tunnelsConfigFileBrowsePushButton);
|
||||
|
||||
initCombobox(ui->logLevelComboBox);
|
||||
initFileChooser( OPTION("","pidfile",[]{return "";}), ui->pidFileLineEdit, ui->pidFileBrowsePushButton);
|
||||
logOption=initNonGUIOption( OPTION("","log",[]{return "";}));
|
||||
daemonOption=initNonGUIOption( OPTION("","daemon",[]{return "";}));
|
||||
serviceOption=initNonGUIOption( OPTION("","service",[]{return "";}));
|
||||
|
||||
initIPAddressBox(ui->routerExternalHostLineEdit, tr("Router external address -> Host"));
|
||||
initTCPPortBox(ui->routerExternalPortLineEdit, tr("Router external address -> Port"));
|
||||
logFileNameOption=initFileChooser( OPTION("","logfile",[]{return "";}), ui->logFileLineEdit, ui->logFileBrowsePushButton);
|
||||
initLogLevelCombobox(OPTION("","loglevel",[]{return "";}), ui->logLevelComboBox);
|
||||
|
||||
initCheckBox(ui->ipv6CheckBox);
|
||||
initCheckBox(ui->notransitCheckBox);
|
||||
initCheckBox(ui->floodfillCheckBox);
|
||||
initIntegerBox(ui->bandwidthLineEdit);
|
||||
initStringBox(ui->familyLineEdit);
|
||||
initIntegerBox(ui->netIdLineEdit);
|
||||
initIPAddressBox( OPTION("","host",[]{return "";}), ui->routerExternalHostLineEdit, tr("Router external address -> Host"));
|
||||
initTCPPortBox( OPTION("","port",[]{return "";}), ui->routerExternalPortLineEdit, tr("Router external address -> Port"));
|
||||
|
||||
initCheckBox( OPTION("","ipv6",[]{return "false";}), ui->ipv6CheckBox);
|
||||
initCheckBox( OPTION("","notransit",[]{return "false";}), ui->notransitCheckBox);
|
||||
initCheckBox( OPTION("","floodfill",[]{return "false";}), ui->floodfillCheckBox);
|
||||
initStringBox( OPTION("","bandwidth",[]{return "";}), ui->bandwidthLineEdit);
|
||||
initStringBox( OPTION("","family",[]{return "";}), ui->familyLineEdit);
|
||||
initIntegerBox( OPTION("","netid",[]{return "2";}), ui->netIdLineEdit, tr("NetID"));
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
initCheckBox( OPTION("","insomnia",[]{return "";}), ui->insomniaCheckBox);
|
||||
initNonGUIOption( OPTION("","svcctl",[]{return "";}));
|
||||
initNonGUIOption( OPTION("","close",[]{return "";}));
|
||||
#else
|
||||
ui->insomniaCheckBox->setEnabled(false);
|
||||
#endif
|
||||
|
||||
initCheckBox( OPTION("http","enabled",[]{return "true";}), ui->webconsoleEnabledCheckBox);
|
||||
initIPAddressBox( OPTION("http","address",[]{return "";}), ui->webconsoleAddrLineEdit, tr("HTTP webconsole -> IP address"));
|
||||
initTCPPortBox( OPTION("http","port",[]{return "7070";}), ui->webconsolePortLineEdit, tr("HTTP webconsole -> Port"));
|
||||
initCheckBox( OPTION("http","auth",[]{return "";}), ui->webconsoleBasicAuthCheckBox);
|
||||
initStringBox( OPTION("http","user",[]{return "i2pd";}), ui->webconsoleUserNameLineEditBasicAuth);
|
||||
initStringBox( OPTION("http","pass",[]{return "";}), ui->webconsolePasswordLineEditBasicAuth);
|
||||
|
||||
initCheckBox( OPTION("httpproxy","enabled",[]{return "";}), ui->httpProxyEnabledCheckBox);
|
||||
initIPAddressBox( OPTION("httpproxy","address",[]{return "";}), ui->httpProxyAddressLineEdit, tr("HTTP proxy -> IP address"));
|
||||
initTCPPortBox( OPTION("httpproxy","port",[]{return "4444";}), ui->httpProxyPortLineEdit, tr("HTTP proxy -> Port"));
|
||||
initFileChooser( OPTION("httpproxy","keys",[]{return "";}), ui->httpProxyKeyFileLineEdit, ui->httpProxyKeyFilePushButton);
|
||||
initSignatureTypeCombobox(OPTION("httpproxy","signaturetype",[]{return "7";}), ui->comboBox_httpPorxySignatureType);
|
||||
initStringBox( OPTION("httpproxy","inbound.length",[]{return "3";}), ui->httpProxyInboundTunnelsLenLineEdit);
|
||||
initStringBox( OPTION("httpproxy","inbound.quantity",[]{return "5";}), ui->httpProxyInboundTunnQuantityLineEdit);
|
||||
initStringBox( OPTION("httpproxy","outbound.length",[]{return "3";}), ui->httpProxyOutBoundTunnLenLineEdit);
|
||||
initStringBox( OPTION("httpproxy","outbound.quantity",[]{return "5";}), ui->httpProxyOutboundTunnQuantityLineEdit);
|
||||
|
||||
initCheckBox( OPTION("socksproxy","enabled",[]{return "";}), ui->socksProxyEnabledCheckBox);
|
||||
initIPAddressBox( OPTION("socksproxy","address",[]{return "";}), ui->socksProxyAddressLineEdit, tr("Socks proxy -> IP address"));
|
||||
initTCPPortBox( OPTION("socksproxy","port",[]{return "4447";}), ui->socksProxyPortLineEdit, tr("Socks proxy -> Port"));
|
||||
initFileChooser( OPTION("socksproxy","keys",[]{return "";}), ui->socksProxyKeyFileLineEdit, ui->socksProxyKeyFilePushButton);
|
||||
initSignatureTypeCombobox(OPTION("socksproxy","signaturetype",[]{return "7";}), ui->comboBox_socksProxySignatureType);
|
||||
initStringBox( OPTION("socksproxy","inbound.length",[]{return "";}), ui->socksProxyInboundTunnelsLenLineEdit);
|
||||
initStringBox( OPTION("socksproxy","inbound.quantity",[]{return "";}), ui->socksProxyInboundTunnQuantityLineEdit);
|
||||
initStringBox( OPTION("socksproxy","outbound.length",[]{return "";}), ui->socksProxyOutBoundTunnLenLineEdit);
|
||||
initStringBox( OPTION("socksproxy","outbound.quantity",[]{return "";}), ui->socksProxyOutboundTunnQuantityLineEdit);
|
||||
initIPAddressBox( OPTION("socksproxy","outproxy",[]{return "";}), ui->outproxyAddressLineEdit, tr("Socks proxy -> Outproxy address"));
|
||||
initTCPPortBox( OPTION("socksproxy","outproxyport",[]{return "";}), ui->outproxyPortLineEdit, tr("Socks proxy -> Outproxy port"));
|
||||
|
||||
initCheckBox( OPTION("sam","enabled",[]{return "false";}), ui->samEnabledCheckBox);
|
||||
initIPAddressBox( OPTION("sam","address",[]{return "";}), ui->samAddressLineEdit, tr("SAM -> IP address"));
|
||||
initTCPPortBox( OPTION("sam","port",[]{return "7656";}), ui->samPortLineEdit, tr("SAM -> Port"));
|
||||
|
||||
initCheckBox( OPTION("bob","enabled",[]{return "false";}), ui->bobEnabledCheckBox);
|
||||
initIPAddressBox( OPTION("bob","address",[]{return "";}), ui->bobAddressLineEdit, tr("BOB -> IP address"));
|
||||
initTCPPortBox( OPTION("bob","port",[]{return "2827";}), ui->bobPortLineEdit, tr("BOB -> Port"));
|
||||
|
||||
initCheckBox( OPTION("i2cp","enabled",[]{return "false";}), ui->i2cpEnabledCheckBox);
|
||||
initIPAddressBox( OPTION("i2cp","address",[]{return "";}), ui->i2cpAddressLineEdit, tr("I2CP -> IP address"));
|
||||
initTCPPortBox( OPTION("i2cp","port",[]{return "7654";}), ui->i2cpPortLineEdit, tr("I2CP -> Port"));
|
||||
|
||||
initCheckBox( OPTION("i2pcontrol","enabled",[]{return "false";}), ui->i2pControlEnabledCheckBox);
|
||||
initIPAddressBox( OPTION("i2pcontrol","address",[]{return "";}), ui->i2pControlAddressLineEdit, tr("I2PControl -> IP address"));
|
||||
initTCPPortBox( OPTION("i2pcontrol","port",[]{return "7650";}), ui->i2pControlPortLineEdit, tr("I2PControl -> Port"));
|
||||
initStringBox( OPTION("i2pcontrol","password",[]{return "";}), ui->i2pControlPasswordLineEdit);
|
||||
initFileChooser( OPTION("i2pcontrol","cert",[]{return "i2pcontrol.crt.pem";}), ui->i2pControlCertFileLineEdit, ui->i2pControlCertFileBrowsePushButton);
|
||||
initFileChooser( OPTION("i2pcontrol","key",[]{return "i2pcontrol.key.pem";}), ui->i2pControlKeyFileLineEdit, ui->i2pControlKeyFileBrowsePushButton);
|
||||
|
||||
initCheckBox( OPTION("upnp","enabled",[]{return "true";}), ui->enableUPnPCheckBox);
|
||||
initStringBox( OPTION("upnp","name",[]{return "I2Pd";}), ui->upnpNameLineEdit);
|
||||
|
||||
initCheckBox(ui->insomniaCheckBox);
|
||||
|
||||
initCheckBox(ui->webconsoleEnabledCheckBox);
|
||||
initIPAddressBox(ui->webconsoleAddrLineEdit, tr("HTTP webconsole -> IP address"));
|
||||
initTCPPortBox(ui->webconsolePortLineEdit, tr("HTTP webconsole -> Port"));
|
||||
initCheckBox(ui->webconsoleBasicAuthCheckBox);
|
||||
initStringBox(ui->webconsoleUserNameLineEditBasicAuth);
|
||||
initStringBox(ui->webconsolePasswordLineEditBasicAuth);
|
||||
|
||||
initCheckBox(ui->httpProxyEnabledCheckBox);
|
||||
initIPAddressBox(ui->httpProxyAddressLineEdit, tr("HTTP proxy -> IP address"));
|
||||
initTCPPortBox(ui->httpProxyPortLineEdit, tr("HTTP proxy -> Port"));
|
||||
initIntegerBox(ui->httpProxyInboundTunnelsLenLineEdit);
|
||||
initIntegerBox(ui->httpProxyInboundTunnQuantityLineEdit);
|
||||
initIntegerBox(ui->httpProxyOutBoundTunnLenLineEdit);
|
||||
initIntegerBox(ui->httpProxyOutboundTunnQuantityLineEdit);
|
||||
|
||||
initCheckBox(ui->socksProxyEnabledCheckBox);
|
||||
initIPAddressBox(ui->socksProxyAddressLineEdit, tr("Socks proxy -> IP address"));
|
||||
initTCPPortBox(ui->socksProxyPortLineEdit, tr("Socks proxy -> Port"));
|
||||
initIntegerBox(ui->socksProxyInboundTunnelsLenLineEdit);
|
||||
initIntegerBox(ui->socksProxyInboundTunnQuantityLineEdit);
|
||||
initIntegerBox(ui->socksProxyOutBoundTunnLenLineEdit);
|
||||
initIntegerBox(ui->socksProxyOutboundTunnQuantityLineEdit);
|
||||
initIPAddressBox(ui->outproxyAddressLineEdit, tr("Socks proxy -> Outproxy address"));
|
||||
initTCPPortBox(ui->outproxyPortLineEdit, tr("Socks proxy -> Outproxy port"));
|
||||
|
||||
initCheckBox(ui->samEnabledCheckBox);
|
||||
initIPAddressBox(ui->samAddressLineEdit, tr("SAM -> IP address"));
|
||||
initTCPPortBox(ui->samPortLineEdit, tr("SAM -> Port"));
|
||||
|
||||
initCheckBox(ui->bobEnabledCheckBox);
|
||||
initIPAddressBox(ui->bobAddressLineEdit, tr("BOB -> IP address"));
|
||||
initTCPPortBox(ui->bobPortLineEdit, tr("BOB -> Port"));
|
||||
|
||||
initCheckBox(ui->i2cpEnabledCheckBox);
|
||||
initIPAddressBox(ui->i2cpAddressLineEdit, tr("I2CP -> IP address"));
|
||||
initTCPPortBox(ui->i2cpPortLineEdit, tr("I2CP -> Port"));
|
||||
|
||||
initCheckBox(ui->i2pControlEnabledCheckBox);
|
||||
initIPAddressBox(ui->i2pControlAddressLineEdit, tr("I2PControl -> IP address"));
|
||||
initTCPPortBox(ui->i2pControlPortLineEdit, tr("I2PControl -> Port"));
|
||||
initStringBox(ui->i2pControlPasswordLineEdit);
|
||||
initCheckBox( OPTION("precomputation","elgamal",[]{return "false";}), ui->useElGamalPrecomputedTablesCheckBox);
|
||||
|
||||
initCheckBox(ui->enableUPnPCheckBox);
|
||||
initStringBox(ui->upnpNameLineEdit);
|
||||
initCheckBox( OPTION("reseed","verify",[]{return "";}), ui->reseedVerifyCheckBox);
|
||||
initFileChooser( OPTION("reseed","file",[]{return "";}), ui->reseedFileLineEdit, ui->reseedFileBrowsePushButton);
|
||||
initStringBox( OPTION("reseed","urls",[]{return "";}), ui->reseedURLsLineEdit);
|
||||
|
||||
initCheckBox(ui->useElGamalPrecomputedTablesCheckBox);
|
||||
initStringBox( OPTION("addressbook","defaulturl",[]{return "";}), ui->addressbookDefaultURLLineEdit);
|
||||
initStringBox( OPTION("addressbook","subscriptions",[]{return "";}), ui->addressbookSubscriptionsURLslineEdit);
|
||||
|
||||
initCheckBox(ui->reseedVerifyCheckBox);
|
||||
initStringBox(ui->reseedURLsLineEdit);
|
||||
|
||||
initStringBox(ui->addressbookDefaultURLLineEdit);
|
||||
initStringBox(ui->addressbookSubscriptionsURLslineEdit);
|
||||
|
||||
initIntegerBox(ui->maxNumOfTransitTunnelsLineEdit);
|
||||
initIntegerBox(ui->maxNumOfOpenFilesLineEdit);
|
||||
initIntegerBox(ui->coreFileMaxSizeNumberLineEdit);
|
||||
initUInt16Box( OPTION("limits","transittunnels",[]{return "2500";}), ui->maxNumOfTransitTunnelsLineEdit, tr("maxNumberOfTransitTunnels"));
|
||||
initUInt16Box( OPTION("limits","openfiles",[]{return "0";}), ui->maxNumOfOpenFilesLineEdit, tr("maxNumberOfOpenFiles"));
|
||||
initUInt32Box( OPTION("limits","coresize",[]{return "0";}), ui->coreFileMaxSizeNumberLineEdit, tr("coreFileMaxSize"));
|
||||
|
||||
initCheckBox( OPTION("trust","enabled",[]{return "false";}), ui->checkBoxTrustEnable);
|
||||
initStringBox( OPTION("trust","family",[]{return "";}), ui->lineEditTrustFamily);
|
||||
initStringBox( OPTION("trust","routers",[]{return "";}), ui->lineEditTrustRouters);
|
||||
initCheckBox( OPTION("trust","hidden",[]{return "false";}), ui->checkBoxTrustHidden);
|
||||
|
||||
initCheckBox( OPTION("websockets","enabled",[]{return "false";}), ui->checkBoxWebsocketsEnable);
|
||||
initIPAddressBox( OPTION("websockets","address",[]{return "127.0.0.1";}), ui->lineEdit_webSock_addr, tr("Websocket server -> IP address"));
|
||||
initTCPPortBox( OPTION("websockets","port",[]{return "7666";}), ui->lineEdit_webSock_port, tr("Websocket server -> Port"));
|
||||
|
||||
# undef OPTION
|
||||
|
||||
loadAllConfigs();
|
||||
|
||||
tunnelsFormGridLayoutWidget = new QWidget(ui->tunnelsScrollAreaWidgetContents);
|
||||
tunnelsFormGridLayoutWidget->setObjectName(QStringLiteral("tunnelsFormGridLayoutWidget"));
|
||||
tunnelsFormGridLayoutWidget->setGeometry(QRect(0, 0, 621, 451));
|
||||
ui->tunnelsScrollAreaWidgetContents->setGeometry(QRect(0, 0, 621, 451));
|
||||
tunnelsFormGridLayout = new QGridLayout(tunnelsFormGridLayoutWidget);
|
||||
tunnelsFormGridLayout->setObjectName(QStringLiteral("tunnelsFormGridLayout"));
|
||||
tunnelsFormGridLayout->setContentsMargins(5, 5, 5, 5);
|
||||
tunnelsFormGridLayout->setVerticalSpacing(5);
|
||||
|
||||
appendTunnelForms();
|
||||
|
||||
ui->configFileLineEdit->setEnabled(false);
|
||||
ui->configFileBrowsePushButton->setEnabled(false);
|
||||
ui->configFileLineEdit->setText(confpath);
|
||||
ui->tunnelsConfigFileLineEdit->setText(tunconfpath);
|
||||
|
||||
for(QList<MainWindowItem*>::iterator it = configItems.begin(); it!= configItems.end(); ++it) {
|
||||
MainWindowItem* item = *it;
|
||||
item->installListeners(this);
|
||||
}
|
||||
|
||||
QObject::connect(ui->tunnelsConfigFileLineEdit, SIGNAL(textChanged(const QString &)),
|
||||
this, SLOT(reloadTunnelsConfigAndUI()));
|
||||
|
||||
|
||||
|
||||
#ifndef ANDROID
|
||||
QObject::connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
||||
this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
|
||||
|
@ -273,19 +342,223 @@ void MainWindow::handleGracefulQuitTimerEvent() {
|
|||
MainWindow::~MainWindow()
|
||||
{
|
||||
qDebug("Destroying main window");
|
||||
for(QList<MainWindowItem*>::iterator it = configItems.begin(); it!= configItems.end(); ++it) {
|
||||
MainWindowItem* item = *it;
|
||||
item->deleteLater();
|
||||
}
|
||||
configItems.clear();
|
||||
//QMessageBox::information(0, "Debug", "mw destructor 1");
|
||||
//delete ui;
|
||||
//QMessageBox::information(0, "Debug", "mw destructor 2");
|
||||
}
|
||||
|
||||
void MainWindow::initFileChooser(QLineEdit* fileNameLineEdit, QPushButton* fileBrowsePushButton){}
|
||||
void MainWindow::initFolderChooser(QLineEdit* folderLineEdit, QPushButton* folderBrowsePushButton){}
|
||||
void MainWindow::initCombobox(QComboBox* comboBox){}
|
||||
void MainWindow::initIPAddressBox(QLineEdit* addressLineEdit, QString fieldNameTranslated){}
|
||||
void MainWindow::initTCPPortBox(QLineEdit* portLineEdit, QString fieldNameTranslated){}
|
||||
void MainWindow::initCheckBox(QCheckBox* checkBox){}
|
||||
void MainWindow::initIntegerBox(QLineEdit* numberLineEdit){}
|
||||
void MainWindow::initStringBox(QLineEdit* lineEdit){}
|
||||
FileChooserItem* MainWindow::initFileChooser(ConfigOption option, QLineEdit* fileNameLineEdit, QPushButton* fileBrowsePushButton){
|
||||
FileChooserItem* retVal;
|
||||
retVal=new FileChooserItem(option, fileNameLineEdit, fileBrowsePushButton);
|
||||
MainWindowItem* super=retVal;
|
||||
configItems.append(super);
|
||||
return retVal;
|
||||
}
|
||||
void MainWindow::initFolderChooser(ConfigOption option, QLineEdit* folderLineEdit, QPushButton* folderBrowsePushButton){
|
||||
configItems.append(new FolderChooserItem(option, folderLineEdit, folderBrowsePushButton));
|
||||
}
|
||||
/*void MainWindow::initCombobox(ConfigOption option, QComboBox* comboBox){
|
||||
configItems.append(new ComboBoxItem(option, comboBox));
|
||||
QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(saveAllConfigs()));
|
||||
}*/
|
||||
void MainWindow::initLogLevelCombobox(ConfigOption option, QComboBox* comboBox){
|
||||
configItems.append(new LogLevelComboBoxItem(option, comboBox));
|
||||
}
|
||||
void MainWindow::initSignatureTypeCombobox(ConfigOption option, QComboBox* comboBox){
|
||||
configItems.append(new SignatureTypeComboBoxItem(option, comboBox));
|
||||
}
|
||||
void MainWindow::initIPAddressBox(ConfigOption option, QLineEdit* addressLineEdit, QString fieldNameTranslated){
|
||||
configItems.append(new IPAddressStringItem(option, addressLineEdit, fieldNameTranslated));
|
||||
}
|
||||
void MainWindow::initTCPPortBox(ConfigOption option, QLineEdit* portLineEdit, QString fieldNameTranslated){
|
||||
configItems.append(new TCPPortStringItem(option, portLineEdit, fieldNameTranslated));
|
||||
}
|
||||
void MainWindow::initCheckBox(ConfigOption option, QCheckBox* checkBox) {
|
||||
configItems.append(new CheckBoxItem(option, checkBox));
|
||||
}
|
||||
void MainWindow::initIntegerBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){
|
||||
configItems.append(new IntegerStringItem(option, numberLineEdit, fieldNameTranslated));
|
||||
}
|
||||
void MainWindow::initUInt32Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){
|
||||
configItems.append(new UInt32StringItem(option, numberLineEdit, fieldNameTranslated));
|
||||
}
|
||||
void MainWindow::initUInt16Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){
|
||||
configItems.append(new UInt16StringItem(option, numberLineEdit, fieldNameTranslated));
|
||||
}
|
||||
void MainWindow::initStringBox(ConfigOption option, QLineEdit* lineEdit){
|
||||
configItems.append(new BaseStringItem(option, lineEdit));
|
||||
}
|
||||
NonGUIOptionItem* MainWindow::initNonGUIOption(ConfigOption option) {
|
||||
NonGUIOptionItem * retValue;
|
||||
configItems.append(retValue=new NonGUIOptionItem(option));
|
||||
return retValue;
|
||||
}
|
||||
|
||||
void MainWindow::loadAllConfigs(){}
|
||||
void MainWindow::saveAllConfigs(){}
|
||||
void MainWindow::loadAllConfigs(){
|
||||
|
||||
//BORROWED FROM ??? //TODO move this code into single location
|
||||
std::string config; i2p::config::GetOption("conf", config);
|
||||
std::string datadir; i2p::config::GetOption("datadir", datadir);
|
||||
bool service = false;
|
||||
#ifndef _WIN32
|
||||
i2p::config::GetOption("service", service);
|
||||
#endif
|
||||
i2p::fs::DetectDataDir(datadir, service);
|
||||
i2p::fs::Init();
|
||||
|
||||
datadir = i2p::fs::GetDataDir();
|
||||
// TODO: drop old name detection in v2.8.0
|
||||
if (config == "")
|
||||
{
|
||||
config = i2p::fs::DataDirPath("i2p.conf");
|
||||
if (i2p::fs::Exists (config)) {
|
||||
LogPrint(eLogWarning, "Daemon: please rename i2p.conf to i2pd.conf here: ", config);
|
||||
} else {
|
||||
config = i2p::fs::DataDirPath("i2pd.conf");
|
||||
if (!i2p::fs::Exists (config)) {
|
||||
// use i2pd.conf only if exists
|
||||
config = ""; /* reset */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//BORROWED FROM ClientContext.cpp //TODO move this code into single location
|
||||
std::string tunConf; i2p::config::GetOption("tunconf", tunConf);
|
||||
if (tunConf == "") {
|
||||
// TODO: cleanup this in 2.8.0
|
||||
tunConf = i2p::fs::DataDirPath ("tunnels.cfg");
|
||||
if (i2p::fs::Exists(tunConf)) {
|
||||
LogPrint(eLogWarning, "FS: please rename tunnels.cfg -> tunnels.conf here: ", tunConf);
|
||||
} else {
|
||||
tunConf = i2p::fs::DataDirPath ("tunnels.conf");
|
||||
}
|
||||
}
|
||||
|
||||
this->confpath = config.c_str();
|
||||
this->datadir = datadir.c_str();
|
||||
this->tunconfpath = tunConf.c_str();
|
||||
|
||||
for(QList<MainWindowItem*>::iterator it = configItems.begin(); it!= configItems.end(); ++it) {
|
||||
MainWindowItem* item = *it;
|
||||
item->loadFromConfigOption();
|
||||
}
|
||||
|
||||
ReadTunnelsConfig();
|
||||
}
|
||||
/** returns false iff not valid items present and save was aborted */
|
||||
bool MainWindow::saveAllConfigs(){
|
||||
programOptionsWriterCurrentSection="";
|
||||
if(!logFileNameOption->lineEdit->text().trimmed().isEmpty())logOption->optionValue=boost::any(std::string("file"));
|
||||
else logOption->optionValue=boost::any(std::string("stdout"));
|
||||
daemonOption->optionValue=boost::any(false);
|
||||
serviceOption->optionValue=boost::any(false);
|
||||
|
||||
std::stringstream out;
|
||||
for(QList<MainWindowItem*>::iterator it = configItems.begin(); it!= configItems.end(); ++it) {
|
||||
MainWindowItem* item = *it;
|
||||
if(!item->isValid()) return false;
|
||||
}
|
||||
|
||||
for(QList<MainWindowItem*>::iterator it = configItems.begin(); it!= configItems.end(); ++it) {
|
||||
MainWindowItem* item = *it;
|
||||
item->saveToStringStream(out);
|
||||
}
|
||||
|
||||
using namespace std;
|
||||
|
||||
QString backup=confpath+"~";
|
||||
if(QFile::exists(backup)) QFile::remove(backup);//TODO handle errors
|
||||
QFile::rename(confpath, backup);//TODO handle errors
|
||||
ofstream outfile;
|
||||
outfile.open(confpath.toStdString());//TODO handle errors
|
||||
string dataToWrite = out.str();
|
||||
outfile << dataToWrite.c_str();
|
||||
outfile.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FileChooserItem::pushButtonReleased() {
|
||||
QString fileName = lineEdit->text().trimmed();
|
||||
fileName = QFileDialog::getOpenFileName(nullptr, tr("Open File"), fileName, tr("All Files (*.*)"));
|
||||
if(fileName.length()>0)lineEdit->setText(fileName);
|
||||
}
|
||||
void FolderChooserItem::pushButtonReleased() {
|
||||
QString fileName = lineEdit->text().trimmed();
|
||||
fileName = QFileDialog::getExistingDirectory(nullptr, tr("Open Folder"), fileName);
|
||||
if(fileName.length()>0)lineEdit->setText(fileName);
|
||||
}
|
||||
|
||||
void BaseStringItem::installListeners(MainWindow *mainWindow) {
|
||||
QObject::connect(lineEdit, SIGNAL(textChanged(const QString &)), mainWindow, SLOT(saveAllConfigs()));
|
||||
}
|
||||
void ComboBoxItem::installListeners(MainWindow *mainWindow) {
|
||||
QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), mainWindow, SLOT(saveAllConfigs()));
|
||||
}
|
||||
void CheckBoxItem::installListeners(MainWindow *mainWindow) {
|
||||
QObject::connect(checkBox, SIGNAL(stateChanged(int)), mainWindow, SLOT(saveAllConfigs()));
|
||||
}
|
||||
|
||||
|
||||
void MainWindowItem::installListeners(MainWindow *mainWindow) {}
|
||||
|
||||
void MainWindow::appendTunnelForms() {
|
||||
int height=0;
|
||||
for(std::list<TunnelConfig*>::iterator it = tunnelConfigs.begin(); it != tunnelConfigs.end(); ++it) {
|
||||
TunnelConfig* tunconf = *it;
|
||||
ServerTunnelConfig* stc = tunconf->asServerTunnelConfig();
|
||||
if(stc){
|
||||
ServerTunnelPane * tunnelPane=new ServerTunnelPane();
|
||||
tunnelPane->appendServerTunnelForm(stc, tunnelsFormGridLayoutWidget, tunnelsFormGridLayout);
|
||||
height+=tunnelPane->height();
|
||||
qDebug() << "tun.height:" << height;
|
||||
tunnelPanes.push_back(tunnelPane);
|
||||
continue;
|
||||
}
|
||||
ClientTunnelConfig* ctc = tunconf->asClientTunnelConfig();
|
||||
if(ctc){
|
||||
ClientTunnelPane * tunnelPane=new ClientTunnelPane();//TODO
|
||||
height+=tunnelPane->height();
|
||||
qDebug() << "tun.height:" << height;
|
||||
tunnelPanes.push_back(tunnelPane);
|
||||
continue;
|
||||
}
|
||||
throw "unknown TunnelConfig subtype";
|
||||
}
|
||||
qDebug() << "tun.setting height:" << height;
|
||||
tunnelsFormGridLayoutWidget->setGeometry(QRect(0, 0, 621, height));
|
||||
ui->tunnelsScrollAreaWidgetContents->setGeometry(QRect(0, 0, 621, height));
|
||||
}
|
||||
void MainWindow::deleteTunnelForms() {
|
||||
for(std::list<TunnelPane*>::iterator it = tunnelPanes.begin(); it != tunnelPanes.end(); ++it) {
|
||||
TunnelPane* tp = *it;
|
||||
ServerTunnelPane* stp = tp->asServerTunnelPane();
|
||||
if(stp){
|
||||
stp->deleteServerTunnelForm(tunnelsFormGridLayout);
|
||||
continue;
|
||||
}
|
||||
ClientTunnelPane* ctp = tp->asClientTunnelPane();
|
||||
if(ctp){
|
||||
ctp->deleteClientTunnelForm(tunnelsFormGridLayout);
|
||||
continue;
|
||||
}
|
||||
throw "unknown TunnelPane subtype";
|
||||
}
|
||||
tunnelPanes.clear();
|
||||
}
|
||||
|
||||
void MainWindow::reloadTunnelsConfigAndUI() {
|
||||
deleteTunnelForms();
|
||||
for(std::list<TunnelConfig*>::iterator it = tunnelConfigs.begin(); it != tunnelConfigs.end(); ++it) {
|
||||
TunnelConfig* tunconf = *it;
|
||||
delete tunconf;
|
||||
}
|
||||
tunnelConfigs.clear();
|
||||
ReadTunnelsConfig();
|
||||
appendTunnelForms();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMainWindow>
|
||||
#include <QPushButton>
|
||||
#include <QtCore/QVariant>
|
||||
|
@ -9,29 +10,313 @@
|
|||
#include <QtWidgets/QButtonGroup>
|
||||
#include <QtWidgets/QHeaderView>
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QtWidgets/QCheckBox>
|
||||
#include <QtWidgets/QComboBox>
|
||||
#include <QtWidgets/QAction>
|
||||
#include <QtWidgets/QGridLayout>
|
||||
#include <QtWidgets/QGroupBox>
|
||||
#include <QtWidgets/QHBoxLayout>
|
||||
#include <QtWidgets/QHeaderView>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QLineEdit>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QSpacerItem>
|
||||
|
||||
#ifndef ANDROID
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QCloseEvent>
|
||||
#include <QMenu>
|
||||
# include <QSystemTrayIcon>
|
||||
# include <QCloseEvent>
|
||||
# include <QMenu>
|
||||
#endif
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "MainWindowItems.h"
|
||||
#include "TunnelPane.h"
|
||||
#include "ServerTunnelPane.h"
|
||||
#include "ClientTunnelPane.h"
|
||||
#include "TunnelConfig.h"
|
||||
|
||||
#include "../../Config.h"
|
||||
#include "../../FS.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/ini_parser.hpp>
|
||||
|
||||
template<typename ValueType>
|
||||
bool isType(boost::any& a) {
|
||||
return
|
||||
#ifdef BOOST_AUX_ANY_TYPE_ID_NAME
|
||||
std::strcmp(a.type().name(), typeid(ValueType).name()) == 0
|
||||
#else
|
||||
a.type() == typeid(ValueType)
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
class ConfigOption {
|
||||
public:
|
||||
QString section;
|
||||
QString option;
|
||||
//MainWindow::DefaultValueGetter defaultValueGetter;
|
||||
ConfigOption(QString section_, QString option_/*, DefaultValueGetter defaultValueGetter_*/):
|
||||
section(section_)
|
||||
, option(option_)
|
||||
//, defaultValueGetter(defaultValueGetter_)
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
extern std::string programOptionsWriterCurrentSection;
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class MainWindowItem : public QObject {
|
||||
Q_OBJECT
|
||||
ConfigOption option;
|
||||
public:
|
||||
MainWindowItem(ConfigOption option_) : option(option_) {}
|
||||
boost::any optionValue;
|
||||
virtual ~MainWindowItem(){}
|
||||
virtual void installListeners(MainWindow *mainWindow);
|
||||
virtual void loadFromConfigOption(){
|
||||
std::string optName="";
|
||||
if(!option.section.isEmpty())optName=option.section.toStdString()+std::string(".");
|
||||
optName+=option.option.toStdString();
|
||||
qDebug() << "loadFromConfigOption[" << optName.c_str() << "]";
|
||||
boost::any programOption;
|
||||
i2p::config::GetOptionAsAny(optName, programOption);
|
||||
optionValue=programOption.empty()?boost::any(std::string(""))
|
||||
:boost::any_cast<boost::program_options::variable_value>(programOption).value();
|
||||
}
|
||||
virtual void saveToStringStream(std::stringstream& out){
|
||||
if(isType<std::string>(optionValue)) {
|
||||
std::string v = boost::any_cast<std::string>(optionValue);
|
||||
if(v.empty())return;
|
||||
}
|
||||
if(optionValue.empty())return;
|
||||
std::string rtti = optionValue.type().name();
|
||||
std::string optName="";
|
||||
if(!option.section.isEmpty())optName=option.section.toStdString()+std::string(".");
|
||||
optName+=option.option.toStdString();
|
||||
qDebug() << "Writing option" << optName.c_str() << "of type" << rtti.c_str();
|
||||
std::string sectionAsStdStr = option.section.toStdString();
|
||||
if(!option.section.isEmpty() &&
|
||||
sectionAsStdStr!=programOptionsWriterCurrentSection) {
|
||||
out << "[" << sectionAsStdStr << "]\n";
|
||||
programOptionsWriterCurrentSection=sectionAsStdStr;
|
||||
}
|
||||
out << option.option.toStdString() << "=";
|
||||
if(isType<std::string>(optionValue)) {
|
||||
out << boost::any_cast<std::string>(optionValue);
|
||||
}else if(isType<bool>(optionValue)) {
|
||||
out << (boost::any_cast<bool>(optionValue) ? "true" : "false");
|
||||
}else if(isType<uint16_t>(optionValue)) {
|
||||
out << boost::any_cast<uint16_t>(optionValue);
|
||||
}else if(isType<uint32_t>(optionValue)) {
|
||||
out << boost::any_cast<uint32_t>(optionValue);
|
||||
}else if(isType<int>(optionValue)) {
|
||||
out << boost::any_cast<int>(optionValue);
|
||||
}else if(isType<unsigned short>(optionValue)) {
|
||||
out << boost::any_cast<unsigned short>(optionValue);
|
||||
}else out << boost::any_cast<std::string>(optionValue); //let it throw
|
||||
out << "\n\n";
|
||||
}
|
||||
virtual bool isValid(){return true;}
|
||||
};
|
||||
class NonGUIOptionItem : public MainWindowItem {
|
||||
public:
|
||||
NonGUIOptionItem(ConfigOption option_) : MainWindowItem(option_) {};
|
||||
virtual ~NonGUIOptionItem(){}
|
||||
virtual bool isValid() { return true; }
|
||||
};
|
||||
class BaseStringItem : public MainWindowItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QLineEdit* lineEdit;
|
||||
BaseStringItem(ConfigOption option_, QLineEdit* lineEdit_) : MainWindowItem(option_), lineEdit(lineEdit_){};
|
||||
virtual ~BaseStringItem(){}
|
||||
virtual void installListeners(MainWindow *mainWindow);
|
||||
virtual QString toString(){
|
||||
return boost::any_cast<std::string>(optionValue).c_str();
|
||||
}
|
||||
virtual boost::any fromString(QString s){return boost::any(s.toStdString());}
|
||||
virtual void loadFromConfigOption(){
|
||||
MainWindowItem::loadFromConfigOption();
|
||||
lineEdit->setText(toString());
|
||||
}
|
||||
|
||||
virtual void saveToStringStream(std::stringstream& out){
|
||||
optionValue=fromString(lineEdit->text());
|
||||
MainWindowItem::saveToStringStream(out);
|
||||
}
|
||||
virtual bool isValid() { return true; }
|
||||
};
|
||||
class FileOrFolderChooserItem : public BaseStringItem {
|
||||
public:
|
||||
QPushButton* browsePushButton;
|
||||
FileOrFolderChooserItem(ConfigOption option_, QLineEdit* lineEdit_, QPushButton* browsePushButton_) :
|
||||
BaseStringItem(option_, lineEdit_), browsePushButton(browsePushButton_) {}
|
||||
virtual ~FileOrFolderChooserItem(){}
|
||||
};
|
||||
class FileChooserItem : public FileOrFolderChooserItem {
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void pushButtonReleased();
|
||||
public:
|
||||
FileChooserItem(ConfigOption option_, QLineEdit* lineEdit_, QPushButton* browsePushButton_) :
|
||||
FileOrFolderChooserItem(option_, lineEdit_, browsePushButton_) {
|
||||
QObject::connect(browsePushButton, SIGNAL(released()), this, SLOT(pushButtonReleased()));
|
||||
}
|
||||
};
|
||||
class FolderChooserItem : public FileOrFolderChooserItem{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void pushButtonReleased();
|
||||
public:
|
||||
FolderChooserItem(ConfigOption option_, QLineEdit* lineEdit_, QPushButton* browsePushButton_) :
|
||||
FileOrFolderChooserItem(option_, lineEdit_, browsePushButton_) {
|
||||
QObject::connect(browsePushButton, SIGNAL(released()), this, SLOT(pushButtonReleased()));
|
||||
}
|
||||
};
|
||||
class ComboBoxItem : public MainWindowItem {
|
||||
public:
|
||||
QComboBox* comboBox;
|
||||
ComboBoxItem(ConfigOption option_, QComboBox* comboBox_) : MainWindowItem(option_), comboBox(comboBox_){};
|
||||
virtual ~ComboBoxItem(){}
|
||||
virtual void installListeners(MainWindow *mainWindow);
|
||||
virtual void loadFromConfigOption()=0;
|
||||
virtual void saveToStringStream(std::stringstream& out)=0;
|
||||
virtual bool isValid() { return true; }
|
||||
};
|
||||
class LogLevelComboBoxItem : public ComboBoxItem {
|
||||
public:
|
||||
LogLevelComboBoxItem(ConfigOption option_, QComboBox* comboBox_) : ComboBoxItem(option_, comboBox_) {};
|
||||
virtual ~LogLevelComboBoxItem(){}
|
||||
virtual void loadFromConfigOption(){
|
||||
MainWindowItem::loadFromConfigOption();
|
||||
const char * ll = boost::any_cast<std::string>(optionValue).c_str();
|
||||
comboBox->setCurrentText(QString(ll));
|
||||
}
|
||||
virtual void saveToStringStream(std::stringstream& out){
|
||||
optionValue=comboBox->currentText().toStdString();
|
||||
MainWindowItem::saveToStringStream(out);
|
||||
}
|
||||
virtual bool isValid() { return true; }
|
||||
};
|
||||
class SignatureTypeComboBoxItem : public ComboBoxItem {
|
||||
public:
|
||||
SignatureTypeComboBoxItem(ConfigOption option_, QComboBox* comboBox_) : ComboBoxItem(option_, comboBox_) {};
|
||||
virtual ~SignatureTypeComboBoxItem(){}
|
||||
virtual void loadFromConfigOption(){//TODO
|
||||
MainWindowItem::loadFromConfigOption();
|
||||
comboBox->setCurrentText(QString::number(boost::any_cast<unsigned short>(optionValue)));
|
||||
}
|
||||
virtual void saveToStringStream(std::stringstream& out){//TODO
|
||||
QString txt = comboBox->currentText();
|
||||
if(txt.isEmpty())
|
||||
optionValue=std::string();
|
||||
else
|
||||
optionValue=(unsigned short)std::stoi(txt.toStdString());
|
||||
MainWindowItem::saveToStringStream(out);
|
||||
}
|
||||
virtual bool isValid() { return true; }
|
||||
};
|
||||
class CheckBoxItem : public MainWindowItem {
|
||||
public:
|
||||
QCheckBox* checkBox;
|
||||
CheckBoxItem(ConfigOption option_, QCheckBox* checkBox_) : MainWindowItem(option_), checkBox(checkBox_){};
|
||||
virtual ~CheckBoxItem(){}
|
||||
virtual void installListeners(MainWindow *mainWindow);
|
||||
virtual void loadFromConfigOption(){
|
||||
MainWindowItem::loadFromConfigOption();
|
||||
checkBox->setChecked(boost::any_cast<bool>(optionValue));
|
||||
}
|
||||
virtual void saveToStringStream(std::stringstream& out){
|
||||
optionValue=checkBox->isChecked();
|
||||
MainWindowItem::saveToStringStream(out);
|
||||
}
|
||||
virtual bool isValid() { return true; }
|
||||
};
|
||||
class BaseFormattedStringItem : public BaseStringItem {
|
||||
public:
|
||||
QString fieldNameTranslated;
|
||||
BaseFormattedStringItem(ConfigOption option_, QLineEdit* lineEdit_, QString fieldNameTranslated_) :
|
||||
BaseStringItem(option_, lineEdit_), fieldNameTranslated(fieldNameTranslated_) {};
|
||||
virtual ~BaseFormattedStringItem(){}
|
||||
virtual bool isValid()=0;
|
||||
};
|
||||
class IntegerStringItem : public BaseFormattedStringItem {
|
||||
public:
|
||||
IntegerStringItem(ConfigOption option_, QLineEdit* lineEdit_, QString fieldNameTranslated_) :
|
||||
BaseFormattedStringItem(option_, lineEdit_, fieldNameTranslated_) {};
|
||||
virtual ~IntegerStringItem(){}
|
||||
virtual bool isValid(){return true;}
|
||||
virtual QString toString(){return QString::number(boost::any_cast<int>(optionValue));}
|
||||
virtual boost::any fromString(QString s){return boost::any(std::stoi(s.toStdString()));}
|
||||
};
|
||||
class UShortStringItem : public BaseFormattedStringItem {
|
||||
public:
|
||||
UShortStringItem(ConfigOption option_, QLineEdit* lineEdit_, QString fieldNameTranslated_) :
|
||||
BaseFormattedStringItem(option_, lineEdit_, fieldNameTranslated_) {};
|
||||
virtual ~UShortStringItem(){}
|
||||
virtual bool isValid(){return true;}
|
||||
virtual QString toString(){return QString::number(boost::any_cast<unsigned short>(optionValue));}
|
||||
virtual boost::any fromString(QString s){return boost::any((unsigned short)std::stoi(s.toStdString()));}
|
||||
};
|
||||
class UInt32StringItem : public BaseFormattedStringItem {
|
||||
public:
|
||||
UInt32StringItem(ConfigOption option_, QLineEdit* lineEdit_, QString fieldNameTranslated_) :
|
||||
BaseFormattedStringItem(option_, lineEdit_, fieldNameTranslated_) {};
|
||||
virtual ~UInt32StringItem(){}
|
||||
virtual bool isValid(){return true;}
|
||||
virtual QString toString(){return QString::number(boost::any_cast<uint32_t>(optionValue));}
|
||||
virtual boost::any fromString(QString s){return boost::any((uint32_t)std::stoi(s.toStdString()));}
|
||||
};
|
||||
class UInt16StringItem : public BaseFormattedStringItem {
|
||||
public:
|
||||
UInt16StringItem(ConfigOption option_, QLineEdit* lineEdit_, QString fieldNameTranslated_) :
|
||||
BaseFormattedStringItem(option_, lineEdit_, fieldNameTranslated_) {};
|
||||
virtual ~UInt16StringItem(){}
|
||||
virtual bool isValid(){return true;}
|
||||
virtual QString toString(){return QString::number(boost::any_cast<uint16_t>(optionValue));}
|
||||
virtual boost::any fromString(QString s){return boost::any((uint16_t)std::stoi(s.toStdString()));}
|
||||
};
|
||||
class IPAddressStringItem : public BaseFormattedStringItem {
|
||||
public:
|
||||
IPAddressStringItem(ConfigOption option_, QLineEdit* lineEdit_, QString fieldNameTranslated_) :
|
||||
BaseFormattedStringItem(option_, lineEdit_, fieldNameTranslated_) {};
|
||||
virtual bool isValid(){return true;}
|
||||
};
|
||||
class TCPPortStringItem : public UShortStringItem {
|
||||
public:
|
||||
TCPPortStringItem(ConfigOption option_, QLineEdit* lineEdit_, QString fieldNameTranslated_) :
|
||||
UShortStringItem(option_, lineEdit_, fieldNameTranslated_) {};
|
||||
virtual bool isValid(){return true;}
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
using namespace i2p::client;
|
||||
|
||||
class TunnelPane;
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
explicit MainWindow(QWidget *parent=0);
|
||||
~MainWindow();
|
||||
|
||||
//typedef std::function<QString ()> DefaultValueGetter;
|
||||
|
||||
//#ifndef ANDROID
|
||||
// void setVisible(bool visible);
|
||||
//#endif
|
||||
|
@ -70,17 +355,210 @@ protected:
|
|||
void resizeEvent(QResizeEvent* event);
|
||||
void onResize();
|
||||
|
||||
void initFileChooser(QLineEdit* fileNameLineEdit, QPushButton* fileBrowsePushButton);
|
||||
void initFolderChooser(QLineEdit* folderLineEdit, QPushButton* folderBrowsePushButton);
|
||||
void initCombobox(QComboBox* comboBox);
|
||||
void initIPAddressBox(QLineEdit* addressLineEdit, QString fieldNameTranslated);
|
||||
void initTCPPortBox(QLineEdit* portLineEdit, QString fieldNameTranslated);
|
||||
void initCheckBox(QCheckBox* checkBox);
|
||||
void initIntegerBox(QLineEdit* numberLineEdit);
|
||||
void initStringBox(QLineEdit* lineEdit);
|
||||
QList<MainWindowItem*> configItems;
|
||||
NonGUIOptionItem* logOption;
|
||||
NonGUIOptionItem* daemonOption;
|
||||
NonGUIOptionItem* serviceOption;
|
||||
FileChooserItem* logFileNameOption;
|
||||
|
||||
FileChooserItem* initFileChooser(ConfigOption option, QLineEdit* fileNameLineEdit, QPushButton* fileBrowsePushButton);
|
||||
void initFolderChooser(ConfigOption option, QLineEdit* folderLineEdit, QPushButton* folderBrowsePushButton);
|
||||
//void initCombobox(ConfigOption option, QComboBox* comboBox);
|
||||
void initLogLevelCombobox(ConfigOption option, QComboBox* comboBox);
|
||||
void initSignatureTypeCombobox(ConfigOption option, QComboBox* comboBox);
|
||||
void initIPAddressBox(ConfigOption option, QLineEdit* addressLineEdit, QString fieldNameTranslated);
|
||||
void initTCPPortBox(ConfigOption option, QLineEdit* portLineEdit, QString fieldNameTranslated);
|
||||
void initCheckBox(ConfigOption option, QCheckBox* checkBox);
|
||||
void initIntegerBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated);
|
||||
void initUInt32Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated);
|
||||
void initUInt16Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated);
|
||||
void initStringBox(ConfigOption option, QLineEdit* lineEdit);
|
||||
NonGUIOptionItem* initNonGUIOption(ConfigOption option);
|
||||
|
||||
void loadAllConfigs();
|
||||
void saveAllConfigs();
|
||||
|
||||
public slots:
|
||||
/** returns false iff not valid items present and save was aborted */
|
||||
bool saveAllConfigs();
|
||||
void reloadTunnelsConfigAndUI();
|
||||
|
||||
private:
|
||||
QString datadir;
|
||||
QString confpath;
|
||||
QString tunconfpath;
|
||||
|
||||
std::list<TunnelConfig*> tunnelConfigs;
|
||||
std::list<TunnelPane*> tunnelPanes;
|
||||
|
||||
QWidget *tunnelsFormGridLayoutWidget;
|
||||
QGridLayout *tunnelsFormGridLayout;
|
||||
|
||||
void appendTunnelForms();
|
||||
void deleteTunnelForms();
|
||||
|
||||
|
||||
/*
|
||||
|
||||
TODO signaturetype
|
||||
|
||||
<orignal_> https://geti2p.net/spec/common-structures#certificate
|
||||
<orignal_> все коды перечислены
|
||||
<Hypnosis> orignal_, это таблица "The defined Signing Public Key types are:" ?
|
||||
<orignal_> да
|
||||
|
||||
see also : Identity.h line 55
|
||||
|
||||
*/
|
||||
|
||||
template<typename Section, typename Type>
|
||||
std::string GetI2CPOption (const Section& section, const std::string& name, const Type& value) const
|
||||
{
|
||||
return section.second.get (boost::property_tree::ptree::path_type (name, '/'), std::to_string (value));
|
||||
}
|
||||
|
||||
template<typename Section>
|
||||
void ReadI2CPOptions (const Section& section, std::map<std::string, std::string>& options, I2CPParameters& param
|
||||
/*TODO fill param*/) const
|
||||
{
|
||||
std::string _INBOUND_TUNNEL_LENGTH = options[I2CP_PARAM_INBOUND_TUNNEL_LENGTH] = GetI2CPOption (section, I2CP_PARAM_INBOUND_TUNNEL_LENGTH, DEFAULT_INBOUND_TUNNEL_LENGTH);
|
||||
param.setInbound_length(QString(_INBOUND_TUNNEL_LENGTH.c_str()));
|
||||
std::string _OUTBOUND_TUNNEL_LENGTH = options[I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH] = GetI2CPOption (section, I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH, DEFAULT_OUTBOUND_TUNNEL_LENGTH);
|
||||
param.setOutbound_length(QString(_OUTBOUND_TUNNEL_LENGTH.c_str()));
|
||||
std::string _INBOUND_TUNNELS_QUANTITY = options[I2CP_PARAM_INBOUND_TUNNELS_QUANTITY] = GetI2CPOption (section, I2CP_PARAM_INBOUND_TUNNELS_QUANTITY, DEFAULT_INBOUND_TUNNELS_QUANTITY);
|
||||
param.setInbound_quantity( QString(_INBOUND_TUNNELS_QUANTITY.c_str()));
|
||||
std::string _OUTBOUND_TUNNELS_QUANTITY = options[I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY] = GetI2CPOption (section, I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY, DEFAULT_OUTBOUND_TUNNELS_QUANTITY);
|
||||
param.setOutbound_quantity(QString(_OUTBOUND_TUNNELS_QUANTITY.c_str()));
|
||||
std::string _TAGS_TO_SEND = options[I2CP_PARAM_TAGS_TO_SEND] = GetI2CPOption (section, I2CP_PARAM_TAGS_TO_SEND, DEFAULT_TAGS_TO_SEND);
|
||||
param.setCrypto_tagsToSend(QString(_TAGS_TO_SEND.c_str()));
|
||||
options[I2CP_PARAM_MIN_TUNNEL_LATENCY] = GetI2CPOption(section, I2CP_PARAM_MIN_TUNNEL_LATENCY, DEFAULT_MIN_TUNNEL_LATENCY);//TODO include into param
|
||||
options[I2CP_PARAM_MAX_TUNNEL_LATENCY] = GetI2CPOption(section, I2CP_PARAM_MAX_TUNNEL_LATENCY, DEFAULT_MAX_TUNNEL_LATENCY);//TODO include into param
|
||||
}
|
||||
|
||||
|
||||
void ReadTunnelsConfig() //TODO deduplicate the code with ClientContext.cpp::ReadTunnels ()
|
||||
{
|
||||
boost::property_tree::ptree pt;
|
||||
std::string tunConf=tunconfpath.toStdString();
|
||||
if (tunConf == "") {
|
||||
// TODO: cleanup this in 2.8.0
|
||||
tunConf = i2p::fs::DataDirPath ("tunnels.cfg");
|
||||
if (i2p::fs::Exists(tunConf)) {
|
||||
LogPrint(eLogWarning, "FS: please rename tunnels.cfg -> tunnels.conf here: ", tunConf);
|
||||
} else {
|
||||
tunConf = i2p::fs::DataDirPath ("tunnels.conf");
|
||||
}
|
||||
}
|
||||
LogPrint(eLogDebug, "tunnels config file: ", tunConf);
|
||||
try
|
||||
{
|
||||
boost::property_tree::read_ini (tunConf, pt);
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
LogPrint (eLogWarning, "Clients: Can't read ", tunConf, ": ", ex.what ());//TODO show err box and disable tunn.page
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& section: pt)
|
||||
{
|
||||
std::string name = section.first;
|
||||
try
|
||||
{
|
||||
std::string type = section.second.get<std::string> (I2P_TUNNELS_SECTION_TYPE);
|
||||
if (type == I2P_TUNNELS_SECTION_TYPE_CLIENT
|
||||
|| type == I2P_TUNNELS_SECTION_TYPE_SOCKS
|
||||
|| type == I2P_TUNNELS_SECTION_TYPE_WEBSOCKS
|
||||
|| type == I2P_TUNNELS_SECTION_TYPE_HTTPPROXY
|
||||
|| type == I2P_TUNNELS_SECTION_TYPE_UDPCLIENT)
|
||||
{
|
||||
// mandatory params
|
||||
std::string dest;
|
||||
if (type == I2P_TUNNELS_SECTION_TYPE_CLIENT || type == I2P_TUNNELS_SECTION_TYPE_UDPCLIENT)
|
||||
dest = section.second.get<std::string> (I2P_CLIENT_TUNNEL_DESTINATION);
|
||||
int port = section.second.get<int> (I2P_CLIENT_TUNNEL_PORT);
|
||||
// optional params
|
||||
std::string keys = section.second.get (I2P_CLIENT_TUNNEL_KEYS, "");
|
||||
std::string address = section.second.get (I2P_CLIENT_TUNNEL_ADDRESS, "127.0.0.1");
|
||||
int destinationPort = section.second.get (I2P_CLIENT_TUNNEL_DESTINATION_PORT, 0);
|
||||
i2p::data::SigningKeyType sigType = section.second.get (I2P_CLIENT_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256);
|
||||
// I2CP
|
||||
std::map<std::string, std::string> options;
|
||||
I2CPParameters i2cpParameters;
|
||||
ReadI2CPOptions (section, options, i2cpParameters);
|
||||
|
||||
tunnelConfigs.push_back(new ClientTunnelConfig(name, QString(type.c_str()), i2cpParameters,
|
||||
dest,
|
||||
port,
|
||||
keys,
|
||||
address,
|
||||
destinationPort,
|
||||
sigType));
|
||||
}
|
||||
else if (type == I2P_TUNNELS_SECTION_TYPE_SERVER
|
||||
|| type == I2P_TUNNELS_SECTION_TYPE_HTTP
|
||||
|| type == I2P_TUNNELS_SECTION_TYPE_IRC
|
||||
|| type == I2P_TUNNELS_SECTION_TYPE_UDPSERVER)
|
||||
{
|
||||
// mandatory params
|
||||
std::string host = section.second.get<std::string> (I2P_SERVER_TUNNEL_HOST);
|
||||
int port = section.second.get<int> (I2P_SERVER_TUNNEL_PORT);
|
||||
std::string keys = section.second.get<std::string> (I2P_SERVER_TUNNEL_KEYS);
|
||||
// optional params
|
||||
int inPort = section.second.get (I2P_SERVER_TUNNEL_INPORT, 0);
|
||||
std::string accessList = section.second.get (I2P_SERVER_TUNNEL_ACCESS_LIST, "");
|
||||
std::string hostOverride = section.second.get (I2P_SERVER_TUNNEL_HOST_OVERRIDE, "");
|
||||
std::string webircpass = section.second.get<std::string> (I2P_SERVER_TUNNEL_WEBIRC_PASSWORD, "");
|
||||
bool gzip = section.second.get (I2P_SERVER_TUNNEL_GZIP, true);
|
||||
i2p::data::SigningKeyType sigType = section.second.get (I2P_SERVER_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256);
|
||||
uint32_t maxConns = section.second.get(i2p::stream::I2CP_PARAM_STREAMING_MAX_CONNS_PER_MIN, i2p::stream::DEFAULT_MAX_CONNS_PER_MIN);
|
||||
std::string address = section.second.get<std::string> (I2P_SERVER_TUNNEL_ADDRESS, "127.0.0.1");
|
||||
bool isUniqueLocal = section.second.get(I2P_SERVER_TUNNEL_ENABLE_UNIQUE_LOCAL, true);
|
||||
|
||||
// I2CP
|
||||
std::map<std::string, std::string> options;
|
||||
I2CPParameters i2cpParameters;
|
||||
ReadI2CPOptions (section, options, i2cpParameters);
|
||||
|
||||
/*
|
||||
std::set<i2p::data::IdentHash> idents;
|
||||
if (accessList.length () > 0)
|
||||
{
|
||||
size_t pos = 0, comma;
|
||||
do
|
||||
{
|
||||
comma = accessList.find (',', pos);
|
||||
i2p::data::IdentHash ident;
|
||||
ident.FromBase32 (accessList.substr (pos, comma != std::string::npos ? comma - pos : std::string::npos));
|
||||
idents.insert (ident);
|
||||
pos = comma + 1;
|
||||
}
|
||||
while (comma != std::string::npos);
|
||||
}
|
||||
*/
|
||||
tunnelConfigs.push_back(new ServerTunnelConfig(name, QString(type.c_str()), i2cpParameters,
|
||||
host,
|
||||
port,
|
||||
keys,
|
||||
inPort,
|
||||
accessList,
|
||||
hostOverride,
|
||||
webircpass,
|
||||
gzip,
|
||||
sigType,
|
||||
maxConns,
|
||||
address,
|
||||
isUniqueLocal));
|
||||
}
|
||||
else
|
||||
LogPrint (eLogWarning, "Clients: Unknown section type=", type, " of ", name, " in ", tunConf);//TODO show err box and disable the tunn gui
|
||||
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
LogPrint (eLogError, "Clients: Can't read tunnel ", name, " params: ", ex.what ());//TODO show err box and disable the tunn gui
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>816</width>
|
||||
<height>5000</height>
|
||||
<height>3000</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -26,7 +26,7 @@
|
|||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>801</width>
|
||||
<height>5000</height>
|
||||
<height>491</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
|
@ -114,7 +114,7 @@
|
|||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>5000</height>
|
||||
<height>516</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
|
@ -127,7 +127,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>671</width>
|
||||
<height>5000</height>
|
||||
<height>491</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
|
@ -175,7 +175,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>701</width>
|
||||
<height>5000</height>
|
||||
<height>460</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
|
@ -213,8 +213,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>684</width>
|
||||
<height>427</height>
|
||||
<width>683</width>
|
||||
<height>426</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -229,7 +229,7 @@
|
|||
<x>10</x>
|
||||
<y>11</y>
|
||||
<width>661</width>
|
||||
<height>5000</height>
|
||||
<height>3000</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="settingsContentsGridLayout" rowstretch="0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">
|
||||
|
@ -2223,7 +2223,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
<widget class="QLineEdit" name="maxNumOfTransitTunnelsLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_23">
|
||||
|
@ -2258,7 +2258,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_2"/>
|
||||
<widget class="QLineEdit" name="maxNumOfOpenFilesLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_24">
|
||||
|
@ -2293,7 +2293,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_3"/>
|
||||
<widget class="QLineEdit" name="coreFileMaxSizeNumberLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_25">
|
||||
|
@ -2736,8 +2736,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>664</width>
|
||||
<height>427</height>
|
||||
<width>84</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
2964
qt/i2pd_qt/mainwindow.ui.bk_26_feb_2017_sn2
Normal file
2964
qt/i2pd_qt/mainwindow.ui.bk_26_feb_2017_sn2
Normal file
File diff suppressed because it is too large
Load diff
3161
qt/i2pd_qt/mainwindow.ui.bk_26_feb_2017_sn3
Normal file
3161
qt/i2pd_qt/mainwindow.ui.bk_26_feb_2017_sn3
Normal file
File diff suppressed because it is too large
Load diff
3231
qt/i2pd_qt/mainwindow.ui_expandedForm_old4
Normal file
3231
qt/i2pd_qt/mainwindow.ui_expandedForm_old4
Normal file
File diff suppressed because it is too large
Load diff
104
qt/i2pd_qt/tunnelform.ui
Normal file
104
qt/i2pd_qt/tunnelform.ui
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>527</width>
|
||||
<height>452</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="gridLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>521</width>
|
||||
<height>451</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="formGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="serverTunnelNameGroupBox">
|
||||
<property name="title">
|
||||
<string>server_tunnel_name</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="gridLayoutWidget_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>20</y>
|
||||
<width>511</width>
|
||||
<height>421</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="tunnelGridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="headerHorizontalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="tunnelTypeComboBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="headerHorizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="deletePushButton">
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="hostLabel">
|
||||
<property name="text">
|
||||
<string>Host:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="hostLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="hostHorizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in a new issue