settings

package
v1.9.10-0...-1ccd1c0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpenAIProviderOpenAI     = "openai"
	OpenAIProviderAtlasCloud = "atlas_cloud"
	OpenAIProviderMiniMax    = "minimax"
	OpenAIProviderCustom     = "custom"
	AtlasCloudBaseURL        = "https://api.atlascloud.ai/v1"
	MiniMaxGlobalOpenAIURL   = "https://api.minimax.io/v1"
	MiniMaxCNOpenAIURL       = "https://api.minimaxi.com/v1"
)
View Source
const InvalidLogrotateIntervalMessage = "logrotate interval must be greater than 0"
View Source
const RedactedSensitiveValue = "__NGINX_UI_REDACTED__"

RedactedSensitiveValue is the sentinel string returned in place of sensitive setting values (secrets, tokens, IP allow-list entries) by the settings API. Payloads that echo it back are treated as "keep the current value" rather than an actual user-supplied override.

Variables

View Source
var (
	LastModified string
	EnvPrefix    = "NGINX_UI_"
)
View Source
var AuthSettings = &Auth{
	BanThresholdMinutes: 10,
	MaxAttempts:         10,
}
View Source
var BackupSettings = &Backup{
	GrantedAccessPath: []string{},
}

BackupSettings is the global configuration instance for backup operations. This variable holds the current backup security settings and access permissions.

Default configuration:

  • GrantedAccessPath: Empty list (no paths allowed by default for security)

To enable backup functionality, administrators must explicitly configure allowed paths through the settings interface or configuration file.

View Source
var CasdoorSettings = &Casdoor{}
View Source
var CertSettings = &Cert{
	Email:                "",
	CADir:                "",
	RenewalInterval:      30,
	RecursiveNameservers: []string{},
	HTTPChallengePort:    "9180",
}
View Source
var ClusterSettings = &Cluster{
	Node: []string{},
}
View Source
var CryptoSettings = &Crypto{}
View Source
var DatabaseSettings = &Database{
	Name: "database",
}
View Source
var HTTPSettings = &HTTP{
	WebSocketTrustedOrigins: []string{},
}
View Source
var LogrotateSettings = &Logrotate{
	Enabled:  false,
	CMD:      "logrotate /etc/logrotate.d/nginx",
	Interval: defaultLogrotateIntervalMinutes,
}
View Source
var NginxLogSettings = &NginxLog{}
View Source
var NginxSettings = &Nginx{}
View Source
var NodeSettings = &Node{}
View Source
var OIDCSettings = &OIDC{}
View Source
var OpenAISettings = &OpenAI{
	Provider: OpenAIProviderOpenAI,
	APIType:  string(openai.APITypeOpenAI),
}
View Source
var SiteCheckSettings = &SiteCheck{
	Enabled:         true,
	Concurrency:     defaultSiteCheckConcurrency,
	IntervalSeconds: defaultSiteCheckIntervalSeconds,
}
View Source
var TerminalSettings = &Terminal{
	StartCmd: "login",
}
View Source
var UpstreamCheckSettings = &UpstreamCheck{
	Enabled:         true,
	IntervalSeconds: defaultUpstreamCheckIntervalSeconds,
}
View Source
var WebAuthnSettings = &WebAuthn{}

Functions

func BuildRestoreConfig

func BuildRestoreConfig(backupPath, currentPath string, preserveProtected bool) ([]byte, []string, error)

BuildRestoreConfig parses and validates a backup configuration. Portable restores copy every field except destination-owned protected settings.

func Init

func Init(confPath string)

func ReloadCluster

func ReloadCluster() (err error)

func Save

func Save() (err error)

func Update

func Update(fn func()) (err error)

Types

type Auth

type Auth struct {
	IPWhiteList         []string `json:"ip_white_list" binding:"omitempty,dive,ip|redacted" ini:",,allowshadow" protected:"true"`
	BanThresholdMinutes int      `json:"ban_threshold_minutes" binding:"min=1"`
	MaxAttempts         int      `json:"max_attempts" binding:"min=1"`
}

type Backup

type Backup struct {
	// GrantedAccessPath defines the list of directory paths that are allowed for backup operations.
	// All backup source paths and storage destination paths must be within one of these directories.
	// This security measure prevents unauthorized access to sensitive system directories.
	//
	// Examples:
	//   - "/tmp" - Allow backups in temporary directory
	//   - "/var/backups" - Allow backups in system backup directory
	//   - "/home/user/backups" - Allow backups in user's backup directory
	//
	// Note: Paths are checked using prefix matching, so "/tmp" allows "/tmp/backup" but not "/tmpfoo"
	GrantedAccessPath []string `json:"granted_access_path" ini:",,allowshadow"`
}

