fix: fixed #257 prevent using manual function Stringify

This commit is contained in:
Qv2ray Bot 2020-01-18 10:54:55 +08:00
parent 69a9c23100
commit e5d87ed052
8 changed files with 23 additions and 53 deletions

View File

@ -1 +1 @@
2866
2871

View File

@ -37,7 +37,7 @@ namespace Qv2ray
vmessUriRoot["host"] = realHost;
vmessUriRoot["path"] = transfer.wsSettings.path;
} else if (transfer.network == "h2" || transfer.network == "http") {
vmessUriRoot["host"] = Stringify(transfer.httpSettings.host, ",");
vmessUriRoot["host"] = transfer.httpSettings.host.join(",");
vmessUriRoot["path"] = transfer.httpSettings.path;
}
@ -206,7 +206,7 @@ namespace Qv2ray
} else{\
*errMessage = QObject::tr(#key " does not exist."); \
LOG(MODULE_IMPORT, "Cannot process \"" #key "\" since it's not included in the json object." ) \
LOG(MODULE_IMPORT, " --> values: " + Stringify(val) ) \
LOG(MODULE_IMPORT, " --> values: " + val.join(";")) \
LOG(MODULE_IMPORT, " --> PS: " + ps) \
}\
}

View File

@ -77,7 +77,7 @@ namespace Qv2ray
}
QString output = QString(proc.readAllStandardOutput());
LOG(MODULE_VCORE, "V2ray output: " + Stringify(SplitLines(output)))
LOG(MODULE_VCORE, "V2ray output: " + SplitLines(output).join(";"))
*message = SplitLines(output).first();
return true;
}
@ -144,7 +144,7 @@ namespace Qv2ray
inboundTags.append(tag);
}
DEBUG(MODULE_VCORE, "Found Inbound Tags: " + Stringify(inboundTags))
DEBUG(MODULE_VCORE, "Found Inbound Tags: " + inboundTags.join(";"))
QString json = JsonToString(root);
// Write the final configuration to the disk.
StringToFile(&json, new QFile(QV2RAY_GENERATED_FILE_PATH));

View File

@ -164,7 +164,7 @@ bool initialiseQv2ray()
// Even the last folder failed to pass the check.
LOG(MODULE_INIT, "FATAL")
LOG(MODULE_INIT, " ---> CANNOT find a proper place to store Qv2ray config files.")
QString searchPath = Stringify(configFilePaths, NEWLINE);
QString searchPath = configFilePaths.join(NEWLINE);
QvMessageBoxWarn(nullptr, QObject::tr("Cannot Start Qv2ray"),
QObject::tr("Cannot find a place to store config files.") + NEWLINE +
QObject::tr("Qv2ray has searched these paths below:") +

View File

@ -49,8 +49,8 @@ void MainWindow::MWFindAndStartAutoConfig()
on_startButton_clicked();
} else {
QvMessageBoxWarn(this, tr("Autostarting a config"), tr("Could not find a specified config named: ") + NEWLINE +
name + NEWLINE + NEWLINE +
tr("Please reset the settings in Preference Window"));
name + NEWLINE + NEWLINE +
tr("Please reset the settings in Preference Window"));
}
} else if (connectionListWidget->topLevelItemCount() > 0) {
// Make the first one our default selected item.
@ -98,7 +98,7 @@ void MainWindow::MWSetSystemProxy()
LOG(MODULE_PROXY, " --> PAC is configured to use socks but socks is not enabled.")
LOG(MODULE_PROXY, " --> PAC is configuted to use http but http is not enabled.")
QvMessageBoxWarn(this, tr("PAC Processing Failed"), tr("HTTP or SOCKS inbound is not properly configured for PAC") +
NEWLINE + tr("Qv2ray will continue, but will not set system proxy."));
NEWLINE + tr("Qv2ray will continue, but will not set system proxy."));
canSetSystemProxy = false;
}
} else {
@ -240,8 +240,8 @@ void MainWindow::CheckSubscriptionsUpdate()
if (!updateList.isEmpty()) {
QvMessageBoxWarn(this, tr("Update Subscriptions"),
tr("There are subscriptions need to be updated, please go to subscriptions window to update them.") + NEWLINE + NEWLINE +
tr("These subscriptions are out-of-date: ") + NEWLINE + Stringify(updateList));
tr("There are subscriptions need to be updated, please go to subscriptions window to update them.") + NEWLINE + NEWLINE +
tr("These subscriptions are out-of-date: ") + NEWLINE + updateList.join(";"));
on_subsButton_clicked();
}
}

View File

