Merge branch 'worktree-agent-ac54c8919e940163a'

# Conflicts:
#	scripts/setup-native.py
This commit is contained in:
2026-11-10 01:07:12 +00:00
34 changed files with 1825 additions and 66 deletions
+2 -1
View File
@@ -39,6 +39,7 @@ func main() {
}
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")
mdnsLAN := flag.Bool("mdns-lan", true, "Advertise the LAN route; false when the web proxy refuses LAN connections (only the tailnet and public routes are advertised)")
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)")
tokenFile := flag.String("token-file", os.Getenv(servertoken.EnvKey), "Require the shared secret in this private file on every request (the installer's server-token; PIPELINES_SERVER_TOKEN_FILE)")
flag.Parse()
@@ -217,7 +218,7 @@ func main() {
chatNames = chats.Backends()
}
if *mdnsOn {
defer keepAdvertising(*addr, *mdnsPort)()
defer keepAdvertising(*addr, *mdnsPort, *mdnsLAN)()
}
printBanner(startup{Build: buildinfo.Current(), Addr: *addr, Database: *db, Artifacts: artifactsRoot,
Authoring: *allowAuthoring, OpenCode: openCodeStatus, Chat: chatNames})
+7 -7
View File
@@ -16,17 +16,17 @@ import (
// advertise publishes the server on the LAN. Any failure is logged and the
// server carries on: discovery is a convenience, never a startup requirement.
// The returned stop (nil when nothing was published) withdraws the advert.
func advertise(addr string, proxyPort int) func() {
return advertiseWith(addr, proxyPort, discovery.LANAddresses(), discovery.TailscaleAddresses())
func advertise(addr string, proxyPort int, lanRoute bool) func() {
return advertiseWith(addr, proxyPort, lanRoute, discovery.LANAddresses(), discovery.TailscaleAddresses())
}
func advertiseWith(addr string, proxyPort int, lan, tailnet []net.IP) func() {
func advertiseWith(addr string, proxyPort int, lanRoute bool, lan, tailnet []net.IP) func() {
hostname, _ := os.Hostname()
// The installer exports the TLS front's origin (tailscale serve) for the
// same proxy; it is advertised so clients can choose that route by name.
advert, err := discovery.Plan(discovery.Config{ListenAddr: addr, ProxyPort: proxyPort,
Version: buildinfo.Current().Version, Hostname: hostname, IPs: lan,
TailscaleIPs: tailnet, PublicURL: os.Getenv("PIPELINES_WEB_PUBLIC_URL")})
TailscaleIPs: tailnet, PublicURL: os.Getenv("PIPELINES_WEB_PUBLIC_URL"), NoLAN: !lanRoute})
if err != nil {
log.Printf("mDNS: not advertising: %v", err)
return nil
@@ -66,9 +66,9 @@ const addressRecheck = 30 * time.Second
// keepAdvertising publishes the server now and republishes whenever the
// host's LAN or tailnet addresses change. The returned stop ends both.
func keepAdvertising(addr string, proxyPort int) func() {
func keepAdvertising(addr string, proxyPort int, lanRoute bool) func() {
lan, tailnet := discovery.LANAddresses(), discovery.TailscaleAddresses()
stop := advertiseWith(addr, proxyPort, lan, tailnet)
stop := advertiseWith(addr, proxyPort, lanRoute, lan, tailnet)
done := make(chan struct{})
go func() {
ticker := time.NewTicker(addressRecheck)
@@ -87,7 +87,7 @@ func keepAdvertising(addr string, proxyPort int) func() {
}
lan, tailnet = nextLAN, nextTailnet
log.Printf("mDNS: addresses changed to %s; republishing", joinIPs(lan))
stop = advertiseWith(addr, proxyPort, lan, tailnet)
stop = advertiseWith(addr, proxyPort, lanRoute, lan, tailnet)
}
}
}()
+2 -2
View File
@@ -21,7 +21,7 @@ func TestMDNSEnvironmentSwitches(t *testing.T) {
// 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 {
if stop := advertise("127.0.0.1:0", 0, true); stop != nil {
stop()
t.Fatal("loopback-only server was advertised")
}
@@ -44,6 +44,6 @@ func TestSameAddressesIgnoresOrder(t *testing.T) {
// keepAdvertising on a loopback-only server publishes nothing, keeps its
// watcher running and stops cleanly.
func TestKeepAdvertisingStopsCleanly(t *testing.T) {
stop := keepAdvertising("127.0.0.1:0", 0)
stop := keepAdvertising("127.0.0.1:0", 0, true)
stop()
}