Skip to content

Store block and allow list entries in canonical form (for the indexed lookup in the plugin) - #21

Open
codeling wants to merge 1 commit into
mainfrom
cidr-lookup-cost
Open

codeling wants to merge 1 commit into
mainfrom
cidr-lookup-cost

Conversation

@codeling

Copy link
Copy Markdown
Owner

Summary

Component side of codeling/bfstop's cidr-lookup-cost branch. The plugin now looks a visitor up in the block and allow list by the canonical spelling of the entries (an indexed lookup instead of reading and testing every network on every request), so the edit forms have to store entries that way:

  • AllowTable::check() / BlockTable::check() store the canonical form (IpHelper::canonicalEntry()): 2001:DB8::1 -> 2001:db8::1, 203.0.113.77/24 -> 203.0.113.0/24. Values that are not an address or network are left to the form validation, as before.

What is blocked or allowed does not change. Existing entries are converted by the plugin on the first request after the update. Please merge together with the plugin PR (without this change, entries typed into the forms in a non-canonical spelling would not be found).

Testing

Tests are in the bfstop repository (ComponentTest::testEntriesOfTheEditFormsAreStoredInCanonicalForm, plus the lookup/migration tests): 352 passing on Joomla 5.4.8 / PostgreSQL 16 with both branches.


Generated by Claude Code

…ical form

The plugin looks the visitor up in these lists by the canonical spelling of
the entries (IpHelper::canonicalEntry()): "2001:DB8::1" is stored as
"2001:db8::1", "203.0.113.77/24" as "203.0.113.0/24". The tests are in the
bfstop repository (branch cidr-lookup-cost).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LhhhdjhErC9ZiaS4HyRjsh
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.

2 participants