wgclient

package module
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2022 License: MIT Imports: 13 Imported by: 0

README

wgclient

Tools for generating wireguard client configuration files.

Probably only interesting for Tracklib internal use.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderClientConfig

func RenderClientConfig(renderContext TemplateContext) ([]byte, error)

func TunnelNameIsValid

func TunnelNameIsValid(name string) bool

TunnelNameIsValid is copied from wireguard windows client because windows put a series of restrictions on tunnel names.

Types

type ClientConfig

type ClientConfig struct {
	IF       int  `json:"if"`        // interface 0=wg0 1=wg1...
	NoDNS    bool `json:"no_dns"`    // comment out the DNS =  line
	RouteDNS bool `json:"route_dns"` // Append the DNS servers to AllowedIPs line
}

ClientConfig .

type ClientConfigs

type ClientConfigs []ClientConfig

type Config

type Config struct {
	Users           Users
	AllowedIPs      []string
	DNSNames        []string
	DNS             []string
	ServerPublicKey string
	Interfaces      Interfaces
}

func ReadConfig

func ReadConfig(data []byte) (Config, error)

func (Config) AllClientConfigs

func (c Config) AllClientConfigs() ClientConfigs

func (*Config) UpdateAllowedIPs

func (c *Config) UpdateAllowedIPs(ctx context.Context, nameserver string) error

func (*Config) UpdateAllowedIPsWithDefaultResolver added in v0.3.0

func (c *Config) UpdateAllowedIPsWithDefaultResolver(ctx context.Context) error

type Interface

type Interface struct {
	Endpoint string
	Prefix   string
}

Interface .

type Interfaces

type Interfaces map[int]Interface

type TemplateContext

type TemplateContext struct {
	PrivateKey    string
	PeerPublicKey string
	PeerEndpoint  string
	NetPrefix     string
	NetSuffix     string
	DNS           string
	AllowedIPS    string
}

TemplateContext is a template for rending a single end user client config file.

type User

type User struct {
	Name          string        `json:"name"`
	Priv          string        `json:"priv"`
	Pub           string        `json:"pub"`
	ClientConfigs ClientConfigs `json:"configs"`
	Email         string        `json:"email"`
	Tags          []string      `json:"tags"`
}

User .

func (User) Filename

func (w User) Filename(cc ClientConfig) string

type Users

type Users map[string]User

func (Users) FilterTags

func (u Users) FilterTags(s ...string) Users

func (Users) FindUserByName

func (u Users) FindUserByName(name string) (string, User, error)

func (Users) Match

func (u Users) Match(s ...string) Users

Jump to

Keyboard shortcuts

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