wgtunnel

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package wgtunnel sets up and configures Encore's WireGuard tunnel for authenticating against private environments.

Index

Constants

This section is empty.

Variables

View Source
var DefaultServerConfig = &ServerConfig{
	Peers: []ServerPeer{
		{
			Endpoint: net.UDPAddr{
				IP:   net.ParseIP("159.65.210.129"),
				Port: 51820,
			},
			PublicKey: mustParseKey("mQzDYCJufL+rNqbS1fBtxx3vxLX/4VaKKUDNS/yhQBs="),
			Subnets: []net.IPNet{
				{
					IP:   net.ParseIP("100.26.25.109"),
					Mask: net.IPv4Mask(255, 255, 255, 255),
				},
				{
					IP:   net.ParseIP("18.214.237.181"),
					Mask: net.IPv4Mask(255, 255, 255, 255),
				},
				{
					IP:   net.ParseIP("54.170.142.107"),
					Mask: net.IPv4Mask(255, 255, 255, 255),
				},
				{
					IP:   net.ParseIP("54.74.172.84"),
					Mask: net.IPv4Mask(255, 255, 255, 255),
				},
			},
		},
	},
}

DefaultServerConfig is the well-known default configuration of Encore's API Gateway.

Functions

func GenKey

func GenKey() (pub, priv wgtypes.Key, err error)

GenKey generates a public/private key pair for the WireGuard tunnel.

func RegisterDevice

func RegisterDevice(ctx context.Context, pubKey wgtypes.Key) (ip string, err error)

RegisterDevice registers the public key with Encore and returns the allocated IP address for use with WireGuard.

func Run

func Run() error

Run synchronously runs the tunnel.

func Start

func Start(cc *ClientConfig, sc *ServerConfig) error

Start starts the WireGuard tunnel in the background.

func Status

func Status() (running bool, err error)

Status reports whether the tunnel is running.

func Stop

func Stop() error

Stop stops the WireGuard tunnel.

Types

type ClientConfig

type ClientConfig struct {
	// Addr is our WireGuard address.
	Addr string
	// PrivKey is our private key.
	PrivKey wgtypes.Key
}

ClientConfig is the configuration necessary to setup WireGuard.

type ServerConfig

type ServerConfig struct {
	Peers []ServerPeer
}

ServerConfig is the configuration to set up WireGuard peers.

type ServerPeer

type ServerPeer struct {
	// Endpoint is the WireGuard endpoint for the server.
	Endpoint net.UDPAddr
	// PublicKey is the server's public key.
	PublicKey wgtypes.Key
	// Subnets are the network subnet that should be routed
	// through WireGuard.
	Subnets []net.IPNet
}

ServerPeer is the required configuration to configure a WireGuard peer.

Jump to

Keyboard shortcuts

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