Files
pipelines/cmd/pipelines-server/mdns_test.go
T
alan 7ecc12b747 LAN discovery: server advertises _pipelines._tcp over mDNS; app finds servers on the connect screen
Server: internal/discovery publishes a DNS-SD record (hashicorp/mdns) with
the port LAN clients dial (the web proxy via -mdns-port, which the
supervisor passes, or a non-loopback -addr) and TXT v, name, path, tls, auth.
On by default; -mdns=false or PIPELINES_MDNS=off disables it. Failures are
logged and never block startup; the advert is withdrawn on shutdown.

App: the Connect to Pipelines screen gets 'Find servers on this network'
behind a ServerDiscovery interface (Bonsoir: Android NSD with multicast lock,
iOS Bonjour with NSLocalNetworkUsageDescription and NSBonjourServices).
Tapping a server fills the address and connects; manual entry stays. Web has
no scan.
2026-11-03 14:54:54 +00:00

26 lines
834 B
Go

package main
import "testing"
func TestMDNSEnvironmentSwitches(t *testing.T) {
for value, want := range map[string]bool{"": true, "1": true, "on": true, "off": false, "0": false, "FALSE": false, " disabled ": false} {
if got := envEnabled(value); got != want {
t.Errorf("envEnabled(%q) = %v, want %v", value, got, want)
}
}
for value, want := range map[string]int{"": 0, "8083": 8083, "x": 0, "70000": 0} {
if got := envPort(value); got != want {
t.Errorf("envPort(%q) = %d, want %d", value, got, want)
}
}
}
// A loopback-only server with no proxy port publishes nothing and does not
// fail: the caller only defers a non-nil stop.
func TestAdvertiseSkipsLoopbackWithoutFailing(t *testing.T) {
if stop := advertise("127.0.0.1:0", 0); stop != nil {
stop()
t.Fatal("loopback-only server was advertised")
}
}