chore: Remove legacy XTLS support (#645)

* chore: Remove legacy XTLS support

* chore: Rename function
This commit is contained in:
Hellojack
2023-07-16 23:26:07 +08:00
committed by GitHub
parent cbb8ef5dfe
commit a82745f544
10 changed files with 55 additions and 264 deletions

View File

@ -3,7 +3,6 @@ package vless
import (
"encoding/binary"
"errors"
"fmt"
"io"
"net"
"sync"
@ -13,7 +12,6 @@ import (
"github.com/Dreamacro/clash/transport/vless/vision"
"github.com/gofrs/uuid/v5"
xtls "github.com/xtls/go"
"google.golang.org/protobuf/proto"
)
@ -201,25 +199,6 @@ func newConn(conn net.Conn, client *Client, dst *DstAddr) (net.Conn, error) {
if client.Addons != nil {
switch client.Addons.Flow {
case XRO, XRD, XRS:
if !dst.UDP {
if xtlsConn, ok := conn.(*xtls.Conn); ok {
xtlsConn.RPRX = true
xtlsConn.SHOW = client.XTLSShow
xtlsConn.MARK = "XTLS"
if client.Addons.Flow == XRS {
client.Addons.Flow = XRD
}
if client.Addons.Flow == XRD {
xtlsConn.DirectMode = true
}
c.addons = client.Addons
} else {
return nil, fmt.Errorf("failed to use %s, maybe \"security\" is not \"xtls\"", client.Addons.Flow)
}
}
case XRV:
visionConn, err := vision.NewConn(c, c.id)
if err != nil {

View File

@ -42,9 +42,8 @@ type DstAddr struct {
// Client is vless connection generator
type Client struct {
uuid *uuid.UUID
Addons *Addons
XTLSShow bool
uuid *uuid.UUID
Addons *Addons
}
// StreamConn return a Conn with net.Conn and DstAddr
@ -53,15 +52,14 @@ func (c *Client) StreamConn(conn net.Conn, dst *DstAddr) (net.Conn, error) {
}
// NewClient return Client instance
func NewClient(uuidStr string, addons *Addons, xtlsShow bool) (*Client, error) {
func NewClient(uuidStr string, addons *Addons) (*Client, error) {
uid, err := utils.UUIDMap(uuidStr)
if err != nil {
return nil, err
}
return &Client{
uuid: &uid,
Addons: addons,
XTLSShow: xtlsShow,
uuid: &uid,
Addons: addons,
}, nil
}

View File

@ -1,37 +0,0 @@
package vless
import (
"context"
"net"
tlsC "github.com/Dreamacro/clash/component/tls"
xtls "github.com/xtls/go"
)
type XTLSConfig struct {
Host string
SkipCertVerify bool
Fingerprint string
NextProtos []string
}
func StreamXTLSConn(ctx context.Context, conn net.Conn, cfg *XTLSConfig) (net.Conn, error) {
xtlsConfig := &xtls.Config{
ServerName: cfg.Host,
InsecureSkipVerify: cfg.SkipCertVerify,
NextProtos: cfg.NextProtos,
}
if len(cfg.Fingerprint) == 0 {
xtlsConfig = tlsC.GetGlobalXTLSConfig(xtlsConfig)
} else {
var err error
if xtlsConfig, err = tlsC.GetSpecifiedFingerprintXTLSConfig(xtlsConfig, cfg.Fingerprint); err != nil {
return nil, err
}
}
xtlsConn := xtls.Client(conn, xtlsConfig)
err := xtlsConn.HandshakeContext(ctx)
return xtlsConn, err
}