@ -373,19 +373,19 @@ void RouteEditor::ShowCurrentRuleDetail()
routePortTxt->setText(CurrentRule.port);
//
// Users
QString users = Stringify(CurrentRule.user, NEWLINE);
QString users = CurrentRule.user.join(NEWLINE);
routeUserTxt->setPlainText(users);
//
// Incoming Sources
QString sources = Stringify(CurrentRule.source, NEWLINE);
QString sources = CurrentRule.source.join(NEWLINE);
sourceIPList->setPlainText(sources);
//
// Domains
QString domains = Stringify(CurrentRule.domain, NEWLINE);
QString domains = CurrentRule.domain.join(NEWLINE);
hostList->setPlainText(domains);
//
// Outcoming IPs
QString ips = Stringify(CurrentRule.ip, NEWLINE);
QString ips = CurrentRule.ip.join(NEWLINE);
ipList->setPlainText(ips);
LOAD_FLAG_END
}
@ -410,7 +410,7 @@ void RouteEditor::on_routeProtocolHTTPCB_stateChanged(int arg1)
if (routeProtocolBTCB->isChecked()) protocols.push_back("bittorrent");
CurrentRule.protocol = protocols;
statusLabel->setText(tr("Protocol list changed: ") + Stringify(protocols));
statusLabel->setText(tr("Protocol list changed: ") + protocols.join(";"));
}
void RouteEditor::on_routeProtocolTLSCB_stateChanged(int arg1)
{
@ -424,7 +424,7 @@ void RouteEditor::on_routeProtocolTLSCB_stateChanged(int arg1)
if (routeProtocolBTCB->isChecked()) protocols.push_back("bittorrent");
CurrentRule.protocol = protocols;
statusLabel->setText(tr("Protocol list changed: ") + Stringify(protocols));
statusLabel->setText(tr("Protocol list changed: ") + protocols.join(";"));
}
void RouteEditor::on_routeProtocolBTCB_stateChanged(int arg1)
{
@ -438,7 +438,7 @@ void RouteEditor::on_routeProtocolBTCB_stateChanged(int arg1)
if (routeProtocolTLSCB->isChecked()) protocols.push_back("tls");
CurrentRule.protocol = protocols;
statusLabel->setText(tr("Protocol list changed: ") + Stringify(protocols));
statusLabel->setText(tr("Protocol list changed: ") + protocols.join(";"));
}
void RouteEditor::on_balancerAddBtn_clicked()
{
@ -693,7 +693,7 @@ void RouteEditor::on_editBtn_clicked()
if (protocol != "http" && protocol != "mtproto" && protocol != "socks" && protocol != "dokodemo-door") {
QvMessageBoxWarn(this, tr("Cannot Edit"), tr("Currently, this type of outbound is not supported by the editor.") + "\r\n" +
tr("We will launch Json Editor instead."));
tr("We will launch Json Editor instead."));
statusLabel->setText(tr("Opening JSON editor"));
JsonEditor *w = new JsonEditor(_in, this);
_result = INBOUND(w->OpenEditor());
@ -727,8 +727,8 @@ void RouteEditor::on_editBtn_clicked()
if (protocol != "vmess" && protocol != "shadowsocks" && protocol != "socks") {
QvMessageBoxWarn(this, tr("Unsupported Outbound Type"),
tr("This outbound entry is not supported by the GUI editor.") + NEWLINE +
tr("We will launch Json Editor instead."));
tr("This outbound entry is not supported by the GUI editor.") + NEWLINE +
tr("We will launch Json Editor instead."));
JsonEditor w(_out, this);
statusLabel->setText(tr("Opening JSON editor"));
_result = OUTBOUND(w.OpenEditor());

View File

@ -47,36 +47,6 @@ namespace Qv2ray
return randomString;
}
QString Stringify(list<string> list, QString saperator)
{
QString out;
for (auto item : list) {
out.append(QString::fromStdString(item));
out.append(saperator);
}
if (out.length() >= 1)
out = out.remove(out.length() - 1, 1);
return out;
}
QString Stringify(QList<QString> list, QString saperator)
{
QString out;
for (auto item : list) {
out.append(item);
out.append(saperator);
}
if (out.length() >= 1)
out = out.remove(out.length() - 1, 1);
return out;
}
QString StringFromFile(QFile *source)
{
source->open(QFile::ReadOnly);

View File

@ -30,8 +30,8 @@ namespace Qv2ray
QString JsonToString(QJsonObject json, QJsonDocument::JsonFormat format = QJsonDocument::JsonFormat::Indented);
QString JsonToString(QJsonArray array, QJsonDocument::JsonFormat format = QJsonDocument::JsonFormat::Indented);
QString VerifyJsonString(const QString &source);
QString Stringify(list<string> list, QString saperator = ";");
QString Stringify(QList<QString> list, QString saperator = ";");
//QString Stringify(list<string> list, QString saperator = ";");
//QString Stringify(QList<QString> list, QString saperator = ";");
QString FormatBytes(long long bytes);
void DeducePossibleFileName(const QString &baseDir, QString *fileName, const QString &extension);
QString ConvertGFWToPAC(const QString &rawContent, const QString &customProxyString);