mirror of
https://github.com/v2rayA/v2rayA.git
synced 2026-11-20 23:02:25 +03:00
feat(vless): support encryption and REALITY ML-DSA-65 verify key
Xray v26.10.31 rejects VLESS with encryption none and no TLS or REALITY on public addresses, so post-quantum encryption strings must reach the core. Parse, generate and export the vless encryption and pqv share-link parameters, and expose both in the server editor with translations for all locales. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
3f39ac1016
commit
3e374af969
14 files changed
+94
-3
No files matched your search
@@ -116,7 +116,24 @@ const secured = computed(
|
||||
dir="ltr"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="6">
|
||||
<v-text-field
|
||||
v-model="model.pqv"
|
||||
:label="t('configureServer.realityMldsa65Verify')"
|
||||
:readonly="readonly"
|
||||
dir="ltr"
|
||||
/>
|
||||
</v-col>
|
||||
</template>
|
||||
<v-col v-if="vless" cols="12">
|
||||
<v-text-field
|
||||
v-model="model.encryption"
|
||||
:label="t('configureServer.vlessEncryption')"
|
||||
placeholder="none"
|
||||
:readonly="readonly"
|
||||
dir="ltr"
|
||||
/>
|
||||
</v-col>
|
||||
<template v-if="on">
|
||||
<v-col cols="12" sm="6">
|
||||
<v-text-field
|
||||
|
||||
@@ -20,6 +20,8 @@ export const v2rayModel = () => ({
|
||||
pbk: "",
|
||||
sid: "",
|
||||
spx: "",
|
||||
pqv: "",
|
||||
encryption: "none",
|
||||
alpn: "",
|
||||
scy: "auto",
|
||||
v: "",
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
"pbk": "PUBLICKEY",
|
||||
"sid": "abcd1234",
|
||||
"spx": "/",
|
||||
"pqv": "",
|
||||
"encryption": "none",
|
||||
"pinnedPeerCertSha256": "",
|
||||
"verifyPeerCertByName": "",
|
||||
"xhttpMode": "auto",
|
||||
@@ -105,6 +107,8 @@
|
||||
"pbk": "",
|
||||
"sid": "",
|
||||
"spx": "",
|
||||
"pqv": "",
|
||||
"encryption": "none",
|
||||
"pinnedPeerCertSha256": "",
|
||||
"verifyPeerCertByName": "",
|
||||
"xhttpMode": "packet-up",
|
||||
|
||||
@@ -23,6 +23,17 @@ describe("serverCodec keeps the editor's behaviour", () => {
|
||||
});
|
||||
}
|
||||
|
||||
test("vless encryption and reality pqv survive a round trip", () => {
|
||||
const link =
|
||||
"vless://b831381d-6324-4d53-ad4f-8cda48b30811@1.2.3.4:443?encryption=mlkem768x25519plus.native.0rtt.AAAA&security=reality&sni=example.com&fp=chrome&pbk=K&sid=ab&spx=%2F&pqv=VERIFY&type=tcp#n";
|
||||
const form = parseShareLink(link)!;
|
||||
expect(form.encryption).toBe("mlkem768x25519plus.native.0rtt.AAAA");
|
||||
expect(form.pqv).toBe("VERIFY");
|
||||
const back = generateShareLink(form)!;
|
||||
expect(back).toContain("encryption=mlkem768x25519plus.native.0rtt.AAAA");
|
||||
expect(back).toContain("pqv=VERIFY");
|
||||
});
|
||||
|
||||
test("an unknown scheme is null both ways", () => {
|
||||
expect(parseShareLink("gopher://x")).toBeNull();
|
||||
expect(generateShareLink({ protocol: "gopher" })).toBeNull();
|
||||
|
||||
@@ -65,6 +65,8 @@ export function parseShareLink(url: string): ShareForm | null {
|
||||
pbk: u.params.pbk || "",
|
||||
sid: u.params.sid || "",
|
||||
spx: u.params.spx || "",
|
||||
pqv: u.params.pqv || "",
|
||||
encryption: u.params.encryption || "none",
|
||||
pinnedPeerCertSha256: u.params.pinnedPeerCertSha256 || "",
|
||||
verifyPeerCertByName: u.params.verifyPeerCertByName || "",
|
||||
key: u.params.key,
|
||||
@@ -399,6 +401,9 @@ export function generateShareLink(srcObj: ShareForm): string | null {
|
||||
if (srcObj.alpn !== "") {
|
||||
query.alpn = srcObj.alpn;
|
||||
}
|
||||
if (srcObj.encryption && srcObj.encryption !== "none") {
|
||||
query.encryption = srcObj.encryption;
|
||||
}
|
||||
if (srcObj.net === "ws") {
|
||||
if (srcObj.maxEarlyData) {
|
||||
query.maxEarlyData = srcObj.maxEarlyData;
|
||||
@@ -494,6 +499,7 @@ export function generateShareLink(srcObj: ShareForm): string | null {
|
||||
query.pbk = srcObj.pbk;
|
||||
query.sid = srcObj.sid;
|
||||
query.spx = srcObj.spx;
|
||||
if (srcObj.pqv) query.pqv = srcObj.pqv;
|
||||
}
|
||||
return buildURL({
|
||||
protocol: "vless",
|
||||
|
||||
@@ -383,6 +383,8 @@ export default {
|
||||
realityPublicKey: "Public Key (pbk)",
|
||||
realityShortId: "Short ID (sid)",
|
||||
realitySpiderX: "Spider X (spx)",
|
||||
realityMldsa65Verify: "ML-DSA-65 Verify Key (pqv)",
|
||||
vlessEncryption: "Encryption (encryption)",
|
||||
method: "Method",
|
||||
plugin: "Plugin",
|
||||
pluginImpl: "Implementation",
|
||||
|
||||
@@ -380,6 +380,8 @@ export default {
|
||||
realityPublicKey: "کلید عمومی (pbk)",
|
||||
realityShortId: "شناسه کوتاه (sid)",
|
||||
realitySpiderX: "Spider X (spx)",
|
||||
realityMldsa65Verify: "کلید تأیید ML-DSA-65 (pqv)",
|
||||
vlessEncryption: "رمزنگاری (encryption)",
|
||||
method: "روش",
|
||||
plugin: "افزونه",
|
||||
pluginImpl: "پیادهسازی",
|
||||
|
||||
@@ -378,6 +378,8 @@ export default {
|
||||
realityPublicKey: "공개 키 (pbk)",
|
||||
realityShortId: "짧은 ID (sid)",
|
||||
realitySpiderX: "Spider X (spx)",
|
||||
realityMldsa65Verify: "ML-DSA-65 검증 키 (pqv)",
|
||||
vlessEncryption: "암호화 (encryption)",
|
||||
method: "방식",
|
||||
plugin: "플러그인",
|
||||
pluginImpl: "구현",
|
||||
|
||||
@@ -387,6 +387,8 @@ export default {
|
||||
realityPublicKey: "Chave pública (pbk)",
|
||||
realityShortId: "ID curto (sid)",
|
||||
realitySpiderX: "Spider X (spx)",
|
||||
realityMldsa65Verify: "Chave de verificação ML-DSA-65 (pqv)",
|
||||
vlessEncryption: "Criptografia (encryption)",
|
||||
method: "Método",
|
||||
plugin: "Plugin",
|
||||
pluginImpl: "Implementação",
|
||||
|
||||
@@ -382,6 +382,8 @@ export default {
|
||||
realityPublicKey: "Открытый ключ (pbk)",
|
||||
realityShortId: "Короткий идентификатор (sid)",
|
||||
realitySpiderX: "Spider X (spx)",
|
||||
realityMldsa65Verify: "Ключ проверки ML-DSA-65 (pqv)",
|
||||
vlessEncryption: "Шифрование (encryption)",
|
||||
method: "Метод",
|
||||
plugin: "Плагин",
|
||||
pluginImpl: "Реализация",
|
||||
|
||||
@@ -372,6 +372,8 @@ export default {
|
||||
realityPublicKey: "公钥(pbk)",
|
||||
realityShortId: "短 ID(sid)",
|
||||
realitySpiderX: "Spider X(spx)",
|
||||
realityMldsa65Verify: "ML-DSA-65 验证公钥(pqv)",
|
||||
vlessEncryption: "加密(encryption)",
|
||||
method: "方法",
|
||||
plugin: "插件",
|
||||
pluginImpl: "实现",
|
||||
|
||||
@@ -283,6 +283,8 @@ type RealitySettings struct {
|
||||
PublicKey string `json:"publicKey,omitempty"`
|
||||
ShortID string `json:"shortId,omitempty"`
|
||||
SpiderX string `json:"spiderX,omitempty"`
|
||||
// Mldsa65Verify is the server's ML-DSA-65 public key (share-link "pqv").
|
||||
Mldsa65Verify string `json:"mldsa65Verify,omitempty"`
|
||||
}
|
||||
type GrpcSettings struct {
|
||||
ServiceName string `json:"serviceName"`
|
||||
|
||||
@@ -292,6 +292,30 @@ func TestVlessRawTransportIsTCP(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestVlessEncryptionAndPqvReachConfigAndRoundTrip(t *testing.T) {
|
||||
enc := "mlkem768x25519plus.native.0rtt.AAAA"
|
||||
link := "vless://b831381d-6324-4d53-ad4f-8cda48b30811@1.2.3.4:443?type=tcp&security=reality&sni=example.com&pbk=key&pqv=VERIFY&fp=chrome&encryption=" + enc + "#n"
|
||||
obj, err := NewFromLink("vless", link)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c, err := obj.Configuration(PriorInfo{Tag: "t"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
vnext := c.CoreOutbound.Settings.Vnext.([]coreObj.Vnext)
|
||||
if got := vnext[0].Users[0].Encryption; got != enc {
|
||||
t.Fatalf("encryption = %q", got)
|
||||
}
|
||||
if got := c.CoreOutbound.StreamSettings.RealitySettings.Mldsa65Verify; got != "VERIFY" {
|
||||
t.Fatalf("mldsa65Verify = %q", got)
|
||||
}
|
||||
again, err := ParseVlessURL(obj.ExportToURL())
|
||||
if err != nil || again.Encryption != enc || again.Mldsa65Verify != "VERIFY" {
|
||||
t.Fatalf("round trip: %+v err=%v", again, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVmessNumericPortAndAid(t *testing.T) {
|
||||
payload := base64.StdEncoding.EncodeToString([]byte(`{"add":"1.2.3.4","aid":0,"id":"93637105-bcea-4a68-b089-1bb6091f0b16","net":"tcp","port":27467,"ps":"n","tls":"none","type":"http","v":2}`))
|
||||
obj, err := NewFromLink("vmess", "vmess://"+payload)
|
||||
|
||||
@@ -46,7 +46,9 @@ type V2Ray struct {
|
||||
PublicKey string `json:"pbk,omitempty"`
|
||||
ShortId string `json:"sid,omitempty"`
|
||||
SpiderX string `json:"spx,omitempty"`
|
||||
Flow string `json:"flow,omitempty"`
|
||||
Mldsa65Verify string `json:"pqv,omitempty"`
|
||||
Encryption string `json:"encryption,omitempty"`
|
||||
Flow string `json:"flow,omitempty"`
|
||||
Alpn string `json:"alpn,omitempty"`
|
||||
PinnedPeerCertSha256 string `json:"pinnedPeerCertSha256,omitempty"`
|
||||
VerifyPeerCertByName string `json:"verifyPeerCertByName,omitempty"`
|
||||
@@ -269,7 +271,9 @@ func ParseVlessURL(vless string) (data *V2Ray, err error) {
|
||||
PublicKey: u.Query().Get("pbk"),
|
||||
ShortId: u.Query().Get("sid"),
|
||||
SpiderX: u.Query().Get("spx"),
|
||||
Flow: u.Query().Get("flow"),
|
||||
Mldsa65Verify: u.Query().Get("pqv"),
|
||||
Encryption: u.Query().Get("encryption"),
|
||||
Flow: u.Query().Get("flow"),
|
||||
Alpn: u.Query().Get("alpn"),
|
||||
PinnedPeerCertSha256: u.Query().Get("pinnedPeerCertSha256"),
|
||||
VerifyPeerCertByName: u.Query().Get("verifyPeerCertByName"),
|
||||
@@ -547,6 +551,10 @@ func (v *V2Ray) Configuration(info PriorInfo) (c Configuration, err error) {
|
||||
if security == "" {
|
||||
security = "auto"
|
||||
}
|
||||
encryption := v.Encryption
|
||||
if encryption == "" {
|
||||
encryption = "none"
|
||||
}
|
||||
core.Settings.Vnext = []coreObj.Vnext{
|
||||
{
|
||||
Address: v.Add,
|
||||
@@ -554,7 +562,7 @@ func (v *V2Ray) Configuration(info PriorInfo) (c Configuration, err error) {
|
||||
Users: []coreObj.User{
|
||||
{
|
||||
ID: id,
|
||||
Encryption: "none",
|
||||
Encryption: encryption,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -834,6 +842,7 @@ func (v *V2Ray) Configuration(info PriorInfo) (c Configuration, err error) {
|
||||
PublicKey: v.PublicKey,
|
||||
ShortID: v.ShortId,
|
||||
SpiderX: v.SpiderX,
|
||||
Mldsa65Verify: v.Mldsa65Verify,
|
||||
}
|
||||
}
|
||||
// Flow
|
||||
@@ -944,8 +953,12 @@ func (v *V2Ray) ExportToURL() string {
|
||||
setValue(&query, "pbk", v.PublicKey)
|
||||
setValue(&query, "sid", v.ShortId)
|
||||
setValue(&query, "spx", v.SpiderX)
|
||||
setValue(&query, "pqv", v.Mldsa65Verify)
|
||||
}
|
||||
}
|
||||
if v.Encryption != "" && v.Encryption != "none" {
|
||||
setValue(&query, "encryption", v.Encryption)
|
||||
}
|
||||
|
||||
U := url.URL{
|
||||
Scheme: "vless",
|
||||
|
||||
Reference in new issue
Block a user