Browse Source

qt: crypto type added

pull/1560/head
user 4 years ago
parent
commit
f6ff232106
  1. 17
      qt/i2pd_qt/ClientTunnelPane.cpp
  2. 13
      qt/i2pd_qt/ClientTunnelPane.h
  3. 17
      qt/i2pd_qt/ServerTunnelPane.cpp
  4. 13
      qt/i2pd_qt/ServerTunnelPane.h
  5. 8
      qt/i2pd_qt/TunnelConfig.cpp
  6. 15
      qt/i2pd_qt/TunnelConfig.h
  7. 56
      qt/i2pd_qt/mainwindow.cpp
  8. 31
      qt/i2pd_qt/mainwindow.h

17
qt/i2pd_qt/ClientTunnelPane.cpp

@ -168,6 +168,23 @@ int ClientTunnelPane::appendClientTunnelForm(
horizontalLayout_2->addItem(horizontalSpacer); horizontalLayout_2->addItem(horizontalSpacer);
tunnelGridLayout->addLayout(horizontalLayout_2); tunnelGridLayout->addLayout(horizontalLayout_2);
} }
{
int cryptoType = tunnelConfig->getcryptoType();
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
ui.cryptoTypeLabel = new QLabel(gridLayoutWidget_2);
cryptoTypeLabel->setObjectName(QStringLiteral("cryptoTypeLabel"));
horizontalLayout_2->addWidget(cryptoTypeLabel);
ui.cryptoTypeLineEdit = new QLineEdit(gridLayoutWidget_2);
cryptoTypeLineEdit->setObjectName(QStringLiteral("cryptoTypeLineEdit"));
cryptoTypeLineEdit->setText(QString::number(cryptoType));
cryptoTypeLineEdit->setMaximumWidth(80);
QObject::connect(cryptoTypeLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(updated()));
horizontalLayout_2->addWidget(cryptoTypeLineEdit);
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
tunnelGridLayout->addLayout(horizontalLayout_2);
}
{ {
i2p::data::SigningKeyType sigType = tunnelConfig->getsigType(); i2p::data::SigningKeyType sigType = tunnelConfig->getsigType();
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout(); QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();

13
qt/i2pd_qt/ClientTunnelPane.h

@ -53,6 +53,10 @@ private:
QLabel * sigTypeLabel; QLabel * sigTypeLabel;
QComboBox * sigTypeComboBox; QComboBox * sigTypeComboBox;
//cryptoType
QLabel * cryptoTypeLabel;
QLineEdit * cryptoTypeLineEdit;
protected slots: protected slots:
virtual void setGroupBoxTitle(const QString & title); virtual void setGroupBoxTitle(const QString & title);
@ -61,6 +65,7 @@ private:
typeLabel->setText(QApplication::translate("cltTunForm", "Client tunnel type:", 0)); typeLabel->setText(QApplication::translate("cltTunForm", "Client tunnel type:", 0));
destinationLabel->setText(QApplication::translate("cltTunForm", "Destination:", 0)); destinationLabel->setText(QApplication::translate("cltTunForm", "Destination:", 0));
portLabel->setText(QApplication::translate("cltTunForm", "Port:", 0)); portLabel->setText(QApplication::translate("cltTunForm", "Port:", 0));
cryptoTypeLabel->setText(QApplication::translate("cltTunForm", "Crypto type:", 0));
keysLabel->setText(QApplication::translate("cltTunForm", "Keys:", 0)); keysLabel->setText(QApplication::translate("cltTunForm", "Keys:", 0));
destinationPortLabel->setText(QApplication::translate("cltTunForm", "Destination port:", 0)); destinationPortLabel->setText(QApplication::translate("cltTunForm", "Destination port:", 0));
addressLabel->setText(QApplication::translate("cltTunForm", "Address:", 0)); addressLabel->setText(QApplication::translate("cltTunForm", "Address:", 0));
@ -86,6 +91,14 @@ protected:
} }
ctc->setport(portInt); ctc->setport(portInt);
auto cryptoTypeStr=cryptoTypeLineEdit->text();
int cryptoTypeInt=cryptoTypeStr.toInt(&ok);
if(!ok){
highlightWrongInput(QApplication::tr("Bad crypto type, must be int.")+" "+cannotSaveSettings,cryptoTypeLineEdit);
return false;
}
ctc->setcryptoType(cryptoTypeInt);
ctc->setkeys(keysLineEdit->text().toStdString()); ctc->setkeys(keysLineEdit->text().toStdString());
ctc->setaddress(addressLineEdit->text().toStdString()); ctc->setaddress(addressLineEdit->text().toStdString());

17
qt/i2pd_qt/ServerTunnelPane.cpp

