Documentation
¶
Index ¶
- Variables
- func BuildBandwidthLimits(cfg *FileConfig) *limiter.ClientBandwidthLimits
- func CreateGetToken(ref *Ref, serverVersion string) types.GetToken
- func Dir(configPath string) string
- func FindFile() string
- func IsDurationField(path string) bool
- func LoadRaw(path string) ([]byte, error)
- func ReadPIDFile(path string) (int, error)
- func RemovePIDFile(path string)
- func ResolvePublicHTTPNoAuthTiming(cfg *FileConfig) (time.Duration, time.Duration)
- func SaveAtomic(path string, cfg *FileConfig) error
- func SaveRawAtomic(path string, raw []byte) error
- func SignalReload(pidFile string) error
- func Validate(cfg *FileConfig) error
- func WritePIDFile(path string) error
- type AdminConfig
- type AdminDatabase
- type AdminRuntime
- type AdminUI
- type ApplyOptions
- type BandwidthLimitsConfig
- type ClientConfig
- type FileConfig
- type Manager
- type Override
- func (o *Override) Apply(base *FileConfig) *FileConfig
- func (o *Override) ClearAll()
- func (o *Override) Delete(path string)
- func (o *Override) Get(path string) (json.RawMessage, bool)
- func (o *Override) List() []OverrideEntry
- func (o *Override) Set(path string, value any) error
- func (o *Override) Size() int
- type OverrideEntry
- type PublicHTTPNoAuthConfig
- type Ref
- type ReloadFunc
- type ResolvedAdmin
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
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 ¶
CreateGetToken returns a GetToken function backed by ref.
func FindFile ¶
func FindFile() string
FindFile returns the first existing config path from SearchPaths.
func IsDurationField ¶
IsDurationField returns true if the leaf at `path` is expected to be a duration string. Used by the admin UI to format input correctly.
func ReadPIDFile ¶
ReadPIDFile returns the pid stored in path.
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 ¶
SaveRawAtomic writes raw YAML to path.
func SignalReload ¶
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 ¶
WritePIDFile writes the current process id to path.
Types ¶
type AdminConfig ¶
type AdminConfig struct {
Enabled bool `yaml:"enabled"`
Listen string `yaml:"listen"`
Database AdminDatabase `yaml:"database"`
Runtime AdminRuntime `yaml:"runtime"`
UI AdminUI `yaml:"ui"`
}
AdminConfig controls the optional admin console HTTP server.
type AdminDatabase ¶
type AdminDatabase struct {
Path string `yaml:"path"`
}
type AdminRuntime ¶
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"`
Clients map[string]*limiter.BandwidthLimit `yaml:"clients"`
}
type ClientConfig ¶
type ClientConfig struct {
ClientID string `yaml:"clientId"`
ClientSecret string `yaml:"clientSecret"`
Config *client.Config `yaml:"config"`
BandwidthLimit *limiter.BandwidthLimit `yaml:"bandwidthLimit"`
Tunnels []client.TunnelSpec `yaml:"tunnels,omitempty"`
}
type FileConfig ¶
type FileConfig struct {
Domain string `yaml:"domain"`
Port int `yaml:"port"`
TCPPort int `yaml:"tcpPort"`
Secure *bool `yaml:"secure"`
Token string `yaml:"token"`
Clients []ClientConfig `yaml:"clients"`
Notification *client.NotificationConfig `yaml:"notification"`
BandwidthLimits *BandwidthLimitsConfig `yaml:"bandwidthLimits"`
PublicHTTPNoAuth *PublicHTTPNoAuthConfig `yaml:"publicHTTPNoAuth,omitempty"`
Admin *AdminConfig `yaml:"admin,omitempty"`
}
FileConfig is the on-disk inlets server YAML document.
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) EffectiveConfig ¶
func (m *Manager) EffectiveConfig() *FileConfig
EffectiveConfig returns the current config with all active overrides applied. Callers that need to observe user-driven temporary changes (the admin UI's "override" tab, for instance) should call this instead of ref.Get() directly.
type Override ¶
type Override struct {
// contains filtered or unexported fields
}
Override is an in-memory set of patches layered over a *FileConfig. Patches are stored as JSON-pointer-like paths (e.g. "clients[0].clientSecret") and applied on top of an immutable base at read time.
Design notes (see AGENTS.md 2024-12-19 concurrency lesson):
- Apply() does NOT mutate its argument. It deep-copies via JSON round-trip and writes the patches into the copy.
- Reads take a brief RLock, copy, return.
- Writes take a Lock.
- Patch paths that resolve to a missing field fail-fast at Set time.
func (*Override) Apply ¶
func (o *Override) Apply(base *FileConfig) *FileConfig
Apply returns a deep copy of `base` with all patches applied. The argument is never mutated.
func (*Override) Get ¶
func (o *Override) Get(path string) (json.RawMessage, bool)
Get returns the raw JSON value of a patch.
func (*Override) List ¶
func (o *Override) List() []OverrideEntry
List returns a copy of the current patches.
type OverrideEntry ¶
type OverrideEntry struct {
Path string `json:"path"`
Value json.RawMessage `json:"value"`
}
OverrideEntry is the JSON-friendly view of a single patch.
type PublicHTTPNoAuthConfig ¶
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.
type ValidationError ¶
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