core: v2ray.com/core/common/protocol Index | Files | Directories

package protocol

import "v2ray.com/core/common/protocol"

Index

Package Files

account.go address.go context.go errors.generated.go headers.go headers.pb.go id.go payload.go protocol.go server_picker.go server_spec.go server_spec.pb.go time.go user.go user.pb.go

Constants

const (
    RequestCommandTCP = RequestCommand(0x01)
    RequestCommandUDP = RequestCommand(0x02)
    RequestCommandMux = RequestCommand(0x03)
)
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
)
const (
    IDBytesLen = 16
)
const (
    ResponseOptionConnectionReuse bitmask.Byte = 0x01
)

Variables

var SecurityType_name = map[int32]string{
    0:  "UNKNOWN",
    1:  "LEGACY",
    2:  "AUTO",
    3:  "AES128_GCM",
    4:  "CHACHA20_POLY1305",
    5:  "NONE",
}
var SecurityType_value = map[string]int32{
    "UNKNOWN":           0,
    "LEGACY":            1,
    "AUTO":              2,
    "AES128_GCM":        3,
    "CHACHA20_POLY1305": 4,
    "NONE":              5,
}

func ContextWithRequestHeader Uses

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

func DefaultIDHash Uses

func DefaultIDHash(key []byte) hash.Hash

type Account Uses

type Account interface {
    Equals(Account) bool
}

Account is a user identity used for authentication.

type AddressOption Uses

type AddressOption func(*option)

func AddressFamilyByte Uses

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

func PortThenAddress Uses

func PortThenAddress() AddressOption

func WithAddressTypeParser Uses

func WithAddressTypeParser(atp AddressTypeParser) AddressOption

type AddressSerializer Uses

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 Uses

func NewAddressParser(options ...AddressOption) AddressSerializer

NewAddressParser creates a new AddressParser

type AddressType Uses

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

type AddressTypeParser Uses

type AddressTypeParser func(byte) byte

type AsAccount Uses

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

AsAccount is an object can be converted into account.

type CommandSwitchAccount Uses

type CommandSwitchAccount struct {
    Host     net.Address
    Port     net.Port
    ID       uuid.UUID
    Level    uint32
    AlterIds uint16
    ValidMin byte
}

type ID Uses

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

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

func NewAlterIDs Uses

func NewAlterIDs(primary *ID, alterIDCount uint16) []*ID

func NewID Uses

func NewID(uuid uuid.UUID) *ID

NewID returns an ID with given UUID.

func (*ID) Bytes Uses

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

func (ID) CmdKey Uses

func (id ID) CmdKey() []byte

func (*ID) Equals Uses

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

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

func (*ID) String Uses

func (id *ID) String() string

func (*ID) UUID Uses

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

type IDHash Uses

type IDHash func(key []byte) hash.Hash

type MemoryUser Uses

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 Uses

type RequestCommand byte

RequestCommand is a custom command in a proxy request.

func (RequestCommand) TransferType Uses

func (c RequestCommand) TransferType() TransferType

type RequestHeader Uses

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

func RequestHeaderFromContext Uses

func RequestHeaderFromContext(ctx context.Context) *RequestHeader

func (*RequestHeader) Destination Uses

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

type ResponseCommand Uses

type ResponseCommand interface{}

type ResponseHeader Uses

type ResponseHeader struct {
    Option  bitmask.Byte
    Command ResponseCommand
}

type RoundRobinServerPicker Uses

type RoundRobinServerPicker struct {
    sync.Mutex
    // contains filtered or unexported fields
}

func NewRoundRobinServerPicker Uses

func NewRoundRobinServerPicker(serverlist *ServerList) *RoundRobinServerPicker

func (*RoundRobinServerPicker) PickServer Uses

func (p *RoundRobinServerPicker) PickServer() *ServerSpec

type SecurityConfig Uses

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 Uses

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

func (*SecurityConfig) GetSecurityType Uses

func (sc *SecurityConfig) GetSecurityType() SecurityType

func (*SecurityConfig) GetType Uses

func (m *SecurityConfig) GetType() SecurityType

func (*SecurityConfig) ProtoMessage Uses

func (*SecurityConfig) ProtoMessage()

func (*SecurityConfig) Reset Uses

func (m *SecurityConfig) Reset()

func (*SecurityConfig) String Uses

func (m *SecurityConfig) String() string

func (*SecurityConfig) XXX_DiscardUnknown Uses

func (m *SecurityConfig) XXX_DiscardUnknown()

func (*SecurityConfig) XXX_Marshal Uses

func (m *SecurityConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SecurityConfig) XXX_Merge Uses

func (m *SecurityConfig) XXX_Merge(src proto.Message)

