implement CLI serverInfo protocol#2015
Conversation
🦋 Changeset detectedLatest commit: dcf8eef The changes in this PR will be included in the next version bump. This PR includes changesets to release 36 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| logger.warn('invalid --cli-addr, skipping dev channel'); | ||
| return; | ||
| } | ||
| const host = this.#cliAddr.slice(0, sep); |
There was a problem hiding this comment.
🟡 IPv6 addresses with brackets fail to connect because brackets are not stripped before passing to the socket library
The extracted host retains square brackets (host = this.#cliAddr.slice(0, sep) at agents/src/cli_client.ts:41) when the CLI address uses the standard bracketed IPv6 format (e.g. [::1]:8080), so the connection silently fails because Node's net module does not accept bracketed hosts.
Impact: When the driving lk CLI listens on an IPv6 address, the agent silently fails to report its server info to the dev channel.
Bracket-stripping omission in IPv6 host parsing
The code at agents/src/cli_client.ts:34-42 splits on the last colon to separate host and port, which correctly identifies the port separator for bracketed IPv6 like [::1]:8080. However, the resulting host value is [::1] (with brackets). Node.js's net.createConnection({ host, port }) passes the host to DNS lookup, which does not strip brackets — it expects a raw IP address or hostname.
The fix would be to strip leading [ and trailing ] from the host after slicing:
let host = this.#cliAddr.slice(0, sep);
if (host.startsWith('[') && host.endsWith(']')) {
host = host.slice(1, -1);
}The Go CLI (which sets --cli-addr) uses Go's net.Listen which formats IPv6 addresses with brackets (e.g. [::]:12345), making this a realistic scenario on dual-stack systems.
| const host = this.#cliAddr.slice(0, sep); | |
| let host = this.#cliAddr.slice(0, sep); | |
| if (host.startsWith('[') && host.endsWith(']')) { | |
| host = host.slice(1, -1); | |
| } |
Was this helpful? React with 👍 or 👎 to provide feedback.
allows the agent to exchange data with lk CLI in dev mode
lk agent dev <agent.js>