2 stable releases
new 1.0.1 | Nov 25, 2024 |
---|
#959 in Network programming
75KB
1.5K
SLoC
ipcheck-rs
A command-line tool for efficient IP range filtering, built on top of iprange-rs library.
This is a fork of iprange-rs with additional binary functionality, as the original library has unexposed internal fields needed for IP filtering operations.
Features
- Fast IP range lookups using trie-based data structures
- Support for both IPv4 and IPv6 ranges
- CSV file input support
- TypeScript output for web integration
- Memory-efficient storage of large IP ranges
- Direct access to internal trie structures (not available in original library)
Installation
From source:
cargo install --features ipcheck ipcheck-rs
Usage
- Prepare your IP ranges in CSV format
- Generate the IP filter:
ipcheck ipv4.csv ipv6.csv output.ts
- Use the generated TypeScript module:
import { ipCheck } from './ipcheck'; // Check if an IP is in the range console.log(ipCheck('192.168.1.1')); // IPv4 console.log(ipCheck('2001:db8::1')); // IPv6
Performance
The tool inherits the optimized binary trie structure from iprange-rs, providing:
- O(1) lookup time for any IP address
- Minimal memory footprint
- Efficient serialization
Differences from iprange-rs
This fork adds:
- Command-line binary for IP filtering
- Access to internal trie structures
- TypeScript code generation
- CSV processing capabilities
The original library's internal fields were not exposed, making certain IP filtering operations impossible through the public API.
License
MIT License - See LICENSE file for details.
Original work Copyright (c) 2017 Yilin Chen Modified work Copyright (c) 2024 Alan WANG
Contributing
- Fork the repository
- Create your feature branch
- Run tests: cargo test --all-features
- Submit a Pull Request
The project follows semantic versioning and welcomes contributions.
Dependencies
~0.1–1MB
~18K SLoC