hostbridge

package
v0.0.1-alpha.30 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package hostbridge wires a stream of domain-registration events from the overcast emulator to the host machine's mDNS responder and local trust store. It is the implementation behind the `overcast dev` subcommand.

The bridge is deliberately small: it owns an active set of published records, consumes Events from a Source, and translates them into calls on an mdns.Publisher. Everything platform-specific lives behind the mdns.Publisher and trust.Store interfaces — this file has no OS knowledge.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProxy

func NewProxy(apiAddr, uiAddr string) http.Handler

NewProxy returns an http.Handler that routes requests to either apiAddr or uiAddr based on the Host header:

  • overcast-app.local → uiAddr (web console)
  • everything else → apiAddr (emulator API + API Gateway custom domains)

Types

type Bridge

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

Bridge consumes Events from a Source and drives an mdns.Publisher, maintaining an internal set of currently-published records so that Close cleanly withdraws every advertisement on shutdown.

func New

func New(pub mdns.Publisher, src Source, log *zap.Logger) *Bridge

New constructs a Bridge. All three arguments are required; passing nil for any of them is a programming error.

func (*Bridge) Active

func (b *Bridge) Active() []mdns.Record

Active returns a snapshot of the currently-published records. Intended for tests and for the `overcast status` subcommand.

func (*Bridge) Run

func (b *Bridge) Run(ctx context.Context) error

Run drives the bridge until ctx is cancelled or the Source's channel is closed. It always withdraws any records it has published before returning, even on error, so callers can simply defer-cancel their context.

Run returns nil when the source channel closes cleanly, ctx.Err() when the caller cancels, and a wrapped error if the source or publisher fails.

type Event

type Event struct {
	Type   EventType
	Record mdns.Record
}

Event is a single domain registration change delivered by a Source.

type EventType

type EventType int

EventType distinguishes a domain registration from a de-registration.

const (
	// EventAdded indicates a domain has been registered with the emulator
	// and should be advertised on the host.
	EventAdded EventType = iota
	// EventRemoved indicates a domain has been de-registered and should
	// be withdrawn from the host advertisement.
	EventRemoved
)

func (EventType) String

func (t EventType) String() string

String returns a human-readable name for logging.

type Source

type Source interface {
	Watch(ctx context.Context) (<-chan Event, error)
}

Source is the upstream feed of domain events. The overcast host CLI implementation of Source tails the emulator's /_internal/domains/watch SSE endpoint; tests can supply an in-memory channel instead.

Watch must return a channel that is closed when the underlying feed terminates (either cleanly or due to an error). Implementations should honour ctx cancellation to unblock the caller promptly.

Directories

Path Synopsis
Package mdns defines the Publisher contract used by the overcast host CLI to advertise custom domain names through the operating system's multicast DNS responder (Bonjour on macOS, Avahi on Linux, DNS-SD on Windows).
Package mdns defines the Publisher contract used by the overcast host CLI to advertise custom domain names through the operating system's multicast DNS responder (Bonjour on macOS, Avahi on Linux, DNS-SD on Windows).
Package trust owns the Overcast local Certificate Authority: minting it, signing leaf server certificates from it (see ca.go), and installing the CA certificate into the operating system's trust store so browsers and HTTP clients accept Overcast's HTTPS without the usual self-signed-cert dance.
Package trust owns the Overcast local Certificate Authority: minting it, signing leaf server certificates from it (see ca.go), and installing the CA certificate into the operating system's trust store so browsers and HTTP clients accept Overcast's HTTPS without the usual self-signed-cert dance.

Jump to

Keyboard shortcuts

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