mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-05 05:20:19 +00:00
serve: inline listener url creation
This commit is contained in:
parent
12c19d627d
commit
342d02aefe
1 changed files with 4 additions and 15 deletions
|
|
@ -119,18 +119,18 @@ const listenEffect: (opts: ListenOptions) => Effect.Effect<EffectListener, unkno
|
|||
function* (opts: ListenOptions) {
|
||||
const state = yield* startWithPortFallback(opts)
|
||||
if (opts.type === "socket") {
|
||||
const listenerUrl = makeSocketURL(opts.socket)
|
||||
|
||||
return {
|
||||
type: "socket" as const,
|
||||
socket: opts.socket,
|
||||
url: listenerUrl,
|
||||
url: new URL(`socket:${encodeURIComponent(opts.socket)}`),
|
||||
stop: yield* makeStop(state, Effect.void),
|
||||
}
|
||||
}
|
||||
|
||||
const address = yield* tcpAddress(state)
|
||||
const listenerUrl = makeURL(opts.hostname, address.port)
|
||||
const listenerUrl = new URL("http://localhost")
|
||||
listenerUrl.hostname = opts.hostname
|
||||
listenerUrl.port = String(address.port)
|
||||
url = listenerUrl
|
||||
|
||||
const unpublishMdns = yield* setupMdns(opts, address.port, state.scope)
|
||||
|
|
@ -193,17 +193,6 @@ function tcpAddress(state: ListenerState) {
|
|||
})
|
||||
}
|
||||
|
||||
function makeURL(hostname: string, port?: number) {
|
||||
const result = new URL("http://localhost")
|
||||
result.hostname = hostname
|
||||
if (port !== undefined) result.port = String(port)
|
||||
return result
|
||||
}
|
||||
|
||||
function makeSocketURL(socket: string) {
|
||||
return new URL(`socket:${encodeURIComponent(socket)}`)
|
||||
}
|
||||
|
||||
function setupMdns(opts: TcpListenOptions, port: number, scope: Scope.Scope) {
|
||||
return Effect.gen(function* () {
|
||||
const publish =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue