- 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
|
||||
|
||||
//qDebug().noquote() << config;
|
||||
return processConfigWithLocalSettings(config);
|
||||
return config;
|
||||
}
|
||||
|
||||
QString OpenVpnConfigurator::processConfigWithLocalSettings(QString config)
|
||||
|
@ -249,6 +249,22 @@ QString OpenVpnConfigurator::processConfigWithLocalSettings(QString 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)
|
||||
{
|
||||
QProcess p;
|
||||
|
|
|
@ -26,6 +26,7 @@ public:
|
|||
const QJsonObject &containerConfig, ErrorCode *errorCode = nullptr);
|
||||
|
||||
static QString processConfigWithLocalSettings(QString config);
|
||||
static QString processConfigWithExportSettings(QString config);
|
||||
|
||||
static QString convertOpenSShKey(const QString &key);
|
||||
|
||||
|
|
|
@ -195,6 +195,9 @@ void MainWindow::goToPage(Page page, bool reset, bool slide)
|
|||
if (page == Page::ServerConfiguring) {
|
||||
ui->progressBar_new_server_configuring->setValue(0);
|
||||
}
|
||||
if (page == Page::GeneralSettings) {
|
||||
updateGeneralSettingPage();
|
||||
}
|
||||
if (page == Page::ServersList) {
|
||||
updateServersListPage();
|
||||
}
|
||||
|
@ -639,8 +642,14 @@ void MainWindow::onPushButtonNewServerImport(bool)
|
|||
else {
|
||||
qDebug() << "Failed to import profile";
|
||||
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,
|
||||
|
@ -809,7 +818,7 @@ void MainWindow::onPushButtonClearServer(bool)
|
|||
|
||||
void MainWindow::onPushButtonForgetServer(bool)
|
||||
{
|
||||
if (m_settings.defaultServerIndex() == selectedServerIndex) {
|
||||
if (m_settings.defaultServerIndex() == selectedServerIndex && m_vpnConnection->isConnected()) {
|
||||
onDisconnect();
|
||||
}
|
||||
m_settings.removeServer(selectedServerIndex);
|
||||
|
@ -974,15 +983,13 @@ void MainWindow::setupUiConnections()
|
|||
if (currentPage() == Page::Start || currentPage() == Page::NewServer) qApp->quit();
|
||||
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); });
|
||||
|
||||
|
||||
QVector<QPushButton *> backButtons {
|
||||
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_new_server,
|
||||
ui->pushButton_back_from_new_server_protocols,
|
||||
|
@ -1114,15 +1121,17 @@ void MainWindow::setupAppSettingsConnections()
|
|||
|
||||
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_app_settings, &QPushButton::clicked, this, [this](){ goToPage(Page::AppSettings); });
|
||||
connect(ui->pushButton_network_settings, &QPushButton::clicked, this, [this](){ goToPage(Page::NetworkSettings); });
|
||||
connect(ui->pushButton_server_settings, &QPushButton::clicked, this, [this](){
|
||||
connect(ui->pushButton_general_settings_app_settings, &QPushButton::clicked, this, [this](){ goToPage(Page::AppSettings); });
|
||||
connect(ui->pushButton_general_settings_network_settings, &QPushButton::clicked, this, [this](){ goToPage(Page::NetworkSettings); });
|
||||
connect(ui->pushButton_general_settings_server_settings, &QPushButton::clicked, this, [this](){
|
||||
selectedServerIndex = m_settings.defaultServerIndex();
|
||||
goToPage(Page::ServerSettings);
|
||||
});
|
||||
connect(ui->pushButton_servers_list, &QPushButton::clicked, this, [this](){ goToPage(Page::ServersList); });
|
||||
connect(ui->pushButton_share_connection, &QPushButton::clicked, this, [this](){
|
||||
connect(ui->pushButton_general_settings_servers_list, &QPushButton::clicked, this, [this](){ goToPage(Page::ServersList); });
|
||||
connect(ui->pushButton_general_settings_share_connection, &QPushButton::clicked, this, [this](){
|
||||
selectedServerIndex = m_settings.defaultServerIndex();
|
||||
selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex);
|
||||
|
||||
|
@ -1528,6 +1537,7 @@ void MainWindow::setupSharePageConnections()
|
|||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
QString cfg = OpenVpnConfigurator::genOpenVpnConfig(credentials, selectedDockerContainer, containerConfig, &e);
|
||||
cfg = OpenVpnConfigurator::processConfigWithExportSettings(cfg);
|
||||
|
||||
ui->textEdit_share_openvpn_code->setPlainText(cfg);
|
||||
|
||||
|
@ -1683,7 +1693,7 @@ void MainWindow::onPushButtonAddCustomSitesClicked()
|
|||
m_settings.setCustomIps(customIps);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1717,8 +1727,8 @@ void MainWindow::onPushButtonDeleteCustomSiteClicked(const QString &siteToDelete
|
|||
updateSitesPage();
|
||||
|
||||
if (m_vpnConnection->connectionState() == VpnProtocol::ConnectionState::Connected) {
|
||||
IpcClient::Interface()->routeDelete(ipToDelete, "");
|
||||
IpcClient::Interface()->flushDns();
|
||||
if (IpcClient::Interface()) IpcClient::Interface()->routeDelete(ipToDelete, "");
|
||||
if (IpcClient::Interface()) IpcClient::Interface()->flushDns();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1766,6 +1776,11 @@ void MainWindow::updateAppSettingsPage()
|
|||
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()
|
||||
{
|
||||
ui->label_server_settings_wait_info->hide();
|
||||
|
|
|
@ -106,6 +106,7 @@ private:
|
|||
void updateSitesPage();
|
||||
void updateVpnPage();
|
||||
void updateAppSettingsPage();
|
||||
void updateGeneralSettingPage();
|
||||
void updateServerPage();
|
||||
void updateServersListPage();
|
||||
void updateProtocolsPage();
|
||||
|
|
|
@ -291,7 +291,7 @@ QPushButton:hover {
|
|||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>11</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_start">
|
||||
<widget class="QLabel" name="label_25">
|
||||
|
@ -3310,9 +3310,13 @@ color: #100A44;
|
|||
|
||||
background-repeat: no-repeat;
|
||||
background-position: left center;
|
||||
}
|
||||
|
||||
QPushButton:!enabled {
|
||||
color: #AAAAAA;
|
||||
}</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="pushButton_back_from_settings">
|
||||
<widget class="QPushButton" name="pushButton_back_from_general_settings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
|
@ -3360,7 +3364,7 @@ QPushButton:hover {
|
|||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_server_settings">
|
||||
<widget class="QPushButton" name="pushButton_general_settings_server_settings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
|
@ -3398,7 +3402,7 @@ QPushButton:hover {
|
|||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_share_connection">
|
||||
<widget class="QPushButton" name="pushButton_general_settings_share_connection">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
@ -3490,7 +3494,7 @@ QPushButton:hover {
|
|||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_app_settings">
|
||||
<widget class="QPushButton" name="pushButton_general_settings_app_settings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
|
@ -3545,7 +3549,7 @@ QPushButton:hover {
|
|||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_network_settings">
|
||||
<widget class="QPushButton" name="pushButton_general_settings_network_settings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
|
@ -3568,7 +3572,7 @@ QPushButton:hover {
|
|||
<string>Network settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_servers_list">
|
||||
<widget class="QPushButton" name="pushButton_general_settings_servers_list">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
|
@ -5397,8 +5401,8 @@ QToolBox::tab:hover {
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<height>30</height>
|
||||
<width>360</width>
|
||||
<height>360</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
|
|
|
@ -116,6 +116,7 @@ QString VpnConnection::createVpnConfigurationForProto(int serverIndex,
|
|||
if (proto == Protocol::OpenVpn) {
|
||||
configData = OpenVpnConfigurator::genOpenVpnConfig(credentials,
|
||||
container, containerConfig, &e);
|
||||
configData = OpenVpnConfigurator::processConfigWithLocalSettings(configData);
|
||||
}
|
||||
else if (proto == Protocol::Cloak) {
|
||||
configData = CloakConfigurator::genCloakConfig(credentials,
|
||||
|
@ -272,10 +273,12 @@ void VpnConnection::disconnectFromVpn()
|
|||
{
|
||||
qDebug() << "Disconnect from VPN";
|
||||
|
||||
IpcClient::Interface()->flushDns();
|
||||
if (IpcClient::Interface()) {
|
||||
IpcClient::Interface()->flushDns();
|
||||
|
||||
if (m_settings.customRouting()) {
|
||||
IpcClient::Interface()->clearSavedRoutes();
|
||||
if (m_settings.customRouting()) {
|
||||
IpcClient::Interface()->clearSavedRoutes();
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_vpnProtocol.data()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue