Skip to content
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

[client] Fix multiple peer name filtering in netbird status command #2798

Merged
merged 2 commits into from
Oct 29, 2024

Conversation

mgarces
Copy link
Contributor

@mgarces mgarces commented Oct 28, 2024

Describe your changes

Issue ticket number and link

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

Description

The current implementation of peer name filtering in the skipDetailByFilters function has a logic issue that prevents filtering by multiple peer names. This PR fixes the issue by:

Changing the initial value of nameEval to true (meaning skip by default)
Inverting the logic to look for matches instead of non-matches
Setting nameEval = false when a match is found (meaning don't skip)

Before the fix:

  • When using --filter-by-names peer-01,peer-02.netbird.cloud, the command would fail to show both peers because:
  1. The function would set nameEval = true if ANY name didn't match
  2. This caused peers to be skipped even if they matched one of the filters

After the fix:

  • The new logic starts with nameEval = true (skip by default)
  • When a peer's FQDN matches ANY of the provided filters, nameEval is set to false
  • This allows the command to properly show all peers that match any of the provided name filters

Example:

Bash

netbird status -d --filter-by-names peer-01,peer-02.netbird.cloud

Now correctly shows both peers that match either name.

Testing:

  • Tested with single peer name filter
  • Tested with multiple peer name filters
  • Tested in combination with other filters (status, IPs)

This fix maintains compatibility with existing functionality while correctly implementing the intended multiple peer name filtering behavior.

@CLAassistant
Copy link

CLAassistant commented Oct 28, 2024

CLA assistant check
All committers have signed the CLA.

pascal-fischer
pascal-fischer previously approved these changes Oct 28, 2024
Copy link

@mgarces mgarces added the good first issue Good for newcomers label Oct 28, 2024
@pascal-fischer pascal-fischer changed the title Fix multiple peer name filtering in netbird status command [client] Fix multiple peer name filtering in netbird status command Oct 28, 2024
@pascal-fischer pascal-fischer merged commit 01f2490 into main Oct 29, 2024
21 checks passed
@pascal-fischer pascal-fischer deleted the bug/filter-by-names branch October 29, 2024 16:49
hurricanehrndz added a commit to hurricanehrndz/netbird that referenced this pull request Nov 5, 2024
…te_change

* upstream/main: (81 commits)
  Fix cached device flow oauth (netbirdio#2833)
  Avoid failing all other matrix tests if one fails (netbirdio#2839)
  add all group to add peer affected peers network map check (netbirdio#2830)
  [client] Log windows panics (netbirdio#2829)
  Fix unused servers cleanup (netbirdio#2826)
  [management] Add DB access duration to logs for context cancel (netbirdio#2781)
  Allocate new buffer for every package (netbirdio#2823)
  [client] Nil check on ICE remote conn (netbirdio#2806)
  [management] remove network map diff calculations (netbirdio#2820)
  Create FUNDING.yml (netbirdio#2814)
  Create funding.json (netbirdio#2813)
  [management] add metrics to network map diff (netbirdio#2811)
  [client] Fix the broken dependency gvisor.dev/gvisor (netbirdio#2789)
  fix meta is equal slices (netbirdio#2807)
  [client] Fix multiple peer name filtering in netbird status command (netbirdio#2798)
  [management] Setup key improvements (netbirdio#2775)
  [client] allow relay leader on iOS (netbirdio#2795)
  [client] Remove legacy forwarding rules in userspace mode (netbirdio#2782)
  [client] Ignore route rules with no sources instead of erroring out (netbirdio#2786)
  [misc] Update Zitadel from v2.54.10 to v2.64.1
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants