Pārlūkot izejas kodu

fix: mdns discover hostname (#9039)

Javier Aceña 1 mēnesi atpakaļ
vecāks
revīzija
7030f49a74

+ 1 - 1
packages/opencode/src/cli/cmd/web.ts

@@ -60,7 +60,7 @@ export const WebCommand = cmd({
       }
 
       if (opts.mdns) {
-        UI.println(UI.Style.TEXT_INFO_BOLD + "  mDNS:              ", UI.Style.TEXT_NORMAL, "opencode.local")
+        UI.println(UI.Style.TEXT_INFO_BOLD + "  mDNS:              ", UI.Style.TEXT_NORMAL, `opencode.local:${server.port}`)
       }
 
       // Open localhost in browser

+ 3 - 1
packages/opencode/src/server/mdns.ts

@@ -7,15 +7,17 @@ export namespace MDNS {
   let bonjour: Bonjour | undefined
   let currentPort: number | undefined
 
-  export function publish(port: number, name = "opencode") {
+  export function publish(port: number) {
     if (currentPort === port) return
     if (bonjour) unpublish()
 
     try {
+      const name = `opencode-${port}`
       bonjour = new Bonjour()
       const service = bonjour.publish({
         name,
         type: "http",
+        host: "opencode.local",
         port,
         txt: { path: "/" },
       })

+ 1 - 1
packages/opencode/src/server/server.ts

@@ -562,7 +562,7 @@ export namespace Server {
       opts.hostname !== "localhost" &&
       opts.hostname !== "::1"
     if (shouldPublishMDNS) {
-      MDNS.publish(server.port!, `opencode-${server.port!}`)
+      MDNS.publish(server.port!)
     } else if (opts.mdns) {
       log.warn("mDNS enabled but hostname is loopback; skipping mDNS publish")
     }