mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 12:34:37 +03:00
fix: tls sni parse
This commit is contained in:
9
.github/workflows/build-qv2ray-cmake.yml
vendored
9
.github/workflows/build-qv2ray-cmake.yml
vendored
@@ -82,12 +82,6 @@ jobs:
|
|||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: download-artifact
|
path: download-artifact
|
||||||
- name: Cache Qt
|
|
||||||
id: cache-qt
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: ${{ runner.workspace }}/Qt
|
|
||||||
key: QtCache-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.qt_version }}
|
|
||||||
- name: Install Qt
|
- name: Install Qt
|
||||||
uses: jurplel/install-qt-action@v3
|
uses: jurplel/install-qt-action@v3
|
||||||
with:
|
with:
|
||||||
@@ -95,7 +89,8 @@ jobs:
|
|||||||
py7zrversion: ' '
|
py7zrversion: ' '
|
||||||
aqtversion: ' '
|
aqtversion: ' '
|
||||||
setup-python: false
|
setup-python: false
|
||||||
cached: ${{ steps.cache-qt.outputs.cache-hit }}
|
cache: true
|
||||||
|
cache-key-prefix: QtCache-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.qt_version }}
|
||||||
# ========================================================================================================= Other install
|
# ========================================================================================================= Other install
|
||||||
- name: Install ninja-build tool
|
- name: Install ninja-build tool
|
||||||
uses: seanmiddleditch/gha-setup-ninja@v3
|
uses: seanmiddleditch/gha-setup-ninja@v3
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ outbound["streamSettings"] = streamSettings;
|
|||||||
namespace NekoRay::fmt {
|
namespace NekoRay::fmt {
|
||||||
QJsonObject V2rayStreamSettings::BuildStreamSettingsV2Ray() {
|
QJsonObject V2rayStreamSettings::BuildStreamSettingsV2Ray() {
|
||||||
QJsonObject streamSettings{
|
QJsonObject streamSettings{
|
||||||
{"network", network},
|
{"network", network},
|
||||||
{"security", security},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (network == "ws") {
|
if (network == "ws") {
|
||||||
@@ -54,6 +53,7 @@ namespace NekoRay::fmt {
|
|||||||
tls["alpn"] = QList2QJsonArray(alpn.split(","));
|
tls["alpn"] = QList2QJsonArray(alpn.split(","));
|
||||||
}
|
}
|
||||||
streamSettings["tlsSettings"] = tls;
|
streamSettings["tlsSettings"] = tls;
|
||||||
|
streamSettings["security"] = "tls";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!header_type.isEmpty()) {
|
if (!header_type.isEmpty()) {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace NekoRay::fmt {
|
|||||||
|
|
||||||
QString VMessBean::InsecureHint() {
|
QString VMessBean::InsecureHint() {
|
||||||
if (security == "none" || security == "zero") {
|
if (security == "none" || security == "zero") {
|
||||||
if (stream->security.isEmpty() || stream->security == "none") {
|
if (stream->security.isEmpty()) {
|
||||||
return QObject::tr(
|
return QObject::tr(
|
||||||
"This profile is cleartext, don't use it if the server is not in your local network.");
|
"This profile is cleartext, don't use it if the server is not in your local network.");
|
||||||
}
|
}
|
||||||
@@ -51,14 +51,14 @@ namespace NekoRay::fmt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString TrojanVLESSBean::InsecureHint() {
|
QString TrojanVLESSBean::InsecureHint() {
|
||||||
if (stream->security.isEmpty() || stream->security == "none") {
|
if (stream->security.isEmpty()) {
|
||||||
return QObject::tr("This profile is cleartext, don't use it if the server is not in your local network.");
|
return QObject::tr("This profile is cleartext, don't use it if the server is not in your local network.");
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SocksHttpBean::InsecureHint() {
|
QString SocksHttpBean::InsecureHint() {
|
||||||
if (stream->security.isEmpty() || stream->security == "none") {
|
if (stream->security.isEmpty()) {
|
||||||
return QObject::tr("This profile is cleartext, don't use it if the server is not in your local network.");
|
return QObject::tr("This profile is cleartext, don't use it if the server is not in your local network.");
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace NekoRay::fmt {
|
|||||||
password = url.password();
|
password = url.password();
|
||||||
if (serverPort == -1) serverPort = socks_http_type == type_HTTP ? 443 : 1080;
|
if (serverPort == -1) serverPort = socks_http_type == type_HTTP ? 443 : 1080;
|
||||||
|
|
||||||
stream->security = GetQueryValue(query, "security", "") == "true" ? "tls" : "none";
|
stream->security = GetQueryValue(query, "security", "");
|
||||||
stream->sni = GetQueryValue(query, "sni");
|
stream->sni = GetQueryValue(query, "sni");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -124,13 +124,7 @@ namespace NekoRay::fmt {
|
|||||||
auto scy = objN["scy"].toString();
|
auto scy = objN["scy"].toString();
|
||||||
if (!scy.isEmpty()) security = scy;
|
if (!scy.isEmpty()) security = scy;
|
||||||
// TLS (XTLS?)
|
// TLS (XTLS?)
|
||||||
if (!objN["tls"].toString().isEmpty() && objN["tls"].toString().toLower() != "none")
|
stream->security = objN["tls"].toString();
|
||||||
stream->security = "tls";
|
|
||||||
if (stream->security == "tls" && IsIpAddress(serverAddress) &&
|
|
||||||
(!stream->host.isEmpty()) && stream->sni.isEmpty()) {
|
|
||||||
// v2rayN config builder generate sni like this, so set sni here for their format.
|
|
||||||
stream->sni = stream->host;
|
|
||||||
}
|
|
||||||
// TODO quic & kcp
|
// TODO quic & kcp
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace Preset {
|
|||||||
inline const char *command = "--no-check -c %config%";
|
inline const char *command = "--no-check -c %config%";
|
||||||
inline const char *config = "{\n"
|
inline const char *config = "{\n"
|
||||||
" \"server\": \"127.0.0.1:%mapping_port%\",\n"
|
" \"server\": \"127.0.0.1:%mapping_port%\",\n"
|
||||||
|
" \"server_name\": \"example.com\",\n"
|
||||||
" \"obfs\": \"fuck me till the daylight\",\n"
|
" \"obfs\": \"fuck me till the daylight\",\n"
|
||||||
" \"up_mbps\": 10,\n"
|
" \"up_mbps\": 10,\n"
|
||||||
" \"down_mbps\": 50,\n"
|
" \"down_mbps\": 50,\n"
|
||||||
|
|||||||
@@ -45,9 +45,11 @@ namespace NekoRay::sub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<ProxyEntity> ent;
|
QSharedPointer<ProxyEntity> ent;
|
||||||
|
bool needFix = true;
|
||||||
|
|
||||||
// Nekoray format
|
// Nekoray format
|
||||||
if (str.startsWith("nekoray://")) {
|
if (str.startsWith("nekoray://")) {
|
||||||
|
needFix = false;
|
||||||
auto link = QUrl(str);
|
auto link = QUrl(str);
|
||||||
if (!link.isValid()) return;
|
if (!link.isValid()) return;
|
||||||
ent = ProfileManager::NewProxyEntity(link.host());
|
ent = ProfileManager::NewProxyEntity(link.host());
|
||||||
@@ -87,7 +89,7 @@ namespace NekoRay::sub {
|
|||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// VMess
|
// VLESS
|
||||||
if (str.startsWith("vless://")) {
|
if (str.startsWith("vless://")) {
|
||||||
ent = ProfileManager::NewProxyEntity("vless");
|
ent = ProfileManager::NewProxyEntity("vless");
|
||||||
auto ok = ent->TrojanVLESSBean()->TryParseLink(str);
|
auto ok = ent->TrojanVLESSBean()->TryParseLink(str);
|
||||||
@@ -103,6 +105,7 @@ namespace NekoRay::sub {
|
|||||||
|
|
||||||
// Naive
|
// Naive
|
||||||
if (str.startsWith("naive+")) {
|
if (str.startsWith("naive+")) {
|
||||||
|
needFix = false;
|
||||||
ent = ProfileManager::NewProxyEntity("naive");
|
ent = ProfileManager::NewProxyEntity("naive");
|
||||||
auto ok = ent->NaiveBean()->TryParseLink(str);
|
auto ok = ent->NaiveBean()->TryParseLink(str);
|
||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
@@ -110,6 +113,7 @@ namespace NekoRay::sub {
|
|||||||
|
|
||||||
// Hysteria
|
// Hysteria
|
||||||
if (str.startsWith("hysteria://")) {
|
if (str.startsWith("hysteria://")) {
|
||||||
|
needFix = false;
|
||||||
// https://github.com/HyNetwork/hysteria/wiki/URI-Scheme
|
// https://github.com/HyNetwork/hysteria/wiki/URI-Scheme
|
||||||
ent = ProfileManager::NewProxyEntity("custom");
|
ent = ProfileManager::NewProxyEntity("custom");
|
||||||
auto bean = ent->CustomBean();
|
auto bean = ent->CustomBean();
|
||||||
@@ -122,6 +126,7 @@ namespace NekoRay::sub {
|
|||||||
bean->core = "hysteria";
|
bean->core = "hysteria";
|
||||||
bean->command = QString(Preset::Hysteria::command).split(" ");
|
bean->command = QString(Preset::Hysteria::command).split(" ");
|
||||||
auto result = QString2QJsonObject(Preset::Hysteria::config);
|
auto result = QString2QJsonObject(Preset::Hysteria::config);
|
||||||
|
result["server_name"] = url.host(); // default sni
|
||||||
result["obfs"] = query.queryItemValue("obfsParam");
|
result["obfs"] = query.queryItemValue("obfsParam");
|
||||||
result["insecure"] = query.queryItemValue("insecure") == "1";
|
result["insecure"] = query.queryItemValue("insecure") == "1";
|
||||||
result["up_mbps"] = query.queryItemValue("upmbps").toInt();
|
result["up_mbps"] = query.queryItemValue("upmbps").toInt();
|
||||||
@@ -133,6 +138,22 @@ namespace NekoRay::sub {
|
|||||||
bean->config_simple = QJsonObject2QString(result, false);
|
bean->config_simple = QJsonObject2QString(result, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fix
|
||||||
|
auto stream = fmt::GetStreamSettings(ent->bean.get());
|
||||||
|
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
|
||||||
if (ent == nullptr) return;
|
if (ent == nullptr) return;
|
||||||
profileManager->AddProfile(ent, gid_add_to);
|
profileManager->AddProfile(ent, gid_add_to);
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
|
|||||||
//
|
//
|
||||||
CACHE.extraCore = QString2QJsonObject(NekoRay::dataStore->extraCore->core_map);
|
CACHE.extraCore = QString2QJsonObject(NekoRay::dataStore->extraCore->core_map);
|
||||||
if (!CACHE.extraCore.contains("naive")) CACHE.extraCore.insert("naive", "");
|
if (!CACHE.extraCore.contains("naive")) CACHE.extraCore.insert("naive", "");
|
||||||
if (!CACHE.extraCore.contains("hysteria")) CACHE.extraCore.insert("hysteria", "");
|
if (!CACHE.extraCore.contains("hysteria") && !IS_NEKO_BOX) CACHE.extraCore.insert("hysteria", "");
|
||||||
//
|
//
|
||||||
auto extra_core_layout = ui->extra_core_box->layout();
|
auto extra_core_layout = ui->extra_core_box->layout();
|
||||||
for (const auto &s: CACHE.extraCore.keys()) {
|
for (const auto &s: CACHE.extraCore.keys()) {
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ DialogEditProfile::DialogEditProfile(const QString &_type, int profileOrGroupId,
|
|||||||
}
|
}
|
||||||
ADJUST_SIZE
|
ADJUST_SIZE
|
||||||
});
|
});
|
||||||
ui->security->removeItem(0);
|
|
||||||
|
|
||||||
// 确定模式和 ent
|
// 确定模式和 ent
|
||||||
newEnt = _type != "";
|
newEnt = _type != "";
|
||||||
|
|||||||
@@ -198,11 +198,6 @@
|
|||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">none</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">tls</string>
|
<string notr="true">tls</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user