GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(cli): give Windows and WSL their own service default ports by Hona · Pull Request #54988 · anomalyco/opencode Conversation
|
| Default port | macOS / Linux | Windows | WSL |
|---|---|---|---|
| Release channels | 0xC0DE (49374) |
0x8048 (32840) |
hash of service.json:<distro> |
local |
0xC0DF (49375) |
0x8049 (32841) |
hash of service-local.json:<distro> |
| Preview channels | hash of channel | hash, XORed below 0xC000 |
hash of service-<channel>.json:<distro> |
0xC000, lower ports are unchanged) and per-distro WSL ports.serve --service still fails as before; the new Windows default sits outside the dynamic range.Not a UI change.
Added by the opencode bot (AI-generated).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Windows hands out 0xC000-0xFFFF for outgoing connections and Hyper-V reserves blocks of it, so 0xC0DE could be taken at random. On Windows, default ports in that range are XORed with 0x4096 (a nod to the v1 port), which moves 0xC0DE to 0x8048 (32840). WSL distros share localhost with Windows and each other, so each distro hashes its own default port. The port is still the service lock; startup logic is unchanged.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The Windows remap looks right. I couldn't reproduce the Windows failure on Linux, so I checked the port mapping directly. I also ran serve --service from source with WSL_DISTRO_NAME set: base listened on 49375, this PR on the per-distro hash (27965). The upgrade path is fine because clients find the service through the registration file and the old-version service on 49374 gets replaced. service.test.ts passes (26/26) and the cli typecheck is clean.
Public API: the default managed-service port changes on Windows (49374 → 32840, 49375 → 32841) and becomes per-distro under WSL. No config keys, flags or HTTP API change, and a configured port still wins. Anything that hard-codes 49374 to reach the service on Windows or WSL (e.g. ssh -L forwards, bookmarks, remembered device URLs) needs the new port.
One concern, inline: the per-distro WSL ports can still fall inside the range Windows reserves for Hyper-V and outgoing connections (49152–65535).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const port = channelPort(channel, distro) | ||
| // Windows hands out 0xC000-0xFFFF for outgoing connections and Hyper-V reserves blocks of it. XOR with 0x4096, a nod | ||
| // to the v1 port, clears bit 14 and steps out of that range: 0xC0DE becomes 0x8048. | ||
| if (platform === "win32" && port >= 0xc000) return port ^ 0x4096 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
WSL ports skip this remap because platform is "linux" there. But with NAT localhost forwarding or mirrored networking, the WSL port is also used on the Windows side, so Windows' 0xC000–0xFFFF reservations still apply. Roughly a third of distros will hash into that range. For example, Ubuntu-22.04 → 50424, kali-linux → 56357 and Arch → 51286, which brings back the same random "already in use" failure for those distros. Could the remap also run when distro is set (e.g. (platform === "win32" || distro) && port >= 0xc000)?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Windows: managed service fails when default port 49374 is in an excluded TCP range
There was an error while loading. Please reload this page.