@ -235,6 +235,23 @@ int ServerTunnelPane::appendServerTunnelForm(
horizontalLayout_2->addItem(horizontalSpacer); horizontalLayout_2->addItem(horizontalSpacer);
tunnelGridLayout->addLayout(horizontalLayout_2); tunnelGridLayout->addLayout(horizontalLayout_2);
} }
{
int cryptoType = tunnelConfig->getcryptoType();
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
ui.cryptoTypeLabel = new QLabel(gridLayoutWidget_2);
cryptoTypeLabel->setObjectName(QStringLiteral("cryptoTypeLabel"));
horizontalLayout_2->addWidget(cryptoTypeLabel);
ui.cryptoTypeLineEdit = new QLineEdit(gridLayoutWidget_2);
cryptoTypeLineEdit->setObjectName(QStringLiteral("cryptoTypeLineEdit"));
cryptoTypeLineEdit->setText(QString::number(cryptoType));
cryptoTypeLineEdit->setMaximumWidth(80);
QObject::connect(cryptoTypeLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(updated()));
horizontalLayout_2->addWidget(cryptoTypeLineEdit);
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
tunnelGridLayout->addLayout(horizontalLayout_2);
}
{ {
I2CPParameters& i2cpParameters = tunnelConfig->getI2cpParameters(); I2CPParameters& i2cpParameters = tunnelConfig->getI2cpParameters();
appendControlsForI2CPParameters(i2cpParameters, gridIndex); appendControlsForI2CPParameters(i2cpParameters, gridIndex);

13
qt/i2pd_qt/ServerTunnelPane.h

@ -65,6 +65,10 @@ private:
QLabel * inPortLabel; QLabel * inPortLabel;
QLineEdit * inPortLineEdit; QLineEdit * inPortLineEdit;
//cryptoType
QLabel * cryptoTypeLabel;
QLineEdit * cryptoTypeLineEdit;
//accessList //accessList
QLabel * accessListLabel; QLabel * accessListLabel;
QLineEdit * accessListLineEdit; QLineEdit * accessListLineEdit;
@ -101,6 +105,7 @@ private:
portLabel->setText(QApplication::translate("srvTunForm", "Port:", 0)); portLabel->setText(QApplication::translate("srvTunForm", "Port:", 0));
keysLabel->setText(QApplication::translate("srvTunForm", "Keys:", 0)); keysLabel->setText(QApplication::translate("srvTunForm", "Keys:", 0));
inPortLabel->setText(QApplication::translate("srvTunForm", "InPort:", 0)); inPortLabel->setText(QApplication::translate("srvTunForm", "InPort:", 0));
cryptoTypeLabel->setText(QApplication::translate("srvTunForm", "Crypto type:", 0));
accessListLabel->setText(QApplication::translate("srvTunForm", "Access list:", 0)); accessListLabel->setText(QApplication::translate("srvTunForm", "Access list:", 0));
hostOverrideLabel->setText(QApplication::translate("srvTunForm", "Host override:", 0)); hostOverrideLabel->setText(QApplication::translate("srvTunForm", "Host override:", 0));
webIRCPassLabel->setText(QApplication::translate("srvTunForm", "WebIRC password:", 0)); webIRCPassLabel->setText(QApplication::translate("srvTunForm", "WebIRC password:", 0));
@ -129,6 +134,14 @@ protected:
} }
stc->setport(portInt); stc->setport(portInt);
auto cryptoTypeStr=cryptoTypeLineEdit->text();
int cryptoTypeInt=cryptoTypeStr.toInt(&ok);
if(!ok){
highlightWrongInput(QApplication::tr("Bad crypto type, must be int.")+" "+cannotSaveSettings,cryptoTypeLineEdit);
return false;
}
stc->setcryptoType(cryptoTypeInt);
stc->setkeys(keysLineEdit->text().toStdString()); stc->setkeys(keysLineEdit->text().toStdString());
auto str=inPortLineEdit->text(); auto str=inPortLineEdit->text();

8
qt/i2pd_qt/TunnelConfig.cpp

