header

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Version uint8 = 1
	Len           = 16
)

Variables

View Source
var ErrHeaderTooShort = errors.New("header is too short")

Functions

func Encode

func Encode(b []byte, v uint8, t MessageType, st MessageSubType, ri uint32, c uint64) []byte

Encode uses the provided byte array to encode the provided header values into. Byte array must be capped higher than HeaderLen or this will panic

func SubTypeName

func SubTypeName(t MessageType, s MessageSubType) string

SubTypeName will transform a nebula message sub type into a human string

func TypeName

func TypeName(t MessageType) string

TypeName will transform a nebula message type into a human string

Types

type H

type H struct {
	Version        uint8
	Type           MessageType
	Subtype        MessageSubType
	Reserved       uint16
	RemoteIndex    uint32
	MessageCounter uint64
}

func NewHeader

func NewHeader(b []byte) (*H, error)

NewHeader turns bytes into a header

func (*H) Encode

func (h *H) Encode(b []byte) ([]byte, error)

Encode turns header into bytes

func (*H) MarshalJSON

func (h *H) MarshalJSON() ([]byte, error)

MarshalJSON creates a json string representation of a header

func (*H) Parse

func (h *H) Parse(b []byte) error

Parse is a helper function to parses given bytes into new Header struct

func (*H) String

func (h *H) String() string

String creates a readable string representation of a header

func (*H) SubTypeName

func (h *H) SubTypeName() string

SubTypeName will transform the headers message sub type into a human string

func (*H) TypeName

func (h *H) TypeName() string

TypeName will transform the headers message type into a human string

type MessageSubType

type MessageSubType uint8
const (
	MessageNone  MessageSubType = 0
	MessageRelay MessageSubType = 1
)
const (
	TestRequest MessageSubType = 0
	TestReply   MessageSubType = 1
)
const (
	HandshakeIXPSK0 MessageSubType = 0
	HandshakeXXPSK0 MessageSubType = 1
)

type MessageType

type MessageType uint8
const (
	Handshake   MessageType = 0
	Message     MessageType = 1
	RecvError   MessageType = 2
	LightHouse  MessageType = 3
	Test        MessageType = 4
	CloseTunnel MessageType = 5
	Control     MessageType = 6
)

Jump to

Keyboard shortcuts

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