Skip to main content

criminalip.ctidb reader

Project description

Description

This is a Python module for reading CTI DB files.

CTI DB is a binary file format that stores data indexed by IP address subnets (IPv4 only).

Installation

To install ctidb, simply:

$ pip install ctidb

Usage

To use this module, you must first download or create a CTI DB file.

After you have obtained a database and imported the module, call CCtiReader with a path, to the database as the first argument. Optionally, you may pass a mode as the second argument. The modes are exported from ctidb. Valid modes are:

  • MODE_MEMORY - load database into memory. Pure Python.

  • MODE_AUTO - Default.

NOTE: To look up an IP address, use the get method on this object. The method will return the corresponding values for the IP address from the database (e.g., a dictionary for GeoIP2/GeoLite2 databases). If the database does not contain a record for that IP address, the method will return None.

Example

>>> import ctidb
>>>
>>> with ctidb.CCtiReader('criminalip.ctidb') as reader:
>>>
>>>     reader.get('223.26.31.75')
{'country': ... }

Exceptions

The module will return an InvalidDatabaseError if the database is corrupt or otherwise invalid. A ValueError will be thrown if you look up an invalid IP address or an IPv6 address in an IPv4 database.

Requirements

This code requires Python 3.7+. Older versions are not supported.

Versioning

Support

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

ctidb-1.1.16.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

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

ctidb-1.1.16-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file ctidb-1.1.16.tar.gz.

File metadata

  • Download URL: ctidb-1.1.16.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for ctidb-1.1.16.tar.gz
Algorithm Hash digest
SHA256 d8fa080451bcd9e0750f9bd78e185d4351114fbcf6f6605eab671bd79387a394
MD5 f4295e1043c189d60bf96ef790bd6880
BLAKE2b-256 a74ff5657addc0228756b65d15d76b15d7a808ba84fe9b3c900c4366a14c82aa

See more details on using hashes here.

File details

Details for the file ctidb-1.1.16-py3-none-any.whl.

File metadata

  • Download URL: ctidb-1.1.16-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for ctidb-1.1.16-py3-none-any.whl
Algorithm Hash digest
SHA256 caf88bf77eeca3143853e8bcc4848f846fa9e56a8e09d3053ebfa6775765d19d
MD5 aaac363d0e3c8f64ae59926dbbf4f8a9
BLAKE2b-256 cbcbdb2a908c2e7a1b164b0f261d679c20a2a62ada4559a849500f0863a823eb

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