Documentation ¶
Overview ¶
Package water is a simple TUN/TAP interface library that efficiently works with standard packages like io, bufio, etc.. Use waterutil with it to work with TUN/TAP packets/frames.
Index ¶
Constants ¶
const ( TUN TAP )
TUN and TAP device types.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // DeviceType specifies whether the device is a TUN or TAP interface. A // zero-value is treated as TUN. DeviceType DeviceType // PlatformSpecificParams defines parameters that differ on different // platforms. See comments for the type for more details. PlatformSpecificParams }
Config defines parameters required to create a TUN/TAP interface. It's only used when the device is initialized. A zero-value Config is a valid configuration.
type DevicePermissions ¶
type DevicePermissions struct { // Owner is the ID of the user which will be granted ownership of the // device. If set to a negative value, the owner value will not be // changed. By default, Linux sets the owner to -1, which allows any user. Owner uint // Group is the ID of the group which will be granted access to the device. // If set to a negative value, the group value will not be changed. By // default, Linux sets the group to -1, which allows any group. Group uint }
DevicePermissions determines the owner and group owner for the newly created interface.
type Interface ¶
type Interface struct { io.ReadWriteCloser // contains filtered or unexported fields }
Interface is a TUN/TAP interface.
MultiQueue(Linux kernel > 3.8): With MultiQueue enabled, user should hold multiple interfaces to send/receive packet in parallel. Kernel document about MultiQueue: https://www.kernel.org/doc/Documentation/networking/tuntap.txt
func NewInterface ¶
func NewInterface(name string, file io.ReadWriteCloser, isTAP bool) *Interface
func NewTAP
deprecated
NewTAP creates a new TAP interface whose name is ifName. If ifName is empty, a default name (tap0, tap1, ... ) will be assigned. ifName should not exceed 16 bytes. TAP interfaces are not supported on darwin. ifName cannot be specified on windows, you will need ifce.Name() to use some cmds.
Deprecated: This function may be removed in the future. Please use New() instead.
func NewTUN
deprecated
NewTUN creates a new TUN interface whose name is ifName. If ifName is empty, a default name (tap0, tap1, ... ) will be assigned. ifName should not exceed ifName cannot be specified on windows, you will need ifce.Name() to use some cmds.
Deprecated: This function will be removed in the future. Please use New() instead.
func (*Interface) SetTunNetwork ¶
Name returns the interface name of ifce, e.g. tun0, tap1, tun0, etc..
type PlatformSpecificParams ¶
type PlatformSpecificParams struct { // Name is the name to be set for the interface to be created. This overrides // the default name assigned by OS such as tap0 or tun0. A zero-value of this // field, i.e. an empty string, indicates that the default name should be // used. Name string // Persist specifies whether persistence mode for the interface device // should be enabled or disabled. Persist bool // Permissions, if non-nil, specifies the owner and group owner for the // interface. A zero-value of this field, i.e. nil, indicates that no // changes to owner or group will be made. Permissions *DevicePermissions // MultiQueue specifies whether the multiqueue flag should be set on the // interface. From version 3.8, Linux supports multiqueue tuntap which can // uses multiple file descriptors (queues) to parallelize packets sending // or receiving. MultiQueue bool }
PlatformSpecificParams defines parameters in Config that are specific to Linux. A zero-value of such type is valid, yielding an interface with OS defined name.