@ -32,6 +32,7 @@ void ClientTunnelConfig::saveToStringStream(std::stringstream& out) {
<< "port=" << port << "\n" << "port=" << port << "\n"
<< "destination=" << dest << "\n" << "destination=" << dest << "\n"
<< "destinationport=" << destinationPort << "\n" << "destinationport=" << destinationPort << "\n"
<< "cryptoType=" << getcryptoType() << "\n"
<< "signaturetype=" << sigType << "\n"; << "signaturetype=" << sigType << "\n";
if(!keys.empty()) out << "keys=" << keys << "\n"; if(!keys.empty()) out << "keys=" << keys << "\n";
} }
@ -41,9 +42,10 @@ void ServerTunnelConfig::saveToStringStream(std::stringstream& out) {
out << "host=" << host << "\n" out << "host=" << host << "\n"
<< "port=" << port << "\n" << "port=" << port << "\n"
<< "signaturetype=" << sigType << "\n" << "signaturetype=" << sigType << "\n"
<< "inport=" << inPort << "\n" << "inport=" << inPort << "\n";
<< "accesslist=" << accessList << "\n" if(accessList.size()>0) { out << "accesslist=" << accessList << "\n"; }
<< "gzip=" << (gzip?"true":"false") << "\n" out << "gzip=" << (gzip?"true":"false") << "\n"
<< "cryptoType=" << getcryptoType() << "\n"
<< "enableuniquelocal=" << (isUniqueLocal?"true":"false") << "\n" << "enableuniquelocal=" << (isUniqueLocal?"true":"false") << "\n"
<< "address=" << address << "\n" << "address=" << address << "\n"
<< "hostoverride=" << hostOverride << "\n" << "hostoverride=" << hostOverride << "\n"

15
qt/i2pd_qt/TunnelConfig.h

@ -58,12 +58,14 @@ class TunnelConfig {
QString type; QString type;
std::string name; std::string name;
TunnelPane* tunnelPane; TunnelPane* tunnelPane;
int cryptoType;
public: public:
TunnelConfig(std::string name_, QString& type_, I2CPParameters& i2cpParameters_): TunnelConfig(std::string name_, QString& type_, I2CPParameters& i2cpParameters_, int cryptoType_):
type(type_), name(name_), i2cpParameters(i2cpParameters_) {} type(type_), name(name_), cryptoType(cryptoType_), i2cpParameters(i2cpParameters_) {}
virtual ~TunnelConfig(){} virtual ~TunnelConfig(){}
const QString& getType(){return type;} const QString& getType(){return type;}
const std::string& getName(){return name;} const std::string& getName(){return name;}
int getcryptoType(){return cryptoType;}
void setType(const QString& type_){type=type_;} void setType(const QString& type_){type=type_;}
void setName(const std::string& name_){name=name_;} void setName(const std::string& name_){name=name_;}
I2CPParameters& getI2cpParameters(){return i2cpParameters;} I2CPParameters& getI2cpParameters(){return i2cpParameters;}
@ -74,6 +76,7 @@ public:
virtual ServerTunnelConfig* asServerTunnelConfig()=0; virtual ServerTunnelConfig* asServerTunnelConfig()=0;
void setTunnelPane(TunnelPane* tp){this->tunnelPane = tp;} void setTunnelPane(TunnelPane* tp){this->tunnelPane = tp;}
TunnelPane* getTunnelPane() {return tunnelPane;} TunnelPane* getTunnelPane() {return tunnelPane;}
void setcryptoType(int cryptoType_){cryptoType=cryptoType_;}
private: private:
I2CPParameters i2cpParameters; I2CPParameters i2cpParameters;
}; };
@ -114,13 +117,14 @@ public:
std::string keys_, std::string keys_,
std::string address_, std::string address_,
int destinationPort_, int destinationPort_,
i2p::data::SigningKeyType sigType_): TunnelConfig(name_, type_, i2cpParameters_), i2p::data::SigningKeyType sigType_,
int cryptoType_): TunnelConfig(name_, type_, i2cpParameters_, cryptoType_),
dest(dest_), dest(dest_),
port(port_), port(port_),
keys(keys_), keys(keys_),
address(address_), address(address_),
destinationPort(destinationPort_), destinationPort(destinationPort_),
sigType(sigType_){} sigType(sigType_) {}
std::string& getdest(){return dest;} std::string& getdest(){return dest;}
int getport(){return port;} int getport(){return port;}
std::string & getkeys(){return keys;} std::string & getkeys(){return keys;}
@ -188,7 +192,8 @@ public:
bool gzip_, bool gzip_,
i2p::data::SigningKeyType sigType_, i2p::data::SigningKeyType sigType_,
std::string address_, std::string address_,
bool isUniqueLocal_): TunnelConfig(name_, type_, i2cpParameters_), bool isUniqueLocal_,
int cryptoType_): TunnelConfig(name_, type_, i2cpParameters_, cryptoType_),
host(host_), host(host_),
port(port_), port(port_),
keys(keys_), keys(keys_),

56
qt/i2pd_qt/mainwindow.cpp

