Merge xray support from CI-He-O/v2rayA (#1004)

* added xtls-rprx-vision & uTLS fingerprint

* removed node option openssl-legacy-provider

* removed node option openssl-legacy-provider

* update github action

* fix: vless id

---------

Co-authored-by: clheo <93776896+Cl-He-O@users.noreply.github.com>
This commit is contained in:
mzz 2023-08-02 23:54:07 +08:00 committed by GitHub
parent 87242dd219
commit 1928283842
16 changed files with 89 additions and 64 deletions

View File

@ -62,15 +62,13 @@ jobs:
cache-dependency-path: gui/yarn.lock
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
ruby-version: 3.2
bundler-cache: true
- name: Install Dependencies
run: |
sudo apt-get update -y && sudo apt-get install -y gzip
- name: Build GUI
run: |
# https://github.com/webpack/webpack/issues/14532#issuecomment-947012063
export NODE_OPTIONS=--openssl-legacy-provider
yarn --cwd gui --check-files
yarn --cwd gui build
- name: Build v2rayA Binaries
@ -131,7 +129,7 @@ jobs:
- name: Install Package Dependencies
if: startsWith(github.ref, 'refs/tags/v')
run: |
gem install fpm -v 1.13.1
gem install fpm -v 1.15.1
sudo apt-get install -y libarchive-tools rpm lintian reprepro gnupg gnupg2 expect tar nsis unzip
- name: Package
if: startsWith(github.ref, 'refs/tags/v')

View File

@ -10,7 +10,7 @@ WORKDIR /build/gui
RUN echo "network-timeout 600000" >> .yarnrc
#RUN yarn config set registry https://registry.npm.taobao.org
#RUN yarn config set sass_binary_site https://cdn.npm.taobao.org/dist/node-sass -g
RUN export NODE_OPTIONS=--openssl-legacy-provider && yarn cache clean && yarn && yarn build
RUN yarn cache clean && yarn && yarn build
FROM golang:alpine AS builder
ADD service /build/service

View File

@ -1,7 +1,7 @@
FROM node:lts-alpine AS builder
ADD gui /gui
WORKDIR /gui
RUN export NODE_OPTIONS=--openssl-legacy-provider && yarn && yarn build
RUN yarn && yarn build
FROM nginx:stable-alpine
COPY --from=builder /web /usr/share/nginx/html

View File

@ -13,7 +13,7 @@ WORKDIR /build/gui
RUN echo "network-timeout 600000" >> .yarnrc
#RUN yarn config set registry https://registry.npmmirror.com
#RUN yarn config set sass_binary_site https://cdn.npm.taobao.org/dist/node-sass -g
RUN export NODE_OPTIONS=--openssl-legacy-provider && yarn cache clean && yarn && yarn build
RUN yarn cache clean && yarn && yarn build
FROM golang:alpine AS builder
ADD service /build/service

View File

@ -69,8 +69,6 @@ Function Build-v2rayA(){
${env:CGO_ENABLED} = "0"
#Set yarn's output path
${env:OUTPUT_DIR} = "$CurrentPath/service/server/router/web"
#Fix node build error: https://github.com/webpack/webpack/issues/14532#issuecomment-947012063
${env:NODE_OPTIONS} = "--openssl-legacy-provider"
#Build Web Panel
Set-Location -Path "$CurrentPath/gui"
yarn; yarn build

View File

@ -59,6 +59,12 @@
expanded
/>
</b-field>
<b-field v-if="v2ray.protocol === 'vless'" label="Flow" label-position="on-border">
<b-select v-model="v2ray.flow" expanded>
<option value="none">none</option>
<option value="xtls-rprx-vision">xtls-rprx-vision</option>
</b-select>
</b-field>
<b-field
v-if="v2ray.protocol === 'vmess'"
label="AlterID"
@ -110,6 +116,18 @@
expanded
/>
</b-field>
<b-field
v-show="v2ray.tls === 'tls'"
label="uTLS fingerprint"
label-position="on-border"
>
<b-input
ref="v2ray_utls_fingerprint"
v-model="v2ray.utls_fingerprint"
placeholder="A uTLS compatable fingerprint name"
expanded
/>
</b-field>
<b-field
v-if="v2ray.tls === 'xtls'"
ref="v2ray_flow"
@ -810,13 +828,14 @@ export default {
add: "",
port: "",
id: "",
aid: "0",
flow: "",
aid: "",
net: "tcp",
type: "none",
host: "",
path: "",
tls: "none",
flow: "none",
utls_fingerprint: "",
alpn: "",
scy: "auto",
v: "",
@ -973,6 +992,7 @@ export default {
add: u.host,
port: u.port,
id: decodeURIComponent(u.username),
flow: u.params.flow || "",
net: u.params.type || "tcp",
type: u.params.headerType || "none",
host: u.params.host || u.params.sni || "",
@ -981,6 +1001,7 @@ export default {
flow: u.params.flow || "none",
sni: u.params.sni || "",
tls: u.params.security || "none",
utls_fingerprint: u.params.fp || "",
allowInsecure: u.params.allowInsecure || false,
protocol: "vless",
};
@ -1168,14 +1189,18 @@ export default {
// https://github.com/XTLS/Xray-core/discussions/716
query = {
type: srcObj.net,
flow: srcObj.flow,
security: srcObj.tls,
fp: srcObj.utls_fingerprint,
path: srcObj.path,
host: srcObj.host,
headerType: srcObj.type,
sni: srcObj.sni,
flow: srcObj.flow,
sni: srcObj.host,
allowInsecure: srcObj.allowInsecure,
};
if (srcObj.flow !== "none"){
query.flow = srcObj.flow;
}
if (srcObj.alpn !== "") {
query.alpn = srcObj.alpn;
}
@ -1219,9 +1244,6 @@ export default {
}
obj.path = "";
}
if (!(obj.protocol === "vless" && obj.tls === "xtls")) {
delete obj.flow;
}
return "vmess://" + Base64.encode(JSON.stringify(obj));
case "ss":
/* ss://BASE64(method:password)@server:port#name */

View File

@ -16,8 +16,6 @@ backup=("etc/default/v2raya")
build() {
cd "$srcdir/v2rayA-$pkgver/gui"
# https://github.com/webpack/webpack/issues/14532#issuecomment-947012063
export NODE_OPTIONS=--openssl-legacy-provider
yarn --check-files
OUTPUT_DIR="$srcdir/v2rayA-$pkgver/service/server/router/web" yarn build

View File

@ -125,6 +125,7 @@ type TLSSettings struct {
Alpn []string `json:"alpn,omitempty"`
PinnedPeerCertificateChainSha256 string `json:"pinnedPeerCertificateChainSha256,omitempty"`
Certificates []Certificate `json:"certificates,omitempty"`
Fingerprint string `json:"fingerprint,omitempty"`
}
type Certificate struct {
CertificateFile string `json:"certificateFile"`

View File

@ -1,10 +1,11 @@
package serverObj
import (
"github.com/v2rayA/v2rayA/core/coreObj"
"net"
"net/url"
"strconv"
"github.com/v2rayA/v2rayA/core/coreObj"
)
func init() {
@ -42,11 +43,11 @@ func NewHTTP(link string) (ServerObj, error) {
func ParseHttpURL(u string) (data *HTTP, err error) {
t, err := url.Parse(u)
if err != nil {
return nil, InvalidParameterErr
return nil, ErrInvalidParameter
}
port, err := strconv.Atoi(t.Port())
if err != nil {
return nil, InvalidParameterErr
return nil, ErrInvalidParameter
}
data = &HTTP{
Name: t.Fragment,

View File

@ -2,13 +2,14 @@ package serverObj
import (
"fmt"
"github.com/v2rayA/v2rayA/common"
"github.com/v2rayA/v2rayA/pkg/util/log"
"net"
"net/url"
"regexp"
"strconv"
"strings"
"github.com/v2rayA/v2rayA/common"
"github.com/v2rayA/v2rayA/pkg/util/log"
)
func init() {
@ -35,7 +36,7 @@ func NewPingTunnel(link string) (ServerObj, error) {
} else if strings.HasPrefix(link, "ping-tunnel://") {
return ParsePingTunnelURL2(link)
}
return nil, InvalidParameterErr
return nil, ErrInvalidParameter
}
func ParsePingTunnelURL1(u string) (data *PingTunnel, err error) {

View File

@ -2,13 +2,14 @@ package serverObj
import (
"fmt"
"net/url"
"github.com/v2rayA/v2rayA/conf"
"github.com/v2rayA/v2rayA/core/coreObj"
"github.com/v2rayA/v2rayA/core/v2ray/where"
"net/url"
)
var InvalidParameterErr = fmt.Errorf("invalid parameters")
var ErrInvalidParameter = fmt.Errorf("invalid parameters")
type ServerObj interface {
Configuration(info PriorInfo) (c Configuration, err error)

View File

@ -3,12 +3,13 @@ package serverObj
import (
"encoding/base64"
"fmt"
"github.com/v2rayA/v2rayA/common"
"github.com/v2rayA/v2rayA/core/coreObj"
"net"
"net/url"
"strconv"
"strings"
"github.com/v2rayA/v2rayA/common"
"github.com/v2rayA/v2rayA/core/coreObj"
)
func init() {
@ -101,7 +102,7 @@ func ParseSSURL(u string) (data *Shadowsocks, err error) {
v, ok = parse(t)
}
if !ok {
return nil, fmt.Errorf("%w: unrecognized ss address", InvalidParameterErr)
return nil, fmt.Errorf("%w: unrecognized ss address", ErrInvalidParameter)
}
return v, nil
}
@ -251,7 +252,7 @@ func (s *Shadowsocks) ConfigurationMT(info PriorInfo) (c Configuration, err erro
Version: "1.1",
Status: "200",
Reason: "OK",
Headers: coreObj.HTTPRespHeader {
Headers: coreObj.HTTPRespHeader{
ContentType: []string{"application/octet-stream", "video/mpeg"},
TransferEncoding: []string{"chunked"},
Connection: []string{"keep-alive"},

View File

@ -3,11 +3,12 @@ package serverObj
import (
"encoding/base64"
"fmt"
"github.com/v2rayA/v2rayA/common"
"net"
"net/url"
"strconv"
"strings"
"github.com/v2rayA/v2rayA/common"
)
func init() {
@ -102,7 +103,7 @@ func ParseSSRURL(u string) (data *ShadowsocksR, err error) {
info, ok = parse(content)
}
if !ok {
err = fmt.Errorf("%w: unrecognized ssr address", InvalidParameterErr)
err = fmt.Errorf("%w: unrecognized ssr address", ErrInvalidParameter)
return
}
return &info, nil

View File

@ -31,11 +31,11 @@ func NewSOCKS(link string) (ServerObj, error) {
func ParseSocksURL(u string) (data *SOCKS, err error) {
t, err := url.Parse(u)
if err != nil {
return nil, InvalidParameterErr
return nil, ErrInvalidParameter
}
port, err := strconv.Atoi(t.Port())
if err != nil {
return nil, InvalidParameterErr
return nil, ErrInvalidParameter
}
data = &SOCKS{
Name: t.Fragment,

View File

@ -2,12 +2,13 @@ package serverObj
import (
"fmt"
"github.com/v2rayA/v2rayA/common"
"github.com/v2rayA/v2rayA/core/coreObj"
"net"
"net/url"
"strconv"
"strings"
"github.com/v2rayA/v2rayA/common"
"github.com/v2rayA/v2rayA/core/coreObj"
)
func init() {
@ -56,7 +57,7 @@ func ParseTrojanURL(u string) (data *Trojan, err error) {
}
port, err := strconv.Atoi(t.Port())
if err != nil {
return nil, InvalidParameterErr
return nil, ErrInvalidParameter
}
data = &Trojan{
Name: t.Fragment,

View File

@ -43,6 +43,7 @@ type V2Ray struct {
SNI string `json:"sni,omitempty"`
Path string `json:"path"`
TLS string `json:"tls"`
Fingerprint string `json:"fingerprint,omitempty"`
Flow string `json:"flow,omitempty"`
Alpn string `json:"alpn,omitempty"`
AllowInsecure bool `json:"allowInsecure"`
@ -56,7 +57,7 @@ func NewV2Ray(link string) (ServerObj, error) {
} else if strings.HasPrefix(link, "vless://") {
return ParseVlessURL(link)
}
return nil, InvalidParameterErr
return nil, ErrInvalidParameter
}
func ParseVlessURL(vless string) (data *V2Ray, err error) {
@ -69,13 +70,14 @@ func ParseVlessURL(vless string) (data *V2Ray, err error) {
Add: u.Hostname(),
Port: u.Port(),
ID: u.User.String(),
Flow: u.Query().Get("flow"),
Net: u.Query().Get("type"),
Type: u.Query().Get("headerType"),
Host: u.Query().Get("host"),
SNI: u.Query().Get("sni"),
Path: u.Query().Get("path"),
TLS: u.Query().Get("security"),
Flow: u.Query().Get("flow"),
Fingerprint: u.Query().Get("fp"),
Alpn: u.Query().Get("alpn"),
AllowInsecure: u.Query().Get("allowInsecure") == "true",
Protocol: "vless",
@ -119,7 +121,7 @@ func ParseVmessURL(vmess string) (data *V2Ray, err error) {
s := strings.Split(vmess[8:], "?")[0]
s, err = common.Base64StdDecode(s)
if err != nil {
s, err = common.Base64URLDecode(s)
s, _ = common.Base64URLDecode(s)
}
subMatch := re.FindStringSubmatch(s)
if subMatch == nil {
@ -245,10 +247,9 @@ func (v *V2Ray) Configuration(info PriorInfo) (c Configuration, err error) {
Port: port,
Users: []coreObj.User{
{
Encryption: "none",
ID: id,
Level: 8,
Security: security,
Encryption: "none",
Flow: v.Flow,
},
},
},
@ -370,19 +371,21 @@ func (v *V2Ray) Configuration(info PriorInfo) (c Configuration, err error) {
}
core.StreamSettings.TLSSettings.Alpn = alpn
}
// uTLS fingerprint
core.StreamSettings.TLSSettings.Fingerprint = v.Fingerprint
} else if strings.ToLower(v.TLS) == "xtls" {
core.StreamSettings.Security = "xtls"
core.StreamSettings.XTLSSettings = &coreObj.TLSSettings{}
// SNI
if v.Host != "" {
core.StreamSettings.TLSSettings.ServerName = v.Host
}
if v.AllowInsecure {
core.StreamSettings.XTLSSettings.AllowInsecure = true
}
// SNI
if v.Host != "" {
core.StreamSettings.XTLSSettings.ServerName = v.Host
} else if v.Host != "" {
core.StreamSettings.TLSSettings.ServerName = v.Host
if v.Flow == "" {
v.Flow = "xtls-rprx-origin"
}
// Alpn
if v.Alpn != "" {
alpn := strings.Split(v.Alpn, ",")
for i := range alpn {
@ -428,12 +431,11 @@ func (v *V2Ray) ExportToURL() string {
setValue(&query, "serviceName", v.Path)
}
if v.TLS != "none" {
setValue(&query, "flow", v.Flow)
setValue(&query, "sni", v.SNI)
setValue(&query, "alpn", v.Alpn)
setValue(&query, "allowInsecure", strconv.FormatBool(v.AllowInsecure))
}
if v.TLS == "xtls" {
setValue(&query, "flow", v.Flow)
setValue(&query, "fp", v.Fingerprint)
}
U := url.URL{