vpn

package
v0.0.0-...-e05d22d Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ProxyHost = "proxy-cpt.cyclopcam.org"

At some point, if we have multiple geo-relevant proxies, then we'd choose the closest server instead of just hard-coding to a single one.

View Source
const ShortPublicKeyLen = 10

Used for host names, encoded as hex. First 10 bytes of public key. SYNC-SHORT-PUBLIC-KEY-LEN

Variables

This section is empty.

Functions

func ProxiedHostName

func ProxiedHostName(publicKey wgtypes.Key) string

Our proxied host name is hex(publicKey[:ShortPublicKeyLen]).p.cyclopcam.org

Types

type IPNetwork

type IPNetwork string

Our VPN supports either IPv4 or IPv6

const (
	IPv4 IPNetwork = "IPv4" // IPv4 - Must match the string required for the 'register' API of the proxy service
	IPv6 IPNetwork = "IPv6" // IPv6 - Must match the string required for the 'register' API of the proxy service
)

type VPN

type VPN struct {
	Log       logs.Log
	AllowedIP net.IPNet // Network of the VPN (actually just the proxy server's addresses, eg 10.6.0.0/32 or fdce:c10b:5ca1:1::1/128)
	// contains filtered or unexported fields
}

Manage connection to our VPN/proxy server

func NewVPN

func NewVPN(log logs.Log, privateKey wgtypes.Key, wgkernelClientSecret string, forceIPv4 bool) *VPN

func (*VPN) ConnectKernelWG

func (v *VPN) ConnectKernelWG() error

Connect to our Wireguard interface process

func (*VPN) DisconnectKernelWG

func (v *VPN) DisconnectKernelWG()

func (*VPN) RunRegisterLoop

func (v *VPN) RunRegisterLoop(exit chan bool)

Keep pinging server so that it knows we're alive. Also, if we've been dormant for a long time, then the proxy may have culled us, and we may not receive a new VPN IP, so that's also why this system is essential.

func (*VPN) Start

func (v *VPN) Start() error

Start our Wireguard device, and save our public key

Jump to

Keyboard shortcuts

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