protocol

package
v1.260113.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MPL-2.0 Imports: 20 Imported by: 347

Documentation

Index

Constants

View Source
const (
	RequestCommandTCP = RequestCommand(0x01)
	RequestCommandUDP = RequestCommand(0x02)
	RequestCommandMux = RequestCommand(0x03)
	RequestCommandRvs = RequestCommand(0x04)
)
View Source
const (
	// [DEPRECATED 2023-06] RequestOptionChunkStream indicates request payload is chunked. Each chunk consists of length, authentication and payload.
	RequestOptionChunkStream bitmask.Byte = 0x01

	RequestOptionChunkMasking bitmask.Byte = 0x04

	RequestOptionGlobalPadding bitmask.Byte = 0x08

	RequestOptionAuthenticatedLength bitmask.Byte = 0x10
)
View Source
const (
	IDBytesLen = 16
)
View Source
const (
	ResponseOptionConnectionReuse bitmask.Byte = 0x01
)

Variables

View Source
var (
	SecurityType_name = map[int32]string{
		0: "UNKNOWN",
		2: "AUTO",
		3: "AES128_GCM",
		4: "CHACHA20_POLY1305",
		5: "NONE",
		6: "ZERO",
	}
	SecurityType_value = map[string]int32{
		"UNKNOWN":           0,
		"AUTO":              2,
		"AES128_GCM":        3,
		"CHACHA20_POLY1305": 4,
		"NONE":              5,
		"ZERO":              6,
	}
)

Enum value maps for SecurityType.

View Source
var ErrProtoNeedMoreData = errors.New("protocol matches, but need more data to complete sniffing")
View Source
var File_common_protocol_headers_proto protoreflect.FileDescriptor
View Source
var File_common_protocol_server_spec_proto protoreflect.FileDescriptor
View Source
var File_common_protocol_user_proto protoreflect.FileDescriptor
View Source
var (
	HasAESGCMHardwareSupport = hasGCMAsmAMD64 || hasGCMAsmARM64 || hasGCMAsmS390X || hasGCMAsmPPC64
)

Functions

func ContextWithRequestHeader

func ContextWithRequestHeader(ctx context.Context, request *RequestHeader) context.Context

Types

type Account

type Account interface {
	Equals(Account) bool
	ToProto() proto.Message
}

Account is a user identity used for authentication.

type AddressOption

type AddressOption func(*option)

func AddressFamilyByte

func AddressFamilyByte(b byte, f net.AddressFamily) AddressOption

func PortThenAddress

func PortThenAddress() AddressOption

func WithAddressTypeParser

func WithAddressTypeParser(atp AddressTypeParser) AddressOption

type AddressSerializer

type AddressSerializer interface {
	ReadAddressPort(buffer *buf.Buffer, input io.Reader) (net.Address, net.Port, error)

	WriteAddressPort(writer io.Writer, addr net.Address, port net.Port) error
}

func NewAddressParser

func NewAddressParser(options ...AddressOption) AddressSerializer

NewAddressParser creates a new AddressParser

type AddressType

type AddressType byte
const (
	AddressTypeIPv4   AddressType = 1
	AddressTypeDomain AddressType = 2
	AddressTypeIPv6   AddressType = 3
)

type AddressTypeParser

type AddressTypeParser func(byte) byte

type AsAccount

type AsAccount interface {
	AsAccount() (Account, error)
}

AsAccount is an object can be converted into account.

type ID

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

The ID of en entity, in the form of a UUID.

func NewID

func NewID(uuid uuid.UUID) *ID

NewID returns an ID with given UUID.

func (*ID) Bytes

func (id *ID) Bytes() []byte

func (ID) CmdKey

func (id ID) CmdKey() []byte

func (*ID) Equals

func (id *ID) Equals(another *ID) bool

Equals returns true if this ID equals to the other one.

func (*ID) String

func (id *ID) String() string

func (*ID) UUID

func (id *ID) UUID() uuid.UUID

type MemoryUser

type MemoryUser struct {
	// Account is the parsed account of the protocol.
	Account Account
	Email   string
	Level   uint32
}

MemoryUser is a parsed form of User, to reduce number of parsing of Account proto.

type RequestCommand

type RequestCommand byte

RequestCommand is a custom command in a proxy request.

func (RequestCommand) TransferType

func (c RequestCommand) TransferType() TransferType

type RequestHeader

type RequestHeader struct {
	Version  byte
	Command  RequestCommand
	Option   bitmask.Byte
	Security SecurityType
	Port     net.Port
	Address  net.Address
	User     *MemoryUser
}

func RequestHeaderFromContext

func RequestHeaderFromContext(ctx context.Context) *RequestHeader

func (*RequestHeader) Destination

func (h *RequestHeader) Destination() net.Destination

type ResponseCommand

type ResponseCommand interface{}

type ResponseHeader

