-
Notifications
You must be signed in to change notification settings - Fork 125
fix(proxy): added family hint for new_udp_socket #862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds an optional family_hint parameter to new_udp_socket so callers can explicitly specify the socket address family, and updates all existing call sites to pass either a computed hint or None. It also refactors binding logic in TUN creation, adjusts DNS runtime UDP binding, and makes the Cargo doc package opt out of default features.
- Extend
new_udp_socketsignature withfamily_hintand incorporate it into domain selection. - Update all proxy modules, DNS runtime, and DHCP to supply or default the new
family_hint. - Refactor TUN builder to avoid double
build_asynccalls and tighten Cargo features inclash-doc.
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| proxy/utils/socket_helpers.rs | Added family_hint to choose socket domain; switched android guard to runtime cfg!. |
| proxy/utils/proxy_connector.rs | Changed _destination to destination and passed its address as family_hint. |
| proxy/tun/inbound.rs | Cached tun_builder.build_async() into dev to prevent duplicate builds. |
| proxy/tuic/types.rs | Passed server.ip as family_hint for TUIC endpoints. |
| proxy/tuic/mod.rs | Temporarily passed None for family_hint; added TODO. |
| proxy/socks/outbound/mod.rs | Passed bind address as family_hint for SOCKS outbound. |
| proxy/socks/inbound/stream.rs | Added None placeholder for new family_hint parameter. |
| proxy/shadowsocks/inbound/mod.rs | Added None placeholder for new family_hint parameter. |
| proxy/shadowquic/mod.rs | Replaced manual bind-addr parsing with None src and Some(addr) hint. |
| proxy/hysteria2/mod.rs | Replaced src hint with server_socket_addr hint. |
| proxy/direct/mod.rs | Imported and used family_hint_for_session to compute hint. |
| app/dns/runtime.rs | Renamed _server_addr to server_addr and passed it as hint. |
| app/dns/resolver/enhanced.rs | Simplified error logging in DNS client error path. |
| app/dns/dhcp.rs | Added None placeholder for new family_hint in DHCP listener. |
| clash-doc/Cargo.toml | Disabled default features for clash-lib in the docs package. |
Comments suppressed due to low confidence (3)
clash-lib/src/proxy/utils/socket_helpers.rs:94
- [nitpick] The parameter
family_hintholds a fullSocketAddr, which may be misleading since only the address family is used. Consider renaming it toaddr_hintorsocket_hintfor clearer intent.
family_hint: Option<std::net::SocketAddr>,
clash-lib/src/proxy/utils/socket_helpers.rs:91
- [nitpick] Clarify in this comment that only the IP component of the
SocketAddris used to derive the socket domain and that the port number is ignored when selecting the family.
// Optional family hint for the socket.
clash-lib/src/proxy/utils/socket_helpers.rs:146
- Switching from a compile-time
#[cfg(not(target_os = "android"))]to a runtimeif !cfg!(...)means themust_bind_socket_on_interfaceimport is omitted on Android but its calls are still compiled, causing build errors. Use a compile-time#[cfg]on the block or import the function unconditionally and keep a runtime guard inside.
if !cfg!(target_os = "android") {
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! |
🤔 This is a ...
🔗 Related issue link
💡 Background and solution
best effort to create proper family of socket for UDP connections
📝 Changelog
☑️ Self-Check before Merge