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.
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/buildinfo"
|
||||
"git.a-wan.net/alan/pipelines/internal/discovery"
|
||||
"git.a-wan.net/alan/pipelines/internal/opencode"
|
||||
"git.a-wan.net/alan/pipelines/internal/paths"
|
||||
"git.a-wan.net/alan/pipelines/internal/pipeline"
|
||||
@@ -34,6 +35,8 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
db := flag.String("db", defaultDB, "SQLite database path (honors XDG_DATA_HOME)")
|
||||
mdnsOn := flag.Bool("mdns", envEnabled(os.Getenv("PIPELINES_MDNS")), "Advertise the server on the LAN with mDNS/DNS-SD ("+discovery.ServiceType+"); PIPELINES_MDNS=off disables")
|
||||
mdnsPort := flag.Int("mdns-port", envPort(os.Getenv("PIPELINES_MDNS_PORT")), "Port LAN clients dial: the authenticated web proxy fronting this server (default: the -addr port when it is not loopback)")
|
||||
flag.Parse()
|
||||
if err := os.MkdirAll(filepath.Dir(*db), 0700); err != nil {
|
||||
log.Fatal(err)
|
||||
@@ -147,6 +150,11 @@ func main() {
|
||||
if len(chats.Backends()) > 0 {
|
||||
chatNames = chats.Backends()
|
||||
}
|
||||
if *mdnsOn {
|
||||
if stopMDNS := advertise(*addr, *mdnsPort); stopMDNS != nil {
|
||||
defer stopMDNS()
|
||||
}
|
||||
}
|
||||
printBanner(startup{Build: buildinfo.Current(), Addr: *addr, Database: *db, Artifacts: artifactsRoot,
|
||||
Authoring: *allowAuthoring, OpenCode: openCodeStatus, Chat: chatNames})
|
||||
log.Printf("listening on %s (WebSocket endpoint: /connect)", *addr)
|
||||
|
||||
Reference in New Issue
Block a user