water/params_windows.go
Dmitry Shihovtsev 86871951e7 Add support for Windows to allow selecting between multiple tap0901 adapters on the same system
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
2019-03-29 20:44:29 -07:00

35 lines
1.6 KiB
Go

package water
// PlatformSpecificParams defines parameters in Config that are specific to
// Windows. A zero-value of such type is valid.
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
// Of course, you may have multiple tap0901 adapters on the system, in which
// case we need a friendlier way to identify them. In that case we can use
// the friendly name of the network adapter as set in Control Panel.
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
}
func defaultPlatformSpecificParams() PlatformSpecificParams {
return PlatformSpecificParams{
ComponentID: "tap0901",
InterfaceName: "",
Network: "192.168.1.10/24",
}
}