Skip to main content

A simple IP address to country mapping tool

Project description

simple_ip_tools

A small Python library for managing IP networks using the standard ipaddress module and efficient prefix lookups with pytricia.

Features

  • Add, remove, and list IPv4/IPv6 networks
  • Fast longest‑prefix match queries
  • Simple, lightweight API

Requirements

  • Python 3.6+
  • pytricia
  • ipaddress (built‑in on Python ≥3.3; installed via requirements for older versions)

Installation

pip install -r requirements.txt

or for local development:

pip install -e .

Usage

import simple_ip_tools

simple_ip_tools.gen_db_from_maxmind_csv("ipdb.bin")
ipdb = simple_ip_tools.load_db("ipdb.bin")
simple_ip_tools.lookup_db(ipdb, "1.2.3.4")
simple_ip_tools.lookup_db(ipdb, "2a01:cb06:c200:3e51:103d:6143:42e0:3d48")

Contributing

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature/foo)
  3. Commit your changes (git commit -am 'Add foo feature')
  4. Push to the branch (git push origin feature/foo)
  5. Open a pull request

License

MIT License – see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

simple_ip_tools-0.2.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file simple_ip_tools-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_ip_tools-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 20f4b0c29ef977bf726135d079c42be18b0cbaa2b276b0e0837c5e5ba150769a
MD5 a55a12d748a17c9fda583be9401ee9f2
BLAKE2b-256 ba0fa481f4b4bfeb66e4b2a4cd09851ac207ac879c50dc78b79c239924626a7b

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