@ -159,12 +159,8 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
# define OPTION(section,option,defaultValueGetter) ConfigOption(QString(section),QString(option)) # define OPTION(section,option,defaultValueGetter) ConfigOption(QString(section),QString(option))
initFileChooser( OPTION("","conf",[](){return "";}), uiSettings->configFileLineEdit, uiSettings->configFileBrowsePushButton); initFileChooser( OPTION("","conf",[](){return "";}), uiSettings->configFileLineEdit, uiSettings->configFileBrowsePushButton);
initFolderChooser( OPTION("","datadir",[]{return "";}), uiSettings->dataFolderLineEdit, uiSettings->dataFolderBrowsePushButton);
initFileChooser( OPTION("","tunconf",[](){return "";}), uiSettings->tunnelsConfigFileLineEdit, uiSettings->tunnelsConfigFileBrowsePushButton); initFileChooser( OPTION("","tunconf",[](){return "";}), uiSettings->tunnelsConfigFileLineEdit, uiSettings->tunnelsConfigFileBrowsePushButton);
initFileChooser( OPTION("","pidfile",[]{return "";}), uiSettings->pidFileLineEdit, uiSettings->pidFileBrowsePushButton); initFileChooser( OPTION("","pidfile",[]{return "";}), uiSettings->pidFileLineEdit, uiSettings->pidFileBrowsePushButton);
daemonOption=initNonGUIOption( OPTION("","daemon",[]{return "";}));
serviceOption=initNonGUIOption( OPTION("","service",[]{return "";}));
uiSettings->logDestinationComboBox->clear(); uiSettings->logDestinationComboBox->clear();
uiSettings->logDestinationComboBox->insertItems(0, QStringList() uiSettings->logDestinationComboBox->insertItems(0, QStringList()
@ -176,20 +172,28 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
logFileNameOption=initFileChooser( OPTION("","logfile",[]{return "";}), uiSettings->logFileLineEdit, uiSettings->logFileBrowsePushButton); logFileNameOption=initFileChooser( OPTION("","logfile",[]{return "";}), uiSettings->logFileLineEdit, uiSettings->logFileBrowsePushButton);
initLogLevelCombobox(OPTION("","loglevel",[]{return "";}), uiSettings->logLevelComboBox); initLogLevelCombobox(OPTION("","loglevel",[]{return "";}), uiSettings->logLevelComboBox);
//TODO add option "logclftime" "Write full CLF-formatted date and time to log (default: write only time)"
initFolderChooser( OPTION("","datadir",[]{return "";}), uiSettings->dataFolderLineEdit, uiSettings->dataFolderBrowsePushButton);
initIPAddressBox( OPTION("","host",[]{return "";}), uiSettings->routerExternalHostLineEdit, tr("Router external address -> Host")); initIPAddressBox( OPTION("","host",[]{return "";}), uiSettings->routerExternalHostLineEdit, tr("Router external address -> Host"));
initTCPPortBox( OPTION("","port",[]{return "";}), uiSettings->routerExternalPortLineEdit, tr("Router external address -> Port")); initTCPPortBox( OPTION("","port",[]{return "";}), uiSettings->routerExternalPortLineEdit, tr("Router external address -> Port"));
daemonOption=initNonGUIOption( OPTION("","daemon",[]{return "";}));
serviceOption=initNonGUIOption( OPTION("","service",[]{return "";}));
//TODO add option "ifname4" Network interface to bind to for IPv4
//TODO add option "ifname6" Network interface to bind to for IPv6
//TODO add option "nat" If true, assume we are behind NAT. true by default
//TODO add option "ipv4" Enable communication through IPv4. true by default
initCheckBox( OPTION("","ipv6",[]{return "false";}), uiSettings->ipv6CheckBox); initCheckBox( OPTION("","ipv6",[]{return "false";}), uiSettings->ipv6CheckBox);
initCheckBox( OPTION("","notransit",[]{return "false";}), uiSettings->notransitCheckBox); initCheckBox( OPTION("","notransit",[]{return "false";}), uiSettings->notransitCheckBox);
initCheckBox( OPTION("","floodfill",[]{return "false";}), uiSettings->floodfillCheckBox); initCheckBox( OPTION("","floodfill",[]{return "false";}), uiSettings->floodfillCheckBox);
initStringBox( OPTION("","bandwidth",[]{return "";}), uiSettings->bandwidthLineEdit); initStringBox( OPTION("","bandwidth",[]{return "";}), uiSettings->bandwidthLineEdit);
//TODO add option "share" Max % of bandwidth limit for transit. 0-100. 100 by default
initStringBox( OPTION("","family",[]{return "";}), uiSettings->familyLineEdit); initStringBox( OPTION("","family",[]{return "";}), uiSettings->familyLineEdit);
initIntegerBox( OPTION("","netid",[]{return "2";}), uiSettings->netIdLineEdit, tr("NetID")); initIntegerBox( OPTION("","netid",[]{return "2";}), uiSettings->netIdLineEdit, tr("NetID"));
//TODO add option "ssu" Enable SSU transport protocol (use UDP). true by default
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
initCheckBox( OPTION("","insomnia",[]{return "";}), uiSettings->insomniaCheckBox);
initNonGUIOption( OPTION("","svcctl",[]{return "";})); initNonGUIOption( OPTION("","svcctl",[]{return "";}));
initCheckBox( OPTION("","insomnia",[]{return "";}), uiSettings->insomniaCheckBox);
initNonGUIOption( OPTION("","close",[]{return "";})); initNonGUIOption( OPTION("","close",[]{return "";}));
#else #else
uiSettings->insomniaCheckBox->setEnabled(false); uiSettings->insomniaCheckBox->setEnabled(false);
@ -201,17 +205,22 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
initCheckBox( OPTION("http","auth",[]{return "";}), uiSettings->webconsoleBasicAuthCheckBox); initCheckBox( OPTION("http","auth",[]{return "";}), uiSettings->webconsoleBasicAuthCheckBox);
initStringBox( OPTION("http","user",[]{return "i2pd";}), uiSettings->webconsoleUserNameLineEditBasicAuth); initStringBox( OPTION("http","user",[]{return "i2pd";}), uiSettings->webconsoleUserNameLineEditBasicAuth);
initStringBox( OPTION("http","pass",[]{return "";}), uiSettings->webconsolePasswordLineEditBasicAuth); initStringBox( OPTION("http","pass",[]{return "";}), uiSettings->webconsolePasswordLineEditBasicAuth);
//TODO add option "http.strictheaders Enable strict host checking on WebUI. true by default
//TODO add option "http.hostname Expected hostname for WebUI (default: localhost)
initCheckBox( OPTION("httpproxy","enabled",[]{return "";}), uiSettings->httpProxyEnabledCheckBox); initCheckBox( OPTION("httpproxy","enabled",[]{return "";}), uiSettings->httpProxyEnabledCheckBox);
initIPAddressBox( OPTION("httpproxy","address",[]{return "";}), uiSettings->httpProxyAddressLineEdit, tr("HTTP proxy -> IP address")); initIPAddressBox( OPTION("httpproxy","address",[]{return "";}), uiSettings->httpProxyAddressLineEdit, tr("HTTP proxy -> IP address"));
initTCPPortBox( OPTION("httpproxy","port",[]{return "4444";}), uiSettings->httpProxyPortLineEdit, tr("HTTP proxy -> Port")); initTCPPortBox( OPTION("httpproxy","port",[]{return "4444";}), uiSettings->httpProxyPortLineEdit, tr("HTTP proxy -> Port"));
//TODO add option "httpproxy.addresshelper Enable address helper (jump). true by default
initFileChooser( OPTION("httpproxy","keys",[]{return "";}), uiSettings->httpProxyKeyFileLineEdit, uiSettings->httpProxyKeyFilePushButton); initFileChooser( OPTION("httpproxy","keys",[]{return "";}), uiSettings->httpProxyKeyFileLineEdit, uiSettings->httpProxyKeyFilePushButton);
initSignatureTypeCombobox(OPTION("httpproxy","signaturetype",[]{return "7";}), uiSettings->comboBox_httpPorxySignatureType); initSignatureTypeCombobox(OPTION("httpproxy","signaturetype",[]{return "7";}), uiSettings->comboBox_httpPorxySignatureType);
initStringBox( OPTION("httpproxy","inbound.length",[]{return "3";}), uiSettings->httpProxyInboundTunnelsLenLineEdit); initStringBox( OPTION("httpproxy","inbound.length",[]{return "3";}), uiSettings->httpProxyInboundTunnelsLenLineEdit);
initStringBox( OPTION("httpproxy","inbound.quantity",[]{return "5";}), uiSettings->httpProxyInboundTunnQuantityLineEdit); initStringBox( OPTION("httpproxy","inbound.quantity",[]{return "5";}), uiSettings->httpProxyInboundTunnQuantityLineEdit);
initStringBox( OPTION("httpproxy","outbound.length",[]{return "3";}), uiSettings->httpProxyOutBoundTunnLenLineEdit); initStringBox( OPTION("httpproxy","outbound.length",[]{return "3";}), uiSettings->httpProxyOutBoundTunnLenLineEdit);
initStringBox( OPTION("httpproxy","outbound.quantity",[]{return "5";}), uiSettings->httpProxyOutboundTunnQuantityLineEdit); initStringBox( OPTION("httpproxy","outbound.quantity",[]{return "5";}), uiSettings->httpProxyOutboundTunnQuantityLineEdit);
//TODO add option "httpproxy.outproxy HTTP proxy upstream out proxy url (like http://false.i2p)
//TODO add option "httpproxy.i2cp.leaseSetType Type of LeaseSet to be sent. 1, 3 or 5. 1 by default
//TODO add option "httpproxy.i2cp.leaseSetEncType Comma separated encryption types to be used in LeaseSet type 3 or 5
initCheckBox( OPTION("socksproxy","enabled",[]{return "";}), uiSettings->socksProxyEnabledCheckBox); initCheckBox( OPTION("socksproxy","enabled",[]{return "";}), uiSettings->socksProxyEnabledCheckBox);
initIPAddressBox( OPTION("socksproxy","address",[]{return "";}), uiSettings->socksProxyAddressLineEdit, tr("Socks proxy -> IP address")); initIPAddressBox( OPTION("socksproxy","address",[]{return "";}), uiSettings->socksProxyAddressLineEdit, tr("Socks proxy -> IP address"));
@ -224,10 +233,13 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
initStringBox( OPTION("socksproxy","outbound.quantity",[]{return "";}), uiSettings->socksProxyOutboundTunnQuantityLineEdit); initStringBox( OPTION("socksproxy","outbound.quantity",[]{return "";}), uiSettings->socksProxyOutboundTunnQuantityLineEdit);
initIPAddressBox( OPTION("socksproxy","outproxy",[]{return "";}), uiSettings->outproxyAddressLineEdit, tr("Socks proxy -> Outproxy address")); initIPAddressBox( OPTION("socksproxy","outproxy",[]{return "";}), uiSettings->outproxyAddressLineEdit, tr("Socks proxy -> Outproxy address"));
initTCPPortBox( OPTION("socksproxy","outproxyport",[]{return "";}), uiSettings->outproxyPortLineEdit, tr("Socks proxy -> Outproxy port")); initTCPPortBox( OPTION("socksproxy","outproxyport",[]{return "";}), uiSettings->outproxyPortLineEdit, tr("Socks proxy -> Outproxy port"));
//TODO add option "socksproxy.i2cp.leaseSetType Type of LeaseSet to be sent. 1, 3 or 5. 1 by default
//TODO add option "socksproxy.i2cp.leaseSetEncType Comma separated encryption types to be used in LeaseSet type 3 or 5
initCheckBox( OPTION("sam","enabled",[]{return "false";}), uiSettings->samEnabledCheckBox); initCheckBox( OPTION("sam","enabled",[]{return "false";}), uiSettings->samEnabledCheckBox);
initIPAddressBox( OPTION("sam","address",[]{return "";}), uiSettings->samAddressLineEdit, tr("SAM -> IP address")); initIPAddressBox( OPTION("sam","address",[]{return "";}), uiSettings->samAddressLineEdit, tr("SAM -> IP address"));
initTCPPortBox( OPTION("sam","port",[]{return "7656";}), uiSettings->samPortLineEdit, tr("SAM -> Port")); initTCPPortBox( OPTION("sam","port",[]{return "7656";}), uiSettings->samPortLineEdit, tr("SAM -> Port"));
//TODO add option "sam.singlethread If false every SAM session runs in own thread. true by default
initCheckBox( OPTION("bob","enabled",[]{return "false";}), uiSettings->bobEnabledCheckBox); initCheckBox( OPTION("bob","enabled",[]{return "false";}), uiSettings->bobEnabledCheckBox);
initIPAddressBox( OPTION("bob","address",[]{return "";}), uiSettings->bobAddressLineEdit, tr("BOB -> IP address")); initIPAddressBox( OPTION("bob","address",[]{return "";}), uiSettings->bobAddressLineEdit, tr("BOB -> IP address"));
@ -236,6 +248,7 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
initCheckBox( OPTION("i2cp","enabled",[]{return "false";}), uiSettings->i2cpEnabledCheckBox); initCheckBox( OPTION("i2cp","enabled",[]{return "false";}), uiSettings->i2cpEnabledCheckBox);
initIPAddressBox( OPTION("i2cp","address",[]{return "";}), uiSettings->i2cpAddressLineEdit, tr("I2CP -> IP address")); initIPAddressBox( OPTION("i2cp","address",[]{return "";}), uiSettings->i2cpAddressLineEdit, tr("I2CP -> IP address"));
initTCPPortBox( OPTION("i2cp","port",[]{return "7654";}), uiSettings->i2cpPortLineEdit, tr("I2CP -> Port")); initTCPPortBox( OPTION("i2cp","port",[]{return "7654";}), uiSettings->i2cpPortLineEdit, tr("I2CP -> Port"));
//TODO add option "i2cp.singlethread If false every I2CP session runs in own thread. true by default
initCheckBox( OPTION("i2pcontrol","enabled",[]{return "false";}), uiSettings->i2pControlEnabledCheckBox); initCheckBox( OPTION("i2pcontrol","enabled",[]{return "false";}), uiSettings->i2pControlEnabledCheckBox);
initIPAddressBox( OPTION("i2pcontrol","address",[]{return "";}), uiSettings->i2pControlAddressLineEdit, tr("I2PControl -> IP address")); initIPAddressBox( OPTION("i2pcontrol","address",[]{return "";}), uiSettings->i2pControlAddressLineEdit, tr("I2PControl -> IP address"));
@ -252,6 +265,9 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
initCheckBox( OPTION("reseed","verify",[]{return "";}), uiSettings->reseedVerifyCheckBox); initCheckBox( OPTION("reseed","verify",[]{return "";}), uiSettings->reseedVerifyCheckBox);
initFileChooser( OPTION("reseed","file",[]{return "";}), uiSettings->reseedFileLineEdit, uiSettings->reseedFileBrowsePushButton); initFileChooser( OPTION("reseed","file",[]{return "";}), uiSettings->reseedFileLineEdit, uiSettings->reseedFileBrowsePushButton);
initStringBox( OPTION("reseed","urls",[]{return "";}), uiSettings->reseedURLsLineEdit); initStringBox( OPTION("reseed","urls",[]{return "";}), uiSettings->reseedURLsLineEdit);
//TODO add option "reseed.zipfile Path to local .zip file to reseed from
//TODO add option "reseed.threshold Minimum number of known routers before requesting reseed. 25 by default
//TODO add option "reseed.proxy Url for https/socks reseed proxy
initStringBox( OPTION("addressbook","defaulturl",[]{return "";}), uiSettings->addressbookDefaultURLLineEdit); initStringBox( OPTION("addressbook","defaulturl",[]{return "";}), uiSettings->addressbookDefaultURLLineEdit);
initStringBox( OPTION("addressbook","subscriptions",[]{return "";}), uiSettings->addressbookSubscriptionsURLslineEdit); initStringBox( OPTION("addressbook","subscriptions",[]{return "";}), uiSettings->addressbookSubscriptionsURLslineEdit);
@ -259,12 +275,34 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
initUInt16Box( OPTION("limits","transittunnels",[]{return "2500";}), uiSettings->maxNumOfTransitTunnelsLineEdit, tr("maxNumberOfTransitTunnels")); initUInt16Box( OPTION("limits","transittunnels",[]{return "2500";}), uiSettings->maxNumOfTransitTunnelsLineEdit, tr("maxNumberOfTransitTunnels"));
initUInt16Box( OPTION("limits","openfiles",[]{return "0";}), uiSettings->maxNumOfOpenFilesLineEdit, tr("maxNumberOfOpenFiles")); initUInt16Box( OPTION("limits","openfiles",[]{return "0";}), uiSettings->maxNumOfOpenFilesLineEdit, tr("maxNumberOfOpenFiles"));
initUInt32Box( OPTION("limits","coresize",[]{return "0";}), uiSettings->coreFileMaxSizeNumberLineEdit, tr("coreFileMaxSize")); initUInt32Box( OPTION("limits","coresize",[]{return "0";}), uiSettings->coreFileMaxSizeNumberLineEdit, tr("coreFileMaxSize"));
//TODO add option "limits.ntcpsoft Threshold to start probabalistic backoff with ntcp sessions (0 - use system limit)
//TODO add option "limits.ntcphard Maximum number of ntcp sessions (0 - use system limit)
initCheckBox( OPTION("trust","enabled",[]{return "false";}), uiSettings->checkBoxTrustEnable); initCheckBox( OPTION("trust","enabled",[]{return "false";}), uiSettings->checkBoxTrustEnable);
initStringBox( OPTION("trust","family",[]{return "";}), uiSettings->lineEditTrustFamily); initStringBox( OPTION("trust","family",[]{return "";}), uiSettings->lineEditTrustFamily);
initStringBox( OPTION("trust","routers",[]{return "";}), uiSettings->lineEditTrustRouters); initStringBox( OPTION("trust","routers",[]{return "";}), uiSettings->lineEditTrustRouters);
initCheckBox( OPTION("trust","hidden",[]{return "false";}), uiSettings->checkBoxTrustHidden); initCheckBox( OPTION("trust","hidden",[]{return "false";}), uiSettings->checkBoxTrustHidden);
//TODO add option "websockets.enabled Enable websocket server. Disabled by default
//TODO add option "websockets.address Address to bind websocket server on. 127.0.0.1 by default
//TODO add option "websockets.port Port to bind websocket server on. 7666 by default
//TODO add option "exploratory.inbound.length Exploratory inbound tunnels length. 2 by default
//TODO add option "exploratory.inbound.quantity Exploratory inbound tunnels quantity. 3 by default
//TODO add option "exploratory.outbound.length Exploratory outbound tunnels length. 2 by default
//TODO add option "exploratory.outbound.quantity Exploratory outbound tunnels length. 3 by default
//TODO add option "ntcp2.enabled Enable NTCP2. Enabled by default
//TODO add option "ntcp2.published Enable incoming NTCP2 connections. Disabled by default
//TODO add option "ntcp2.port Port to listen for incoming NTCP2 connections (default: auto)
//TODO add option "ntcp2.addressv6 External IPv6 for incoming connections
//TODO add option "ntcp2.proxy Specify proxy server for NTCP2. Should be http://address:port or socks://address:port
//TODO add option "nettime.enabled Enable NTP sync. Disabled by default
//TODO add option "nettime.ntpservers Comma-separated list of NTP server. pool.ntp.org by default
//TODO add option "nettime.ntpsyncinterval NTP time sync interval in hours. 72 by default
//TODO add option "persist.profiles Enable peer profile persisting to disk. Enabled by default
# undef OPTION # undef OPTION
//widgetlocks.add(new widgetlock(widget,lockbtn)); //widgetlocks.add(new widgetlock(widget,lockbtn));
@ -666,7 +704,7 @@ void MainWindow::layoutTunnels() {
int height=0; int height=0;
ui->tunnelsScrollAreaWidgetContents->setGeometry(0,0,0,0); ui->tunnelsScrollAreaWidgetContents->setGeometry(0,0,0,0);
for(std::map<std::string, TunnelConfig*>::iterator it = tunnelConfigs.begin(); it != tunnelConfigs.end(); ++it) { for(std::map<std::string, TunnelConfig*>::iterator it = tunnelConfigs.begin(); it != tunnelConfigs.end(); ++it) {
const std::string& name=it->first; //const std::string& name=it->first;
TunnelConfig* tunconf = it->second; TunnelConfig* tunconf = it->second;
TunnelPane * tunnelPane=tunconf->getTunnelPane(); TunnelPane * tunnelPane=tunconf->getTunnelPane();
if(!tunnelPane)continue; if(!tunnelPane)continue;

31
qt/i2pd_qt/mainwindow.h

@ -104,10 +104,13 @@ class MainWindowItem : public QObject {
QWidget* widgetToFocus; QWidget* widgetToFocus;
QString requirementToBeValid; QString requirementToBeValid;
public: public:
MainWindowItem(ConfigOption option_, QWidget* widgetToFocus_, QString requirementToBeValid_) : option(option_), widgetToFocus(widgetToFocus_), requirementToBeValid(requirementToBeValid_) {} MainWindowItem(ConfigOption option_, QWidget* widgetToFocus_, QString requirementToBeValid_) :
option(option_), widgetToFocus(widgetToFocus_), requirementToBeValid(requirementToBeValid_),
optionValuePresent(false) {}
QWidget* getWidgetToFocus(){return widgetToFocus;} QWidget* getWidgetToFocus(){return widgetToFocus;}
QString& getRequirementToBeValid() { return requirementToBeValid; } QString& getRequirementToBeValid() { return requirementToBeValid; }
ConfigOption& getConfigOption() { return option; } ConfigOption& getConfigOption() { return option; }
bool optionValuePresent;
boost::any optionValue; boost::any optionValue;
virtual ~MainWindowItem(){} virtual ~MainWindowItem(){}
virtual void installListeners(MainWindow *mainWindow); virtual void installListeners(MainWindow *mainWindow);
@ -118,7 +121,8 @@ public:
//qDebug() << "loadFromConfigOption[" << optName.c_str() << "]"; //qDebug() << "loadFromConfigOption[" << optName.c_str() << "]";
boost::any programOption; boost::any programOption;
i2p::config::GetOptionAsAny(optName, programOption); i2p::config::GetOptionAsAny(optName, programOption);
optionValue=programOption.empty()?boost::any(std::string("")) optionValuePresent=!programOption.empty();
optionValue=!optionValuePresent?boost::any(std::string(""))
:boost::any_cast<boost::program_options::variable_value>(programOption).value(); :boost::any_cast<boost::program_options::variable_value>(programOption).value();
} }
virtual void saveToStringStream(std::stringstream& out){ virtual void saveToStringStream(std::stringstream& out){
@ -126,7 +130,7 @@ public:
std::string v = boost::any_cast<std::string>(optionValue); std::string v = boost::any_cast<std::string>(optionValue);
if(v.empty())return; if(v.empty())return;
} }
if(optionValue.empty())return; if(!optionValuePresent || optionValue.empty())return;
std::string rtti = optionValue.type().name(); std::string rtti = optionValue.type().name();
std::string optName=""; std::string optName="";
if(!option.section.isEmpty())optName=option.section.toStdString()+std::string("."); if(!option.section.isEmpty())optName=option.section.toStdString()+std::string(".");
@ -180,6 +184,7 @@ public:
virtual void saveToStringStream(std::stringstream& out){ virtual void saveToStringStream(std::stringstream& out){
optionValue=fromString(lineEdit->text()); optionValue=fromString(lineEdit->text());
optionValuePresent=true;
MainWindowItem::saveToStringStream(out); MainWindowItem::saveToStringStream(out);
} }
virtual bool isValid() { return true; } virtual bool isValid() { return true; }
@ -234,6 +239,7 @@ public:
virtual void saveToStringStream(std::stringstream& out){ virtual void saveToStringStream(std::stringstream& out){
std::string logDest = comboBox->currentText().toStdString(); std::string logDest = comboBox->currentText().toStdString();
optionValue=logDest; optionValue=logDest;
optionValuePresent=true;
MainWindowItem::saveToStringStream(out); MainWindowItem::saveToStringStream(out);
} }
virtual bool isValid() { return true; } virtual bool isValid() { return true; }
@ -251,6 +257,7 @@ public:
} }
virtual void saveToStringStream(std::stringstream& out){ virtual void saveToStringStream(std::stringstream& out){
optionValue=comboBox->currentText().toStdString(); optionValue=comboBox->currentText().toStdString();
optionValuePresent=true;
MainWindowItem::saveToStringStream(out); MainWindowItem::saveToStringStream(out);
} }
virtual bool isValid() { return true; } virtual bool isValid() { return true; }
@ -268,6 +275,7 @@ public:
virtual void saveToStringStream(std::stringstream& out){ virtual void saveToStringStream(std::stringstream& out){
uint16_t selected = SignatureTypeComboBoxFactory::getSigType(comboBox->currentData()); uint16_t selected = SignatureTypeComboBoxFactory::getSigType(comboBox->currentData());
optionValue=(unsigned short)selected; optionValue=(unsigned short)selected;
optionValuePresent=true;
MainWindowItem::saveToStringStream(out); MainWindowItem::saveToStringStream(out);
} }
virtual bool isValid() { return true; } virtual bool isValid() { return true; }
@ -284,6 +292,7 @@ public:
} }
virtual void saveToStringStream(std::stringstream& out){ virtual void saveToStringStream(std::stringstream& out){
optionValue=checkBox->isChecked(); optionValue=checkBox->isChecked();
optionValuePresent=true;
MainWindowItem::saveToStringStream(out); MainWindowItem::saveToStringStream(out);
} }
virtual bool isValid() { return true; } virtual bool isValid() { return true; }
@ -613,6 +622,7 @@ private:
std::string keys = ""; std::string keys = "";
std::string address = "127.0.0.1"; std::string address = "127.0.0.1";
int destinationPort = 0; int destinationPort = 0;
int cryptoType = 0;
i2p::data::SigningKeyType sigType = i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256; i2p::data::SigningKeyType sigType = i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256;
// I2CP // I2CP
I2CPParameters i2cpParameters; I2CPParameters i2cpParameters;
@ -624,7 +634,8 @@ private:
keys, keys,
address, address,
destinationPort, destinationPort,
sigType); sigType,
cryptoType);
saveAllConfigs(true, name); saveAllConfigs(true, name);
} }
@ -643,6 +654,7 @@ private:
i2p::data::SigningKeyType sigType = i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256; i2p::data::SigningKeyType sigType = i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256;
std::string address = "127.0.0.1"; std::string address = "127.0.0.1";
bool isUniqueLocal = true; bool isUniqueLocal = true;
int cryptoType = 0;
// I2CP // I2CP
I2CPParameters i2cpParameters; I2CPParameters i2cpParameters;
@ -659,7 +671,8 @@ private:
gzip, gzip,
sigType, sigType,
address, address,
isUniqueLocal); isUniqueLocal,
cryptoType);
saveAllConfigs(true, name); saveAllConfigs(true, name);
@ -712,6 +725,7 @@ private:
// optional params // optional params
std::string keys = section.second.get (I2P_CLIENT_TUNNEL_KEYS, ""); std::string keys = section.second.get (I2P_CLIENT_TUNNEL_KEYS, "");
std::string address = section.second.get (I2P_CLIENT_TUNNEL_ADDRESS, "127.0.0.1"); std::string address = section.second.get (I2P_CLIENT_TUNNEL_ADDRESS, "127.0.0.1");
int cryptoType = section.second.get<int>(I2P_CLIENT_TUNNEL_CRYPTO_TYPE, 0);
int destinationPort = section.second.get<int>(I2P_CLIENT_TUNNEL_DESTINATION_PORT, 0); int destinationPort = section.second.get<int>(I2P_CLIENT_TUNNEL_DESTINATION_PORT, 0);
std::cout << "had read tunnel destinationPort: " << destinationPort << std::endl; std::cout << "had read tunnel destinationPort: " << destinationPort << std::endl;
i2p::data::SigningKeyType sigType = section.second.get (I2P_CLIENT_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256); i2p::data::SigningKeyType sigType = section.second.get (I2P_CLIENT_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256);
@ -726,7 +740,8 @@ private:
keys, keys,
address, address,
destinationPort, destinationPort,
sigType); sigType,
cryptoType);
} }
else if (type == I2P_TUNNELS_SECTION_TYPE_SERVER else if (type == I2P_TUNNELS_SECTION_TYPE_SERVER
|| type == I2P_TUNNELS_SECTION_TYPE_HTTP || type == I2P_TUNNELS_SECTION_TYPE_HTTP
@ -746,6 +761,7 @@ private:
i2p::data::SigningKeyType sigType = section.second.get (I2P_SERVER_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256); i2p::data::SigningKeyType sigType = section.second.get (I2P_SERVER_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256);
std::string address = section.second.get<std::string> (I2P_SERVER_TUNNEL_ADDRESS, "127.0.0.1"); 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); bool isUniqueLocal = section.second.get(I2P_SERVER_TUNNEL_ENABLE_UNIQUE_LOCAL, true);
int cryptoType = section.second.get<int>(I2P_CLIENT_TUNNEL_CRYPTO_TYPE, 0);
// I2CP // I2CP
std::map<std::string, std::string> options; std::map<std::string, std::string> options;
@ -779,7 +795,8 @@ private:
gzip, gzip,
sigType, sigType,
address, address,
isUniqueLocal); isUniqueLocal,
cryptoType);
} }
else else
LogPrint (eLogWarning, "Clients: Unknown section type=", type, " of ", name, " in ", tunConf);//TODO show err box and disable the tunn gui LogPrint (eLogWarning, "Clients: Unknown section type=", type, " of ", name, " in ", tunConf);//TODO show err box and disable the tunn gui

Loading…
Cancel
Save