mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 12:34:37 +03:00
fix config
This commit is contained in:
@@ -33,6 +33,7 @@ namespace NekoRay::fmt {
|
|||||||
streamSettings["grpcSettings"] = grpc;
|
streamSettings["grpcSettings"] = grpc;
|
||||||
} else if (network == "quic") {
|
} else if (network == "quic") {
|
||||||
QJsonObject quic;
|
QJsonObject quic;
|
||||||
|
if (!header_type.isEmpty()) quic["header"] = QJsonObject{{"type", header_type}};
|
||||||
if (!path.isEmpty()) quic["key"] = path;
|
if (!path.isEmpty()) quic["key"] = path;
|
||||||
if (!host.isEmpty()) quic["security"] = host;
|
if (!host.isEmpty()) quic["security"] = host;
|
||||||
streamSettings["quicSettings"] = quic;
|
streamSettings["quicSettings"] = quic;
|
||||||
|
|||||||
@@ -22,6 +22,23 @@ namespace NekoRay::sub {
|
|||||||
|
|
||||||
GroupUpdater *groupUpdater = new GroupUpdater;
|
GroupUpdater *groupUpdater = new GroupUpdater;
|
||||||
|
|
||||||
|
void RawUpdater_FixEnt(const QSharedPointer<ProxyEntity> &ent) {
|
||||||
|
if (ent == nullptr) return;
|
||||||
|
auto stream = fmt::GetStreamSettings(ent->bean.get());
|
||||||
|
if (stream == nullptr) return;
|
||||||
|
// 1. "security"
|
||||||
|
if (stream->security == "none" || stream->security == "0" || stream->security == "false") {
|
||||||
|
stream->security = "";
|
||||||
|
} else if (stream->security == "xtls" || stream->security == "1" || stream->security == "true") {
|
||||||
|
stream->security = "tls";
|
||||||
|
}
|
||||||
|
// 2. TLS SNI: v2rayN config builder generate sni like this, so set sni here for their format.
|
||||||
|
if (stream->security == "tls" && IsIpAddress(ent->bean->serverAddress)
|
||||||
|
&& (!stream->host.isEmpty()) && stream->sni.isEmpty()) {
|
||||||
|
stream->sni = stream->host;;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RawUpdater::update(const QString &str) {
|
void RawUpdater::update(const QString &str) {
|
||||||
// Base64 encoded subscription
|
// Base64 encoded subscription
|
||||||
if (auto str2 = DecodeB64IfValid(str);!str2.isEmpty()) {
|
if (auto str2 = DecodeB64IfValid(str);!str2.isEmpty()) {
|
||||||
@@ -141,20 +158,7 @@ namespace NekoRay::sub {
|
|||||||
if (ent == nullptr) return;
|
if (ent == nullptr) return;
|
||||||
|
|
||||||
// Fix
|
// Fix
|
||||||
auto stream = fmt::GetStreamSettings(ent->bean.get());
|
if (needFix) RawUpdater_FixEnt(ent);
|
||||||
if (needFix && stream != nullptr) {
|
|
||||||
// 1. "security"
|
|
||||||
if (stream->security == "none" || stream->security == "0" || stream->security == "false") {
|
|
||||||
stream->security = "";
|
|
||||||
} else if (stream->security == "xtls" || stream->security == "1" || stream->security == "true") {
|
|
||||||
stream->security = "tls";
|
|
||||||
}
|
|
||||||
// 2. TLS SNI: v2rayN config builder generate sni like this, so set sni here for their format.
|
|
||||||
if (stream->security == "tls" && IsIpAddress(ent->bean->serverAddress)
|
|
||||||
&& (!stream->host.isEmpty()) && stream->sni.isEmpty()) {
|
|
||||||
stream->sni = stream->host;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// End
|
// End
|
||||||
profileManager->AddProfile(ent, gid_add_to);
|
profileManager->AddProfile(ent, gid_add_to);
|
||||||
@@ -210,6 +214,7 @@ namespace NekoRay::sub {
|
|||||||
|
|
||||||
auto ent = ProfileManager::NewProxyEntity(type);
|
auto ent = ProfileManager::NewProxyEntity(type);
|
||||||
if (ent->bean->version == -114514) continue;
|
if (ent->bean->version == -114514) continue;
|
||||||
|
bool needFix = false;
|
||||||
|
|
||||||
// common
|
// common
|
||||||
ent->bean->name = Node2QString(proxy["name"]);
|
ent->bean->name = Node2QString(proxy["name"]);
|
||||||
@@ -239,6 +244,7 @@ namespace NekoRay::sub {
|
|||||||
if (Node2Bool(proxy["tls"])) bean->stream->security = "tls";
|
if (Node2Bool(proxy["tls"])) bean->stream->security = "tls";
|
||||||
if (Node2Bool(proxy["skip-cert-verify"])) bean->stream->allow_insecure = true;
|
if (Node2Bool(proxy["skip-cert-verify"])) bean->stream->allow_insecure = true;
|
||||||
} else if (type == "trojan") {
|
} else if (type == "trojan") {
|
||||||
|
needFix = true;
|
||||||
auto bean = ent->TrojanVLESSBean();
|
auto bean = ent->TrojanVLESSBean();
|
||||||
bean->password = Node2QString(proxy["password"]);
|
bean->password = Node2QString(proxy["password"]);
|
||||||
bean->stream->security = "tls";
|
bean->stream->security = "tls";
|
||||||
@@ -246,6 +252,7 @@ namespace NekoRay::sub {
|
|||||||
bean->stream->sni = FIRST_OR_SECOND(Node2QString(proxy["sni"]), Node2QString(proxy["servername"]));
|
bean->stream->sni = FIRST_OR_SECOND(Node2QString(proxy["sni"]), Node2QString(proxy["servername"]));
|
||||||
if (Node2Bool(proxy["skip-cert-verify"])) bean->stream->allow_insecure = true;
|
if (Node2Bool(proxy["skip-cert-verify"])) bean->stream->allow_insecure = true;
|
||||||
} else if (type == "vmess") {
|
} else if (type == "vmess") {
|
||||||
|
needFix = true;
|
||||||
auto bean = ent->VMessBean();
|
auto bean = ent->VMessBean();
|
||||||
bean->uuid = Node2QString(proxy["uuid"]);
|
bean->uuid = Node2QString(proxy["uuid"]);
|
||||||
bean->aid = Node2Int(proxy["alterId"]);
|
bean->aid = Node2Int(proxy["alterId"]);
|
||||||
@@ -302,6 +309,7 @@ namespace NekoRay::sub {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (needFix) RawUpdater_FixEnt(ent);
|
||||||
profileManager->AddProfile(ent, gid_add_to);
|
profileManager->AddProfile(ent, gid_add_to);
|
||||||
update_counter++;
|
update_counter++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user