https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43258
--- Comment #7 from David Nind <[email protected]> --- Created attachment 203425 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=203425&action=edit Bug 43258: Add Koha::IP utility class Introduce Koha::IP with a single class method is_ip_in_range() that centralizes IP address matching logic. Currently, at least four system preferences use IP range matching (OpacSuppressionByIPRange, RestrictedPageLocalIPs, SelfCheckAllowByIPRanges, ILS-DI:AuthorizedIPs) each reimplementing the check inline with inconsistent approaches (regex prefix, Net::CIDR, Net::Netmask). Koha::IP->is_ip_in_range({ ip => $ip, range => $range }) supports all existing syntax styles: - Prefix strings: '172.18.' (legacy, used by OpacSuppressionByIPRange) - CIDR notation: '192.168.0.0/16' - Explicit ranges: '10.0.0.1-10.0.0.255' - Space-separated lists combining any of the above This is a proof-of-concept class intended as the canonical low-level matcher. Controllers read their own syspref and pass the value here. A future Mojo helper plugin can wrap this for REST API controllers, sourcing the IP from $c->tx->remote_address instead of $ENV{REMOTE_ADDR}. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/Koha/IP.t => SUCCESS: All tests pass 3. Tests cover: - Edge cases (undef/empty IP or range) - Prefix matching (anchored, no regex injection) - CIDR matching via Net::CIDR - Explicit range notation - Space-separated mixed lists 4. Sign off :-D Signed-off-by: David Nind <[email protected]> -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list -- [email protected] To unsubscribe send an email to [email protected] website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