type ResponseHeader struct {
	Option  bitmask.Byte
	Command ResponseCommand
}

type SecurityConfig

type SecurityConfig struct {
	Type SecurityType `protobuf:"varint,1,opt,name=type,proto3,enum=xray.common.protocol.SecurityType" json:"type,omitempty"`
	// contains filtered or unexported fields
}

func (*SecurityConfig) Descriptor deprecated

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

Deprecated: Use SecurityConfig.ProtoReflect.Descriptor instead.

func (*SecurityConfig) GetSecurityType

func (sc *SecurityConfig) GetSecurityType() SecurityType

func (*SecurityConfig) GetType

func (x *SecurityConfig) GetType() SecurityType

func (*SecurityConfig) ProtoMessage

func (*SecurityConfig) ProtoMessage()

func (*SecurityConfig) ProtoReflect

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

func (*SecurityConfig) Reset

func (x *SecurityConfig) Reset()

func (*SecurityConfig) String

func (x *SecurityConfig) String() string

type SecurityType

type SecurityType int32
const (
	SecurityType_UNKNOWN           SecurityType = 0
	SecurityType_AUTO              SecurityType = 2
	SecurityType_AES128_GCM        SecurityType = 3
	SecurityType_CHACHA20_POLY1305 SecurityType = 4
	SecurityType_NONE              SecurityType = 5 // [DEPRECATED 2023-06]
	SecurityType_ZERO              SecurityType = 6
)

func (SecurityType) Descriptor

func (SecurityType) Enum

func (x SecurityType) Enum() *SecurityType

func (SecurityType) EnumDescriptor deprecated

func (SecurityType) EnumDescriptor() ([]byte, []int)

Deprecated: Use SecurityType.Descriptor instead.

func (SecurityType) Number

func (SecurityType) String

func (x SecurityType) String() string

func (SecurityType) Type

type ServerEndpoint

type ServerEndpoint struct {
	Address *net.IPOrDomain `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
	Port    uint32          `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"`
	User    *User           `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty"`
	// contains filtered or unexported fields
}

func (*ServerEndpoint) Descriptor deprecated

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

Deprecated: Use ServerEndpoint.ProtoReflect.Descriptor instead.

func (*ServerEndpoint) GetAddress

func (x *ServerEndpoint) GetAddress() *net.IPOrDomain

func (*ServerEndpoint) GetPort

func (x *ServerEndpoint) GetPort() uint32

func (*ServerEndpoint) GetUser

func (x *ServerEndpoint) GetUser() *User

func (*ServerEndpoint) ProtoMessage

func (*ServerEndpoint) ProtoMessage()

func (*ServerEndpoint) ProtoReflect

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

func (*ServerEndpoint) Reset

func (x *ServerEndpoint) Reset()

func (*ServerEndpoint) String

func (x *ServerEndpoint) String() string

type ServerSpec

type ServerSpec struct {
	Destination net.Destination
	User        *MemoryUser
}

func NewServerSpec

func NewServerSpec(dest net.Destination, user *MemoryUser) *ServerSpec

func NewServerSpecFromPB

func NewServerSpecFromPB(spec *ServerEndpoint) (*ServerSpec, error)

type Timestamp

type Timestamp int64

func NowTime

func NowTime() Timestamp

type TimestampGenerator

type TimestampGenerator func() Timestamp

func NewTimestampGenerator

func NewTimestampGenerator(base Timestamp, delta int) TimestampGenerator

type TransferType

type TransferType byte
const (
	TransferTypeStream TransferType = 0
	TransferTypePacket TransferType = 1
)

type User

type User struct {
	Level uint32 `protobuf:"varint,1,opt,name=level,proto3" json:"level,omitempty"`
	Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
	// Protocol specific account information. Must be the account proto in one of
	// the proxies.
	Account *serial.TypedMessage `protobuf:"bytes,3,opt,name=account,proto3" json:"account,omitempty"`
	// contains filtered or unexported fields
}

User is a generic user for all protocols.

func ToProtoUser added in v1.250306.0

func ToProtoUser(mu *MemoryUser) *User

func (*User) Descriptor deprecated

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

Deprecated: Use User.ProtoReflect.Descriptor instead.

func (*User) GetAccount

func (x *User) GetAccount() *serial.TypedMessage

func (*User) GetEmail

func (x *User) GetEmail() string

func (*User) GetLevel

func (x *User) GetLevel() uint32

func (*User) GetTypedAccount

func (u *User) GetTypedAccount() (Account, error)

func (*User) ProtoMessage

func (*User) ProtoMessage()

func (*User) ProtoReflect

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

func (*User) Reset

func (x *User) Reset()

func (*User) String

func (x *User) String() string

func (*User) ToMemoryUser

func (u *User) ToMemoryUser() (*MemoryUser, error)

Directories

Path Synopsis
tls

Jump to

Keyboard shortcuts

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