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
|
||||
with:
|
||||
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
|
||||
uses: jurplel/install-qt-action@v3
|
||||
with:
|
||||
@@ -95,7 +89,8 @@ jobs:
|
||||
py7zrversion: ' '
|
||||
aqtversion: ' '
|
||||
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
|
||||
- name: Install ninja-build tool
|
||||
uses: seanmiddleditch/gha-setup-ninja@v3
|
||||
|
||||
@@ -10,8 +10,7 @@ outbound["streamSettings"] = streamSettings;
|
||||
namespace NekoRay::fmt {
|
||||
QJsonObject V2rayStreamSettings::BuildStreamSettingsV2Ray() {
|
||||
QJsonObject streamSettings{
|
||||
{"network", network},
|
||||
{"security", security},
|
||||
{"network", network},
|
||||
};
|
||||
|
||||
if (network == "ws") {
|
||||
@@ -54,6 +53,7 @@ namespace NekoRay::fmt {
|
||||
tls["alpn"] = QList2QJsonArray(alpn.split(","));
|
||||
}
|
||||
streamSettings["tlsSettings"] = tls;
|
||||
streamSettings["security"] = "tls";
|
||||
}
|
||||
|
||||
if (!header_type.isEmpty()) {
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace NekoRay::fmt {
|
||||
|
||||
QString VMessBean::InsecureHint() {
|
||||
if (security == "none" || security == "zero") {
|
||||
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.");
|
||||
}
|
||||
@@ -51,14 +51,14 @@ namespace NekoRay::fmt {
|
||||
}
|
||||
|
||||
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 {};
|
||||
}
|
||||
|
||||
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 {};
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace NekoRay::fmt {
|
||||
password = url.password();
|
||||
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");
|
||||
}
|
||||
return true;
|
||||
@@ -124,13 +124,7 @@ namespace NekoRay::fmt {
|
||||
auto scy = objN["scy"].toString();
|
||||
if (!scy.isEmpty()) security = scy;
|
||||
// TLS (XTLS?)
|
||||
if (!objN["tls"].toString().isEmpty() && objN["tls"].toString().toLower() != "none")
|
||||
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;
|
||||
}
|
||||
stream->security = objN["tls"].toString();
|
||||
// TODO quic & kcp
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Preset {
|
||||
inline const char *command = "--no-check -c %config%";
|
||||
inline const char *config = "{\n"
|
||||
" \"server\": \"127.0.0.1:%mapping_port%\",\n"
|
||||
" \"server_name\": \"example.com\",\n"
|
||||
" \"obfs\": \"fuck me till the daylight\",\n"
|
||||
" \"up_mbps\": 10,\n"
|
||||
" \"down_mbps\": 50,\n"
|
||||
|
||||
@@ -45,9 +45,11 @@ namespace NekoRay::sub {
|
||||
}
|
||||
|
||||
QSharedPointer<ProxyEntity> ent;
|
||||
bool needFix = true;
|
||||
|
||||
// Nekoray format
|
||||
if (str.startsWith("nekoray://")) {
|
||||
needFix = false;
|
||||
auto link = QUrl(str);
|
||||
if (!link.isValid()) return;
|
||||
ent = ProfileManager::NewProxyEntity(link.host());
|
||||
@@ -87,7 +89,7 @@ namespace NekoRay::sub {
|
||||
if (!ok) return;
|
||||
}
|
||||
|
||||
// VMess
|
||||
// VLESS
|
||||
if (str.startsWith("vless://")) {
|
||||
ent = ProfileManager::NewProxyEntity("vless");
|
||||
auto ok = ent->TrojanVLESSBean()->TryParseLink(str);
|
||||
@@ -103,6 +105,7 @@ namespace NekoRay::sub {
|
||||
|
||||
// Naive
|
||||
if (str.startsWith("naive+")) {
|
||||
needFix = false;
|
||||
ent = ProfileManager::NewProxyEntity("naive");
|
||||
auto ok = ent->NaiveBean()->TryParseLink(str);
|
||||
if (!ok) return;
|
||||
@@ -110,6 +113,7 @@ namespace NekoRay::sub {
|
||||
|
||||
// Hysteria
|
||||
if (str.startsWith("hysteria://")) {
|
||||
needFix = false;
|
||||
// https://github.com/HyNetwork/hysteria/wiki/URI-Scheme
|
||||
ent = ProfileManager::NewProxyEntity("custom");
|
||||
auto bean = ent->CustomBean();
|
||||
@@ -122,6 +126,7 @@ namespace NekoRay::sub {
|
||||
bean->core = "hysteria";
|
||||
bean->command = QString(Preset::Hysteria::command).split(" ");
|
||||
auto result = QString2QJsonObject(Preset::Hysteria::config);
|
||||
result["server_name"] = url.host(); // default sni
|
||||
result["obfs"] = query.queryItemValue("obfsParam");
|
||||
result["insecure"] = query.queryItemValue("insecure") == "1";
|
||||
result["up_mbps"] = query.queryItemValue("upmbps").toInt();
|
||||
@@ -133,6 +138,22 @@ namespace NekoRay::sub {
|
||||
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
|
||||
if (ent == nullptr) return;
|
||||
profileManager->AddProfile(ent, gid_add_to);
|
||||
|
||||
@@ -154,7 +154,7 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
|
||||
//
|
||||
CACHE.extraCore = QString2QJsonObject(NekoRay::dataStore->extraCore->core_map);
|
||||
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();
|
||||
for (const auto &s: CACHE.extraCore.keys()) {
|
||||
|
||||
@@ -83,7 +83,6 @@ DialogEditProfile::DialogEditProfile(const QString &_type, int profileOrGroupId,
|
||||
}
|
||||
ADJUST_SIZE
|
||||
});
|
||||
ui->security->removeItem(0);
|
||||
|
||||
// 确定模式和 ent
|
||||
newEnt = _type != "";
|
||||
|
||||
@@ -198,11 +198,6 @@
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">none</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">tls</string>
|
||||
|
||||
Reference in New Issue
Block a user