feat: added supported protocols field processing
This commit is contained in:
parent
ab340c3257
commit
98c4389445
3 changed files with 18 additions and 2 deletions
|
@ -35,6 +35,7 @@ namespace
|
|||
constexpr char serviceType[] = "service_type";
|
||||
constexpr char serviceInfo[] = "service_info";
|
||||
constexpr char serviceProtocol[] = "service_protocol";
|
||||
constexpr char supportedProtocols[] = "supported_protocols";
|
||||
|
||||
constexpr char apiPayload[] = "api_payload";
|
||||
constexpr char keyPayload[] = "key_payload";
|
||||
|
@ -197,8 +198,8 @@ namespace
|
|||
auto apiConfig = QJsonObject::fromVariantMap(map);
|
||||
|
||||
if (newServerConfig.value(config_key::configVersion).toInt() == apiDefs::ConfigSource::AmneziaGateway) {
|
||||
apiConfig.insert(configKey::serviceInfo,
|
||||
QJsonDocument::fromJson(apiResponseBody).object().value(configKey::serviceInfo).toObject());
|
||||
apiConfig.insert(configKey::supportedProtocols,
|
||||
QJsonDocument::fromJson(apiResponseBody).object().value(configKey::supportedProtocols).toArray());
|
||||
}
|
||||
|
||||
serverConfig[configKey::apiConfig] = apiConfig;
|
||||
|
@ -592,6 +593,18 @@ bool ApiConfigsController::isVlessProtocol()
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ApiConfigsController::isProtocolSelectionSupported()
|
||||
{
|
||||
auto serverIndex = m_serversModel->getProcessedServerIndex();
|
||||
auto serverConfigObject = m_serversModel->getServerConfig(serverIndex);
|
||||
auto apiConfigObject = serverConfigObject.value(configKey::apiConfig).toObject();
|
||||
|
||||
if (apiConfigObject[configKey::supportedProtocols].toArray().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QList<QString> ApiConfigsController::getQrCodes()
|
||||
{
|
||||
return m_qrCodes;
|
||||
|
|
|
@ -37,6 +37,7 @@ public slots:
|
|||
|
||||
void setCurrentProtocol(const QString &protocolName);
|
||||
bool isVlessProtocol();
|
||||
bool isProtocolSelectionSupported();
|
||||
|
||||
signals:
|
||||
void errorOccurred(ErrorCode errorCode);
|
||||
|
|
|
@ -168,6 +168,8 @@ PageType {
|
|||
Layout.rightMargin: 16
|
||||
Layout.leftMargin: 16
|
||||
|
||||
visible: ApiConfigsController.isProtocolSelectionSupported()
|
||||
|
||||
text: qsTr("Use VLESS protocol")
|
||||
checked: switcher.isVlessProtocol
|
||||
onToggled: function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue