change core v2ray to xray

This commit is contained in:
arm64v8a
2023-07-05 13:56:18 +09:00
parent 9dab2d689b
commit a7f3195482
34 changed files with 596 additions and 893 deletions

View File

@@ -1,10 +1,9 @@
#include "db/ProxyEntity.hpp"
#include "fmt/includes.h"
#define MAKE_SETTINGS_STREAM_SETTINGS \
if (!stream->packet_encoding.isEmpty()) settings["packetEncoding"] = stream->packet_encoding; \
outbound["settings"] = settings; \
auto streamSettings = stream->BuildStreamSettingsV2Ray(); \
#define MAKE_SETTINGS_STREAM_SETTINGS \
outbound["settings"] = settings; \
auto streamSettings = stream->BuildStreamSettingsV2Ray(); \
outbound["streamSettings"] = streamSettings;
namespace NekoGui_fmt {
@@ -15,19 +14,7 @@ namespace NekoGui_fmt {
QJsonObject ws;
if (!host.isEmpty()) ws["headers"] = QJsonObject{{"Host", host}};
// ws path & ed
auto pathWithoutEd = SubStrBefore(path, "?ed=");
if (!pathWithoutEd.isEmpty()) ws["path"] = pathWithoutEd;
if (pathWithoutEd != path) {
auto ed = SubStrAfter(path, "?ed=").toInt();
if (ed > 0) {
ws["maxEarlyData"] = ed;
ws["earlyDataHeaderName"] = "Sec-WebSocket-Protocol";
}
}
if (ws_early_data_length > 0) {
ws["maxEarlyData"] = ws_early_data_length;
ws["earlyDataHeaderName"] = ws_early_data_name;
}
if (!path.isEmpty()) ws["path"] = path;
streamSettings["wsSettings"] = ws;
} else if (network == "http") {
QJsonObject http;
@@ -57,31 +44,29 @@ namespace NekoGui_fmt {
if (security == "tls") {
auto fp = utlsFingerprint.isEmpty() ? NekoGui::dataStore->utlsFingerprint : utlsFingerprint;
bool v5_utls = !fp.isEmpty();
QJsonObject tls;
if (allow_insecure || NekoGui::dataStore->skip_cert) tls["allowInsecure"] = true;
if (!fp.trimmed().isEmpty()) tls["fingerprint"] = fp;
if (!sni.trimmed().isEmpty()) tls["serverName"] = sni;
if (!certificate.trimmed().isEmpty()) {
tls["disableSystemRoot"] = true;
tls["certificates"] = QJsonArray{
QJsonObject{
{"usage", v5_utls ? "ENCIPHERMENT" : "verify"},
{"certificate", QList2QJsonArray(SplitLines(certificate.trimmed()))},
},
};
}
if (!alpn.trimmed().isEmpty()) {
tls[v5_utls ? "nextProtocol" : "alpn"] = QList2QJsonArray(alpn.split(","));
}
if (v5_utls) {
streamSettings["utlsSettings"] = QJsonObject{
{"imitate", fp},
{"tlsConfig", tls},
};
streamSettings["security"] = "utls";
} else {
if (reality_pbk.trimmed().isEmpty()) {
if (allow_insecure || NekoGui::dataStore->skip_cert) tls["allowInsecure"] = true;
if (!alpn.trimmed().isEmpty()) tls["alpn"] = QList2QJsonArray(alpn.split(","));
if (!certificate.trimmed().isEmpty()) {
tls["disableSystemRoot"] = true;
tls["certificates"] = QJsonArray{
QJsonObject{
{"usage", "verify"},
{"certificate", QList2QJsonArray(SplitLines(certificate.trimmed()))},
},
};
}
streamSettings["tlsSettings"] = tls;
streamSettings["security"] = "tls";
} else {
tls["publicKey"] = reality_pbk;
tls["shortId"] = reality_sid;
tls["spiderX"] = reality_spx;
streamSettings["realitySettings"] = tls;
streamSettings["security"] = "reality";
}
}
@@ -130,6 +115,7 @@ namespace NekoGui_fmt {
server["port"] = serverPort;
server["method"] = method;
server["password"] = password;
server["uot"] = uot;
servers.push_back(server);
settings["servers"] = servers;
@@ -185,6 +171,7 @@ namespace NekoGui_fmt {
QJsonObject{
{"id", password.trimmed()},
{"encryption", "none"},
{"flow", flow},
}}},
}}}};
} else {