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
Release files for ctidb 1.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ctidb-1.1.6.tar.gz | 13.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ctidb-1.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.1 kB
Release files / ctidb-1.1.6.tar.gz
| Download URL | ctidb-1.1.6.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4e627dbd426e3b93bb349b8d66490f33841dbd0839c92c34c272161ee0ff7fb
|
|
BLAKE2b-256 checksum How to use checksums |
c8157ca3840a0e1fe3d6bbf302b5feffd424e524615d476d2bc036b0c3b2f724
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|
Release files / ctidb-1.1.6-py3-none-any.whl
| Download URL | ctidb-1.1.6-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f60969814a8410b30fae009d439b6ed95f033563ba4f74dbb84625ad3d99c465
|
|
BLAKE2b-256 checksum How to use checksums |
9bbe839d441f11c11e2849b260d8824c4adbaa1c756c621ac7b97d5726b5baad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|