mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-18 21:14:37 +03:00
feat: custom config
This commit is contained in:
@@ -20,11 +20,16 @@ namespace NekoRay {
|
|||||||
status->forTest = forTest;
|
status->forTest = forTest;
|
||||||
status->forExport = forExport;
|
status->forExport = forExport;
|
||||||
|
|
||||||
|
auto customBean = dynamic_cast<fmt::CustomBean *>(ent->bean.get());
|
||||||
|
if (customBean != nullptr && customBean->core == "internal-full") {
|
||||||
|
result->coreConfig = QString2QJsonObject(customBean->config_simple);
|
||||||
|
} else {
|
||||||
if (IS_NEKO_BOX) {
|
if (IS_NEKO_BOX) {
|
||||||
BuildConfigSingBox(status);
|
BuildConfigSingBox(status);
|
||||||
} else {
|
} else {
|
||||||
BuildConfigV2Ray(status);
|
BuildConfigV2Ray(status);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// hook.js
|
// hook.js
|
||||||
if (result->error.isEmpty() && !forTest) {
|
if (result->error.isEmpty() && !forTest) {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace NekoRay::fmt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int CustomBean::NeedExternal(bool isFirstProfile, bool isVPN) {
|
int CustomBean::NeedExternal(bool isFirstProfile, bool isVPN) {
|
||||||
if (core == "internal") return 0;
|
if (core == "internal" || core == "internal-full") return 0;
|
||||||
if (core == "hysteria") {
|
if (core == "hysteria") {
|
||||||
if (isFirstProfile && !isVPN) {
|
if (isFirstProfile && !isVPN) {
|
||||||
return 2;
|
return 2;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ namespace NekoRay::fmt {
|
|||||||
if (core == "internal") {
|
if (core == "internal") {
|
||||||
auto obj = QString2QJsonObject(config_simple);
|
auto obj = QString2QJsonObject(config_simple);
|
||||||
return obj[IS_NEKO_BOX ? "type" : "protocol"].toString();
|
return obj[IS_NEKO_BOX ? "type" : "protocol"].toString();
|
||||||
|
} else if (core == "internal-full") {
|
||||||
|
return software_core_name + " config";
|
||||||
}
|
}
|
||||||
return core;
|
return core;
|
||||||
};
|
};
|
||||||
@@ -39,6 +41,8 @@ namespace NekoRay::fmt {
|
|||||||
} else {
|
} else {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
} else if (core == "internal-full") {
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
return AbstractBean::DisplayAddress();
|
return AbstractBean::DisplayAddress();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -379,10 +379,6 @@
|
|||||||
<source>Application layer protocol negotiation, clear text. Please separate them with commas.</source>
|
<source>Application layer protocol negotiation, clear text. Please separate them with commas.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Custom (%1)</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Custom (Extra Core)</source>
|
<source>Custom (Extra Core)</source>
|
||||||
<translation>سفارشی ( هسته اضافه)</translation>
|
<translation>سفارشی ( هسته اضافه)</translation>
|
||||||
@@ -407,6 +403,14 @@
|
|||||||
<source>Reality public key. If not empty, turn TLS into REALITY.</source>
|
<source>Reality public key. If not empty, turn TLS into REALITY.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Custom (%1 outbound)</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Custom (%1 config)</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>DialogHotkey</name>
|
<name>DialogHotkey</name>
|
||||||
@@ -712,6 +716,10 @@ https://matsuridayo.github.io/n-configuration/#vpn-tun</source>
|
|||||||
<source>Preview config</source>
|
<source>Preview config</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Please fill the complete config.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>EditNaive</name>
|
<name>EditNaive</name>
|
||||||
|
|||||||
@@ -381,10 +381,6 @@
|
|||||||
<source>Custom (Extra Core)</source>
|
<source>Custom (Extra Core)</source>
|
||||||
<translation>自定义 (其他核心)</translation>
|
<translation>自定义 (其他核心)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Custom (%1)</source>
|
|
||||||
<translation>自定义 (%1)</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>TLS Security Settings</source>
|
<source>TLS Security Settings</source>
|
||||||
<translation>TLS 安全设置</translation>
|
<translation>TLS 安全设置</translation>
|
||||||
@@ -397,6 +393,14 @@
|
|||||||
<source>Reality public key. If not empty, turn TLS into REALITY.</source>
|
<source>Reality public key. If not empty, turn TLS into REALITY.</source>
|
||||||
<translation>Reality public key. 如果不为空,则将 TLS 变为 REALITY。</translation>
|
<translation>Reality public key. 如果不为空,则将 TLS 变为 REALITY。</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Custom (%1 outbound)</source>
|
||||||
|
<translation>自定义 (%1 出站)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Custom (%1 config)</source>
|
||||||
|
<translation>自定义 (%1 完整配置)</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>DialogHotkey</name>
|
<name>DialogHotkey</name>
|
||||||
@@ -705,6 +709,10 @@ https://matsuridayo.github.io/n-configuration/#vpn-tun</translation>
|
|||||||
<source>Preview config</source>
|
<source>Preview config</source>
|
||||||
<translation>预览配置</translation>
|
<translation>预览配置</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Please fill the complete config.</source>
|
||||||
|
<translation>请填写完整配置。</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>EditNaive</name>
|
<name>EditNaive</name>
|
||||||
|
|||||||
@@ -124,7 +124,8 @@ DialogEditProfile::DialogEditProfile(const QString &_type, int profileOrGroupId,
|
|||||||
LOAD_TYPE("vless");
|
LOAD_TYPE("vless");
|
||||||
LOAD_TYPE("naive");
|
LOAD_TYPE("naive");
|
||||||
ui->type->addItem("Hysteria", "hysteria");
|
ui->type->addItem("Hysteria", "hysteria");
|
||||||
ui->type->addItem(tr("Custom (%1)").arg(software_core_name), "internal");
|
ui->type->addItem(tr("Custom (%1 outbound)").arg(software_core_name), "internal");
|
||||||
|
ui->type->addItem(tr("Custom (%1 config)").arg(software_core_name), "internal-full");
|
||||||
ui->type->addItem(tr("Custom (Extra Core)"), "custom");
|
ui->type->addItem(tr("Custom (Extra Core)"), "custom");
|
||||||
LOAD_TYPE("chain");
|
LOAD_TYPE("chain");
|
||||||
|
|
||||||
@@ -176,7 +177,7 @@ void DialogEditProfile::typeSelected(const QString &newType) {
|
|||||||
auto _innerWidget = new EditNaive(this);
|
auto _innerWidget = new EditNaive(this);
|
||||||
innerWidget = _innerWidget;
|
innerWidget = _innerWidget;
|
||||||
innerEditor = _innerWidget;
|
innerEditor = _innerWidget;
|
||||||
} else if (type == "custom" || type == "internal" || type == "hysteria") {
|
} else if (type == "custom" || type == "internal" || type == "internal-full" || type == "hysteria") {
|
||||||
auto _innerWidget = new EditCustom(this);
|
auto _innerWidget = new EditCustom(this);
|
||||||
innerWidget = _innerWidget;
|
innerWidget = _innerWidget;
|
||||||
innerEditor = _innerWidget;
|
innerEditor = _innerWidget;
|
||||||
@@ -198,7 +199,7 @@ void DialogEditProfile::typeSelected(const QString &newType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// hide some widget
|
// hide some widget
|
||||||
auto showAddressPort = type != "chain" && customType != "internal";
|
auto showAddressPort = type != "chain" && customType != "internal" && customType != "internal-full";
|
||||||
ui->address->setVisible(showAddressPort);
|
ui->address->setVisible(showAddressPort);
|
||||||
ui->address_l->setVisible(showAddressPort);
|
ui->address_l->setVisible(showAddressPort);
|
||||||
ui->port->setVisible(showAddressPort);
|
ui->port->setVisible(showAddressPort);
|
||||||
|
|||||||
@@ -56,6 +56,13 @@ void EditCustom::onStart(QSharedPointer<NekoRay::ProxyEntity> _ent) {
|
|||||||
" \"type\": \"socks\",\n"
|
" \"type\": \"socks\",\n"
|
||||||
" // ...\n"
|
" // ...\n"
|
||||||
"}");
|
"}");
|
||||||
|
} else if (preset_core == "internal-full") {
|
||||||
|
preset_command = preset_config = "";
|
||||||
|
ui->config_simple->setPlaceholderText(
|
||||||
|
"{\n"
|
||||||
|
" \"inbounds\": [],\n"
|
||||||
|
" \"outbounds\": []\n"
|
||||||
|
"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// load core ui
|
// load core ui
|
||||||
@@ -78,9 +85,13 @@ void EditCustom::onStart(QSharedPointer<NekoRay::ProxyEntity> _ent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// custom internal
|
// custom internal
|
||||||
if (preset_core == "internal") {
|
if (preset_core == "internal" || preset_core == "internal-full") {
|
||||||
ui->core->hide();
|
ui->core->hide();
|
||||||
|
if (preset_core == "internal") {
|
||||||
ui->core_l->setText(tr("Outbound JSON, please read the documentation."));
|
ui->core_l->setText(tr("Outbound JSON, please read the documentation."));
|
||||||
|
} else {
|
||||||
|
ui->core_l->setText(tr("Please fill the complete config."));
|
||||||
|
}
|
||||||
ui->w_ext1->hide();
|
ui->w_ext1->hide();
|
||||||
ui->w_ext2->hide();
|
ui->w_ext2->hide();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user