protocol

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransportTCP = uint8(iota)
	TransportUDP
	TransportICMP
)
View Source
const (
	Networkv4 = uint8(iota)
	Networkv6
)
View Source
const (
	GetRoutesReqCmd        = "GetRoutesReq"
	EstablishConnectionCmd = "EstablishConnection"
)

Commands for communication within the VPN protocol.

View Source
const (
	ApplicationOK = quic.ApplicationErrorCode(0x0)
)

Constants representing QUIC application error codes.

View Source
const (
	Name = "raido"
)

Constants representing the VPN name and transport protocols (TCP, UDP, ICMP).

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectResponse

type ConnectResponse struct {
	Established bool
}

ConnectResponse indicates whether a connection was successfully established.

type Data

type Data struct {
	Command string
	Body    []byte
}

Data represents the data structure sent over the protocol.

type Decoder

type Decoder[T any] struct {
	// contains filtered or unexported fields
}

Decoder wraps the gob decoder for a specific type.

func NewDecoder

func NewDecoder[T any](rd io.ReadCloser) Decoder[T]

NewDecoder initializes a new Decoder for type T.

func (Decoder[T]) Close

func (d Decoder[T]) Close() error

Close closes the underlying reader.

func (Decoder[T]) Decode

func (d Decoder[T]) Decode() (T, error)

Decode decodes the next value from the stream.

type Encoder

type Encoder[T any] struct {
	// contains filtered or unexported fields
}

Encoder wraps the gob encoder for a specific type.

func NewEncoder

func NewEncoder[T any](wr io.WriteCloser) Encoder[T]

NewEncoder initializes a new Encoder for type T.

func (Encoder[T]) Close

func (e Encoder[T]) Close() error

Close closes the underlying writer.

func (Encoder[T]) Encode

func (e Encoder[T]) Encode(t T) error

Encode encodes the provided value to the stream.

type GetRoutesResp

type GetRoutesResp struct {
	Name   string
	Routes []string
}

GetRoutesResp holds the name and list of routes for the VPN.

type IPAddressWithPortProtocol

type IPAddressWithPortProtocol struct {
	IP       net.IP // Can hold both IPv4 (4 bytes) or IPv6 (16 bytes)
	Port     uint16 // 16 bits for the port
	Protocol uint8  // 2 bits for protocol (TCP, UDP, ICMP)
	Network  uint8  // 2 bits for network version (v4 or v6)
}

IPAddressWithPortProtocol holds IP, port, protocol, and network information for both IPv4 and IPv6.

func Decode

func Decode(encoded []byte) (*IPAddressWithPortProtocol, error)

Decode decodes the byte slice back into the IPAddressWithPortProtocol structure.

func (*IPAddressWithPortProtocol) Encode

func (ipStruct *IPAddressWithPortProtocol) Encode() ([]byte, error)

Encode encodes the structure into a byte slice that contains all the necessary information.

Jump to

Keyboard shortcuts

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