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 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 (*Interface) SetTunNetwork ¶
update tundevice just for windows
type PlatformSpecificParams ¶
type PlatformSpecificParams struct { // ComponentID associates with the virtual adapter that exists in Windows. // This is usually configured when driver for the adapter is installed. A // zero-value of this field, i.e., an empty string, causes the interface to // use the default ComponentId. The default ComponentId is set to tap0901, // the one used by OpenVPN. ComponentID string // InterfaceName is a friendly name of the network adapter as set in Control Panel. // Of course, you may have multiple tap0901 adapters on the system, in which // case we need a friendlier way to identify them. InterfaceName string // Network is required when creating a TUN interface. The library will call // net.ParseCIDR() to parse this string into LocalIP, RemoteNetaddr, // RemoteNetmask. The underlying driver will need those to generate ARP // response to Windows kernel, to emulate an TUN interface. // Please note that it cannot perceive the IP changes caused by DHCP, user // configuration to the adapter and etc,. If IP changed, please reconfigure // the adapter using syscall, just like openDev(). // For detail, please refer // https://github.com/OpenVPN/tap-windows6/blob/master/src/device.c#L431 // and https://github.com/songgao/water/pull/13#issuecomment-270341777 Network string }
PlatformSpecificParams defines parameters in Config that are specific to Windows. A zero-value of such type is valid.