mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 20:44:38 +03:00
feat: custom config suffix
This commit is contained in:
@@ -92,10 +92,15 @@ namespace NekoRay::fmt {
|
||||
auto config = config_simple;
|
||||
config = config.replace("%mapping_port%", Int2String(mapping_port));
|
||||
config = config.replace("%socks_port%", Int2String(socks_port));
|
||||
config = config.replace("%server_addr%", serverAddress);
|
||||
config = config.replace("%server_port%", Int2String(serverPort));
|
||||
|
||||
// suffix
|
||||
QString suffix;
|
||||
if (!config_suffix.isEmpty()) {
|
||||
suffix = "." + config_suffix;
|
||||
} else if (!QString2QJsonObject(config).isEmpty()) {
|
||||
// trojan-go: unsupported config format: xxx.tmp. use .yaml or .json instead.
|
||||
auto suffix = ".tmp";
|
||||
if (!QString2QJsonObject(config).isEmpty()) {
|
||||
suffix = ".json";
|
||||
}
|
||||
|
||||
|
||||
@@ -7,14 +7,14 @@ namespace NekoRay::fmt {
|
||||
public:
|
||||
QString core;
|
||||
QList<QString> command;
|
||||
// QString config_map; // map: fn to text
|
||||
QString config_suffix;
|
||||
QString config_simple;
|
||||
|
||||
CustomBean() : AbstractBean(0) {
|
||||
_add(new configItem("core", &core, itemType::string));
|
||||
_add(new configItem("cmd", &command, itemType::stringList));
|
||||
// _add(new configItem("cm", &config_map, itemType::string));
|
||||
_add(new configItem("cs", &config_simple, itemType::string));
|
||||
_add(new configItem("cs_suffix", &config_suffix, itemType::string));
|
||||
};
|
||||
|
||||
QString DisplayType() override {
|
||||
|
||||
@@ -599,6 +599,10 @@
|
||||
<source>Please read the documentation. If you don't understand, use a share link instead.</source>
|
||||
<translation>格式请看文档。如果不懂,直接导入 hysteria:// 链接。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Config Suffix</source>
|
||||
<translation>配置文件后缀</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>EditNaive</name>
|
||||
|
||||
@@ -50,6 +50,7 @@ void EditCustom::onStart(QSharedPointer<NekoRay::ProxyEntity> _ent) {
|
||||
P_LOAD_COMBO(core)
|
||||
ui->command->setText(bean->command.join(" "));
|
||||
P_LOAD_STRING(config_simple)
|
||||
P_LOAD_COMBO(config_suffix)
|
||||
|
||||
// custom external
|
||||
if (!bean->core.isEmpty()) {
|
||||
@@ -68,6 +69,8 @@ void EditCustom::onStart(QSharedPointer<NekoRay::ProxyEntity> _ent) {
|
||||
ui->core_l->setText(tr("Outbound JSON, please read the documentation."));
|
||||
ui->command->hide();
|
||||
ui->command_l->hide();
|
||||
ui->config_suffix->hide();
|
||||
ui->config_suffix_l->hide();
|
||||
}
|
||||
|
||||
// Generators
|
||||
@@ -80,6 +83,7 @@ bool EditCustom::onEnd() {
|
||||
P_SAVE_COMBO(core)
|
||||
bean->command = ui->command->text().split(" ");
|
||||
P_SAVE_STRING_QTEXTEDIT(config_simple)
|
||||
P_SAVE_COMBO(config_suffix)
|
||||
|
||||
if (bean->core.isEmpty()) {
|
||||
MessageBoxWarning(software_name, tr("Please pick a core."));
|
||||
|
||||
@@ -63,6 +63,30 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="config_suffix_l">
|
||||
<property name="text">
|
||||
<string>Config Suffix</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="config_suffix">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">json</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
Reference in New Issue
Block a user