native

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package native provdies common base implementations of the networking.Environment and related interfaces, or at least the portions that can be implemented using common native Go APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoEnvironment

type GoEnvironment struct{}

GoEnvironment is a partial implementation of Environment which provides the methods and types that the go runtime can answer

func (*GoEnvironment) Close added in v0.13.0

func (e *GoEnvironment) Close() error

Close implements Environment by doing nothing and returning nil

func (*GoEnvironment) InterfaceByName

func (e *GoEnvironment) InterfaceByName(name string) (networking.Interface, error)

InterfaceByName implements Environment by wrapping net.InterfaceByName

func (*GoEnvironment) Interfaces

func (e *GoEnvironment) Interfaces() ([]networking.Interface, error)

Interfaces implements Environment

func (*GoEnvironment) ListenUDP added in v0.9.1

func (e *GoEnvironment) ListenUDP(network string, laddr *net.UDPAddr) (networking.UDPConn, error)

ListenUDP implements Environment by wrapping net.ListenUDP

func (*GoEnvironment) NewWgClient added in v0.10.0

func (e *GoEnvironment) NewWgClient() (internal.WgClient, error)

NewWgClient implements Environment by wrapping wgctrl.New()

type GoInterface

type GoInterface struct {
	net.Interface
}

GoInterface provides as much of Interface as the go runtime can

func (*GoInterface) AddAddr added in v0.13.0

func (i *GoInterface) AddAddr(net.IPNet) error

AddAddr implements Interface, returns ErrAddAddrUnsupported

func (*GoInterface) Addrs

func (i *GoInterface) Addrs() ([]net.IPNet, error)

Addrs implements Interface, looks up the IP addresses for the interface

func (*GoInterface) IsUp

func (i *GoInterface) IsUp() bool

IsUp implements Interface, checks for FlagUp

func (*GoInterface) Name

func (i *GoInterface) Name() string

Name implements Interface, gets its name

type GoUDPConn added in v0.9.1

type GoUDPConn struct {
	net.UDPConn
}

GoUDPConn implements networking.UDPConn by wrapping net.UDPConn

func (*GoUDPConn) ReadPackets added in v0.9.1

func (c *GoUDPConn) ReadPackets(
	ctx context.Context,
	maxSize int,
	packets chan<- *networking.UDPPacket,
) error

ReadPackets implements networking.UDPConn. TODO: the cancellation context won't be obeyed very well. Methodology loosely adapted from: https://medium.com/@zombiezen/canceling-i-o-in-go-capn-proto-5ae8c09c5b29 via https://github.com/golang/go/issues/20280#issue-227074518 UDP makes this simpler however as partial reads are not a concern

Jump to

Keyboard shortcuts

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