conf

package
v0.0.0-...-c0af14d Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingUser  error = errors.New("at least one tunnel is missing a username and no default username was provided")
	ErrUnkownSyntax error = errors.New("unknown/unsupported configuration syntax")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	XMLName xml.Name `json:"-" toml:"-" xml:"config" yaml:"-" `
	/*
		Username, if provided, will be the default username used for any Tunnel that does not specify one (via Tunnel.Username).
		This should be the username used when authenticating to tunnelbroker.net.
		It is optional, as the username can be specified/overridden for each Tunnel, but at least one or the other *must* be provided.
		This makes it easier if you have multiple tunnels under the same account.
		If a username is specified in Tunnel.Username, it will be used.
		If not (and, of course, Config.Username is specified), then Config.Username will be used for that Tunnel.
	*/
	Username *string `` /* 133-byte string literal not displayed */
	// SingleTunnel, if true, will suppress goroutine-management of tunnels and instead execute them sequentially instead.
	SingleTunnel bool `json:"1tun,omitempty" toml:"SingleTunnel,omitempty" xml:"oneTun,attr,omitempty" yaml:"NoGoTunnel,omitempty"`
	// CacheDB, if specified, is a path to a SQLite3 DB on-disk to make cached information persistent across reboots.
	CacheDB string `` /* 181-byte string literal not displayed */
	// CacheDbPerms specifies the optional permissions for the file and parent directory for CacheDB; only used if persistent cache.
	CacheDbPerms *Perms `` /* 129-byte string literal not displayed */
	// Tunnels contains one or more tunnel configurations.
	Tunnels []*Tunnel `json:"tunnels" toml:"Tunnel" xml:"tunnels>tunnel" yaml:"Tunnels" validate:"required"`
	/*
		Cmds are executed, in order, *after* all Tunnel configurations have been run.
		Unlike in Tunnel and ConfigTemplate, no templating on these commands is performed.
	*/
	Cmds []tplCmd.Cmd `json:"cmds,omitempty" toml:"Command,omitempty" xml:"commands>cmd,omitempty" yaml:"Commands,omitempty"`
}

Config represents a configuration file.

func NewConfig

func NewConfig(path string) (cfg *Config, err error)

func NewConfigFromBytes

func NewConfigFromBytes(b []byte) (cfg *Config, err error)

type ConfigTemplate

type ConfigTemplate struct {
	XMLName xml.Name `json:"-" toml:"-" xml:"tpl" yaml:"-"`
	/*
		Template is the path to the template file on disk.
		It must follow the syntax, rules, etc. of a Golang (text/)template.Template (https://pkg.go.dev/text/template#Template).
		The struct passed to it is a tunnelbroker.FetchedTunnel.
	*/
	Template string `json:"tpl" toml:"Template" xml:"tpl,attr" yaml:"Template File Path" validate:"required,filepath"`
	// Dest contains the filepath that the Template should be written out to.
	Dest string `json:"dest" toml:"Destination" xml:"dest,attr" yaml:"Destination File Path" validate:"required,filepath"`
	// Perms allows specifying permissions/ownerships, if the curent user has the capability to do so.
	Perms *Perms `json:"perms,omitempty" toml:"Permissions,omitempty" xml:"perms,omitempty" yaml:"Permissions and Ownership,omitempty"`
	// Commands specifiies commands to run after this ConfigTemplate run.
	Commands []tplCmd.TemplateCmd `json:"cmds,omitempty" toml:"Command,omitempty" xml:"cmds>cmd,omitempty" yaml:"Commands,omitempty"`
}

ConfigTemplate allows the templating of configuration files, etc. from the tunnel information. Templates are executed *after* the IP update (if an update was necessary), but are always *run*. ConfigTemplate.Dest will only be written to if:

  • The file does not exist (yet), or
  • The templated content differs from the file on disk

type PermSpec

