Documentation
¶
Index ¶
- Constants
- Variables
- func ContextWithRequestHeader(ctx context.Context, request *RequestHeader) context.Context
- func DefaultIDHash(key []byte) hash.Hash
- type Account
- type AddressOption
- type AddressSerializer
- type AddressType
- type AddressTypeParser
- type AsAccount
- type CommandSwitchAccount
- type ID
- type IDHash
- type MemoryUser
- type RequestCommand
- type RequestHeader
- type ResponseCommand
- type ResponseHeader
- type RoundRobinServerPicker
- type SecurityConfig
- func (*SecurityConfig) Descriptor() ([]byte, []int)
- func (sc *SecurityConfig) GetSecurityType() SecurityType
- func (m *SecurityConfig) GetType() SecurityType
- func (*SecurityConfig) ProtoMessage()
- func (m *SecurityConfig) Reset()
- func (m *SecurityConfig) String() string
- func (m *SecurityConfig) XXX_DiscardUnknown()
- func (m *SecurityConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *SecurityConfig) XXX_Merge(src proto.Message)
- func (m *SecurityConfig) XXX_Size() int
- func (m *SecurityConfig) XXX_Unmarshal(b []byte) error
- type SecurityType
- type ServerEndpoint
- func (*ServerEndpoint) Descriptor() ([]byte, []int)
- func (m *ServerEndpoint) GetAddress() *net.IPOrDomain
- func (m *ServerEndpoint) GetPort() uint32
- func (m *ServerEndpoint) GetUser() []*User
- func (*ServerEndpoint) ProtoMessage()
- func (m *ServerEndpoint) Reset()
- func (m *ServerEndpoint) String() string
- func (m *ServerEndpoint) XXX_DiscardUnknown()
- func (m *ServerEndpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *ServerEndpoint) XXX_Merge(src proto.Message)
- func (m *ServerEndpoint) XXX_Size() int
- func (m *ServerEndpoint) XXX_Unmarshal(b []byte) error
- type ServerList
- type ServerPicker
- type ServerSpec
- type Timestamp
- type TimestampGenerator
- type TransferType
- type User
- func (*User) Descriptor() ([]byte, []int)
- func (m *User) GetAccount() *serial.TypedMessage
- func (m *User) GetEmail() string
- func (m *User) GetLevel() uint32
- func (u *User) GetTypedAccount() (Account, error)
- func (*User) ProtoMessage()
- func (m *User) Reset()
- func (m *User) String() string
- func (u *User) ToMemoryUser() (*MemoryUser, error)
- func (m *User) XXX_DiscardUnknown()
- func (m *User) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *User) XXX_Merge(src proto.Message)
- func (m *User) XXX_Size() int
- func (m *User) XXX_Unmarshal(b []byte) error
- type ValidationStrategy
Constants ¶
View Source
const (
RequestCommandTCP = RequestCommand(0x01)
RequestCommandUDP = RequestCommand(0x02)
RequestCommandMux = RequestCommand(0x03)
)
View Source
const (
// RequestOptionChunkStream indicates request payload is chunked. Each chunk consists of length, authentication and payload.
RequestOptionChunkStream bitmask.Byte = 0x01
// RequestOptionConnectionReuse indicates client side expects to reuse the connection.
RequestOptionConnectionReuse bitmask.Byte = 0x02
RequestOptionChunkMasking bitmask.Byte = 0x04
RequestOptionGlobalPadding bitmask.Byte = 0x08
)
View Source
const (
IDBytesLen = 16
)
View Source
const (
ResponseOptionConnectionReuse bitmask.Byte = 0x01
)
Variables ¶
View Source
var SecurityType_name = map[int32]string{
0: "UNKNOWN",
1: "LEGACY",
2: "AUTO",
3: "AES128_GCM",
4: "CHACHA20_POLY1305",
5: "NONE",
}
View Source
var SecurityType_value = map[string]int32{
"UNKNOWN": 0,
"LEGACY": 1,
"AUTO": 2,
"AES128_GCM": 3,
"CHACHA20_POLY1305": 4,
"NONE": 5,
}
Functions ¶
func ContextWithRequestHeader ¶
func ContextWithRequestHeader(ctx context.Context, request *RequestHeader) context.Context
func DefaultIDHash ¶
func DefaultIDHash(key []byte) hash.Hash
Types ¶
type Account ¶ added in v1.11.1
type Account interface {
Equals(Account) bool
}
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 CommandSwitchAccount ¶
type CommandSwitchAccount struct {
Host net.Address
Port net.Port
ID uuid.UUID
Level uint32
AlterIds uint16
ValidMin byte
}
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
The ID of en entity, in the form of a UUID.
func NewAlterIDs ¶ added in v1.12.7
func NewAlterIDs(primary *ID, alterIDCount uint16) []*ID
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 RoundRobinServerPicker ¶ added in v1.21.1
type RoundRobinServerPicker struct {
sync.Mutex
// contains filtered or unexported fields
}
func NewRoundRobinServerPicker ¶ added in v1.21.1
func NewRoundRobinServerPicker(serverlist *ServerList) *RoundRobinServerPicker
func (*RoundRobinServerPicker) PickServer ¶ added in v1.21.1
func (p *RoundRobinServerPicker) PickServer() *ServerSpec
type SecurityConfig ¶
type SecurityConfig struct {
Type SecurityType `protobuf:"varint,1,opt,name=type,proto3,enum=v2ray.core.common.protocol.SecurityType" json:"type,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*SecurityConfig) Descriptor ¶
func (*SecurityConfig) Descriptor() ([]byte, []int)
func (*SecurityConfig) GetSecurityType ¶
func (sc *SecurityConfig) GetSecurityType() SecurityType
func (*SecurityConfig) ProtoMessage ¶
func (*SecurityConfig) ProtoMessage()
func (*SecurityConfig) XXX_DiscardUnknown ¶
func (m *SecurityConfig) XXX_DiscardUnknown()
func (*SecurityConfig) XXX_Marshal ¶
func (m *SecurityConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*SecurityConfig) XXX_Unmarshal ¶
func (m *SecurityConfig) XXX_Unmarshal(b []byte) error
type SecurityType ¶
type SecurityType int32
const (
SecurityType_UNKNOWN SecurityType = 0
SecurityType_LEGACY SecurityType = 1
SecurityType_AUTO SecurityType = 2
SecurityType_AES128_GCM SecurityType = 3
SecurityType_CHACHA20_POLY1305 SecurityType = 4
SecurityType_NONE SecurityType = 5
)
func (SecurityType) EnumDescriptor ¶
func (SecurityType) EnumDescriptor() ([]byte, []int)
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,rep,name=user,proto3" json:"user,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*ServerEndpoint) Descriptor ¶
func (*ServerEndpoint) Descriptor() ([]byte, []int)
func (*ServerEndpoint) GetAddress ¶
func (m *ServerEndpoint) GetAddress() *net.IPOrDomain
func (*ServerEndpoint) ProtoMessage ¶
func (*ServerEndpoint) ProtoMessage()
func (*ServerEndpoint) XXX_DiscardUnknown ¶
func (m *ServerEndpoint) XXX_DiscardUnknown()
func (*ServerEndpoint) XXX_Marshal ¶
func (m *ServerEndpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*ServerEndpoint) XXX_Unmarshal ¶
func (m *ServerEndpoint) XXX_Unmarshal(b []byte) error
type ServerList ¶ added in v1.21.1
type ServerList struct {
sync.RWMutex
// contains filtered or unexported fields
}
func NewServerList ¶ added in v1.21.1
func NewServerList() *ServerList
type ServerPicker ¶ added in v1.21.1
type ServerPicker interface {
PickServer() *ServerSpec
}
type ServerSpec ¶ added in v1.21.1
type ServerSpec struct {
sync.RWMutex
// contains filtered or unexported fields
}
func NewServerSpec ¶ added in v1.21.1
func NewServerSpec(dest net.Destination, valid ValidationStrategy, users ...*MemoryUser) *ServerSpec
func NewServerSpecFromPB ¶
func NewServerSpecFromPB(spec ServerEndpoint) (*ServerSpec, error)
func (*ServerSpec) Destination ¶ added in v1.21.1
func (s *ServerSpec) Destination() net.Destination
func (*ServerSpec) Invalidate ¶ added in v1.21.2
func (s *ServerSpec) Invalidate()
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"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
User is a generic user for all procotols.
func (*User) Descriptor ¶
func (*User) Descriptor() ([]byte, []int)
func (*User) GetAccount ¶
func (m *User) GetAccount() *serial.TypedMessage
func (*User) GetTypedAccount ¶
func (u *User) GetTypedAccount() (Account, error)
func (*User) ProtoMessage ¶
func (*User) ProtoMessage()
func (*User) ToMemoryUser ¶
func (u *User) ToMemoryUser() (*MemoryUser, error)
func (*User) XXX_DiscardUnknown ¶
func (m *User) XXX_DiscardUnknown()
func (*User) XXX_Marshal ¶
func (m *User) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*User) XXX_Unmarshal ¶
func (m *User) XXX_Unmarshal(b []byte) error
type ValidationStrategy ¶ added in v1.21.2
type ValidationStrategy interface {
IsValid() bool
Invalidate()
}
func AlwaysValid ¶ added in v1.21.2
func AlwaysValid() ValidationStrategy
func BeforeTime ¶ added in v1.21.2
func BeforeTime(t time.Time) ValidationStrategy
Source Files
¶
Click to show internal directories.
Click to hide internal directories.