| 153 | } |
| 154 | |
| 155 | function 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 | |
| 172 | function makeStop(state: ListenerState, unpublishMdns: Effect.Effect<void>, listenerUrl: URL) { |
| 173 | return Effect.gen(function* () { |