packet

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ping = "i"
	Pong = "o"
	ID   = "id"
)

Variables

This section is empty.

Functions

func GetCommand

func GetCommand(packet []byte) (string, error)

func GetCommandIgnoreError

func GetCommandIgnoreError(packet []byte) string

Types

type IDPayload

type IDPayload struct {
	ID uint32 `json:"i"`
}

type Packet

type Packet struct {
	Command   string          `json:"c,omitempty"`
	Payload   json.RawMessage `json:"p,omitempty"`
	Signature []byte          `json:"s,omitempty"`
}

func From

func From(packet []byte) (*Packet, error)

func FromIgnoreError

func FromIgnoreError(packet []byte) *Packet

func FromNew

func FromNew(pk *Packet, err error) *Packet

func New

func New(command string, payload any, key *rsa.PrivateKey) (*Packet, error)

func NewID

func NewID(id uint32, key *rsa.PrivateKey) (*Packet, error)

func NewPing

func NewPing() *Packet

func NewPong

func NewPong() *Packet

func (*Packet) GetCommand

func (p *Packet) GetCommand() string

func (*Packet) GetPayload

func (p *Packet) GetPayload(v any) error

GetPayload parameter v must be a pointer to the payload object type

func (*Packet) Sign

func (p *Packet) Sign(key *rsa.PrivateKey) error

func (*Packet) ToBytes

func (p *Packet) ToBytes() ([]byte, error)

func (*Packet) ToBytesIgnoreError

func (p *Packet) ToBytesIgnoreError() []byte

func (*Packet) Valid

func (p *Packet) Valid(key *rsa.PublicKey) bool

func (*Packet) Verify

func (p *Packet) Verify(key *rsa.PublicKey) error

Jump to

Keyboard shortcuts

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