wgconfig

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddrPort

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

AddrPort represents an address and port where the host part can be an IP address, a hostname, or some other string.

func AddrPortFrom

func AddrPortFrom(host string, port uint16) AddrPort

func (AddrPort) Host

func (o AddrPort) Host() string

func (AddrPort) IsIP

func (o AddrPort) IsIP() (netip.AddrPort, bool)

func (AddrPort) Port

func (o AddrPort) Port() uint16

func (AddrPort) String

func (o AddrPort) String() string

type Config

type Config struct {
	Interface *Interface
	Peers     []*Peer
	Others    []*ini.Section
	NamedPeer map[string]*Peer
}

Config represents the WireGuard configuration.

func Parse

func Parse(r io.Reader) (*Config, error)

Parse parses a Config from an io.Reader.

func (*Config) IPCConfig

func (o *Config) IPCConfig() (string, error)

IPCConfig returns the Config in WireGuard IPC format.

For more information regarding this format, please refer to: https://www.wireguard.com/xplatform/#configuration-protocol

func (*Config) IPCConfigWithoutDnsPeers

func (o *Config) IPCConfigWithoutDnsPeers() (string, error)

func (*Config) OnGlobalParam

func (o *Config) OnGlobalParam(paramName string) (func(*ini.Param) error, ini.SchemaRule)

OnGlobalParam partly implements the ini.Schema interface.

func (*Config) OnSection

func (o *Config) OnSection(name string, _ string) (func() (ini.SectionSchema, error), ini.SchemaRule)

OnSection partly implements the ini.Schema interface.

func (*Config) Rules

func (o *Config) Rules() ini.ParserRules

Rules partly implements the ini.Schema interface.

func (*Config) Validate

func (o *Config) Validate() error

Validate partly implements the ini.Schema interface.

func (*Config) WireGuardString

func (o *Config) WireGuardString() string

type Interface

type Interface struct {
	PrivateKey *device.NoisePrivateKey
	PublicKey  *device.NoisePublicKey
	ListenPort *uint16
	Addresses  []netip.Prefix
	MTU        *int
	Others     []*ini.Param
}

Interface represents the Interface section found in a WireGuard configuration file.

See also:

func (*Interface) AddressByIndex added in v0.0.10

func (o *Interface) AddressByIndex(index uint64) (netip.Prefix, error)

func (*Interface) OnParam

func (o *Interface) OnParam(paramName string) (func(*ini.Param) error, ini.SchemaRule)

OnParam partly implements the ini.SectionSchema interface.

func (*Interface) RequiredParams

func (o *Interface) RequiredParams() []string

RequiredParams partly implements the ini.SectionSchema interface.

func (*Interface) Validate

func (o *Interface) Validate() error

Validate partly implements the ini.SectionSchema interface.

type Peer

type Peer struct {
	PublicKey           *device.NoisePublicKey
	Endpoint            *AddrPort
	AllowedIPs          []netip.Prefix
	PersistentKeepalive *uint64
	Name                string
	Others              []*ini.Param
}

Peer represents the Peer section found in a WireGuard configuration file.

See also:

func (*Peer) IPCString

func (o *Peer) IPCString(b *bytes.Buffer) error

func (*Peer) OnParam

func (o *Peer) OnParam(paramName string) (func(*ini.Param) error, ini.SchemaRule)

OnParam partly implements the ini.SectionSchema interface.

func (*Peer) RequiredParams

func (o *Peer) RequiredParams() []string

RequiredParams partly implements the ini.SectionSchema interface.

func (*Peer) Validate

func (o *Peer) Validate() error

Validate partly implements the ini.SectionSchema interface.

Jump to

Keyboard shortcuts

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