Add relay candidate ranking#257
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly upgrades the client's ability to interact with and manage network relays. By introducing a new, unified JSON-RPC method for relays and implementing sophisticated candidate ranking and caching mechanisms, the system gains improved flexibility, reliability, and performance in establishing and maintaining connections. These changes ensure that the client can intelligently select the best available relay, adapt to network conditions, and recover more gracefully from connection issues, ultimately leading to a more robust and efficient user experience. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces significant improvements to relay candidate management, including ranking, caching, and discovery, alongside a new rpc method. The changes are well-structured, with good refactoring to reduce code duplication and extensive new tests. I've identified a critical bug in the candidate penalization logic and a high-severity issue with unsafe type assertions that could lead to a panic. Addressing these will further enhance the robustness of the new system.
|
@tuhalf why is there no change in Which is the primary server candidate selection for port connects? Also please fix the CI errors:
|
It's structurally the same, but the candidate list it loops over is no longer raw append order. That host ranking lives in the candidate helper, not in socks.go, mainly in relay_candidates.go |
This pull request introduces support for a new "relay" JSON-RPC method (
rpc) alongside improvements to relay candidate management and connection logic. The changes unify how JSON-RPC responses are parsed, add robust relay candidate caching, and enhance client connection reliability. Several new tests ensure the correctness of the new relay RPC path and related parsing logic.Relay RPC support and unified response parsing:
RelayRPCmethod to theClientstruct for forwarding JSON-RPC calls to a relay, with unified parsing logic for bothsapphire:rpcand the newrpcmethod. Error messages are now more descriptive and consistent. [1] [2] [3] [4] [5]Relay candidate and connection management improvements:
ClientManager, candidate cache loading and flushing, and tighter integration with address normalization. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]Testing and validation:
Other improvements:
These changes collectively improve the system's flexibility in handling new RPC methods, its robustness in managing relay candidates and connections, and its test coverage for new and existing functionality.