config

package
v1.29.4 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SearchPaths = []string{
	"{CWD}/.go-idp/inlets.yaml",
	"{CWD}/.inlets.yaml",
	"{HOME}/.go-idp/inlets/config.yaml",
	"{HOME}/.config/inlets.yaml",
	"{HOME}/.config/inlets.yml",
	"/etc/go-idp/inlets/config.yaml",
	"/etc/inlets/config.yaml",
}

SearchPaths defines default config file locations (priority order).

Functions

func BuildBandwidthLimits

func BuildBandwidthLimits(cfg *FileConfig) *limiter.ClientBandwidthLimits

func CreateGetToken

func CreateGetToken(ref *Ref, serverVersion string) types.GetToken

CreateGetToken returns a GetToken function backed by ref.

func Dir

func Dir(configPath string) string

Dir returns the directory containing the config file.

func FindFile

func FindFile() string

FindFile returns the first existing config path from SearchPaths.

func LoadRaw

func LoadRaw(path string) ([]byte, error)

LoadRaw returns the raw YAML bytes.

func ReadPIDFile

func ReadPIDFile(path string) (int, error)

ReadPIDFile returns the pid stored in path.

func RemovePIDFile

func RemovePIDFile(path string)

RemovePIDFile deletes the pid file if present.

func ResolvePublicHTTPNoAuthTiming

func ResolvePublicHTTPNoAuthTiming(cfg *FileConfig) (time.Duration, time.Duration)

func SaveAtomic

func SaveAtomic(path string, cfg *FileConfig) error

SaveAtomic writes cfg to path using a temp file and rename.

func SaveRawAtomic

func SaveRawAtomic(path string, raw []byte) error

SaveRawAtomic writes raw YAML to path.

func SignalReload

func SignalReload(pidFile string) error

SignalReload sends SIGHUP to the process in pidFile.

func Validate

func Validate(cfg *FileConfig) error

Validate returns a single error (errors.Join) or nil. Kept for callers that only need a yes/no answer.

func WritePIDFile

func WritePIDFile(path string) error

WritePIDFile writes the current process id to path.

Types

type AdminConfig

type AdminConfig struct {
	Enabled  bool          `yaml:"enabled" json:"enabled"`
	Listen   string        `yaml:"listen" json:"listen,omitempty"`
	Database AdminDatabase `yaml:"database" json:"database,omitempty"`
	Runtime  AdminRuntime  `yaml:"runtime" json:"runtime,omitempty"`
	UI       AdminUI       `yaml:"ui" json:"ui,omitempty"`
}

AdminConfig controls the optional admin console HTTP server.

type AdminDatabase

type AdminDatabase struct {
	Path string `yaml:"path" json:"path,omitempty"`
}

type AdminRuntime

type AdminRuntime struct {
	PidFile          string `yaml:"pidFile" json:"pidFile,omitempty"`
	SnapshotInterval string `yaml:"snapshotInterval" json:"snapshotInterval,omitempty"`
}

type AdminUI

type AdminUI struct {
	BasePath string `yaml:"basePath" json:"basePath,omitempty"`
}

type ApplyOptions

type ApplyOptions struct {
	GetToken                     types.GetToken
	Notification                 *client.NotificationConfig
	BandwidthLimits              *limiter.ClientBandwidthLimits
	PublicHTTPNoAuthSessionTTL   time.Duration
	PublicHTTPNoAuthWarnLeadTime time.Duration
}

ApplyOptions carries runtime fields derived from FileConfig.

func BuildApplyOptions

func BuildApplyOptions(cfg *FileConfig, serverVersion string, getToken types.GetToken) ApplyOptions

BuildApplyOptions constructs ApplyOptions from a config document.

type BandwidthLimitsConfig

type BandwidthLimitsConfig struct {
	Global  *limiter.BandwidthLimit            `yaml:"global" json:"global,omitempty"`
	Clients map[string]*limiter.BandwidthLimit `yaml:"clients" json:"clients,omitempty"`
}