type PermSpec struct {
	/*
		User is the username or UID (tried in that order) to chown.
		If specified as an empty string, the current/runtime UID will be used.
		If unspecified, UID will not be enforced.
	*/
	User *string `json:"user,omitempty" toml:"User,omitempty" xml:"user,attr,omitempty" yaml:"User,omitempty"`
	/*
		Group is the groupname or GID (tried in that order) to chown.
		If specified as an empty string, the current/runtime GID will be used.
		If unspecified, GID will not be enforced.
	*/
	Group *string `json:"group,omitempty" toml:"Group,omitempty" xml:"group,attr,omitempty" yaml:"Group,omitempty"`
	// Mode is the permission mode bitset. If unspecified, mode will not be enforced.
	Mode *os.FileMode `json:"mode,omitempty" toml:"Mode,omitempty" xml:"mode,attr,omitempty" yaml:"Mode,omitempty"`
}

type Perms

type Perms struct {
	// File specifies the desired permissions/ownership of the target file.
	File *PermSpec `json:"file,omitempty" toml:"File,omitempty" xml:"file,omitempty" yaml:"File,omitempty"`
	// ParentDir specifies the desired permissions/ownership of the parent ("dirname") of File.
	ParentDir *PermSpec `json:"dir,omitempty" toml:"Dir,omitempty" xml:"dir,omitempty" yaml:"Directory,omitempty"`
}

type Tunnel

type Tunnel struct {
	XMLName xml.Name `json:"-" toml:"-" xml:"tunnel" yaml:"-"`
	/*
		TunnelID can be found by logging into https://tunnelbroker.net/ and, at the "Main Page" that loads
		when logging in, clicking on the desired tunnel name. The tunnel ID is then displayed in both the URL bar:
			https://tunnelbroker.net/tunnel_detail.php?tid=<TunnelID>
		And as the first line on the first tab ("IPv6 Tunnel" tab),	labeled "Tunnel ID".
	*/
	TunnelID uint `json:"tun_id" toml:"TunnelID" xml:"id,attr" yaml:"Tunnel ID" validate:"required,ge=1"`
	/*
		ExplicitAddr, if provided, will be used as the tunnelbroker.FetchedTunnel.CurrentIPv4.
		If not provided, this will be fetched dynamically from an external source.
	*/
	ExplicitAddr *net.IP `json:"addr,omitempty" toml:"ExplicitClientIP,omitempty" xml:"addr,attr,omitempty" yaml:"Explicit Client IP Address,omitempty"`
	/*
		MTU should be specified if you have defined a custom one (under the "Advanced" tab for this tunnel at tunnlebroker.net).
		If you did not change this, the default is 1480 (the maximum allowed), and the default value of this struct field
		on configuration parsing will reflect this.
	*/
	MTU uint `` /* 135-byte string literal not displayed */
	/*
		Username field is optional IF DefaultUsername was specified.
		This also allows you to specify tunnels from different accounts
		by providing a tunnel-specific username.
	*/
	Username *string `json:"username,omitempty" toml:"Username,omitempty" xml:"username,attr,omitempty" yaml:"Username,omitempty"`
	/*
		UpdateKey can be found under the "Advanced" tab on your tunnelbroker.net tunnel's page, labeled "Update Key".
		This token is used to not only update the client-side tunnel IP but also to	query the HE Tunnelbroker "API"
		(it's really just a single endpoint) to get the tunnel information necessary for local configuration.
	*/
	UpdateKey string `json:"update_key" toml:"UpdateKey" xml:"key,attr" yaml:"Update Key" validate:"required"`
	// TemplateConfgs is optional. It holds templates that will be executed in order given. See ConfigTemplate.
	TemplateConfigs []ConfigTemplate `json:"cfg_tpls" toml:"ConfigTemplate" xml:"config>tpl" yaml:"Configuration File Templates"`
	/*
		Cmds are executed, in order, *after* all tunnel updates/fetching and the templating has completed (if any specified).
		Each command will also have tunnelbroker.FetchedTunnel templated to it like TemplateConfigs/ConfigTemplate.Commands,
		so they may be templated as necessary.
	*/
	Cmds []tplCmd.TemplateCmd `json:"cmds,omitempty" toml:"Command,omitempty" xml:"commands>cmd,omitempty" yaml:"Commands,omitempty"`
	// contains filtered or unexported fields
}

Tunnel represents a single tunnel configuration from tunnelbroker.net.

Jump to

Keyboard shortcuts

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