Matchy
Fast unified database for IP addresses, strings, and glob patterns.
Match IP addresses, CIDR ranges, exact strings, and thousands of glob patterns in microseconds. One database format, one API, zero compromises on performance.
let db = open?;
// All query types use the same API
db.lookup?; // IP address
db.lookup?; // Exact string
db.lookup?; // Matches *.example.com pattern
Features
- 7M+ queries/second for IP lookups, 3M+ for glob patterns
- <1ms load time via memory mapping, regardless of database size
- 99% memory savings in multi-process deployments
- Query result caching: 2-10x speedup for high-traffic workloads
- Log scanning: SIMD-accelerated extraction of domains, IPs (IPv4/IPv6), emails, file hashes (MD5/SHA1/SHA256/SHA384), and cryptocurrency addresses (Bitcoin, Ethereum, Monero)
- Unified database: IPs, strings, and patterns in one file
- MaxMind compatible: Extended MMDB format
- Rich metadata: JSON-like structured data storage
- Multiple APIs: Rust, C, and MaxMind-compatible C APIs
Quick Start
CLI
# Install
# Create a threats database
# Query - matches return JSON
# [{"threat_level":"high","category":"malware"}]
# [{"threat_level":"critical","category":"phishing"}]
# Scan logs for threats (outputs JSON, one match per line)
# Outputs JSON to stdout (one line per match):
# {"matched_text":"evil.example.com","match_type":"pattern","data":[{"threat_level":"critical"}]}
# {"matched_text":"1.2.3.4","match_type":"ip","cidr":"1.2.3.0/24",...}
#
# Statistics to stderr (with --stats flag):
# [INFO] Lines processed: 15,234
# [INFO] Lines with matches: 127 (0.8%)
# [INFO] Throughput: 450.23 MB/s
Rust API
use ;
// Build
let mut builder = new;
builder.add_ip?;
builder.add_pattern?;
builder.save?;
// Query with caching for high-traffic workloads
let db = from
.cache_capacity // LRU cache for 10k queries
.open?;
if let Some = db.lookup?
// Extract patterns from logs
let extractor = new?;
for line in log_file.lines
C API
matchy_t *db = ;
matchy_result_t result = ;
if
;
Documentation
- The Matchy Book - Complete guide for CLI and APIs
- API Reference - Rust API documentation
- DEVELOPMENT.md - Architecture and implementation details
Building
Requirements: Rust 1.70+
Contributing
Contributions welcome! See CONTRIBUTING.md for guidelines.
License
BSD-2-Clause
Acknowledgments
Matchy extends MaxMind's MMDB format with Paraglob's pattern matching, creating a unified database for IPs, strings, and patterns with memory efficiency that scales to hundreds of worker processes.