feat: custom config

This commit is contained in:
arm64v8a
2023-04-09 14:00:08 +09:00
parent caca5a59f6
commit 8a0b8554b1
7 changed files with 54 additions and 17 deletions

View File

@@ -20,10 +20,15 @@ namespace NekoRay {
status->forTest = forTest;
status->forExport = forExport;
if (IS_NEKO_BOX) {
BuildConfigSingBox(status);
auto customBean = dynamic_cast<fmt::CustomBean *>(ent->bean.get());
if (customBean != nullptr && customBean->core == "internal-full") {
result->coreConfig = QString2QJsonObject(customBean->config_simple);
} else {
BuildConfigV2Ray(status);
if (IS_NEKO_BOX) {
BuildConfigSingBox(status);
} else {
BuildConfigV2Ray(status);
}
}
// hook.js

View File

@@ -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;

View File

@@ -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();
};

View File

@@ -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>

View File

@@ -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>

View File

@@ -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);

View File

@@ -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();
ui->core_l->setText(tr("Outbound JSON, please read the documentation."));
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();
}