Redis as a storage for IP range
Project description
IPRange
Store IP Ranges in Redis as sorted sets for fast retrieval
Installation
pip install iprange-python
Usage
from iprange import IPRange
iprange = IPRange()
# Add a new range with some metadata
iprange.add('192.168.0.1/24', {'some': 'data', 'more': 'metadata'})
# Find the most specific range that contains a specific IP
iprange.find('192.168.0.20')
# => {'range': '192.168.0.1/24', 'some': 'data', 'more': 'metadata'}
# Find all ranges that contains a specific IP
iprange.find_all('192.168.0.20')
# => [{'range': '192.168.0.1/24', 'some': 'data', 'more': 'metadata'}]
# Delete the range
iprange.remove('192.168.0.1/24')
You can use it with Redis Cluster too:
from iprange import IPRange
# Requires at least one node for cluster discovery. Multiple nodes is recommended.
startup_nodes = [{'host': '127.0.0.1', 'port': 16379}]
iprange = IPRange(redis_cluster=True, startup_nodes=startup_nodes)
# ...
IPRange in other languages
Notice
This library relies on a Redis fork that implements interval sets, as described in this blog post.
You can also use a more recent version of Redis with Interval Sets.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
iprange-python-0.0.9.tar.gz
(3.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iprange-python-0.0.9.tar.gz.
File metadata
- Download URL: iprange-python-0.0.9.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53aeff4de99bd0d83922e0cf49d12fd5978c3dc2b674876c4974068c37341227
|
|
| MD5 |
738ff04f2d00f51a2119208587a2292f
|
|
| BLAKE2b-256 |
c7d8d0150e7931a7262a0b3b3f0951a79a251236b6a26e2315b63adb8a69211d
|
File details
Details for the file iprange_python-0.0.9-py2.py3-none-any.whl.
File metadata
- Download URL: iprange_python-0.0.9-py2.py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef9cee3e38ef09c971a7ae7b32a900defeb005a542868e4f5561040868c8c8d5
|
|
| MD5 |
830c3260288671267e54801af5cfa2e0
|
|
| BLAKE2b-256 |
2db9951242d6ba9371acec2d161531276717a671ba44aeb3d44dfb10b960d1fe
|