Skip to main content

License: MIT PyPI version

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.

Release files for iprange-python 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iprange-python 0.0.9
File Size Uploaded
iprange-python-0.0.9.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for iprange-python 0.0.9
File Interpreter ABI Platform
iprange_python-0.0.9-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 7.1 kB

Release files / iprange-python-0.0.9.tar.gz

Download URL iprange-python-0.0.9.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
53aeff4de99bd0d83922e0cf49d12fd5978c3dc2b674876c4974068c37341227
BLAKE2b-256 checksum
How to use checksums
c7d8d0150e7931a7262a0b3b3f0951a79a251236b6a26e2315b63adb8a69211d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.0

Release files / iprange_python-0.0.9-py2.py3-none-any.whl

Download URL iprange_python-0.0.9-py2.py3-none-any.whl
Size 3.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ef9cee3e38ef09c971a7ae7b32a900defeb005a542868e4f5561040868c8c8d5
BLAKE2b-256 checksum
How to use checksums
2db9951242d6ba9371acec2d161531276717a671ba44aeb3d44dfb10b960d1fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.0

Release history Release notifications | RSS feed

This release

0.0.9 This release

2 release files

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page