diff --git a/fmt/Bean2External.cpp b/fmt/Bean2External.cpp index f6bb100..94979aa 100644 --- a/fmt/Bean2External.cpp +++ b/fmt/Bean2External.cpp @@ -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)); - // trojan-go: unsupported config format: xxx.tmp. use .yaml or .json instead. - auto suffix = ".tmp"; - if (!QString2QJsonObject(config).isEmpty()) { + // 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. suffix = ".json"; } diff --git a/fmt/CustomBean.hpp b/fmt/CustomBean.hpp index 2d62a1d..164b836 100644 --- a/fmt/CustomBean.hpp +++ b/fmt/CustomBean.hpp @@ -7,14 +7,14 @@ namespace NekoRay::fmt { public: QString core; QList 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 { diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index f4a9a84..d7099ad 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -599,6 +599,10 @@ Please read the documentation. If you don't understand, use a share link instead. 格式请看文档。如果不懂,直接导入 hysteria:// 链接。 + + Config Suffix + 配置文件后缀 + EditNaive diff --git a/ui/edit/edit_custom.cpp b/ui/edit/edit_custom.cpp index ddc1855..cd59766 100644 --- a/ui/edit/edit_custom.cpp +++ b/ui/edit/edit_custom.cpp @@ -50,6 +50,7 @@ void EditCustom::onStart(QSharedPointer _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 _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.")); diff --git a/ui/edit/edit_custom.ui b/ui/edit/edit_custom.ui index a001bfa..4882542 100644 --- a/ui/edit/edit_custom.ui +++ b/ui/edit/edit_custom.ui @@ -63,6 +63,30 @@ + + + + Config Suffix + + + + + + + true + + + + + + + + + json + + + +