Feature: add xtls support for VLESS

This commit is contained in:
yaling888
2021-07-06 23:55:34 +08:00
parent 56dff65149
commit b4d93c4438
11 changed files with 567 additions and 193 deletions

View File

@ -6,7 +6,13 @@ import (
"github.com/gofrs/uuid"
)
const Version byte = 0 // protocol version. preview version is 0
const (
XRO = "xtls-rprx-origin"
XRD = "xtls-rprx-direct"
XRS = "xtls-rprx-splice"
Version byte = 0 // protocol version. preview version is 0
)
// Command types
const (
@ -40,22 +46,26 @@ type Config struct {
// Client is vless connection generator
type Client struct {
uuid *uuid.UUID
uuid *uuid.UUID
Addons *Addons
XTLSShow bool
}
// StreamConn return a Conn with net.Conn and DstAddr
func (c *Client) StreamConn(conn net.Conn, dst *DstAddr) (net.Conn, error) {
return newConn(conn, c.uuid, dst)
return newConn(conn, c, dst)
}
// NewClient return Client instance
func NewClient(uuidStr string) (*Client, error) {
func NewClient(uuidStr string, addons *Addons, xtlsShow bool) (*Client, error) {
uid, err := uuid.FromString(uuidStr)
if err != nil {
return nil, err
}
return &Client{
uuid: &uid,
uuid: &uid,
Addons: addons,
XTLSShow: xtlsShow,
}, nil
}