config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func NormalizeCORSOrigin(value string) (string, error)

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

func Path(configFlag string, lookupEnv func(string) (string, bool)) (string, bool)

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

func ResolveHost(host string) (net.IP, error)

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.

func Load

func Load(configFlag string, lookupEnv func(string) (string, bool), flags Overrides) (*Config, error)

Load resolves the configuration. configFlag is the --config value (empty when unset), lookupEnv is os.LookupEnv outside tests, and flags holds only the flags the user actually passed.

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.

func (*Error) Error

func (e *Error) Error() string

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.

Jump to

Keyboard shortcuts

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