Skip to content

Commit 7030f49

Browse files
authored
fix: mdns discover hostname (#9039)
1 parent c4e4f2a commit 7030f49

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

packages/opencode/src/cli/cmd/web.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const WebCommand = cmd({
6060
}
6161

6262
if (opts.mdns) {
63-
UI.println(UI.Style.TEXT_INFO_BOLD + " mDNS: ", UI.Style.TEXT_NORMAL, "opencode.local")
63+
UI.println(UI.Style.TEXT_INFO_BOLD + " mDNS: ", UI.Style.TEXT_NORMAL, `opencode.local:${server.port}`)
6464
}
6565

6666
// Open localhost in browser

packages/opencode/src/server/mdns.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ export namespace MDNS {
77
let bonjour: Bonjour | undefined
88
let currentPort: number | undefined
99

10-
export function publish(port: number, name = "opencode") {
10+
export function publish(port: number) {
1111
if (currentPort === port) return
1212
if (bonjour) unpublish()
1313

1414
try {
15+
const name = `opencode-${port}`
1516
bonjour = new Bonjour()
1617
const service = bonjour.publish({
1718
name,
1819
type: "http",
20+
host: "opencode.local",
1921
port,
2022
txt: { path: "/" },
2123
})

packages/opencode/src/server/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ export namespace Server {
562562
opts.hostname !== "localhost" &&
563563
opts.hostname !== "::1"
564564
if (shouldPublishMDNS) {
565-
MDNS.publish(server.port!, `opencode-${server.port!}`)
565+
MDNS.publish(server.port!)
566566
} else if (opts.mdns) {
567567
log.warn("mDNS enabled but hostname is loopback; skipping mDNS publish")
568568
}

0 commit comments

Comments
 (0)