protocol

package
v2.21.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestCommandTCP = RequestCommand(0x01)
	RequestCommandUDP = RequestCommand(0x02)
)
View Source
const (
	// RequestOptionChunkStream indicates request payload is chunked. Each chunk consists of length, authentication and payload.
	RequestOptionChunkStream = RequestOption(0x01)

	// RequestOptionConnectionReuse indicates client side expects to reuse the connection.
	RequestOptionConnectionReuse = RequestOption(0x02)

	RequestOptionChunkMasking = RequestOption(0x04)
)
View Source
const (
	IDBytesLen = 16
)
View Source
const (
	ResponseOptionConnectionReuse = ResponseOption(0x01)
)

Variables

View Source
var (
	ErrAccountMissing     = errors.New("Account is not specified.")
	ErrNonMessageType     = errors.New("Not a protobuf message.")
	ErrUnknownAccountType = errors.New("Unknown account type.")
)
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 ContextWithUser

func ContextWithUser(ctx context.Context, user *User) 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 an user identity used for authentication.

type AlternativeOutboundConfig

type AlternativeOutboundConfig struct {
	Settings       *v2ray_core_common_serial.TypedMessage      `protobuf:"bytes,1,opt,name=settings" json:"settings,omitempty"`
	StreamSettings *v2ray_core_transport_internet.StreamConfig `protobuf:"bytes,3,opt,name=stream_settings,json=streamSettings" json:"stream_settings,omitempty"`
}

func (*AlternativeOutboundConfig) Descriptor

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

func (*AlternativeOutboundConfig) GetSettings

func (*AlternativeOutboundConfig) GetStreamSettings

func (*AlternativeOutboundConfig) ProtoMessage

func (*AlternativeOutboundConfig) ProtoMessage()

func (*AlternativeOutboundConfig) Reset

func (m *AlternativeOutboundConfig) Reset()

func (*AlternativeOutboundConfig) String

func (m *AlternativeOutboundConfig) String() string

type AlwaysValidStrategy added in v1.21.2

type AlwaysValidStrategy struct{}

func (AlwaysValidStrategy) Invalidate added in v1.21.2

func (v AlwaysValidStrategy) Invalidate()

func (AlwaysValidStrategy) IsValid added in v1.21.2

func (v AlwaysValidStrategy) IsValid() bool

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
	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 added in v1.12.7

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

func NewID

func NewID(uuid *uuid.UUID) *ID

func (*ID) Bytes

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

func (ID) CmdKey

func (v ID) CmdKey() []byte

func (*ID) Equals

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

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

func (*ID) String

func (v *ID) String() string

func (*ID) UUID

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

type IDHash

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

type RequestCommand

type RequestCommand byte

RequestCommand is a custom command in a proxy request.

type RequestHeader

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

func (*RequestHeader) Destination

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

type RequestOption

type RequestOption byte

RequestOption is the options of a request.

func (*RequestOption) Clear added in v1.17.1

func (v *RequestOption) Clear(option RequestOption)

func (RequestOption) Has added in v1.17.1

func (v RequestOption) Has(option RequestOption) bool

func (*RequestOption) Set added in v1.17.1

func (v *RequestOption) Set(option RequestOption)

type ResponseCommand

type ResponseCommand interface{}

type ResponseHeader

type ResponseHeader struct {
	Option  ResponseOption
	Command ResponseCommand
}

type ResponseOption added in v1.17.1

type ResponseOption byte

func (*ResponseOption) Clear added in v1.17.1

func (v *ResponseOption) Clear(option ResponseOption)

func (ResponseOption) Has added in v1.17.1

func (v ResponseOption) Has(option ResponseOption) bool

func (*ResponseOption) Set added in v1.17.1

func (v *ResponseOption) Set(option ResponseOption)

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 (v *RoundRobinServerPicker) PickServer() *ServerSpec

type Security

type Security byte

func NormSecurity

func NormSecurity(s Security) Security

func (Security) Is

func (v Security) Is(t SecurityType) bool

type SecurityConfig

type SecurityConfig struct {
	Type SecurityType `protobuf:"varint,1,opt,name=type,enum=v2ray.core.common.protocol.SecurityType" json:"type,omitempty"`
}

func (*SecurityConfig) AsSecurity

func (v *SecurityConfig) AsSecurity() Security

func (*SecurityConfig) Descriptor

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

func (*SecurityConfig) GetType

func (m *SecurityConfig) GetType() SecurityType

func (*SecurityConfig) ProtoMessage

func (*SecurityConfig) ProtoMessage()

func (*SecurityConfig) Reset

func (m *SecurityConfig) Reset()

func (*SecurityConfig) String

func (m *SecurityConfig) String() string

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)

func (SecurityType) String

func (x SecurityType) String() string

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) GetPort

func (m *ServerEndpoint) GetPort() uint32

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 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

func (*ServerList) AddServer added in v1.21.1

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

func (*ServerList) GetServer added in v1.21.1

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

func (*ServerList) RemoveServer added in v1.21.1

func (v *ServerList) RemoveServer(idx uint32)

Private: Visible for testing.

func (*ServerList) Size added in v1.21.1

func (v *ServerList) Size() uint32

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 ...*User) *ServerSpec

func NewServerSpecFromPB

func NewServerSpecFromPB(spec ServerEndpoint) *ServerSpec

func (*ServerSpec) AddUser added in v1.21.1

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

func (*ServerSpec) Destination added in v1.21.1

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

func (*ServerSpec) HasUser added in v1.21.1

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

func (*ServerSpec) Invalidate added in v1.21.2

func (v *ServerSpec) Invalidate()

func (*ServerSpec) IsValid added in v1.21.1

func (v *ServerSpec) IsValid() bool

func (*ServerSpec) PickUser added in v1.21.1

func (v *ServerSpec) PickUser() *User

type TimeoutValidStrategy added in v1.21.2

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

func (*TimeoutValidStrategy) Invalidate added in v1.21.2

func (v *TimeoutValidStrategy) Invalidate()

func (*TimeoutValidStrategy) IsValid added in v1.21.2

func (v *TimeoutValidStrategy) IsValid() bool

type Timestamp

type Timestamp int64

func NowTime

func NowTime() Timestamp

func (Timestamp) Bytes

func (v 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_serial.TypedMessage `protobuf:"bytes,3,opt,name=account" json:"account,omitempty"`
}

User is a generic user for all procotols.

func UserFromContext

func UserFromContext(ctx context.Context) *User

func (*User) Descriptor

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

func (*User) GetAccount

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

func (*User) GetEmail

func (m *User) GetEmail() string

func (*User) GetLevel

func (m *User) GetLevel() uint32

func (*User) GetSettings

func (v *User) GetSettings() UserSettings

func (*User) GetTypedAccount

func (v *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 {
	PayloadTimeout time.Duration
}

type UserValidator

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

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

Jump to

Keyboard shortcuts

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