-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add send_allowlist to the server API #47
Conversation
WalkthroughThe changes in this pull request involve updates to the Changes
Possibly related PRs
Suggested labels
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #47 +/- ##
==========================================
+ Coverage 69.87% 71.96% +2.08%
==========================================
Files 9 9
Lines 966 1020 +54
==========================================
+ Hits 675 734 +59
+ Misses 291 286 -5 ☔ View full report in Codecov by Sentry. |
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
src/types.rs (1)
Line range hint
37-41
: Consider adding documentation comments for improved code clarity.While the code structure looks good, it would be beneficial to add documentation comments (using
///
) for theHostNetworkGroup
struct and its fields. This would provide more context about the purpose and usage of this type, making the code more self-explanatory and easier to maintain.For example:
/// Represents a group of hosts and networks. #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] pub struct HostNetworkGroup { /// List of individual host IP addresses. pub hosts: Vec<IpAddr>, /// List of IP networks. pub networks: Vec<IpNet>, /// List of IP address ranges. pub ip_ranges: Vec<RangeInclusive<IpAddr>>, }This practice could be extended to other types in the file as well, where additional context would be helpful.
CHANGELOG.md (1)
15-16
: LGTM! Consider adding more details about the new APIs.The additions to the changelog accurately reflect the new APIs added to the
server::Connection
struct, which aligns with the PR objectives.Consider adding brief descriptions of what these new APIs do, similar to how other entries in the changelog provide context. For example:
- `send_allowlist`: Sends the list of allowed networks to the client - `send_trusted_domain_list`: Sends the list of trusted domains to the clientThis would provide more context for users reading the changelog.
src/server/api.rs (2)
17-17
: Consider testing the unreachable code pathLine 17 contains an
unreachable!
macro, which is not covered by tests according to the static analysis. While serialization of au32
should not fail, adding a test to cover this path can improve code coverage and ensure robustness.Would you like assistance in creating a test case that simulates a serialization failure to cover this scenario?
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 17-17: src/server/api.rs#L17
Added line #L17 was not covered by tests
77-83
: Inconsistent method naming:allow_list
vsallowlist
The method
allow_list
in theHandler
implementation uses an underscore, whereas the corresponding method in theConnection
implementation issend_allowlist
. For consistency, consider renamingallow_list
toallowlist
.Apply this diff to rename the method:
- async fn allow_list(&mut self, list: HostNetworkGroup) -> Result<(), String> { + async fn allowlist(&mut self, list: HostNetworkGroup) -> Result<(), String> {And update any references accordingly.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
- CHANGELOG.md (1 hunks)
- src/server/api.rs (2 hunks)
- src/types.rs (1 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
src/server/api.rs
[warning] 17-17: src/server/api.rs#L17
Added line #L17 was not covered by tests
🔇 Additional comments (3)
src/types.rs (1)
37-37
: LGTM! Good addition of theDebug
trait.Adding the
Debug
trait to theHostNetworkGroup
struct is a positive change. This enhancement allows for easier debugging and logging ofHostNetworkGroup
instances, which can be particularly useful during development and troubleshooting. The change is consistent with other structs in this file that also deriveDebug
, maintaining a uniform approach to type definitions.src/server/api.rs (2)
15-29
: Well-implementedsend_allowlist
methodThe
send_allowlist
function is correctly implemented, handling serialization and asynchronous communication effectively. Error handling is appropriately managed, and the use ofunreachable!
reflects confidence in the reliability ofbincode::serialize
for au32
value.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 17-17: src/server/api.rs#L17
Added line #L17 was not covered by tests
54-100
: Effective test forsend_allowlist
The test
send_allowlist
successfully verifies the functionality of thesend_allowlist
method, ensuring that the allowlist is sent and received correctly between server and client.
Part of #13.
Summary by CodeRabbit
New Features
send_allowlist
andsend_trusted_domain_list
methods for improved network management.GetTidbPatterns
functionality for enhanced data retrieval.open_uni
method inConnection
for initiating unidirectional streams.ConnectionBuilder
for dynamic management of certificates and keys.Bug Fixes
trusted_domain_list
function.Documentation
CHANGELOG.md
to reflect notable changes and improvements across multiple versions.