vision

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: AGPL-3.0 Imports: 19 Imported by: 0

README

vision is modified from https://github.com/MetaCubeX/mihomo/tree/0e228765fce4d709af1e672426dea5294e6b7544/transport/vless/vision

Documentation

Overview

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

Index

Constants

View Source
const (
	PaddingHeaderLen = len(uuid.Nil) + 1 + 2 + 2 // =21

	BufferSize = 32 * 1024
)

Variables

View Source
var ErrNotTLS13 = errors.New("XTLS Vision based on TLS 1.3 outer connection")

Functions

func ApplyPaddingFromPool

func ApplyPaddingFromPool(p []byte, command byte, userUUID []byte, longPadding bool) (prefix, suffix pool.PB)

func IPAddrToPacketAddrLength

func IPAddrToPacketAddrLength(addr netip.AddrPort) int

func PutPacketAddr

func PutPacketAddr(src []byte, addr netip.AddrPort) error

func ReadPacketAddr

func ReadPacketAddr(p []byte) (addr netip.AddrPort, err error)

func ReshapeBytes

func ReshapeBytes(b []byte) (_ []byte, b2 []byte)

Types

type Conn

type Conn struct {
	net.Conn // underlay conn (net.Conn/net.PacketConn)
	// contains filtered or unexported fields
}

func NewConn

func NewConn(conn netproxy.Conn, userUUID []byte) (*Conn, error)

func (*Conn) FilterTLS

func (vc *Conn) FilterTLS(buffer []byte) (index int)

func (*Conn) Read

func (vc *Conn) Read(b []byte) (int, error)

func (*Conn) Write

func (vc *Conn) Write(p []byte) (int, error)

func (*Conn) WriteTo

func (vc *Conn) WriteTo(w io.Writer) (n int64, err error)

WriteTo implements io.WriterTo.

type PacketConn

type PacketConn struct {
	*Conn
	// contains filtered or unexported fields
}

func NewPacketConn

func NewPacketConn(conn netproxy.Conn, userUUID []byte, network string, addr string) (*PacketConn, error)

func (*PacketConn) Read

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

func (*PacketConn) ReadFrom

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

+-------------------+-------------------+ | Frame Length (2B) | Frame Header (4B) | +-------------------+-------------------+ |Net Type (1B) | PORT (2B) | IP Type (1B) | IP Address | +-------------------+-------------------+ | Length Data | Payload | +-------------------+-------------------+

func (*PacketConn) Write

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

func (*PacketConn) WriteTo

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

+------------------------+------------------------+ | Metadata Length (2B) | Session ID (2B) | +------------------------+------------------------+ | Type (1B) | Options (1B) | | (New=1/Keep=2) | | +------------------------+------------------------+ | Protocol Type (1B) | | +------------------------+ | | Target Address | Port | | (Variable) | | +------------------------+------------------------+ | Global ID (8B) | | | (Optional) | | +------------------------+------------------------+ | Data Length (2B) | Payload | +------------------------+------------------------+

Jump to

Keyboard shortcuts

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