Backup contains configuration settings for backup operations. This structure defines security constraints and access permissions for backup functionality.

type Casdoor

type Casdoor struct {
	Endpoint        string `json:"endpoint" protected:"true"`
	ExternalUrl     string `json:"external_url" protected:"true"`
	ClientId        string `json:"client_id" protected:"true"`
	ClientSecret    string `json:"client_secret" protected:"true" sensitive:"true"`
	CertificatePath string `json:"certificate_path" protected:"true"`
	Organization    string `json:"organization" protected:"true"`
	Application     string `json:"application" protected:"true"`
	RedirectUri     string `json:"redirect_uri" protected:"true"`
}

type Cert

type Cert struct {
	Email                string   `json:"email" protected:"true"`
	CADir                string   `json:"ca_dir" binding:"omitempty,url"`
	RenewalInterval      int      `json:"renewal_interval" binding:"min=1,max=90"`
	RecursiveNameservers []string `json:"recursive_nameservers" binding:"omitempty,dive,hostname_port"`
	HTTPChallengePort    string   `json:"http_challenge_port"`
}

func (*Cert) GetCADir

func (s *Cert) GetCADir() string

func (*Cert) GetCertRenewalInterval

func (s *Cert) GetCertRenewalInterval() int

GetCertRenewalInterval returns the configured remaining-validity threshold in days.

type Cluster

type Cluster struct {
	Node []string `json:"node" ini:",,allowshadow" protected:"true" sensitive:"true"`
}

type Crypto

type Crypto struct {
	Secret string `json:"secret" protected:"true" sensitive:"true"`
}

func (*Crypto) GetSecretMd5

func (c *Crypto) GetSecretMd5() []byte

type Database

type Database struct {
	Name string `json:"name"`
}

func (*Database) GetName

func (d *Database) GetName() string

type HTTP

type HTTP struct {
	GithubProxy             string   `json:"github_proxy" binding:"omitempty,url"`
	InsecureSkipVerify      bool     `json:"insecure_skip_verify" protected:"true"`
	WebSocketTrustedOrigins []string `json:"websocket_trusted_origins" binding:"omitempty,dive,url" env:"WEBSOCKET_TRUSTED_ORIGINS"`
}

type Logrotate

type Logrotate struct {
	Enabled  bool   `json:"enabled"`
	CMD      string `json:"cmd" protected:"true"`
	Interval int    `json:"interval" binding:"omitempty,min=1"`
}

func (*Logrotate) GetInterval

func (l *Logrotate) GetInterval() time.Duration

Pointer receiver so the call reads only Interval rather than copying the whole struct, which would make it race with any concurrent settings write.

func (Logrotate) HasValidInterval

func (l Logrotate) HasValidInterval() bool

type Nginx

type Nginx struct {
	AccessLogPath       string   `json:"access_log_path" protected:"true"`
	ErrorLogPath        string   `json:"error_log_path" protected:"true"`
	LogDirWhiteList     []string `json:"log_dir_white_list" protected:"true"`
	ConfigDir           string   `json:"config_dir" protected:"true"`
	ConfigPath          string   `json:"config_path" protected:"true"`
	PIDPath             string   `json:"pid_path" protected:"true"`
	SbinPath            string   `json:"sbin_path" protected:"true"`
	TestConfigCmd       string   `json:"test_config_cmd" protected:"true"`
	ReloadCmd           string   `json:"reload_cmd" protected:"true"`
	RestartCmd          string   `json:"restart_cmd" protected:"true"`
	StubStatusPort      uint     `json:"stub_status_port" binding:"omitempty,min=1,max=65535"`
	ContainerName       string   `json:"container_name" protected:"true"`
	MaintenanceTemplate string   `json:"maintenance_template"`
}

func (*Nginx) GetStubStatusPort

func (n *Nginx) GetStubStatusPort() uint

func (*Nginx) RunningInAnotherContainer

func (n *Nginx) RunningInAnotherContainer() bool

type NginxLog

type NginxLog struct {
	IndexingEnabled bool   `json:"indexing_enabled"`
	IndexPath       string `json:"index_path"`
	// IncrementalIndexInterval controls how often the incremental indexing job runs, in minutes.
	// When set to 0 or a negative value, a conservative default will be used.
	IncrementalIndexInterval int `json:"incremental_index_interval"`
	// MaxConcurrentIndexTasks caps how many log groups are indexed at the same
	// time. Each concurrent group buffers a parse batch and an index batch per
	// rotated file, so this is the main lever on peak indexing memory.
	// When set to 0 or a negative value, the value is derived from the CPU
	// budget the process is allowed to use.
	MaxConcurrentIndexTasks int `json:"max_concurrent_index_tasks"`
}

func (*NginxLog) GetIncrementalIndexInterval

func (n *NginxLog) GetIncrementalIndexInterval() time.Duration

GetIncrementalIndexInterval returns the effective incremental indexing interval. Defaults to 15 minutes when not configured or configured with an invalid value.

type Node

type Node struct {
	Name                 string `json:"name" binding:"omitempty,safety_text"`
	Secret               string `json:"secret" protected:"true" sensitive:"true"`
	InstanceID           string `json:"instance_id" protected:"true"`
	SkipInstallation     bool   `json:"skip_installation" protected:"true"`
	Demo                 bool   `json:"demo" protected:"true"`
	ICPNumber            string `json:"icp_number" binding:"omitempty,safety_text"`
	PublicSecurityNumber string `json:"public_security_number" binding:"omitempty,safety_text"`
}

type OIDC

type OIDC struct {
	ClientId     string `json:"client_id" protected:"true"`
	ClientSecret string `json:"client_secret" protected:"true" sensitive:"true"`
	Endpoint     string `json:"endpoint" protected:"true"`
	RedirectUri  string `json:"redirect_uri" protected:"true"`
	Scopes       string `json:"scopes" protected:"true"`
	Identifier   string `json:"identifier" protected:"true"`
}

type OpenAI

type OpenAI struct {
	Provider             string `json:"provider" binding:"omitempty,oneof=openai atlas_cloud minimax custom"`
	BaseUrl              string `json:"base_url" binding:"omitempty,url"`
	Token                string `json:"token" binding:"omitempty,safety_text" sensitive:"true"`
	Proxy                string `json:"proxy" binding:"omitempty,url"`
	Model                string `json:"model" binding:"omitempty,safety_text"`
	APIType              string `json:"api_type" binding:"omitempty,oneof=OPEN_AI AZURE"`
	EnableCodeCompletion bool   `json:"enable_code_completion" binding:"omitempty"`
	CodeCompletionModel  string `json:"code_completion_model" binding:"omitempty,safety_text"`
}

func (*OpenAI) GetBaseURL

func (o *OpenAI) GetBaseURL() string

func (*OpenAI) GetCodeCompletionModel

func (o *OpenAI) GetCodeCompletionModel() string

func (*OpenAI) GetProvider

func (o *OpenAI) GetProvider() string

type SiteCheck

type SiteCheck struct {
	Enabled         bool `json:"enabled"`
	Concurrency     int  `json:"concurrency" binding:"omitempty,min=1,max=20"`
	IntervalSeconds int  `json:"interval_seconds" binding:"omitempty,min=30"`
}

func (*SiteCheck) GetConcurrency

func (s *SiteCheck) GetConcurrency() int

GetConcurrency returns the configured concurrency, clamped to a safe range.

Pointer receiver on purpose. A value receiver copies the whole struct on every call, so the periodic check loop was reading Enabled once a tick even though it only wants Concurrency — enough for the race detector to flag it against any test that toggles Enabled. Reading just the field also avoids a struct copy in a hot loop.

func (*SiteCheck) GetInterval

func (s *SiteCheck) GetInterval() time.Duration

GetInterval returns the periodic sweep interval, clamped to a safe minimum. Pointer receiver for the same reason as GetConcurrency.

type Terminal

type Terminal struct {
	StartCmd string `json:"start_cmd" protected:"true"`
}

type UpstreamCheck

type UpstreamCheck struct {
	Enabled         bool `json:"enabled"`
	IntervalSeconds int  `json:"interval_seconds" binding:"omitempty,min=5"`
}

func (*UpstreamCheck) GetInterval

func (s *UpstreamCheck) GetInterval() time.Duration

Pointer receiver so the call reads only the interval field rather than copying the whole struct, which would make it race with concurrent writes.

type WebAuthn

type WebAuthn struct {
	RPDisplayName string   `json:"rp_display_name"`
	RPID          string   `json:"rpid"`
	RPOrigins     []string `json:"rp_origins"`
}

Jump to

Keyboard shortcuts

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