commands

package
v0.0.0-...-d4d4850 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const CommandSerializationHeaderName = "Command-Serialization"
View Source
const SupportedCommandSerializationsHeaderName = "Supported-Command-Serializations"

Variables

This section is empty.

Functions

func GetSupportedSerializationTypeNames

func GetSupportedSerializationTypeNames() []string

func SerializationTypePriority

func SerializationTypePriority(stype SerializationType) int

func SerializationTypeToString

func SerializationTypeToString(stype SerializationType) string

Types

type AddRouteParameters

type AddRouteParameters struct {
	Route IPAddressWithCIDR `json:"route"`
}

func (*AddRouteParameters) ClientCanIssue

func (c *AddRouteParameters) ClientCanIssue() bool

func (*AddRouteParameters) MakeCommand

func (c *AddRouteParameters) MakeCommand(id string) (*OutgoingCommand, error)

func (*AddRouteParameters) MinProtocolVersion

func (c *AddRouteParameters) MinProtocolVersion() int

func (*AddRouteParameters) ServerCanIssue

func (c *AddRouteParameters) ServerCanIssue() bool

type CommandID

type CommandID = string

type CommandName

type CommandName = string
const AddRouteCommandName CommandName = "add_route"
const InitCommandName CommandName = "init"
const MessageCommandName CommandName = "message"
const ReplyCommandName CommandName = "reply"
const SetMTUCommandName CommandName = "set_mtu"
const VersionCommandName CommandName = "version"

type CommandParameters

type CommandParameters interface {
	MakeCommand(id string) (*OutgoingCommand, error)
	MinProtocolVersion() int
	ServerCanIssue() bool
	ClientCanIssue() bool
}

type IPAddressWithCIDR

type IPAddressWithCIDR = string

type IncomingCommand

type IncomingCommand struct {
	ID         CommandID       `json:"id"`
	Command    CommandName     `json:"command"`
	Parameters json.RawMessage `json:"parameters"`
}

func DeserializeCommand

func DeserializeCommand(message []byte, serializationType SerializationType) (*IncomingCommand, error)

func (*IncomingCommand) DeserializeParameters

func (c *IncomingCommand) DeserializeParameters(parameters CommandParameters) error

type InitParameters

type InitParameters struct {
	Mode                InterfaceMode     `json:"mode"`
	DoIPConfig          bool              `json:"do_ip_config"`
	IPAddress           IPAddressWithCIDR `json:"ip_address"`
	MTU                 int               `json:"mtu"`
	ServerID            string            `json:"server_id"`
	ClientID            string            `json:"client_id"`
	EnableFragmentation bool              `json:"enable_fragmentation"`
}

func (*InitParameters) ClientCanIssue

func (c *InitParameters) ClientCanIssue() bool

func (*InitParameters) MakeCommand

func (c *InitParameters) MakeCommand(id string) (*OutgoingCommand, error)

func (*InitParameters) MinProtocolVersion

func (c *InitParameters) MinProtocolVersion() int

func (*InitParameters) ServerCanIssue

func (c *InitParameters) ServerCanIssue() bool

type InterfaceMode

type InterfaceMode = string

type MessageParameters

type MessageParameters struct {
	Type    string `json:"type"`
	Message string `json:"message"`
}

func (*MessageParameters) ClientCanIssue

func (c *MessageParameters) ClientCanIssue() bool

func (*MessageParameters) MakeCommand

func (c *MessageParameters) MakeCommand(id string) (*OutgoingCommand, error)

func (*MessageParameters) MinProtocolVersion

func (c *MessageParameters) MinProtocolVersion() int

func (*MessageParameters) ServerCanIssue

func (c *MessageParameters) ServerCanIssue() bool

type OutgoingCommand

type OutgoingCommand struct {
	ID         CommandID         `json:"id"`
	Command    CommandName       `json:"command"`
	Parameters CommandParameters `json:"parameters"`
}

func (*OutgoingCommand) Serialize

func (c *OutgoingCommand) Serialize(serializationType SerializationType) ([]byte, error)

type ReplyParameters

type ReplyParameters struct {
	Ok      bool   `json:"ok"`
	Message string `json:"message"`
}

func (*ReplyParameters) ClientCanIssue

func (c *ReplyParameters) ClientCanIssue() bool

func (*ReplyParameters) MakeCommand

func (c *ReplyParameters) MakeCommand(id string) (*OutgoingCommand, error)

func (*ReplyParameters) MinProtocolVersion

func (c *ReplyParameters) MinProtocolVersion() int

func (*ReplyParameters) ServerCanIssue

func (c *ReplyParameters) ServerCanIssue() bool

type SerializationType

type SerializationType = int
const (
	SerializationTypeInvalid SerializationType = iota
	SerializationTypeJSON
)

func GetSupportedSerializationTypes

func GetSupportedSerializationTypes() []SerializationType

func SerializationTypeFromString

func SerializationTypeFromString(name string) SerializationType

type SetMTUParameters

type SetMTUParameters struct {
	MTU int `json:"mtu"`
}

func (*SetMTUParameters) ClientCanIssue

func (c *SetMTUParameters) ClientCanIssue() bool

func (*SetMTUParameters) MakeCommand

func (c *SetMTUParameters) MakeCommand(id string) (*OutgoingCommand, error)

func (*SetMTUParameters) MinProtocolVersion

func (c *SetMTUParameters) MinProtocolVersion() int

func (*SetMTUParameters) ServerCanIssue

func (c *SetMTUParameters) ServerCanIssue() bool

type VersionParameters

type VersionParameters struct {
	ProtocolVersion int                `json:"protocol_version"`
	Version         string             `json:"version"`
	EnabledFeatures []features.Feature `json:"enabled_features"`
}

func (*VersionParameters) ClientCanIssue

func (c *VersionParameters) ClientCanIssue() bool

func (*VersionParameters) MakeCommand

func (c *VersionParameters) MakeCommand(id string) (*OutgoingCommand, error)

func (*VersionParameters) MinProtocolVersion

func (c *VersionParameters) MinProtocolVersion() int

func (*VersionParameters) ServerCanIssue

func (c *VersionParameters) ServerCanIssue() bool

Jump to

Keyboard shortcuts

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