protocol

package
v1.24.3 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestCommandTCP = RequestCommand(0x01)
	RequestCommandUDP = RequestCommand(0x02)
)
View Source
const (
	RequestOptionChunkStream     = RequestOption(0x01)
	RequestOptionConnectionReuse = RequestOption(0x02)
)
View Source
const (
	UserLevelAdmin     = UserLevel(255)
	UserLevelUntrusted = UserLevel(0)
)
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 (
	InvalidID = errors.New("Invalid ID.")
)

Functions

func DefaultIDHash

func DefaultIDHash(key []byte) hash.Hash

Types

type Account added in v1.11.1

type Account interface {
	Equals(Account) bool
}

type AlwaysValidStrategy added in v1.21.2

type AlwaysValidStrategy struct{}

func (AlwaysValidStrategy) Invalidate added in v1.21.2

func (this AlwaysValidStrategy) Invalidate()

func (AlwaysValidStrategy) IsValid added in v1.21.2

func (this AlwaysValidStrategy) IsValid() bool

type CommandSwitchAccount

type CommandSwitchAccount struct {
	Host     v2net.Address
	Port     v2net.Port
	ID       *uuid.UUID
	AlterIds uint16
	Level    UserLevel
	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.8

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

func (this *RequestOption) Clear(option RequestOption)

func (RequestOption) Has added in v1.17.1

func (this RequestOption) Has(option RequestOption) bool

func (*RequestOption) Set added in v1.17.1

func (this *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 (this *ResponseOption) Clear(option ResponseOption)

func (ResponseOption) Has added in v1.17.1

func (this ResponseOption) Has(option ResponseOption) bool

func (*ResponseOption) Set added in v1.17.1

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

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 (this *ServerList) AddServer(server *ServerSpec)

func (*ServerList) GetServer added in v1.21.1

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

func (*ServerList) RemoveServer added in v1.21.1

func (this *ServerList) RemoveServer(idx uint32)

@Private

func (*ServerList) Size added in v1.21.1

func (this *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 v2net.Destination, valid ValidationStrategy, users ...*User) *ServerSpec

func (*ServerSpec) AddUser added in v1.21.1

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

func (*ServerSpec) Destination added in v1.21.1

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

func (*ServerSpec) HasUser added in v1.21.1

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

func (*ServerSpec) Invalidate added in v1.21.2

func (this *ServerSpec) Invalidate()

func (*ServerSpec) IsValid added in v1.21.1

func (this *ServerSpec) IsValid() bool

func (*ServerSpec) PickUser added in v1.21.1

func (this *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 (this *TimeoutValidStrategy) Invalidate()

func (*TimeoutValidStrategy) IsValid added in v1.21.2

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 {
	Account Account
	Level   UserLevel
	Email   string
}

func NewUser

func NewUser(level UserLevel, email string) *User

type UserLevel

type UserLevel byte

type UserSettings

type UserSettings struct {
	PayloadReadTimeout int
}

func GetUserSettings

func GetUserSettings(level UserLevel) UserSettings

type UserValidator

type UserValidator interface {
	common.Releasable

	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