func (*SecurityConfig) XXX_Size Uses

func (m *SecurityConfig) XXX_Size() int

func (*SecurityConfig) XXX_Unmarshal Uses

func (m *SecurityConfig) XXX_Unmarshal(b []byte) error

type SecurityType Uses

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 Uses

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

func (SecurityType) String Uses

func (x SecurityType) String() string

type ServerEndpoint Uses

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 Uses

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

func (*ServerEndpoint) GetAddress Uses

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

func (*ServerEndpoint) GetPort Uses

func (m *ServerEndpoint) GetPort() uint32

func (*ServerEndpoint) GetUser Uses

func (m *ServerEndpoint) GetUser() []*User

func (*ServerEndpoint) ProtoMessage Uses

func (*ServerEndpoint) ProtoMessage()

func (*ServerEndpoint) Reset Uses

func (m *ServerEndpoint) Reset()

func (*ServerEndpoint) String Uses

func (m *ServerEndpoint) String() string

func (*ServerEndpoint) XXX_DiscardUnknown Uses

func (m *ServerEndpoint) XXX_DiscardUnknown()

func (*ServerEndpoint) XXX_Marshal Uses

func (m *ServerEndpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ServerEndpoint) XXX_Merge Uses

func (m *ServerEndpoint) XXX_Merge(src proto.Message)

func (*ServerEndpoint) XXX_Size Uses

func (m *ServerEndpoint) XXX_Size() int

func (*ServerEndpoint) XXX_Unmarshal Uses

func (m *ServerEndpoint) XXX_Unmarshal(b []byte) error

type ServerList Uses

type ServerList struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

func NewServerList Uses

func NewServerList() *ServerList

func (*ServerList) AddServer Uses

func (sl *ServerList) AddServer(server *ServerSpec)

func (*ServerList) GetServer Uses

func (sl *ServerList) GetServer(idx uint32) *ServerSpec

func (*ServerList) Size Uses

func (sl *ServerList) Size() uint32

type ServerPicker Uses

type ServerPicker interface {
    PickServer() *ServerSpec
}

type ServerSpec Uses

type ServerSpec struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

func NewServerSpec Uses

func NewServerSpec(dest net.Destination, valid ValidationStrategy, users ...*MemoryUser) *ServerSpec

func NewServerSpecFromPB Uses

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

func (*ServerSpec) AddUser Uses

func (s *ServerSpec) AddUser(user *MemoryUser)

func (*ServerSpec) Destination Uses

func (s *ServerSpec) Destination() net.Destination

func (*ServerSpec) HasUser Uses

func (s *ServerSpec) HasUser(user *MemoryUser) bool

func (*ServerSpec) Invalidate Uses

func (s *ServerSpec) Invalidate()

func (*ServerSpec) IsValid Uses

func (s *ServerSpec) IsValid() bool

func (*ServerSpec) PickUser Uses

func (s *ServerSpec) PickUser() *MemoryUser

type Timestamp Uses

type Timestamp int64

func NowTime Uses

func NowTime() Timestamp

type TimestampGenerator Uses

type TimestampGenerator func() Timestamp

func NewTimestampGenerator Uses

func NewTimestampGenerator(base Timestamp, delta int) TimestampGenerator

type TransferType Uses

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

type User Uses

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 Uses

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

func (*User) GetAccount Uses

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

func (*User) GetEmail Uses

func (m *User) GetEmail() string

func (*User) GetLevel Uses

func (m *User) GetLevel() uint32

func (*User) GetTypedAccount Uses

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

func (*User) ProtoMessage Uses

func (*User) ProtoMessage()

func (*User) Reset Uses

func (m *User) Reset()

func (*User) String Uses

func (m *User) String() string

func (*User) ToMemoryUser Uses

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

func (*User) XXX_DiscardUnknown Uses

func (m *User) XXX_DiscardUnknown()

func (*User) XXX_Marshal Uses

func (m *User) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*User) XXX_Merge Uses

func (m *User) XXX_Merge(src proto.Message)

func (*User) XXX_Size Uses

func (m *User) XXX_Size() int

func (*User) XXX_Unmarshal Uses

func (m *User) XXX_Unmarshal(b []byte) error

type ValidationStrategy Uses

type ValidationStrategy interface {
    IsValid() bool
    Invalidate()
}

func AlwaysValid Uses

func AlwaysValid() ValidationStrategy

func BeforeTime Uses

func BeforeTime(t time.Time) ValidationStrategy

Directories

PathSynopsis
bittorrent
dns
http
tls
tls/cert
udp

Package protocol imports 19 packages (graph) and is imported by 67 packages. Updated 2019-03-13. Refresh now. Tools for package owners.