vless

package
v0.3.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2025 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version          = 0  // VLESS 协议版本
	AddonDataLenByte = 1  // 附加数据长度字节
	ReservedByte     = 1  // 保留字节
	UUIDBytes        = 16 // UUID 字节长度
	CmdTCP           = 1  // TCP 命令
	CmdUDP           = 2  // UDP 命令
	CmdMux           = 3  // 多路复用命令
)

VLESS 协议常量

View Source
const (
	AtypIPv4       = 1 // IPv4 地址类型
	AtypDomainName = 2 // 域名地址类型
	AtypIPv6       = 3 // IPv6 地址类型
)

地址类型常量,兼容 Xray-core

View Source
const (
	XRV = "xtls-rprx-vision"
	// 添加更多 Xray-core 兼容的流控制选项
	FlowVisionReality = "xtls-rprx-vision-udp443"
	FlowOrigin        = "xtls-rprx-origin"
	FlowOriginUDP443  = "xtls-rprx-origin-udp443"
	FlowDirect        = "xtls-rprx-direct"
	FlowDirectUDP443  = "xtls-rprx-direct-udp443"
	FlowSplice        = "xtls-rprx-splice"
	FlowSpliceUDP443  = "xtls-rprx-splice-udp443"
	// 额外的流控制类型(Xray-core 支持的)
	FlowVisionRealityTCP = "xtls-rprx-vision-tcp443"

	// 支持的加密模式
	// EncryptionNone 定义在 types.go,避免重复声明
	EncryptionMLKEM768X25519Plus = "mlkem768x25519plus.native.0rtt"

	// 传输类型
	TransportXHTTP = "xhttp"
)
View Source
const (
	UserLevelDefault = 0
	UserLevelVIP     = 1
)

支持的用户级别常量

View Source
const (
	EncryptionNone = "none"
)

支持的加密方式常量

Variables

View Source
var (
	FailAuthErr = fmt.Errorf("incorrect UUID")
)
View Source
var File_transport_vless_config_proto protoreflect.FileDescriptor

Functions

func CompleteMetadataFromReader

func CompleteMetadataFromReader(m *Metadata, first4 []byte, r io.Reader) (err error)

func NewDialer

func NewDialer(nextDialer netproxy.Dialer, header protocol.Header) (netproxy.Dialer, error)

func ParseNfsPKeysCSVBase64 added in v0.3.1

func ParseNfsPKeysCSVBase64(csv string) ([][]byte, error)

ParseNfsPKeysCSVBase64 解析以逗号分隔的 base64url 键列表 每个元素应为单个公钥(X25519 32 字节或 ML-KEM768 1088 字节)的 base64url 表示

func Password2Key

func Password2Key(password string) (id []byte, err error)

Types

type Addons

type Addons struct {
	Flow string `protobuf:"bytes,1,opt,name=Flow,proto3" json:"Flow,omitempty"`
	Seed []byte `protobuf:"bytes,2,opt,name=Seed,proto3" json:"Seed,omitempty"`
	// contains filtered or unexported fields
}

func (*Addons) Descriptor deprecated

func (*Addons) Descriptor() ([]byte, []int)

Deprecated: Use Addons.ProtoReflect.Descriptor instead.

func (*Addons) GetFlow

func (x *Addons) GetFlow() string

func (*Addons) GetSeed

func (x *Addons) GetSeed() []byte

func (*Addons) ProtoMessage

func (*Addons) ProtoMessage()

func (*Addons) ProtoReflect

func (x *Addons) ProtoReflect() protoreflect.Message

func (*Addons) Reset

func (x *Addons) Reset()

func (*Addons) String

func (x *Addons) String() string

type Conn

type Conn struct {
	netproxy.Conn
	// contains filtered or unexported fields
}

func NewConn

func NewConn(conn netproxy.Conn, metadata Metadata, cmdKey []byte) (c *Conn, err error)

func (*Conn) IntrinsicConn

func (c *Conn) IntrinsicConn() netproxy.Conn

func (*Conn) Read

func (c *Conn) Read(b []byte) (n int, err error)

func (*Conn) ReadFrom

func (c *Conn) ReadFrom(p []byte) (n int, addr netip.AddrPort, err error)

func (*Conn) ReadReqHeader

