Skip to content

Optimize IP's reassignement & tests#2160

Merged
jakub-tldr merged 19 commits intodevfrom
static_ips_regeneration
Mar 4, 2026
Merged

Optimize IP's reassignement & tests#2160
jakub-tldr merged 19 commits intodevfrom
static_ips_regeneration

Conversation

@jakub-tldr
Copy link
Copy Markdown
Contributor

Involves: #2112

@jakub-tldr jakub-tldr changed the title Optimize ip reassignement & tests Optimize IP's reassignement & tests Mar 2, 2026
moubctez
moubctez previously approved these changes Mar 3, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates DefGuard’s WireGuard location/network address modification flow so admins can change the VPN network while devices exist, and the system will reassign device IPs that no longer fit the updated network (issue #2112), with additional optimization work and tests.

Changes:

  • Allow updating a location’s network address while devices exist and show a UI warning about address rewrites.
  • Optimize IP assignment by precomputing “used IPs” and passing them through assignment paths; add all_used_ips_for_network.
  • Update/adjust tests for the new “network update succeeds” behavior and add new assignment tests.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
web/src/pages/EditLocationPage/EditLocationPage.tsx Shows a new warning and allows editing the gateway/network address even when devices exist.
web/messages/en/location.json Adds new warning copy for address rewrite behavior.
tools/defguard_generator/src/vpn_session_stats.rs Uses precomputed used_ips when auto-assigning device IPs during stats generation.
crates/defguard_core/tests/integration/api/wireguard.rs Updates the network address reassignment integration test expectations.
crates/defguard_core/src/location_management/mod.rs Uses used_ips to speed up reassignment during allowed-device sync.
crates/defguard_core/src/lib.rs Updates dev env init to pass used_ips into assignment.
crates/defguard_core/src/handlers/wireguard.rs Removes the server-side block that prevented network address changes when devices are assigned.
crates/defguard_common/src/db/models/wireguard.rs Adds all_used_ips_for_network helper and threads used_ips through assignment helpers.
crates/defguard_common/src/db/models/device.rs Updates assign_next_network_ip to use used_ips and adds tests around subnet changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@DefGuard DefGuard deleted a comment from Copilot AI Mar 3, 2026
@DefGuard DefGuard deleted a comment from Copilot AI Mar 3, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

wojcik91
wojcik91 previously approved these changes Mar 4, 2026
@jakub-tldr jakub-tldr merged commit 1b7d475 into dev Mar 4, 2026
3 checks passed
@jakub-tldr jakub-tldr deleted the static_ips_regeneration branch March 4, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants