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