Documentation
¶
Index ¶
- Constants
- Variables
- type Device
- type Event
- type NativeTun
- func (tun *NativeTun) AddRoute(destination netip.Prefix, gateway netip.Addr, metric int) error
- func (tun *NativeTun) Close() error
- func (tun *NativeTun) Events() <-chan Event
- func (tun *NativeTun) File() *os.File
- func (tun *NativeTun) GetIPAddresses() ([]netip.Prefix, error)
- func (tun *NativeTun) MTU() (int, error)
- func (tun *NativeTun) Name() (string, error)
- func (tun *NativeTun) Read(b []byte) (int, error)
- func (tun *NativeTun) RemoveRoute(destination netip.Prefix, gateway netip.Addr) error
- func (tun *NativeTun) SetIPAddresses(addresses []netip.Prefix) error
- func (tun *NativeTun) SetMTU(mtu int) error
- func (tun *NativeTun) Write(b []byte) (int, error)
Constants ¶
View Source
const ( EventUp = 1 << iota EventDown EventMTUUpdate )
Variables ¶
View Source
var ( // ErrTooManySegments is returned by Device.Read() when segmentation // overflows the length of supplied buffers. This error should not cause // reads to cease. ErrTooManySegments = errors.New("too many segments") )
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device interface {
// File returns the file descriptor of the device.
File() *os.File
// Read one packet from the Device (without any additional headers).
// On a successful read it returns the number of bytes read.
Read(b []byte) (int, error)
// Write one packet to the device (without any additional headers).
// On a successful write it returns the number of bytes written.
Write(b []byte) (int, error)
// Set MTU on the device.
SetMTU(int) error
// MTU returns the MTU of the Device.
MTU() (int, error)
// Name returns the current name of the Device.
Name() (string, error)
// Set IP Addresses for the device.
SetIPAddresses(addresses []netip.Prefix) error
// Get IP Addresses for the device.
GetIPAddresses() ([]netip.Prefix, error)
// Add static route.
AddRoute(destination netip.Prefix, gateway netip.Addr, metric int) error
// Remove static route.
RemoveRoute(destination netip.Prefix, gateway netip.Addr) error
// Events returns a channel of type Event, which is fed Device events.
Events() <-chan Event
// Close stops the Device and closes the Event channel.
Close() error
}
func CreateTUNFromFile ¶
CreateTUNFromFile creates a Device from an os.File with the provided MTU.
type NativeTun ¶
type NativeTun struct {
// contains filtered or unexported fields
}
func (*NativeTun) RemoveRoute ¶ added in v0.2.1
func (*NativeTun) SetIPAddresses ¶
Click to show internal directories.
Click to hide internal directories.