protocol

package
v2.5.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2016 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package protocol is a generated protocol buffer package.

It is generated from these files:

v2ray.com/core/common/protocol/server_spec.proto
v2ray.com/core/common/protocol/user.proto

It has these top-level messages:

ServerEndpoint
User

Index

Constants

View Source
const (
	RequestCommandTCP = RequestCommand(0x01)
	RequestCommandUDP = RequestCommand(0x02)
)
View Source
const (
	RequestOptionChunkStream     = RequestOption(0x01)
	RequestOptionConnectionReuse = RequestOption(0x02)
)
View Source
const (
	IDBytesLen = 16
)
View Source
const (
	ResponseOptionConnectionReuse = ResponseOption(1)
)

Variables

View Source
var (
	ErrInvalidUser    = errors.New("Invalid user.")
	ErrInvalidVersion = errors.New("Invalid version.")
)
View Source
var (
	ErrUserMissing        = errors.New("User is not specified.")
	ErrAccountMissing     = errors.New("Account is not specified.")
	ErrNonMessageType     = errors.New("Not a protobuf message.")
	ErrUnknownAccountType = errors.New("Unknown account type.")
)
View Source
var (
	InvalidID = errors.New("Invalid ID.")
)

Functions

func DefaultIDHash

func DefaultIDHash(key []byte) hash.Hash

Types

type Account

type Account interface {
	Equals(Account) bool
}

type AlwaysValidStrategy

type AlwaysValidStrategy struct{}

func (AlwaysValidStrategy) Invalidate

func (this AlwaysValidStrategy) Invalidate()

func (AlwaysValidStrategy) IsValid

func (this AlwaysValidStrategy) IsValid() bool

type AsAccount

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

type CommandSwitchAccount

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

type ID

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

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

func NewAlterIDs

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

func NewID

func NewID(uuid *uuid.UUID) *ID

func (*ID) Bytes

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

func (ID) CmdKey

func (v ID) CmdKey() []byte

func (*ID) Equals

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

func (*ID) String

func (this *ID) String() string

func (*ID) UUID

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

type IDHash

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

type NewAccountFactory

type NewAccountFactory func() AsAccount

type RequestCommand

type RequestCommand byte

type RequestHeader

type RequestHeader struct {
	Version byte
	User    *User
	Command RequestCommand
	Option  RequestOption
	Address v2net.Address
	Port    v2net.Port
}

func (*RequestHeader) Destination

func (this *RequestHeader) Destination() v2net.Destination

type RequestOption

type RequestOption byte

func (*RequestOption) Clear

func (this *RequestOption) Clear(option RequestOption)

func (RequestOption) Has

func (this RequestOption) Has(option RequestOption) bool

func (*RequestOption) Set

func (this *RequestOption) Set(option RequestOption)

type ResponseCommand

type ResponseCommand interface{}

type ResponseHeader

type ResponseHeader struct {
	Option  ResponseOption
	Command ResponseCommand
}

type ResponseOption

type ResponseOption byte

func (*ResponseOption) Clear

func (this *ResponseOption) Clear(option ResponseOption)

func (ResponseOption) Has

func (this ResponseOption) Has(option ResponseOption) bool

func (*ResponseOption) Set

func (this *ResponseOption) Set(option ResponseOption)

type RoundRobinServerPicker

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

func NewRoundRobinServerPicker

func NewRoundRobinServerPicker(serverlist *ServerList) *RoundRobinServerPicker

func (*RoundRobinServerPicker) PickServer

func (this *RoundRobinServerPicker) PickServer() *ServerSpec

type ServerEndpoint

type ServerEndpoint struct {
	Address *v2ray_core_common_net.IPOrDomain `protobuf:"bytes,1,opt,name=address" json:"address,omitempty"`
	Port    uint32                            `protobuf:"varint,2,opt,name=port" json:"port,omitempty"`
	User    []*User                           `protobuf:"bytes,3,rep,name=user" json:"user,omitempty"`
}

func (*ServerEndpoint) Descriptor

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

func (*ServerEndpoint) GetAddress

func (*ServerEndpoint) GetUser

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

func (*ServerEndpoint) ProtoMessage

func (*ServerEndpoint) ProtoMessage()

func (*ServerEndpoint) Reset

func (m *ServerEndpoint) Reset()

func (*ServerEndpoint) String

func (m *ServerEndpoint) String() string

type ServerList

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

func NewServerList

func NewServerList() *ServerList

func (*ServerList) AddServer

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

func (*ServerList) GetServer

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

func (*ServerList) RemoveServer

func (this *ServerList) RemoveServer(idx uint32)

Private: Visible for testing.

func (*ServerList) Size

func (this *ServerList) Size() uint32

type ServerPicker

type ServerPicker interface {
	PickServer() *ServerSpec
}

type ServerSpec

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

func NewServerSpec

func NewServerSpec(dest v2net.Destination, valid ValidationStrategy, users ...*User) *ServerSpec

func NewServerSpecFromPB

func NewServerSpecFromPB(spec ServerEndpoint) *ServerSpec

func (*ServerSpec) AddUser

func (this *ServerSpec) AddUser(user *User)

func (*ServerSpec) Destination

func (this *ServerSpec) Destination() v2net.Destination

func (*ServerSpec) HasUser

func (this *ServerSpec) HasUser(user *User) bool

func (*ServerSpec) Invalidate

func (this *ServerSpec) Invalidate()

func (*ServerSpec) IsValid

func (this *ServerSpec) IsValid() bool

func (*ServerSpec) PickUser

func (this *ServerSpec) PickUser() *User

type TimeoutValidStrategy

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

func (*TimeoutValidStrategy) Invalidate

func (this *TimeoutValidStrategy) Invalidate()

func (*TimeoutValidStrategy) IsValid

func (this *TimeoutValidStrategy) IsValid() bool

type Timestamp

type Timestamp int64

func NowTime

func NowTime() Timestamp

func (Timestamp) Bytes

func (this Timestamp) Bytes(b []byte) []byte

type TimestampGenerator

type TimestampGenerator func() Timestamp

func NewTimestampGenerator

func NewTimestampGenerator(base Timestamp, delta int) TimestampGenerator

type User

type User struct {
	Level uint32 `protobuf:"varint,1,opt,name=level" json:"level,omitempty"`
	Email string `protobuf:"bytes,2,opt,name=email" json:"email,omitempty"`
	// Protocol specific account information.
	Account *v2ray_core_common_loader.TypedSettings `protobuf:"bytes,3,opt,name=account" json:"account,omitempty"`
}

func (*User) Descriptor

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

func (*User) GetAccount

func (m *User) GetAccount() *v2ray_core_common_loader.TypedSettings

func (*User) GetSettings

func (this *User) GetSettings() UserSettings

func (*User) GetTypedAccount

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

func (*User) ProtoMessage

func (*User) ProtoMessage()

func (*User) Reset

func (m *User) Reset()

func (*User) String

func (m *User) String() string

type UserSettings

type UserSettings struct {
	PayloadReadTimeout uint32
}

type UserValidator

type UserValidator interface {
	common.Releasable

	Add(user *User) error
	Get(timeHash []byte) (*User, Timestamp, bool)
}

type ValidationStrategy

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

func AlwaysValid

func AlwaysValid() ValidationStrategy

func BeforeTime

func BeforeTime(t time.Time) ValidationStrategy

Jump to

Keyboard shortcuts

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