Documentation ¶
Index ¶
- Constants
- type Device
- func (d *Device) AddAddress(prefix netip.Prefix) error
- func (d *Device) AddRoute(prefix netip.Prefix, highPrio bool) error
- func (d *Device) AddSendRawOffset(data []byte) (withOffset []byte, copied bool)
- func (d *Device) BatchSize() int
- func (d *Device) CheckWorkarounds()
- func (d *Device) Close() error
- func (d *Device) InitInterface(prefix netip.Prefix) error
- func (d *Device) PrepTUN()
- func (d *Device) Read(bufs [][]byte, sizes []int, offset int) (n int, err error)
- func (d *Device) RemoveAddress(prefix netip.Prefix) error
- func (d *Device) RemoveRoute(prefix netip.Prefix) error
- func (d *Device) SendRawOffset() int
- func (d *Device) Start(mgr *mgr.Manager) error
- func (d *Device) StartInterface() error
- func (d *Device) Stop(mgr *mgr.Manager) error
- func (d *Device) TunEvents() <-chan tun.Event
- func (d *Device) Write(bufs [][]byte, offset int) (int, error)
Constants ¶
const DefaultTunName = "mycoria"
DefaultTunName is the default interface name for the tunnel interface.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct { RecvRaw chan []byte SendRaw chan []byte SendFrame chan frame.Frame // contains filtered or unexported fields }
Device represents a tun device.
func (*Device) AddAddress ¶
AddAddress adds an address to the interface.
func (*Device) AddSendRawOffset ¶ added in v0.1.0
AddSendRawOffset returns the given data with the required offset of packets submitted via SendRaw.
func (*Device) BatchSize ¶
BatchSize returns the preferred/max number of packets that can be read or written in a single read/write call. BatchSize must not change over the lifetime of a Device.
func (*Device) CheckWorkarounds ¶ added in v0.4.0
func (d *Device) CheckWorkarounds()
CheckWorkarounds may be called to make sure any workarounds are correctly applied after the network or related resources have changed.
func (*Device) InitInterface ¶
InitInterface initializes the interface.
func (*Device) PrepTUN ¶ added in v0.1.0
func (d *Device) PrepTUN()
PrepTUN prepares the creation of the TUN device.
func (*Device) Read ¶
Read one or more packets from the Device (without any additional headers). On a successful read it returns the number of packets read, and sets packet lengths within the sizes slice. len(sizes) must be >= len(bufs). A nonzero offset can be used to instruct the Device on where to begin reading into each element of the bufs slice.
func (*Device) RemoveAddress ¶
RemoveAddress removes an address from the interface.
func (*Device) RemoveRoute ¶ added in v0.1.0
RemoveRoute removes a route to the interface.
func (*Device) SendRawOffset ¶ added in v0.1.0
SendRawOffset returns the required offset of packets submitted via SendRaw.
func (*Device) StartInterface ¶
StartInterface starts the interface and brings it online.