Skip to main content

Retrieve, store and query information about Regional Internet Registries

Project description

Retrieve, store and query information about Regional Internet Registries

Build_Status codecov PyPI_Version Python_Version

Installation

pip install iprir

Usage

Query by ip:

>>> import iprir
>>> from ipaddress import IPv4Address, IPv6Address
>>> iprir.by_ip(IPv4Address('8.8.8.8'))
RIRRecord(country='US', type='ipv4', start='8.0.0.0', value='16777216', status='allocated')

Attributes of RIRRecord:

>>> record = iprir.by_ip(IPv4Address('8.8.8.8'))
>>> record.ipv4
IPv4Address('8.0.0.0')
>>> record.ipv4_network
IPv4Network('8.0.0.0/8')
>>> record.length
16777216
>>> record.as_int
134217728

Use IpSet:

>>> us = iprir.by_country('ipv4', 'US')
>>> IPv4Address('8.8.4.4') in us
True
>>> IPv4Address('1.2.3.4') in us
False
>>> from iprir.ipset import IpSet
>>> db = iprir.get_db()
>>> us_and_ca_v6 = IpSet(db.by_country('ipv6', 'US') + db.by_country('ipv6', 'CA'))
>>> IPv6Address('2001:4860:4860::8888') in us_and_ca_v6
True

Update database:

# update text db and sqlite db
python3 -m iprir.updater

# show more choices
python3 -m iprir.updater -h

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

iprir-0.3.0.dev0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iprir-0.3.0.dev0-py3-none-any.whl (12.4 MB view details)

Uploaded Python 3

File details

Details for the file iprir-0.3.0.dev0.tar.gz.

File metadata

  • Download URL: iprir-0.3.0.dev0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for iprir-0.3.0.dev0.tar.gz
Algorithm Hash digest
SHA256 af8c60da4440ef942656e99d76bf6a89b8009dd4cc4ff11bc9100d7ab5d71276
MD5 e2b18ff33ddc88079ce4cf7c62b87aa5
BLAKE2b-256 3ca8520551ad91fbf1dcde2af2430f1b24e97e5ea9b549cacb2dfe8d59d40ea4

See more details on using hashes here.

File details

Details for the file iprir-0.3.0.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for iprir-0.3.0.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae9675d836769fff5c471dc6eab47ddf658f81ff739da5ea363334404da605cd
MD5 d9b46851789d063aa32edd91e5d7a48a
BLAKE2b-256 72009424e7d76c045c700e57b0b6d485bc4fb710941d039ace58f17da55936b0

See more details on using hashes here.

Supported by

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