func (c *Conn) ReadReqHeader() (err error)

func (*Conn) ReadRespHeader

func (c *Conn) ReadRespHeader() (err error)

func (*Conn) Write

func (c *Conn) Write(b []byte) (n int, err error)

func (*Conn) WriteTo

func (c *Conn) WriteTo(p []byte, addr string) (n int, err error)

type Dialer

type Dialer struct {
	// contains filtered or unexported fields
}

func (*Dialer) DialContext

func (d *Dialer) DialContext(ctx context.Context, network string, addr string) (c netproxy.Conn, err error)

func (*Dialer) DialTcp

func (d *Dialer) DialTcp(ctx context.Context, addr string) (c netproxy.Conn, err error)

func (*Dialer) DialUdp

func (d *Dialer) DialUdp(ctx context.Context, addr string) (c netproxy.PacketConn, err error)

type Fallback

type Fallback struct {
	Name string // 回退名称
	Alpn string // ALPN 协议标识
	Path string // 路径匹配
	Dest string // 回退目标地址
	Xver uint32 // PROXY protocol 版本
}

Fallback 定义 VLESS 协议的回退机制,兼容 Xray-core

type FallbackConn

type FallbackConn struct {
	netproxy.Conn
	// contains filtered or unexported fields
}

FallbackConn 包装回退连接

func (*FallbackConn) Close

func (fc *FallbackConn) Close() error

Close 关闭回退连接

func (*FallbackConn) GetFallbackInfo

func (fc *FallbackConn) GetFallbackInfo() *Fallback

GetFallbackInfo 获取回退信息

func (*FallbackConn) Read

func (fc *FallbackConn) Read(b []byte) (n int, err error)

Read 从回退连接读取数据

func (*FallbackConn) Write

func (fc *FallbackConn) Write(b []byte) (n int, err error)

Write 向回退连接写入数据

type FallbackManager

type FallbackManager struct {
	// contains filtered or unexported fields
}

FallbackManager 管理 VLESS 协议的回退机制

func NewFallbackManager

func NewFallbackManager(fallbacks []Fallback) *FallbackManager

NewFallbackManager 创建新的回退管理器

func (*FallbackManager) HandleFallback

func (fm *FallbackManager) HandleFallback(conn netproxy.Conn, alpn, path string) (netproxy.Conn, error)

HandleFallback 处理回退连接

func (*FallbackManager) SelectFallback

func (fm *FallbackManager) SelectFallback(alpn, path string) (*Fallback, error)

SelectFallback 根据连接信息选择合适的回退配置

type Metadata

type Metadata struct {
	vmess.Metadata
	Flow       string
	Mux        bool
	Encryption string // 加密方式
	Level      uint32 // 用户级别
}

type NfsKeyCache added in v0.3.1

type NfsKeyCache struct {
	// contains filtered or unexported fields
}

NfsKeyCache 提供基于目标地址的服务端 NFS 公钥链缓存

func (*NfsKeyCache) Get added in v0.3.1

func (c *NfsKeyCache) Get(server string) ([][]byte, bool)

func (*NfsKeyCache) Set added in v0.3.1

func (c *NfsKeyCache) Set(server string, keys [][]byte)

type VlessConfig

type VlessConfig struct {
	VNext []VlessServerConfig // 服务器列表
}

VlessConfig 定义完整的 VLESS 配置结构

type VlessServerConfig

type VlessServerConfig struct {
	Address string      // 服务器地址
	Port    uint32      // 服务器端口
	Users   []VlessUser // 用户列表
}

VlessServerConfig 定义 VLESS 服务器配置

type VlessSettings

type VlessSettings struct {
	Decryption string     // 解密方式
	Fallbacks  []Fallback // 回退配置列表
}

VlessSettings 定义 VLESS 协议设置

type VlessUser

type VlessUser struct {
	ID         string // 用户 UUID
	Flow       string // 流控制类型
	Encryption string // 加密方式 (对于 VLESS 通常是 "none")
	Level      uint32 // 用户级别
}

VlessUser 定义 VLESS 用户配置,兼容 Xray-core

Directories

Path Synopsis
Package vision implements VLESS flow `xtls-rprx-vision` introduced by Xray-core.
Package vision implements VLESS flow `xtls-rprx-vision` introduced by Xray-core.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL