Documentation ¶
Overview ¶
Copyright 2023 Sebastian Bünger SPDX-License-Identifier: AGPL-3.0-only OR MIT
Index ¶
- Variables
- type Config
- func (c *Config) AddFile(name string, content string)
- func (c *Config) AddFlag(name string)
- func (c *Config) AddOptions(options ...ConfigOption)
- func (c *Config) AddParam(name string, values ...string)
- func (c *Config) Dir() string
- func (c *Config) GetOption(name string) ConfigOption
- func (c *Config) GetProto() NetProtocol
- func (c *Config) GetRemote() (string, int)
- func (c *Config) Path() string
- func (c *Config) RemoveOption(name string) bool
- func (c *Config) Save(filePath string) error
- func (c *Config) SetAuth(username, password string, allowFile bool)
- func (c *Config) SetDevice(device string)
- func (c *Config) SetManagementAddress(ip string, port int)
- func (c *Config) SetPort(port int)
- func (c *Config) SetProto(proto NetProtocol)
- func (c *Config) SetTLSCaCert(caFile string) error
- func (c *Config) SetTLSClientCert(certFile string) error
- func (c *Config) SetTLSCrypt(cryptFile string) error
- func (c *Config) SetTLSPrivateKey(keyFile string) error
- func (c *Config) ToCli() ([]string, error)
- func (c *Config) ToString() (string, error)
- type ConfigOption
- type NetProtocol
Constants ¶
This section is empty.
Variables ¶
var ( ErrCannotReadFile = errors.New("cannot read file") // Matches any XML open tag // <tag> XMLOpenTag = regexp.MustCompile("<([a-zA-Z0-9-_]+)>") // Matches any XML close tag // </tag> XMLCloseTag = regexp.MustCompile("</([a-zA-Z0-9-_]+)>") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Options []ConfigOption Auth *auth.AuthOption // contains filtered or unexported fields }
Config is a representation of a OpenVPN configuration.
func FromString ¶
FromString parses a OpenVPN configuration string and returns a Config object.
func (*Config) AddOptions ¶
func (c *Config) AddOptions(options ...ConfigOption)
AddOptions adds one or more ConfigOption to the Config object.
func (*Config) Dir ¶
Dir returns the directory of the file the Config object has been loaded from or written to.
func (*Config) GetOption ¶
func (c *Config) GetOption(name string) ConfigOption
func (*Config) GetProto ¶
func (c *Config) GetProto() NetProtocol
func (*Config) RemoveOption ¶
func (*Config) Save ¶
Save serializes the Config object and writes it to a file in the OpenVPN configuration format at the given path. It also sets the path of the Config object to the given path.
func (*Config) SetAuth ¶
SetAuth sets username and password for authentication. allowFile controls whether the password can be written to a file or must be send via the management interface.
func (*Config) SetManagementAddress ¶
SetManagementAddress sets the IP address and port of the management interface.
func (*Config) SetProto ¶
func (c *Config) SetProto(proto NetProtocol)
func (*Config) SetTLSCaCert ¶
SetTLSCaCert sets the CA certificate for TLS authentication.
func (*Config) SetTLSClientCert ¶
SetTLSClientCert sets the client certificate for TLS authentication.
func (*Config) SetTLSCrypt ¶
SetTLSCrypt sets the tls-crypt key for TLS authentication.
func (*Config) SetTLSPrivateKey ¶
SetTLSPrivateKey sets the client private key for TLS authentication.
type ConfigOption ¶
ConfigOption is an interface for all configuration options.
type NetProtocol ¶
type NetProtocol string
const ( TCP NetProtocol = "tcp" UDP NetProtocol = "udp" )