Documentation
¶
Overview ¶
Package proxy contains all proxies used by Xray.
To implement an inbound or outbound proxy, one needs to do the following: 1. Implement the interface(s) below. 2. Register a config creator through creator.RegisterConfig.
Package vless contains the implementation of VLess protocol and transportation.
VLess contains both inbound and outbound connections. VLess inbound is usually used on servers together with 'freedom' to talk to final destination, while VLess outbound is usually used on clients with 'socks' for proxying.
Index ¶
- Constants
- Variables
- func CopyRawConnIfExist(ctx context.Context, readerConn net.Conn, writerConn net.Conn, ...) error
- func ReshapeMultiBuffer(ctx context.Context, buffer buf.MultiBuffer) buf.MultiBuffer
- func UnwrapRawConn(conn net.Conn) (net.Conn, *atomic.Uint64, *atomic.Uint64)
- func WithInbound(ctx context.Context, ib *InboundInfo) context.Context
- func WithOutbounds(ctx context.Context, ob []*OutboundInfo) context.Context
- func XtlsFilterTls(buffer buf.MultiBuffer, trafficState *TrafficState, ctx context.Context)
- func XtlsPadding(b *buf.Buffer, command byte, userUUID *[]byte, longPadding bool, ...) *buf.Buffer
- func XtlsUnpadding(b *buf.Buffer, s *TrafficState, ctx context.Context) *buf.Buffer
- type InboundInfo
- type MemoryAccount
- type OutboundInfo
- type TrafficState
- type VisionReader
- type VisionWriter
Constants ¶
const ( TlsHandshakeTypeClientHello byte = 0x01 TlsHandshakeTypeServerHello byte = 0x02 CommandPaddingContinue byte = 0x00 CommandPaddingEnd byte = 0x01 CommandPaddingDirect byte = 0x02 )
const (
XRV = "xtls-rprx-vision"
)
Variables ¶
var ( Tls13SupportedVersions = []byte{0x00, 0x2b, 0x00, 0x02, 0x03, 0x04} TlsClientHandShakeStart = []byte{0x16, 0x03} TlsServerHandShakeStart = []byte{0x16, 0x03, 0x03} TlsApplicationDataStart = []byte{0x17, 0x03, 0x03} Tls13CipherSuiteDic = map[uint16]string{ 0x1301: "TLS_AES_128_GCM_SHA256", 0x1302: "TLS_AES_256_GCM_SHA384", 0x1303: "TLS_CHACHA20_POLY1305_SHA256", 0x1304: "TLS_AES_128_CCM_SHA256", 0x1305: "TLS_AES_128_CCM_8_SHA256", } )
var ContextKeyInbound = 0
var ContextKeyOutbound = 1
Functions ¶
func CopyRawConnIfExist ¶
func CopyRawConnIfExist(ctx context.Context, readerConn net.Conn, writerConn net.Conn, writer buf.Writer, timer *signal.ActivityChecker, inTimer *signal.ActivityChecker) error
CopyRawConnIfExist use the most efficient copy method. - If caller don't want to turn on splice, do not pass in both reader conn and writer conn - writer are from *transport.Link
func ReshapeMultiBuffer ¶
func ReshapeMultiBuffer(ctx context.Context, buffer buf.MultiBuffer) buf.MultiBuffer
ReshapeMultiBuffer prepare multi buffer for padding structure (max 21 bytes)
func UnwrapRawConn ¶
UnwrapRawConn support unwrap stats, tls, utls, reality and proxyproto conn and get raw tcp conn from it
func WithInbound ¶
func WithInbound(ctx context.Context, ib *InboundInfo) context.Context
func WithOutbounds ¶
func WithOutbounds(ctx context.Context, ob []*OutboundInfo) context.Context
func XtlsFilterTls ¶
func XtlsFilterTls(buffer buf.MultiBuffer, trafficState *TrafficState, ctx context.Context)
XtlsFilterTls filter and recognize tls 1.3 and other Debug
func XtlsPadding ¶
func XtlsPadding(b *buf.Buffer, command byte, userUUID *[]byte, longPadding bool, ctx context.Context) *buf.Buffer
XtlsPadding add padding to eliminate length signature during tls handshake
func XtlsUnpadding ¶
XtlsUnpadding remove padding and parse command
Types ¶
type InboundInfo ¶
type InboundInfo struct {
CanSpliceCopy int
Conn net.Conn
Timer *signal.ActivityChecker
UpCounter session.UpCounters
DownCounter session.DownCounters
}
func InboundFromContext ¶
func InboundFromContext(ctx context.Context) *InboundInfo
type MemoryAccount ¶
type MemoryAccount struct {
Uid string
// ID of the account.
ID *protocol.ID
// Flow of the account. May be "xtls-rprx-vision".
Flow string
// Encryption of the account. Used for client connections, and only accepts "none" for now.
Encryption string
}
MemoryAccount is an in-memory form of VLess account.
type OutboundInfo ¶
type OutboundInfo struct {
Target net.Destination
// 1 yes, 2 maybe, we'll see, 3 no
CanSpliceCopy int
}
func OutboundsFromContext ¶
func OutboundsFromContext(ctx context.Context) []*OutboundInfo
type TrafficState ¶
type TrafficState struct {
UserUUID []byte
NumberOfPacketToFilter int
EnableXtls bool
IsTLS12orAbove bool
IsTLS bool
Cipher uint16
RemainingServerHello int32
// reader link state
WithinPaddingBuffers bool
ReaderSwitchToDirectCopy bool
RemainingCommand int32
RemainingContent int32
RemainingPadding int32
CurrentCommand int
// write link state
IsPadding bool
WriterSwitchToDirectCopy bool
}
TrafficState is used to track uplink and downlink of one connection It is used by XTLS to determine if switch to raw copy mode, It is used by Vision to calculate padding
func NewTrafficState ¶
func NewTrafficState(userUUID []byte) *TrafficState
type VisionReader ¶
VisionReader is used to read xtls vision protocol Note Vision probably only make sense as the inner most layer of reader, since it need assess traffic state from origin proxy traffic
func NewVisionReader ¶
func NewVisionReader(reader buf.Reader, state *TrafficState, context context.Context) *VisionReader
func (*VisionReader) ReadMultiBuffer ¶
func (w *VisionReader) ReadMultiBuffer() (buf.MultiBuffer, error)
The buffer read out does not contain a complete record and a incomplete record. It either contains a complete record or an incomplete record
type VisionWriter ¶
VisionWriter is used to write xtls vision protocol Note Vision probably only make sense as the inner most layer of writer, since it need assess traffic state from origin proxy traffic
func NewVisionWriter ¶
func NewVisionWriter(writer buf.Writer, state *TrafficState, context context.Context) *VisionWriter
func (*VisionWriter) WriteMultiBuffer ¶
func (w *VisionWriter) WriteMultiBuffer(mb buf.MultiBuffer) error