conffile

package
v1.92.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: BSD-3-Clause Imports: 21 Imported by: 5

Documentation

Overview

Package conffile contains code to load, manipulate, and access config file settings.

Index

Constants

View Source
const VMUserDataPath = "vm:user-data"

VMUserDataPath is a sentinel value for Load to use to get the data from the VM's metadata service's user-data field.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Path    string // disk path of HuJSON, or VMUserDataPath
	Raw     []byte // raw bytes from disk, in HuJSON form
	Std     []byte // standardized JSON form
	Version string // "alpha0" for now

	// Parsed is the parsed config, converted from its on-disk version to the
	// latest known format.
	//
	// As of 2023-10-15 there is exactly one format ("alpha0") so this is both
	// the on-disk format and the in-memory upgraded format.
	Parsed ipn.ConfigVAlpha
}

Config describes a config file.

func Load

func Load(path string) (*Config, error)

Load reads and parses the config file at the provided path on disk.

func (*Config) WantRunning

func (c *Config) WantRunning() bool

WantRunning reports whether c is non-nil and it's configured to be running.

type ServiceDetailsFile added in v1.90.0

type ServiceDetailsFile struct {
	// Version is always "0.0.1", set if and only if this is not inside a
	// [ServiceConfigFile].
	Version string `json:"version,omitzero"`

	// Endpoints are sets of reverse proxy mappings from ProtoPortRanges on a
	// Service to Targets (proto+destination+port) on remote destinations (or
	// localhost).
	// For example, "tcp:443" -> "tcp://localhost:8000" is an endpoint definition
	// mapping traffic on the TCP port 443 of the Service to port 8080 on localhost.
	// The Proto in the key must be populated.
	// As a special case, if the only mapping provided is "*" -> "TUN", that
	// enables TUN/L3 mode, where packets are delivered to the Tailscale network
	// interface with the understanding that the user will deal with them manually.
	Endpoints map[*tailcfg.ProtoPortRange]*Target `json:"endpoints"`

	// Advertised is a flag that tells control whether or not the client thinks
	// it is ready to host a particular Tailscale Service. If unset, it is
	// assumed to be true.
	Advertised opt.Bool `json:"advertised,omitzero"`
}

ServiceDetailsFile is the config syntax for an individual Tailscale Service.

type ServiceProtocol added in v1.90.0

type ServiceProtocol string

ServiceProtocol is the protocol of a Target.

const (
	ProtoHTTP             ServiceProtocol = "http"
	ProtoHTTPS            ServiceProtocol = "https"
	ProtoHTTPSInsecure    ServiceProtocol = "https+insecure"
	ProtoTCP              ServiceProtocol = "tcp"
	ProtoTLSTerminatedTCP ServiceProtocol = "tls-terminated-tcp"
	ProtoFile             ServiceProtocol = "file"
	ProtoTUN              ServiceProtocol = "TUN"
)

type ServicesConfigFile added in v1.90.0

type ServicesConfigFile struct {
	// Version is always "0.0.1" and always present.
	Version string `json:"version"`

	Services map[tailcfg.ServiceName]*ServiceDetailsFile `json:"services,omitzero"`
}

ServicesConfigFile is the config file format for services configuration.

func LoadServicesConfig added in v1.90.0

func LoadServicesConfig(filename string, forService string) (*ServicesConfigFile, error)

type Target added in v1.90.0

type Target struct {
	// The protocol over which to communicate with the Destination.
	// Protocol == ProtoTUN is a special case, activating "TUN mode" where
	// packets are delivered to the Tailscale TUN interface and then manually
	// handled by the user.
	Protocol ServiceProtocol

	// If Protocol is ProtoFile, then Destination is a file path.
	// If Protocol is ProtoTUN, then Destination is empty.
	// Otherwise, it is a host.
	Destination string

	// If Protocol is not ProtoFile or ProtoTUN, then DestinationPorts is the
	// set of ports on which to connect to the host referred to by Destination.
	DestinationPorts tailcfg.PortRange
}

Target is a destination for traffic to go to when it arrives at a Tailscale Service host.

func (*Target) MarshalText added in v1.90.0

func (t *Target) MarshalText() ([]byte, error)

func (*Target) UnmarshalJSON added in v1.90.0

func (t *Target) UnmarshalJSON(buf []byte) error

UnmarshalJSON implements [jsonv1.Unmarshaler].

func (*Target) UnmarshalJSONFrom added in v1.90.0

func (t *Target) UnmarshalJSONFrom(dec *jsontext.Decoder) error

UnmarshalJSONFrom implements jsonv2.UnmarshalerFrom.

Jump to

Keyboard shortcuts

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