Skip to main content

A Python package for storing, removing and checking IP's efficiently, Use cases: Blacklisting, Whitelisting etc

Project description

Generic badge PyPI license

Ip-Model

A Data Structure for efficiently storing, removing and checking all Ipv4 addresses in O(1) time.

v1.0.0 supports for all Ipv4 addresses.

Usage

from ip_model.Ipv4 import Ipv4

blacklist = Ipv4()

To add an IP:

# arg: String
blacklist.add("192.0.0.18")

To remove an IP:

# arg: String
blacklist.remove("192.0.0.18")

To check if an IP is present/not:

# arg: String
# returns: bool
blacklist.is_present("192.0.0.18")

Exception Handling

  • Throws TypeError: passing Invalid Datatype, incorrect number of arguments
  • Throws InvalidIpException: When an invalid Ip is passed
from ip_model.Exceptions import InvalidIpException

try:
    blacklist.add("192.455.554.343")
except InvalidIpException:
    print("Incorrect Ipv4 Address")

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

ip_model-1.0.1.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

ip_model-1.0.1-py2-none-any.whl (7.8 kB view hashes)

Uploaded Python 2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page