#ip #ipv6 #ipv4 #networking #filter #csv

bin+lib ipcheck-rs

A command tool generates typescript ip checker from CIDR

2 stable releases

new 1.0.1 Nov 25, 2024

#959 in Network programming

MIT license

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

  1. Prepare your IP ranges in CSV format
  2. Generate the IP filter:
ipcheck ipv4.csv ipv6.csv output.ts
  1. 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

  1. Fork the repository
  2. Create your feature branch
  3. Run tests: cargo test --all-features
  4. Submit a Pull Request

The project follows semantic versioning and welcomes contributions.

Dependencies

~0.1–1MB
~18K SLoC