wireguard

package
Version: v0.0.0-...-846a3b6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2021 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKeys

func GenerateKeys(wgToolBinaryPath string) (publicKey string, privateKey string, err error)

GenerateKeys generates new WireGuard keys pair

Types

type ConnectionParams

type ConnectionParams struct {
	// contains filtered or unexported fields
}

ConnectionParams contains all information to make new connection

func CreateConnectionParams

func CreateConnectionParams(
	hostPort int,
	hostIP net.IP,
	hostPublicKey string,
	hostLocalIP net.IP) ConnectionParams

CreateConnectionParams initializing connection parameters object

func (*ConnectionParams) SetCredentials

func (cp *ConnectionParams) SetCredentials(privateKey string, localIP net.IP)

SetCredentials update WG credentials

type WireGuard

type WireGuard struct {
	// contains filtered or unexported fields
}

WireGuard structure represents all data of wireguard connection

func NewWireGuardObject

func NewWireGuardObject(wgBinaryPath string, wgToolBinaryPath string, wgConfigFilePath string, connectionParams ConnectionParams) (*WireGuard, error)

NewWireGuardObject creates new wireguard structure

func (*WireGuard) Connect

func (wg *WireGuard) Connect(stateChan chan<- vpn.StateInfo) error

Connect - SYNCHRONOUSLY execute openvpn process (wait until it finished)

func (*WireGuard) DestinationIP

func (wg *WireGuard) DestinationIP() net.IP

DestinationIP - Get destination IP (VPN host server or proxy server IP address) This information if required, for example, to allow this address in firewall

func (*WireGuard) Disconnect

func (wg *WireGuard) Disconnect() error

Disconnect stops the connection

func (*WireGuard) Init

func (wg *WireGuard) Init() error

Init performs basic initializations before connection It is useful, for example:

- for WireGuard(Windows) - to ensure that WG service is fully uninstalled
- for OpenVPN(Linux) - to ensure that OpenVPN has correct version

func (*WireGuard) IsPaused

func (wg *WireGuard) IsPaused() bool

IsPaused checking if we are in paused state

func (*WireGuard) OnRoutingChanged

func (wg *WireGuard) OnRoutingChanged() error

func (*WireGuard) Pause

func (wg *WireGuard) Pause() error

Pause doing required operation for Pause (temporary restoring default DNS)

func (*WireGuard) ResetManualDNS

func (wg *WireGuard) ResetManualDNS() error

ResetManualDNS restores DNS

func (*WireGuard) Resume

func (wg *WireGuard) Resume() error

Resume doing required operation for Resume (restores DNS configuration before Pause)

func (*WireGuard) SetManualDNS

func (wg *WireGuard) SetManualDNS(addr net.IP) error

SetManualDNS changes DNS to manual IP

func (*WireGuard) Type

func (wg *WireGuard) Type() vpn.Type

Type just returns VPN type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL