- Crash fix if service not connected
- import fix - disabled share button for readonly server
This commit is contained in:
parent
7fd13faa59
commit
0ea085cc02
6 changed files with 65 additions and 25 deletions
|
@ -217,7 +217,7 @@ QString OpenVpnConfigurator::genOpenVpnConfig(const ServerCredentials &credentia
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//qDebug().noquote() << config;
|
//qDebug().noquote() << config;
|
||||||
return processConfigWithLocalSettings(config);
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString OpenVpnConfigurator::processConfigWithLocalSettings(QString config)
|
QString OpenVpnConfigurator::processConfigWithLocalSettings(QString config)
|
||||||
|
@ -249,6 +249,22 @@ QString OpenVpnConfigurator::processConfigWithLocalSettings(QString config)
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString OpenVpnConfigurator::processConfigWithExportSettings(QString config)
|
||||||
|
{
|
||||||
|
config.replace("$PRIMARY_DNS", m_settings().primaryDns());
|
||||||
|
config.replace("$SECONDARY_DNS", m_settings().secondaryDns());
|
||||||
|
|
||||||
|
if(!config.contains("redirect-gateway def1 bypass-dhcp")) {
|
||||||
|
config.append("redirect-gateway def1 bypass-dhcp\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
config.replace("block-outside-dns", "");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
QString OpenVpnConfigurator::convertOpenSShKey(const QString &key)
|
QString OpenVpnConfigurator::convertOpenSShKey(const QString &key)
|
||||||
{
|
{
|
||||||
QProcess p;
|
QProcess p;
|
||||||
|
|
|
@ -26,6 +26,7 @@ public:
|
||||||
const QJsonObject &containerConfig, ErrorCode *errorCode = nullptr);
|
const QJsonObject &containerConfig, ErrorCode *errorCode = nullptr);
|
||||||
|
|
||||||
static QString processConfigWithLocalSettings(QString config);
|
static QString processConfigWithLocalSettings(QString config);
|
||||||
|
static QString processConfigWithExportSettings(QString config);
|
||||||
|
|
||||||
static QString convertOpenSShKey(const QString &key);
|
static QString convertOpenSShKey(const QString &key);
|
||||||
|
|
||||||
|
|
|
@ -195,6 +195,9 @@ void MainWindow::goToPage(Page page, bool reset, bool slide)
|
||||||
if (page == Page::ServerConfiguring) {
|
if (page == Page::ServerConfiguring) {
|
||||||
ui->progressBar_new_server_configuring->setValue(0);
|
ui->progressBar_new_server_configuring->setValue(0);
|
||||||
}
|
}
|
||||||
|
if (page == Page::GeneralSettings) {
|
||||||
|
updateGeneralSettingPage();
|
||||||
|
}
|
||||||
if (page == Page::ServersList) {
|
if (page == Page::ServersList) {
|
||||||
updateServersListPage();
|
updateServersListPage();
|
||||||
}
|
}
|
||||||
|
@ -639,8 +642,14 @@ void MainWindow::onPushButtonNewServerImport(bool)
|
||||||
else {
|
else {
|
||||||
qDebug() << "Failed to import profile";
|
qDebug() << "Failed to import profile";
|
||||||
qDebug().noquote() << QJsonDocument(o).toJson();
|
qDebug().noquote() << QJsonDocument(o).toJson();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!o.contains(config_key::containers)) {
|
||||||
|
selectedServerIndex = m_settings.defaultServerIndex();
|
||||||
|
selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex);
|
||||||
|
goToPage(Page::ServerVpnProtocols);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::installContainers(ServerCredentials credentials,
|
bool MainWindow::installContainers(ServerCredentials credentials,
|
||||||
|
@ -809,7 +818,7 @@ void MainWindow::onPushButtonClearServer(bool)
|
||||||
|
|
||||||
void MainWindow::onPushButtonForgetServer(bool)
|
void MainWindow::onPushButtonForgetServer(bool)
|
||||||
{
|
{
|
||||||
if (m_settings.defaultServerIndex() == selectedServerIndex) {
|
if (m_settings.defaultServerIndex() == selectedServerIndex && m_vpnConnection->isConnected()) {
|
||||||
onDisconnect();
|
onDisconnect();
|
||||||
}
|
}
|
||||||
m_settings.removeServer(selectedServerIndex);
|
m_settings.removeServer(selectedServerIndex);
|
||||||
|
@ -974,15 +983,13 @@ void MainWindow::setupUiConnections()
|
||||||
if (currentPage() == Page::Start || currentPage() == Page::NewServer) qApp->quit();
|
if (currentPage() == Page::Start || currentPage() == Page::NewServer) qApp->quit();
|
||||||
else hide();
|
else hide();
|
||||||
});
|
});
|
||||||
connect(ui->pushButton_general_settings_exit, &QPushButton::clicked, this, [&](){ qApp->quit(); });
|
|
||||||
|
|
||||||
|
|
||||||
connect(ui->pushButton_vpn_add_site, &QPushButton::clicked, this, [this](){ goToPage(Page::Sites); });
|
connect(ui->pushButton_vpn_add_site, &QPushButton::clicked, this, [this](){ goToPage(Page::Sites); });
|
||||||
|
|
||||||
|
|
||||||
QVector<QPushButton *> backButtons {
|
QVector<QPushButton *> backButtons {
|
||||||
ui->pushButton_back_from_sites,
|
ui->pushButton_back_from_sites,
|
||||||
ui->pushButton_back_from_settings,
|
ui->pushButton_back_from_general_settings,
|
||||||
ui->pushButton_back_from_start,
|
ui->pushButton_back_from_start,
|
||||||
ui->pushButton_back_from_new_server,
|
ui->pushButton_back_from_new_server,
|
||||||
ui->pushButton_back_from_new_server_protocols,
|
ui->pushButton_back_from_new_server_protocols,
|
||||||
|
@ -1114,15 +1121,17 @@ void MainWindow::setupAppSettingsConnections()
|
||||||
|
|
||||||
void MainWindow::setupGeneralSettingsConnections()
|
void MainWindow::setupGeneralSettingsConnections()
|
||||||
{
|
{
|
||||||
|
connect(ui->pushButton_general_settings_exit, &QPushButton::clicked, this, [&](){ qApp->quit(); });
|
||||||
|
|
||||||
connect(ui->pushButton_settings, &QPushButton::clicked, this, [this](){ goToPage(Page::GeneralSettings); });
|
connect(ui->pushButton_settings, &QPushButton::clicked, this, [this](){ goToPage(Page::GeneralSettings); });
|
||||||
connect(ui->pushButton_app_settings, &QPushButton::clicked, this, [this](){ goToPage(Page::AppSettings); });
|
connect(ui->pushButton_general_settings_app_settings, &QPushButton::clicked, this, [this](){ goToPage(Page::AppSettings); });
|
||||||
connect(ui->pushButton_network_settings, &QPushButton::clicked, this, [this](){ goToPage(Page::NetworkSettings); });
|
connect(ui->pushButton_general_settings_network_settings, &QPushButton::clicked, this, [this](){ goToPage(Page::NetworkSettings); });
|
||||||
connect(ui->pushButton_server_settings, &QPushButton::clicked, this, [this](){
|
connect(ui->pushButton_general_settings_server_settings, &QPushButton::clicked, this, [this](){
|
||||||
selectedServerIndex = m_settings.defaultServerIndex();
|
selectedServerIndex = m_settings.defaultServerIndex();
|
||||||
goToPage(Page::ServerSettings);
|
goToPage(Page::ServerSettings);
|
||||||
});
|
});
|
||||||
connect(ui->pushButton_servers_list, &QPushButton::clicked, this, [this](){ goToPage(Page::ServersList); });
|
connect(ui->pushButton_general_settings_servers_list, &QPushButton::clicked, this, [this](){ goToPage(Page::ServersList); });
|
||||||
connect(ui->pushButton_share_connection, &QPushButton::clicked, this, [this](){
|
connect(ui->pushButton_general_settings_share_connection, &QPushButton::clicked, this, [this](){
|
||||||
selectedServerIndex = m_settings.defaultServerIndex();
|
selectedServerIndex = m_settings.defaultServerIndex();
|
||||||
selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex);
|
selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex);
|
||||||
|
|
||||||
|
@ -1528,6 +1537,7 @@ void MainWindow::setupSharePageConnections()
|
||||||
|
|
||||||
ErrorCode e = ErrorCode::NoError;
|
ErrorCode e = ErrorCode::NoError;
|
||||||
QString cfg = OpenVpnConfigurator::genOpenVpnConfig(credentials, selectedDockerContainer, containerConfig, &e);
|
QString cfg = OpenVpnConfigurator::genOpenVpnConfig(credentials, selectedDockerContainer, containerConfig, &e);
|
||||||
|
cfg = OpenVpnConfigurator::processConfigWithExportSettings(cfg);
|
||||||
|
|
||||||
ui->textEdit_share_openvpn_code->setPlainText(cfg);
|
ui->textEdit_share_openvpn_code->setPlainText(cfg);
|
||||||
|
|
||||||
|
@ -1683,7 +1693,7 @@ void MainWindow::onPushButtonAddCustomSitesClicked()
|
||||||
m_settings.setCustomIps(customIps);
|
m_settings.setCustomIps(customIps);
|
||||||
|
|
||||||
if (m_vpnConnection->connectionState() == VpnProtocol::ConnectionState::Connected) {
|
if (m_vpnConnection->connectionState() == VpnProtocol::ConnectionState::Connected) {
|
||||||
IpcClient::Interface()->routeAddList(m_vpnConnection->vpnProtocol()->vpnGateway(),
|
if (IpcClient::Interface()) IpcClient::Interface()->routeAddList(m_vpnConnection->vpnProtocol()->vpnGateway(),
|
||||||
QStringList() << newIp);
|
QStringList() << newIp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1717,8 +1727,8 @@ void MainWindow::onPushButtonDeleteCustomSiteClicked(const QString &siteToDelete
|
||||||
updateSitesPage();
|
updateSitesPage();
|
||||||
|
|
||||||
if (m_vpnConnection->connectionState() == VpnProtocol::ConnectionState::Connected) {
|
if (m_vpnConnection->connectionState() == VpnProtocol::ConnectionState::Connected) {
|
||||||
IpcClient::Interface()->routeDelete(ipToDelete, "");
|
if (IpcClient::Interface()) IpcClient::Interface()->routeDelete(ipToDelete, "");
|
||||||
IpcClient::Interface()->flushDns();
|
if (IpcClient::Interface()) IpcClient::Interface()->flushDns();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1766,6 +1776,11 @@ void MainWindow::updateAppSettingsPage()
|
||||||
ui->lineEdit_network_settings_dns2->setText(m_settings.secondaryDns());
|
ui->lineEdit_network_settings_dns2->setText(m_settings.secondaryDns());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateGeneralSettingPage()
|
||||||
|
{
|
||||||
|
ui->pushButton_general_settings_share_connection->setEnabled(m_settings.haveAuthData(m_settings.defaultServerIndex()));
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::updateServerPage()
|
void MainWindow::updateServerPage()
|
||||||
{
|
{
|
||||||
ui->label_server_settings_wait_info->hide();
|
ui->label_server_settings_wait_info->hide();
|
||||||
|
|
|
@ -106,6 +106,7 @@ private:
|
||||||
void updateSitesPage();
|
void updateSitesPage();
|
||||||
void updateVpnPage();
|
void updateVpnPage();
|
||||||
void updateAppSettingsPage();
|
void updateAppSettingsPage();
|
||||||
|
void updateGeneralSettingPage();
|
||||||
void updateServerPage();
|
void updateServerPage();
|
||||||
void updateServersListPage();
|
void updateServersListPage();
|
||||||
void updateProtocolsPage();
|
void updateProtocolsPage();
|
||||||
|
|
|
@ -291,7 +291,7 @@ QPushButton:hover {
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>11</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="page_start">
|
<widget class="QWidget" name="page_start">
|
||||||
<widget class="QLabel" name="label_25">
|
<widget class="QLabel" name="label_25">
|
||||||
|
@ -3310,9 +3310,13 @@ color: #100A44;
|
||||||
|
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: left center;
|
background-position: left center;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton:!enabled {
|
||||||
|
color: #AAAAAA;
|
||||||
}</string>
|
}</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QPushButton" name="pushButton_back_from_settings">
|
<widget class="QPushButton" name="pushButton_back_from_general_settings">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
|
@ -3360,7 +3364,7 @@ QPushButton:hover {
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="pushButton_server_settings">
|
<widget class="QPushButton" name="pushButton_general_settings_server_settings">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>30</x>
|
<x>30</x>
|
||||||
|
@ -3398,7 +3402,7 @@ QPushButton:hover {
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="pushButton_share_connection">
|
<widget class="QPushButton" name="pushButton_general_settings_share_connection">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -3490,7 +3494,7 @@ QPushButton:hover {
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="pushButton_app_settings">
|
<widget class="QPushButton" name="pushButton_general_settings_app_settings">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>30</x>
|
<x>30</x>
|
||||||
|
@ -3545,7 +3549,7 @@ QPushButton:hover {
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="pushButton_network_settings">
|
<widget class="QPushButton" name="pushButton_general_settings_network_settings">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>30</x>
|
<x>30</x>
|
||||||
|
@ -3568,7 +3572,7 @@ QPushButton:hover {
|
||||||
<string>Network settings</string>
|
<string>Network settings</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="pushButton_servers_list">
|
<widget class="QPushButton" name="pushButton_general_settings_servers_list">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>30</x>
|
<x>30</x>
|
||||||
|
@ -5397,8 +5401,8 @@ QToolBox::tab:hover {
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>100</width>
|
<width>360</width>
|
||||||
<height>30</height>
|
<height>360</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
|
|
|
@ -116,6 +116,7 @@ QString VpnConnection::createVpnConfigurationForProto(int serverIndex,
|
||||||
if (proto == Protocol::OpenVpn) {
|
if (proto == Protocol::OpenVpn) {
|
||||||
configData = OpenVpnConfigurator::genOpenVpnConfig(credentials,
|
configData = OpenVpnConfigurator::genOpenVpnConfig(credentials,
|
||||||
container, containerConfig, &e);
|
container, containerConfig, &e);
|
||||||
|
configData = OpenVpnConfigurator::processConfigWithLocalSettings(configData);
|
||||||
}
|
}
|
||||||
else if (proto == Protocol::Cloak) {
|
else if (proto == Protocol::Cloak) {
|
||||||
configData = CloakConfigurator::genCloakConfig(credentials,
|
configData = CloakConfigurator::genCloakConfig(credentials,
|
||||||
|
@ -272,11 +273,13 @@ void VpnConnection::disconnectFromVpn()
|
||||||
{
|
{
|
||||||
qDebug() << "Disconnect from VPN";
|
qDebug() << "Disconnect from VPN";
|
||||||
|
|
||||||
|
if (IpcClient::Interface()) {
|
||||||
IpcClient::Interface()->flushDns();
|
IpcClient::Interface()->flushDns();
|
||||||
|
|
||||||
if (m_settings.customRouting()) {
|
if (m_settings.customRouting()) {
|
||||||
IpcClient::Interface()->clearSavedRoutes();
|
IpcClient::Interface()->clearSavedRoutes();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_vpnProtocol.data()) {
|
if (!m_vpnProtocol.data()) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue