Documentation
¶
Overview ¶
Package config resolves the proxy's settings from defaults, a TOML file, COMFY_PROXY_* environment variables, and flags, in that order of precedence.
Index ¶
Constants ¶
const ( DefaultComfyUI = "http://127.0.0.1:8188" DefaultHost = HostLocal DefaultPort = 8189 DefaultMaxUploadMB = 100 // HostLocal and HostGlobal are the named bind scopes accepted wherever a // host is, alongside a literal IP or "localhost". HostLocal = "local" HostGlobal = "global" EnvPrefix = "COMFY_PROXY_" EnvConfig = EnvPrefix + "CONFIG" )
Variables ¶
This section is empty.
Functions ¶
func NormalizeCORSOrigin ¶
NormalizeCORSOrigin validates one allowlisted browser origin and returns it in the form browsers send in the Origin header: http(s)://host[:port], with default ports dropped. A "*" wildcard is refused, since authenticated browser traffic must never get an unrestricted Access-Control-Allow-Origin.
func Path ¶
Path reports which config file Load would read and whether it was named explicitly (by --config or COMFY_PROXY_CONFIG). Empty when there is no default location to look in.
func ResolveHost ¶
ResolveHost turns a host setting into the IP to bind. It accepts the named scopes "local" and "global", "localhost", or a literal IPv4/IPv6 address. An empty host is rejected: a socket treats it as every interface, which would slip past the loopback check while reading as unset.
Types ¶
type Config ¶
type Config struct {
ComfyUI string `toml:"comfyui"`
Host string `toml:"host"`
Port int `toml:"port"`
Token string `toml:"token"`
// ComfyUIToken is sent to ComfyUI as a bearer token, for a ComfyUI
// behind an authenticating gateway. Never forwarded to clients.
ComfyUIToken string `toml:"comfyui_token"`
ComfyUIBaseDir string `toml:"comfyui_base_dir"`
MaxUploadMB int `toml:"max_upload_mb"`
AllowInsecureBind bool `toml:"allow_insecure_bind"`
StateDir string `toml:"state_dir"`
CORSOrigins []string `toml:"cors_origins"`
// PublicURL is the origin clients reach the proxy at, used for every URL
// the proxy puts in a response. Unset, links follow the request's Host,
// which reads as http behind a TLS-terminating reverse proxy.
PublicURL string `toml:"public_url"`
// Quiet turns off the per-request access log.
Quiet bool `toml:"quiet"`
// BindIP is Host resolved to the address the listener binds.
BindIP net.IP `toml:"-"`
// File is the config file that was read, empty when none was.
File string `toml:"-"`
// Sources records where each key's final value came from, for error
// messages and startup output.
Sources map[string]string `toml:"-"`
}
Config is the fully resolved configuration. Field tags are the TOML keys.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is a configuration problem the user has to fix. The CLI exits 2 on it.
type Overrides ¶
type Overrides struct {
ComfyUI *string
Host *string
Port *int
Token *string
ComfyUIToken *string
ComfyUIBaseDir *string
MaxUploadMB *int
AllowInsecureBind *bool
StateDir *string
CORSOrigins []string
PublicURL *string
Quiet *bool
}
Overrides carries values from one layer above the file. A nil field means the layer did not set that key.