mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-18 20:50:09 +08:00
Add xray vless headers
This commit is contained in:
parent
9fa1fbe05a
commit
dde50e5eb8
@ -290,6 +290,9 @@ set(PROJECT_SOURCES
|
||||
include/ui/profile/edit_advanced.h
|
||||
src/ui/profile/edit_advanced.cpp
|
||||
include/ui/profile/edit_advanced.ui
|
||||
include/configs/common/xrayStreamSetting.h
|
||||
include/configs/outbounds/xrayVless.h
|
||||
include/configs/common/xrayMultiplex.h
|
||||
)
|
||||
|
||||
if (NOT APPLE AND Qt6_VERSION VERSION_GREATER_EQUAL 6.9.0)
|
||||
|
||||
@ -78,6 +78,8 @@ namespace Configs
|
||||
return QString("[%1] %2").arg(DisplayType(), DisplayName());
|
||||
}
|
||||
|
||||
virtual bool IsXray() { return false; }
|
||||
|
||||
virtual bool HasMux() { return false; }
|
||||
|
||||
virtual bool HasTransport() { return false; }
|
||||
|
||||
23
include/configs/common/xrayMultiplex.h
Normal file
23
include/configs/common/xrayMultiplex.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include "include/configs/baseConfig.h"
|
||||
|
||||
namespace Configs {
|
||||
class xrayMultiplex : public baseConfig {
|
||||
public:
|
||||
bool enabled = false;
|
||||
int concurrency = 0;
|
||||
int xudpConcurrency = 16;
|
||||
|
||||
xrayMultiplex() {
|
||||
_add(new configItem("enabled", &enabled, boolean));
|
||||
_add(new configItem("concurrency", &concurrency, integer));
|
||||
_add(new configItem("xudpConcurrency", &xudpConcurrency, integer));
|
||||
}
|
||||
|
||||
bool ParseFromLink(const QString& link) override;
|
||||
bool ParseFromJson(const QJsonObject& object) override;
|
||||
QString ExportToLink() override;
|
||||
QJsonObject ExportToJson() override;
|
||||
BuildResult Build() override;
|
||||
};
|
||||
}
|
||||
122
include/configs/common/xrayStreamSetting.h
Normal file
122
include/configs/common/xrayStreamSetting.h
Normal file
@ -0,0 +1,122 @@
|
||||
#pragma once
|
||||
#include "include/configs/baseConfig.h"
|
||||
|
||||
namespace Configs {
|
||||
inline QStringList XrayNetworks = {"raw", "xhttp"};
|
||||
inline QStringList XrayXHTTPModes = {"auto", "packet-up", "stream-up", "stream-one"};
|
||||
|
||||
class xrayTLS : public baseConfig {
|
||||
public:
|
||||
QString serverName;
|
||||
bool allowInsecure = false;
|
||||
QStringList alpn;
|
||||
QString fingerprint;
|
||||
|
||||
xrayTLS() {
|
||||
_add(new configItem("serverName", &serverName, string));
|
||||
_add(new configItem("allowInsecure", &allowInsecure, boolean));
|
||||
_add(new configItem("alpn", &alpn, stringList));
|
||||
_add(new configItem("fingerprint", &fingerprint, string));
|
||||
}
|
||||
|
||||
bool ParseFromLink(const QString& link) override;
|
||||
bool ParseFromJson(const QJsonObject& object) override;
|
||||
QString ExportToLink() override;
|
||||
QJsonObject ExportToJson() override;
|
||||
BuildResult Build() override;
|
||||
};
|
||||
|
||||
class xrayReality : public baseConfig {
|
||||
public:
|
||||
QString target;
|
||||
QString privateKey;
|
||||
QString fingerprint;
|
||||
QString serverName;
|
||||
QString password;
|
||||
QString shortId;
|
||||
QString spiderX;
|
||||
|
||||
xrayReality() {
|
||||
_add(new configItem("target", &target, string));
|
||||
_add(new configItem("privateKey", &privateKey, string));
|
||||
_add(new configItem("fingerprint", &fingerprint, string));
|
||||
_add(new configItem("serverName", &serverName, string));
|
||||
_add(new configItem("password", &password, string));
|
||||
_add(new configItem("shortId", &shortId, string));
|
||||
_add(new configItem("spiderX", &spiderX, string));
|
||||
}
|
||||
|
||||
bool ParseFromLink(const QString& link) override;
|
||||
bool ParseFromJson(const QJsonObject& object) override;
|
||||
QString ExportToLink() override;
|
||||
QJsonObject ExportToJson() override;
|
||||
BuildResult Build() override;
|
||||
};
|
||||
|
||||
class xrayXHTTP : public baseConfig {
|
||||
public:
|
||||
QString host;
|
||||
QString path;
|
||||
QString mode;
|
||||
// extra
|
||||
QStringList headers;
|
||||
QString xPaddingBytes;
|
||||
bool noGRPCHeader = false;
|
||||
int scMaxEachPostBytes = 1000000; // packet-up only
|
||||
int scMinPostsIntervalMs = 30; // packet-up only
|
||||
// extra/xmux
|
||||
QString maxConcurrency;
|
||||
int maxConnections;
|
||||
int cMaxReuseTimes;
|
||||
QString hMaxRequestTimes;
|
||||
QString hMaxReusableSecs;
|
||||
int hKeepAlivePeriod;
|
||||
// todo do we need to add downloadsettings or is it useless?
|
||||
|
||||
xrayXHTTP() {
|
||||
_add(new configItem("host", &host, string));
|
||||
_add(new configItem("path", &path, string));
|
||||
_add(new configItem("mode", &mode, string));
|
||||
_add(new configItem("headers", &headers, stringList));
|
||||
_add(new configItem("xPaddingBytes", &xPaddingBytes, string));
|
||||
_add(new configItem("noGRPCHeader", &noGRPCHeader, boolean));
|
||||
_add(new configItem("scMaxEachPostBytes", &scMaxEachPostBytes, integer));
|
||||
_add(new configItem("scMinPostsIntervalMs", &scMinPostsIntervalMs, integer));
|
||||
_add(new configItem("maxConcurrency", &maxConcurrency, string));
|
||||
_add(new configItem("maxConnections", &maxConnections, integer));
|
||||
_add(new configItem("cMaxReuseTimes", &cMaxReuseTimes, integer));
|
||||
_add(new configItem("hMaxRequestTimes", &hMaxRequestTimes, string));
|
||||
_add(new configItem("hMaxReusableSecs", &hMaxReusableSecs, string));
|
||||
_add(new configItem("hKeepAlivePeriod", &hKeepAlivePeriod, integer));
|
||||
}
|
||||
|
||||
bool ParseFromLink(const QString& link) override;
|
||||
bool ParseFromJson(const QJsonObject& object) override;
|
||||
QString ExportToLink() override;
|
||||
QJsonObject ExportToJson() override;
|
||||
BuildResult Build() override;
|
||||
};
|
||||
|
||||
class xrayStreamSetting : public baseConfig {
|
||||
public:
|
||||
QString network;
|
||||
QString security;
|
||||
std::shared_ptr<xrayTLS> TLS = std::make_shared<xrayTLS>();
|
||||
std::shared_ptr<xrayReality> reality = std::make_shared<xrayReality>();
|
||||
std::shared_ptr<xrayXHTTP> xhttp = std::make_shared<xrayXHTTP>();
|
||||
|
||||
xrayStreamSetting() {
|
||||
_add(new configItem("network", &network, string));
|
||||
_add(new configItem("security", &security, string));
|
||||
_add(new configItem("tls", dynamic_cast<JsonStore *>(TLS.get()), jsonStore));
|
||||
_add(new configItem("reality", dynamic_cast<JsonStore *>(reality.get()), jsonStore));
|
||||
_add(new configItem("xhttp", dynamic_cast<JsonStore *>(xhttp.get()), jsonStore));
|
||||
}
|
||||
|
||||
bool ParseFromLink(const QString& link) override;
|
||||
bool ParseFromJson(const QJsonObject& object) override;
|
||||
QString ExportToLink() override;
|
||||
QJsonObject ExportToJson() override;
|
||||
BuildResult Build() override;
|
||||
};
|
||||
}
|
||||
38
include/configs/outbounds/xrayVless.h
Normal file
38
include/configs/outbounds/xrayVless.h
Normal file
@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
#include "include/configs/common/Outbound.h"
|
||||
#include "include/configs/common/xrayMultiplex.h"
|
||||
#include "include/configs/common/xrayStreamSetting.h"
|
||||
|
||||
namespace Configs {
|
||||
inline QStringList xrayFlows = {"", "xtls-rprx-vision", "xtls-rprx-vision-udp443"};
|
||||
|
||||
class xrayVless : public outbound {
|
||||
public:
|
||||
QString uuid;
|
||||
QString encryption = "none";
|
||||
QString flow;
|
||||
std::shared_ptr<xrayStreamSetting> streamSetting = std::make_shared<xrayStreamSetting>();
|
||||
std::shared_ptr<xrayMultiplex> multiplex = std::make_shared<xrayMultiplex>();
|
||||
|
||||
xrayVless() : outbound() {
|
||||
_add(new configItem("uuid", &uuid, string));
|
||||
_add(new configItem("encryption", &encryption, string));
|
||||
_add(new configItem("flow", &flow, string));
|
||||
_add(new configItem("streamSetting", dynamic_cast<JsonStore *>(streamSetting.get()), jsonStore));
|
||||
_add(new configItem("multiplex", dynamic_cast<JsonStore *>(multiplex.get()), jsonStore));
|
||||
}
|
||||
|
||||
bool ParseFromLink(const QString& link) override;
|
||||
bool ParseFromJson(const QJsonObject& object) override;
|
||||
QString ExportToLink() override;
|
||||
QJsonObject ExportToJson() override;
|
||||
BuildResult Build() override;
|
||||
|
||||
QString DisplayType() override {
|
||||
return "VLESS (Xray)";
|
||||
}
|
||||
bool IsXray() override {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user