feat: custom config suffix

This commit is contained in:
arm64v8a
2022-11-14 09:36:12 +09:00
parent 42b231c1fc
commit 1039262274
5 changed files with 42 additions and 5 deletions

View File

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

View File

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

View File

@@ -599,6 +599,10 @@
<source>Please read the documentation. If you don&apos;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>

View File

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

View File

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