Documentation ¶
Overview ¶
Package webtunnelclient runs the client side of the webtunnel; websocket based VPN. See examples for client implementation.
Index ¶
- Variables
- type Interface
- type WebtunnelClient
- func (w *WebtunnelClient) GetMetrics() (int, int)
- func (w *WebtunnelClient) IsInterfaceReady() bool
- func (w *WebtunnelClient) PingHandler(wsConn *websocket.Conn) func(appStr string) error
- func (w *WebtunnelClient) ResetMetrics()
- func (w *WebtunnelClient) Retry() error
- func (w *WebtunnelClient) SetServer(serverIPPort string, secure bool, wsDialer *websocket.Dialer)
- func (w *WebtunnelClient) SetTapInterface(customTapParam *water.PlatformSpecificParams)
- func (w *WebtunnelClient) Start() error
- func (w *WebtunnelClient) Stop() error
Constants ¶
This section is empty.
Variables ¶
var GetMacbyName = wc.GetMacbyName
GetMacbyName (Overridable) Get HW address.
var IsConfigured = wc.IsConfigured
IsConfigured (Overridable) Check if network interface configured.
var NewWaterInterface = wc.NewWaterInterface
NewWaterInterface (Overridable) Return new water interface.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface struct { IP net.IP // IP address. GWIP net.IP // Gateway IP. Netmask net.IP // Netmask of the interface. DNS []net.IP // IP of DNS servers. RoutePrefix []*net.IPNet // Route prefix to send via tunnel. LocalHWAddr net.HardwareAddr // MAC address of network interface. GWHWAddr net.HardwareAddr // fake MAC address of gateway. LeaseTime uint32 // DHCP lease time. wc.Interface // Interface to network. }
Interface represents the network interface and its related configuration.
type WebtunnelClient ¶
type WebtunnelClient struct { Error chan error // Channel to handle errors from goroutines. // contains filtered or unexported fields }
WebtunnelClient represents the client struct.
func NewWebtunnelClient ¶
func NewWebtunnelClient(serverIPPort string, wsDialer *websocket.Dialer, useTap bool, f func(*Interface) error, secure bool, leaseTime uint32) (*WebtunnelClient, error)
NewWebtunnelClient returns an initialized webtunnel client
serverIPPort: IP:Port of the websocket server.
wsDialer: Initialized websocket dialer with options.
devType: Tun or Tap.
f: User callback function for any OS initialization (eg. manual routes etc) mostly used in TUN.
secure: Enable secure websocket connection
leaseTime: If TAP, the DHCP lease time in seconds. Make sure to use a big enough value on Windows.
func (*WebtunnelClient) GetMetrics ¶
func (w *WebtunnelClient) GetMetrics() (int, int)
GetMetrics returns the internal metrics.
func (*WebtunnelClient) IsInterfaceReady ¶
func (w *WebtunnelClient) IsInterfaceReady() bool
IsInterfaceReady returns true when the network interface is ready and configured with the right IP address.
func (*WebtunnelClient) PingHandler ¶
func (w *WebtunnelClient) PingHandler(wsConn *websocket.Conn) func(appStr string) error
PingHandler will return the function to handle the Ping sent from the server. It sends the time diff seen between the client and server.
func (*WebtunnelClient) ResetMetrics ¶
func (w *WebtunnelClient) ResetMetrics()
ResetMetrics reset the internal counters.
func (*WebtunnelClient) Retry ¶
func (w *WebtunnelClient) Retry() error
Retry the connection after a disconnection
func (*WebtunnelClient) SetServer ¶
func (w *WebtunnelClient) SetServer(serverIPPort string, secure bool, wsDialer *websocket.Dialer)
SetServer changes the websocket connection end point.
func (*WebtunnelClient) SetTapInterface ¶
func (w *WebtunnelClient) SetTapInterface(customTapParam *water.PlatformSpecificParams)
SetTapInterface sets the Tap ComponentId for Windows tap interface It will set it only if the value is different from tap0901 which is the default
func (*WebtunnelClient) Stop ¶
func (w *WebtunnelClient) Stop() error
Stop gracefully shutdowns the client after notifying the server.