templates

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package templates is responsible for managing the creating of caddyfiles through templates.

Index

Constants

This section is empty.

Variables

View Source
var (
	//go:embed Dockerfile
	Dockerfile string
	//go:embed client_modules.json
	ClientConfig []byte
	//go:embed server_modules.json
	ServerConfig []byte
	//go:embed Caddyfile.client
	CaddyfileClient string
	//go:embed Caddyfile.server
	CaddyfileServer string
)

Functions

func ApplyTemplate

func ApplyTemplate(t errs.Testing, tmpl string, dot any) []byte

ApplyTemplate applies the given template to the given dot.

func DeJSON

func DeJSON[T any](t errs.Testing, b []byte) (v T)

DeJSON helps decode json into a type.

func NewDotPair

func NewDotPair(t errs.Testing) (DotClient, DotServer)

NewDotPair produces a pair of configs for the server and the client.

Types

type Dot

type Dot interface {
	ApplyTemplate(errs.Testing) []byte
}

Dot is something that provides context for a template.

type DotClient

type DotClient struct {
	NetworkName  string
	IP           net.IP
	Endpoint     string
	EndpointPort uint16
	Private      wgapi.PrivateKey
	Public       wgapi.PublicKey
	Shared       wgapi.PresharedKey
	Directive    string
}

DotClient is a client template config.

func (DotClient) ApplyTemplate

func (dc DotClient) ApplyTemplate(t errs.Testing) []byte

func (DotClient) GetNetworkName added in v0.1.0

func (dc DotClient) GetNetworkName() string

type DotDockerfile

type DotDockerfile struct {
	Caddy string   `json:"caddy"`
	Mods  []string `json:"mods"`
}

func (DotDockerfile) ApplyTemplate

func (dd DotDockerfile) ApplyTemplate(t errs.Testing) []byte

type DotServer

type DotServer struct {
	NetworkName    string
	FwdNetworkName string
	IP             net.IP
	Port           uint16
	Private        wgapi.PrivateKey
	Peers          []DotServerPeer
}

DotServer is a server template config.

func (DotServer) ApplyTemplate

func (ds DotServer) ApplyTemplate(t errs.Testing) []byte

func (DotServer) GetNetworkName added in v0.1.0

func (ds DotServer) GetNetworkName() string

type DotServerPeer

type DotServerPeer struct {
	NetworkName string
	IP          net.IP
	Public      wgapi.PublicKey
	Shared      wgapi.PresharedKey
}

DotServerPeer allows for configuring peers in the server caddyfile.

Jump to

Keyboard shortcuts

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