added import of configs in .ovpn format
- on the "OpenVPN Settings" page, such a config will be displayed as raw text
This commit is contained in:
parent
b62d0697be
commit
53d7a92a0d
15 changed files with 430 additions and 322 deletions
|
@ -23,7 +23,7 @@ CloakLogic::CloakLogic(UiLogic *logic, QObject *parent):
|
|||
|
||||
}
|
||||
|
||||
void CloakLogic::updateProtocolPage(const QJsonObject &ckConfig, DockerContainer container, bool haveAuthData)
|
||||
void CloakLogic::updateProtocolPage(const QJsonObject &ckConfig, DockerContainer container, bool haveAuthData, bool isThirdPartyConfig)
|
||||
{
|
||||
set_pageEnabled(haveAuthData);
|
||||
set_pushButtonSaveVisible(haveAuthData);
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
explicit CloakLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~CloakLogic() = default;
|
||||
|
||||
void updateProtocolPage (const QJsonObject &ckConfig, DockerContainer container, bool haveAuthData) override;
|
||||
void updateProtocolPage(const QJsonObject &ckConfig, DockerContainer container, bool haveAuthData, bool isThirdPartyConfig) override;
|
||||
QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -35,7 +35,7 @@ OpenVpnLogic::OpenVpnLogic(UiLogic *logic, QObject *parent):
|
|||
|
||||
}
|
||||
|
||||
void OpenVpnLogic::updateProtocolPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData)
|
||||
void OpenVpnLogic::updateProtocolPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData, bool isThirdPartyConfig)
|
||||
{
|
||||
qDebug() << "OpenVpnLogic::updateProtocolPage";
|
||||
set_pageEnabled(haveAuthData);
|
||||
|
@ -87,6 +87,16 @@ void OpenVpnLogic::updateProtocolPage(const QJsonObject &openvpnConfig, DockerCo
|
|||
toString(protocols::openvpn::defaultPort));
|
||||
|
||||
set_lineEditPortEnabled(container == DockerContainer::OpenVpn);
|
||||
|
||||
auto lastConfig = openvpnConfig.value(config_key::last_config).toString();
|
||||
auto lastConfigJson = QJsonDocument::fromJson(lastConfig.toUtf8()).object();
|
||||
QStringList lines = lastConfigJson.value(config_key::config).toString().replace("\r", "").split("\n");
|
||||
for (const QString &l: lines) {
|
||||
m_openVpnLastConfigText.append(l + "\n");
|
||||
}
|
||||
|
||||
emit openVpnLastConfigTextChanged(m_openVpnLastConfigText);
|
||||
set_isThirdPartyConfig(isThirdPartyConfig);
|
||||
}
|
||||
|
||||
void OpenVpnLogic::onPushButtonProtoOpenVpnSaveClicked()
|
||||
|
|
|
@ -35,6 +35,9 @@ class OpenVpnLogic : public PageProtocolLogicBase
|
|||
AUTO_PROPERTY(int, progressBarResetValue)
|
||||
AUTO_PROPERTY(int, progressBarResetMaximium)
|
||||
|
||||
AUTO_PROPERTY(QString, openVpnLastConfigText)
|
||||
AUTO_PROPERTY(bool, isThirdPartyConfig)
|
||||
|
||||
public:
|
||||
Q_INVOKABLE void onPushButtonProtoOpenVpnSaveClicked();
|
||||
|
||||
|
@ -42,7 +45,7 @@ public:
|
|||
explicit OpenVpnLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~OpenVpnLogic() = default;
|
||||
|
||||
void updateProtocolPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData) override;
|
||||
void updateProtocolPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData, bool isThirdPartyConfig) override;
|
||||
QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -36,7 +36,7 @@ OtherProtocolsLogic::~OtherProtocolsLogic()
|
|||
#endif
|
||||
}
|
||||
|
||||
void OtherProtocolsLogic::updateProtocolPage(const QJsonObject &config, DockerContainer container, bool haveAuthData)
|
||||
void OtherProtocolsLogic::updateProtocolPage(const QJsonObject &config, DockerContainer container, bool haveAuthData, bool isThirdPartyConfig)
|
||||
{
|
||||
set_labelTftpUserNameText(config.value(config_key::userName).toString());
|
||||
set_labelTftpPasswordText(config.value(config_key::password).toString(protocols::sftp::defaultUserName));
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
explicit OtherProtocolsLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~OtherProtocolsLogic();
|
||||
|
||||
void updateProtocolPage(const QJsonObject &config, DockerContainer container, bool haveAuthData) override;
|
||||
void updateProtocolPage(const QJsonObject &config, DockerContainer container, bool haveAuthData, bool isThirdPartyConfig) override;
|
||||
//QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
explicit PageProtocolLogicBase(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~PageProtocolLogicBase() = default;
|
||||
|
||||
virtual void updateProtocolPage(const QJsonObject &config, DockerContainer container, bool haveAuthData) {}
|
||||
virtual void updateProtocolPage(const QJsonObject &config, DockerContainer container, bool haveAuthData, bool isThirdPartyConfig) {}
|
||||
virtual QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) { return QJsonObject(); }
|
||||
|
||||
};
|
||||
|
|
|
@ -21,7 +21,7 @@ ShadowSocksLogic::ShadowSocksLogic(UiLogic *logic, QObject *parent):
|
|||
|
||||
}
|
||||
|
||||
void ShadowSocksLogic::updateProtocolPage(const QJsonObject &ssConfig, DockerContainer container, bool haveAuthData)
|
||||
void ShadowSocksLogic::updateProtocolPage(const QJsonObject &ssConfig, DockerContainer container, bool haveAuthData, bool isThirdPartyConfig)
|
||||
{
|
||||
set_pageEnabled(haveAuthData);
|
||||
set_pushButtonSaveVisible(haveAuthData);
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
explicit ShadowSocksLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~ShadowSocksLogic() = default;
|
||||
|
||||
void updateProtocolPage(const QJsonObject &ssConfig, DockerContainer container, bool haveAuthData) override;
|
||||
void updateProtocolPage(const QJsonObject &ssConfig, DockerContainer container, bool haveAuthData, bool isThirdPartyConfig) override;
|
||||
QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue