web

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateServer added in v0.4.0

type PrivateServer struct {
	*Server
	// contains filtered or unexported fields
}

PrivateServer is the desktop-shell topology from the control deck plan (0E): a per-launch DevX web server bound to a random loopback port with an ephemeral token that lives only in process memory. The desktop host reads Addr/Token via native bindings and injects them into the privileged WebView; the token is never placed in URLs, CLI args, logs, or persisted storage.

func NewPrivateServer added in v0.4.0

func NewPrivateServer() (*PrivateServer, error)

NewPrivateServer creates a private server on a random loopback port with a freshly generated ephemeral token.

func (*PrivateServer) Addr added in v0.4.0

func (p *PrivateServer) Addr() string

Addr returns the bound loopback address, e.g. "127.0.0.1:49213".

func (*PrivateServer) Serve added in v0.4.0

func (p *PrivateServer) Serve() error

Serve blocks serving HTTP on the pre-bound listener.

func (*PrivateServer) TerminalBootstrapToken added in v0.4.0

func (p *PrivateServer) TerminalBootstrapToken() string

TerminalBootstrapToken returns a per-launch token scoped to direct terminal iframes from the Wails shell. It is not the main API token: presenting it as desktop_token on /terminal/<session> authorizes only terminal traffic. The token stays in the iframe URL rather than using a cookie redirect because the iframe is cross-site relative to wails:// and WebKit blocks SameSite cookies in that third-party context.

func (*PrivateServer) Token added in v0.4.0

func (p *PrivateServer) Token() string

Token returns the ephemeral per-launch token. Callers must keep it in memory only.

type Server

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

Server is the devx web HTTP server

func New

func New(token string, port int, gatepostCfg target.GatepostRuntimeConfig) (*Server, error)

New creates a new Server. token must be non-empty.

func NewWithBind added in v0.4.0

func NewWithBind(token string, port int, bind string, gatepostCfg target.GatepostRuntimeConfig) (*Server, error)

NewWithBind creates a new Server bound to the given address. bind defaults to loopback (127.0.0.1) when empty. Binding to 0.0.0.0 is only intended for running devx web inside a container where Docker port publishing requires it; it must not be used to expose plain HTTP directly on an untrusted network.

func (*Server) ConfigureUsage added in v0.4.0

func (s *Server) ConfigureUsage(opts UsageOptions) error

ConfigureUsage validates opts and stores them for startBackground to build a poller from. It must be called before Start/Serve, and must not be called again while a poller built from a previous call is running (Shutdown or a never-started server): usage.Poller.Start panics if a single Poller instance is started twice, so reconfiguring live would either crash on the next start or silently keep serving the old config. Call ConfigureUsage again only after Shutdown (or before the first Start).

Validation builds a Redline client from opts to catch a misconfigured URL (non-loopback without allow_remote, which would put the API token on the network) at startup rather than on the first poll; that client is discarded and startBackground builds its own so a fresh Start→Stop→Start cycle never reuses one. A missing or unreadable Redline token is not a startup failure: the poller still runs and reports "Redline rejected the API token" or "not running" instead of the server refusing to boot.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully stops the server. The poller is cancelled first, the HTTP server is shut down second, and only then does Shutdown wait for the poller's goroutine to exit — so a slow in-flight Redline poll cannot eat into ctx's deadline before the HTTP server even starts closing connections (desktop passes a 3s deadline here).

func (*Server) Start

func (s *Server) Start() error

Start begins listening and serving.

type UsageOptions added in v0.4.0

type UsageOptions struct {
	Enabled      bool
	PollInterval time.Duration
	RedlineURL   string
	TokenFile    string
	AllowRemote  bool
}

UsageOptions configures the provider usage poller. It is viper-free so the desktop shell, which never initializes viper, can build it directly.

func UsageOptionsFromGlobalConfig added in v0.4.0

func UsageOptionsFromGlobalConfig() UsageOptions

UsageOptionsFromGlobalConfig builds UsageOptions the way every caller (cmd/web.go, cmd/web_windows.go, desktop/main.go) must: usage.enabled and usage.poll_interval may come from the merged viper singleton (a project override there is harmless), but the three usage.redline.* keys are security-sensitive — url, token_file and allow_remote control which host gets the Redline bearer token and which file on disk is read as that token. A project-level .devx/config.yaml is repo-supplied and must never set them: a malicious repo could point url at an attacker host and token_file at an arbitrary 0600 file to exfiltrate it. So the redline.* keys are read from a private viper instance pinned to the global config file only (~/.config/devx/config.yaml), mirroring the global-config path logic in initConfig (cmd/root.go), with the same DEVX_ env-var override support. Defaults for all four fields come from usage.DefaultBaseURL / usage.DefaultPollInterval, the same source cmd/root.go's viper defaults use.

Directories

Path Synopsis
Package imagepolicy is the single source of truth for which image types the upload flow accepts and the maximum upload size.
Package imagepolicy is the single source of truth for which image types the upload flow accepts and the maximum upload size.

Jump to

Keyboard shortcuts

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