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

Add logic for IP-based dynamic redirects #2151

Merged
merged 9 commits into from
Jul 18, 2024

Conversation

acelaya
Copy link
Member

@acelaya acelaya commented Jul 6, 2024

Closes #2120

Allow redirect rule conditions based on visitors IP addresses. Condition values can be static IP addresses (100.200.80.40), CIDR blocks (192.168.10.0/24) or wildcard patterns (11.22.*.*).

Alternative implementation to #2121, with the next differences:

  • The logic to check if the IP address matches the rule pattern, is shared with the existing logic to check if current IP address matches the values provided in DISABLE_TRACKING_FROM.
  • Every condition will allow only one Ip address to match, instead of a comma-separated list. If more than one group should redirect to the same place, users will simply have to create a few consecutive rules.
  • Validation is done in RedirectRulesInputFilter.

TODO

  • API test.
  • IP address/CIDR block/Wildcard pattern validation.
  • API spec.

Copy link
Member Author

Choose a reason for hiding this comment

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

All this logic was originally defined in RequestTracker, and has been extracted to be reused for IP-based redirect rules.

Copy link

codecov bot commented Jul 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.98%. Comparing base (e4f66b7) to head (9e6cdcb).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #2151      +/-   ##
=============================================
+ Coverage      95.95%   95.98%   +0.03%     
- Complexity      1507     1520      +13     
=============================================
  Files            264      266       +2     
  Lines           5116     5137      +21     
=============================================
+ Hits            4909     4931      +22     
+ Misses           207      206       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@acelaya acelaya changed the title Extract logic to match IP address against list of groups Add logic for IP-based dynamic redirects Jul 17, 2024
@acelaya acelaya force-pushed the feature/ip-dynamic-redirects branch from 4adce88 to 626caa4 Compare July 17, 2024 18:13
@acelaya acelaya marked this pull request as ready for review July 18, 2024 19:27
@acelaya acelaya merged commit 7c65969 into shlinkio:develop Jul 18, 2024
23 checks passed
@acelaya acelaya deleted the feature/ip-dynamic-redirects branch July 18, 2024 19:32
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.

IP based redirection
1 participant