wg

package
v0.3.39 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package wg implements a WireGuard tunnel device and TCP/UDP forwarding.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apoxy4To6Range

func Apoxy4To6Range() netip.Prefix

Apoxy4To6Range returns the Unique Local Adddres prefix used by Apoxy for IPv4 to IPv6 translation.

func NewApoxy4To6Prefix

func NewApoxy4To6Prefix(orgID uuid.UUID, endpoint string) netip.Prefix

NewApoxy4To6Prefix generates a new IPv6 address from the Apoxy4To6Range prefix.

func TrySTUN

func TrySTUN(srcPort int, addrs ...string) (net.IP, []int, error)

TrySTUN tries to resolve the external IP address and port of the host by sending a STUN request to the specified STUN servers.

Types

type Tunnel

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

func CreateTunnel

func CreateTunnel(
	ctx context.Context,
	projectID uuid.UUID,
	endpoint string,
	verbose bool,
) (*Tunnel, error)

CreateTunnel creates a new WireGuard device (userspace).

func (*Tunnel) AddPeer

func (t *Tunnel) AddPeer(
	pubKeyHex string,
	endpoint netip.AddrPort,
	allowedIPs []net.IPNet,
	persistentKeepaliveInterval time.Duration,
) error

func (*Tunnel) Close

func (t *Tunnel) Close()

func (*Tunnel) ExternalAddress

func (t *Tunnel) ExternalAddress() netip.AddrPort

func (*Tunnel) InternalAddress

func (t *Tunnel) InternalAddress() netip.Prefix

func (*Tunnel) PubKey

func (t *Tunnel) PubKey() wgtypes.Key

func (*Tunnel) RemovePeer

func (t *Tunnel) RemovePeer(pubKeyHex string) error

Jump to

Keyboard shortcuts

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