Repository navigation
feat(remote): read a port, host:port or URL typed into the ports page (#2231) - #156
Merged
Merged
Conversation
… (Refs 1lck/Lithe-IDEA#2231) remote.parseForwardAddress turns what the user types into a forward target without a connection: a port alone on localhost, host:port, or a URL whose scheme and path the page keeps to open the forwarded address the same way. User names and passwords are refused, not kept; each refusal names one reason in details.
xiaoyumuxi
marked this pull request as ready for review
November 21, 2026 13:47
This was referenced Nov 21, 2026
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.
关联 Issue
1lck/Lithe-IDEA#2231(远程开发完整设计):端口页的远端端口要带上 IP,转发目标要能写网址,不只是 IP+端口。桌面端在 1lck/Lithe-IDEA#2286 上接入。
类型
remote.parseForwardAddress,把端口页里输入的端口、host:port或网址解析成转发目标改动说明
解析(新文件
crates/remote/src/client/forward_address.rs)3000),目标是主机上的localhost;host:port,IPv6 要加方括号([::1]:5432);scheme://host[:port][/path][?query][#fragment]。http、ws用 80,https、wss用 443;其他协议(如postgres)必须写端口。ForwardAddress { targetHost, targetPort, scheme?, path? }:targetHost不带方括号,主机名转成小写,校验沿用ForwardSet的目标主机规则(新增forward_set::is_target_host),所以能解析的地址一定能转发;scheme和path只在输入里有时才返回,path是主机和端口后面的部分,空或只有/时省略。桌面端用它们按原来的协议和路径打开转发后的地址。empty、tooLong(超过 2048 字节)、malformed(含空白或控制字符)、scheme、credentials、host、port。user:pass@host)一律拒绝(credentials),不保存、不回显,避免密码出现在端口列表、日志或复制内容里。命令
crates/workspace/src/forwards.rs新增parse_address,请求是{ text },拒绝未知字段。拒绝时返回invalid_request,details为{ field: "text", reason },错误信息不包含输入原文。crates/core新增RemoteCommand::ParseForwardAddress、命令名映射和 dispatcher 分支,只做转接。契约(
rust/contracts/rust-core-api.md)范围
crates/remote;crates/workspace和crates/core只做转接。验证
cargo test -p lithe-remote:104 个通过,其中新增 7 个forward_address单测,覆盖只写端口、host:port、网址补默认端口、纯数字当端口、拒绝用户名密码、长度与空白边界、每种拒绝原因各不相同。cargo test -p lithe-core --lib:888 个通过。connection_window_helpers_answer_through_the_dispatcher新增remote.parseForwardAddress的调用,覆盖网址、只写端口、拒绝用户名密码(且错误里不含密码)和未知字段。cargo test -p lithe-workspace:47 个通过。cargo clippy -p lithe-remote -p lithe-workspace -p lithe-core --all-targets --all-features -- -D warnings:通过。cargo fmt --all --check、scripts/rust-core/verify-rust-core-comments.sh:通过。x86_64-pc-windows-msvc)的 clippy 本机没跑成:libsqlite3-sys需要 Windows 的 C 编译器,本机没有。新增代码是纯字符串解析,没有平台分支,交给 CI 的 Windows 任务检查。