MCPcopy Index your code
hub / github.com/anomalyco/opencode / setupMdns

Function setupMdns

packages/opencode/src/server/server.ts:155–170  ·  view source on GitHub ↗
(opts: ListenOptions, port: number, scope: Scope.Scope)

Source from the content-addressed store, hash-verified

153}
154
155function setupMdns(opts: ListenOptions, port: number, scope: Scope.Scope) {
156 return Effect.gen(function* () {
157 const publish =
158 opts.mdns && port && opts.hostname !== "127.0.0.1" && opts.hostname !== "localhost" && opts.hostname !== "::1"
159 if (publish) {
160 const unpublish = yield* Effect.cached(Effect.sync(() => MDNS.unpublish()))
161 yield* Effect.sync(() => MDNS.publish(port, opts.mdnsDomain))
162 yield* Scope.addFinalizer(scope, unpublish)
163 return unpublish
164 }
165 if (opts.mdns) {
166 yield* Effect.logWarning("mDNS enabled but hostname is loopback; skipping mDNS publish")
167 }
168 return Effect.void
169 })
170}
171
172function makeStop(state: ListenerState, unpublishMdns: Effect.Effect<void>, listenerUrl: URL) {
173 return Effect.gen(function* () {

Callers 1

server.tsFile · 0.85

Calls 2

syncMethod · 0.80
publishMethod · 0.45

Tested by

no test coverage detected