Repository navigation
✨ Add the port group and serve current --share - #29
Merged
Merged
Conversation
port share holds a public share on ws-server's session socket while it
runs and prints the URLs; Ctrl+C, a kill or port unshare from any
terminal ends it. port list reads the listeners from /proc/net/tcp{,6}
with each port's visibility, URLs and Ports-tab state, and is the only
MCP tool (port_list). port clear closes the editor's unused ports. An
old ws-server's 404 reads as needing a newer workspace image.
Serves the folder and shares its port in one process. While shared the site answers 404 for dotfiles, for links leaving the folder and for a folder without an index.html, and it stops when the share ends.
- The session socket client shares the editor client's error mapping (`peer.requestError`, `errorMessage`) instead of its own copies. - `cli.SignalContext` replaces the two signal contexts in `port share` and `serve mcp`. - `port.Hold` reads the event stream in a plain loop and stops by closing the body when its context ends. One `Event` type replaces `Shared`, `Ended` and `event`. - `serve current --share` serves until its share ends, with no hand-off between goroutines. - `server.Confined` serves through `os.Root`, which refuses symlinks that leave the folder, as well as absolute ones. - `cobra.ExactArgs` replaces the custom argument check, and the unused Ports-tab fields are gone. - Tests use `testutil.ServeSession`, and cases already covered in the other package are dropped.
Moves the seven imports from v3 to v4; v3 stays only as an indirect dependency. commands.yaml and the golden outputs come out unchanged.
Hold reports any end before the shared event as an error and any end after it as the workspace server ending the share. port list shows the listeners with visibility unknown when ws-server cannot answer, and lists forwarded Ports-tab entries that stopped listening.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Public ports, the ws-cli half of story 6.24. ws-server keeps the list of public ports in memory. A shared port answers on
<port>.<proxy-domain>without the workspace sign-in. ws-cli holds a share for as long as it runs.ws-cli port share <port>runs in the foreground. It holds the share open on ws-server's session socket (POST /ports/share, a stream of newline-delimited JSON events) and prints the public URLs. Ctrl+C, a kill, orport unsharefrom any terminal ends the share. When someone else ends it, the holder prints who did and exits 0.ws-cli port unshare <port>ends any share, including one held by another terminal or by the editor's Ports view.ws-cli port listreads the listening ports from/proc/net/tcp{,6}. For each port it shows whether it is public or private, its URLs, and its state in the Ports tab. It is the only MCP tool in the group (port_list, read).ws-cli port clearcloses the forwarded ports in the Ports tab whose process has exited. It uses the newportClearpipe verb.ws-cli serve current --shareserves the folder and shares its port in one process. While shared, it answers 404 for dotfiles and dot-segments, for symlinks that leave the root, and for a folder without anindex.html, so no directory is ever listed. It stops serving when the share ends.net.SessionCallandSessionStreamcall ws-server's session socket. The stream has no 3 s timeout. An old ws-server's404 {"error":"not found"}reads as "needs a newer workspace image".since: next.commands.yamlis regenerated.Related: kloudkit/ws-server
feature/public-ports(the socket routes, the gate, and theportList/portClearverbs), and kloudkit/workspacefeature/public-ports(WS_SERVER_PROXY_ALLOW_PUBLIC).What type of PR is this? (check all that apply)
How to test this PR
go vet ./...andgo test ./...pass. Unit tests cover:/proc/netparser;serve current --shareending when the share ends.WS_SERVER_PROXY_ALLOW_PUBLIC=true,WS_SERVER_PROXY_DOMAINand a password, then:ws-cli port share 8000.8000.<domain>loads anonymously, and/proxy/8000/still redirects to login.ws-cli port listshows 8000 as public with its URL.ws-cli port unshare 8000from another terminal makes the holder print who ended the share and exit. The host redirects to login again.portcommand exceptclearreports that it needs a newer workspace image.Screenshots or Output (if applicable)
Not attached. Step 2 ran against a local ws-server built from its branch with an editor stub. It has not run in a workspace image yet.