protocol

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2016 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestCommandTCP = RequestCommand(0x01)
	RequestCommandUDP = RequestCommand(0x02)
)
View Source
const (
	UserLevelAdmin     = UserLevel(255)
	UserLevelUntrusted = UserLevel(0)
)
View Source
const (
	IDBytesLen = 16
)
View Source
const (
	RequestOptionChunkStream = RequestOption(0x01)
)

Variables

View Source
var (
	ErrorInvalidUser    = errors.New("Invalid user.")
	ErrorInvalidVersion = 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 {
	CryptionKey() []byte
}

type CommandSwitchAccount

type CommandSwitchAccount struct {
	Host     v2net.Address
	Port     v2net.Port
	ID       *uuid.UUID
	AlterIds serial.Uint16Literal
	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 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 RequestDecoder

type RequestDecoder interface {
	DecodeRequestHeader(io.Reader) (*RequestHeader, error)
	DecodeRequestBody(io.Reader) io.Reader
}

type RequestEncoder

type RequestEncoder interface {
	EncodeRequestHeader(*RequestHeader, io.Writer)
	EncodeRequestBody(io.Writer) io.Writer
}

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

func (this RequestOption) IsChunkStream() bool

type ResponseCommand

type ResponseCommand interface{}

type ResponseDecoder

type ResponseDecoder interface {
	DecodeResponseHeader(io.Reader) (*ResponseHeader, error)
	DecodeResponseBody(io.Reader) io.Reader
}

type ResponseEncoder

type ResponseEncoder interface {
	EncodeResponseHeader(*ResponseHeader, io.Writer)
	EncodeResponseBody(io.Writer) io.Writer
}

type ResponseHeader

type ResponseHeader struct {
	Command ResponseCommand
}

type TimedUserValidator

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

func (*TimedUserValidator) Add

func (this *TimedUserValidator) Add(user *User) error

func (*TimedUserValidator) Get

func (this *TimedUserValidator) Get(userHash []byte) (*User, Timestamp, bool)

type Timestamp

type Timestamp int64

func NowTime

func NowTime() Timestamp

func (Timestamp) Bytes

func (this Timestamp) Bytes() []byte

type TimestampGenerator

type TimestampGenerator func() Timestamp

func NewTimestampGenerator

func NewTimestampGenerator(base Timestamp, delta int) TimestampGenerator

type User

type User struct {
	ID       *ID
	AlterIDs []*ID
	Level    UserLevel
	Email    string
}

func NewUser

func NewUser(id *ID, level UserLevel, alterIdCount uint16, email string) *User

func (*User) AnyValidID

func (this *User) AnyValidID() *ID

type UserLevel

type UserLevel byte

type UserSettings

type UserSettings struct {
	PayloadReadTimeout int
}

func GetUserSettings

func GetUserSettings(level UserLevel) UserSettings

type UserValidator

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

func NewTimedUserValidator

func NewTimedUserValidator(hasher IDHash) UserValidator

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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