type ClientConfig

type ClientConfig struct {
	ClientID       string                  `yaml:"clientId" json:"clientId"`
	ClientSecret   string                  `yaml:"clientSecret" json:"clientSecret"`
	Config         *client.Config          `yaml:"config" json:"config,omitempty"`
	BandwidthLimit *limiter.BandwidthLimit `yaml:"bandwidthLimit" json:"bandwidthLimit,omitempty"`
	Tunnels        []client.TunnelSpec     `yaml:"tunnels,omitempty" json:"tunnels,omitempty"`
}

type FileConfig

type FileConfig struct {
	Domain           string                     `yaml:"domain" json:"domain"`
	Port             int                        `yaml:"port" json:"port"`
	TCPPort          int                        `yaml:"tcpPort" json:"tcpPort"`
	Secure           *bool                      `yaml:"secure" json:"secure,omitempty"`
	Token            string                     `yaml:"token" json:"token,omitempty"`
	Clients          []ClientConfig             `yaml:"clients" json:"clients,omitempty"`
	Notification     *client.NotificationConfig `yaml:"notification" json:"notification,omitempty"`
	BandwidthLimits  *BandwidthLimitsConfig     `yaml:"bandwidthLimits" json:"bandwidthLimits,omitempty"`
	PublicHTTPNoAuth *PublicHTTPNoAuthConfig    `yaml:"publicHTTPNoAuth,omitempty" json:"publicHTTPNoAuth,omitempty"`
	Admin            *AdminConfig               `yaml:"admin,omitempty" json:"admin,omitempty"`
}

FileConfig is the on-disk inlets server YAML document.

func Load

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

Load reads and parses a YAML config file.

type Manager

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

Manager coordinates config file reload.

func NewManager

func NewManager(path string, ref *Ref, apply ReloadFunc) *Manager

func (*Manager) Path

func (m *Manager) Path() string

func (*Manager) Ref

func (m *Manager) Ref() *Ref

func (*Manager) Reload

func (m *Manager) Reload() error

Reload reads the config file, validates, updates ref, and applies.

type PublicHTTPNoAuthConfig

type PublicHTTPNoAuthConfig struct {
	Timeout  string `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	WarnLead string `yaml:"warnLead,omitempty" json:"warnLead,omitempty"`
}

type Ref

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

Ref holds the live server config document for hot reload.

func NewRef

func NewRef(initial *FileConfig) *Ref

func (*Ref) Get

func (r *Ref) Get() *FileConfig

func (*Ref) Set

func (r *Ref) Set(cfg *FileConfig)

type ReloadFunc

type ReloadFunc func(cfg *FileConfig) error

ReloadFunc applies a freshly loaded config to the running server.

type ResolvedAdmin

type ResolvedAdmin struct {
	Enabled          bool
	Host             string
	Port             int
	DatabasePath     string
	PidFile          string
	SnapshotInterval time.Duration
	UIBasePath       string
}

ResolvedAdmin holds parsed admin settings with defaults applied.

func ResolveAdmin

func ResolveAdmin(cfg *FileConfig, configPath string) (*ResolvedAdmin, error)

ResolveAdmin applies defaults for admin settings.

func (*ResolvedAdmin) SameListen added in v1.29.3

func (r *ResolvedAdmin) SameListen(other *ResolvedAdmin) bool

SameListen reports whether two resolved admin configs bind the same HTTP listener.

type ValidationError

type ValidationError struct {
	Path    string `json:"path"`
	Message string `json:"message"`
}

ValidationError describes a single configuration problem with a machine-addressable path (dotted/indexed, e.g. "clients[2].clientSecret").

func ValidateWithDetails

func ValidateWithDetails(cfg *FileConfig) []ValidationError

validateWithDetails runs the same checks as Validate but returns a structured list of errors keyed by JSON-pointer-like paths. The function is pure (does not load files) and is safe to call from request handlers.

func (ValidationError) Error

func (e ValidationError) Error() string

Jump to

Keyboard shortcuts

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