Skip to main content

High-performance IP address extraction from text, powered by Rust

Project description

ipextract

High-performance IP address extraction for Python, powered by standard-compliant Rust DFAs.

ipextract is a Python binding for the ip-extract Rust crate. It provides O(n) scanning of unstructured text to find IPv4 and IPv6 addresses without the overhead and backtracking of regex engines.

Installation

pip install ipextract

Quick Start

import ipextract

# Extract all IPs from a string
ips = ipextract.extract("Connection from 192.168.1.1 and 8.8.8.8")
# ["192.168.1.1", "8.8.8.8"]

# Deduplicate, preserving first-seen order
ips = ipextract.extract_unique("8.8.8.8 1.1.1.1 8.8.8.8")
# ["8.8.8.8", "1.1.1.1"]

# bytes input works too (faster for large log files)
ips = ipextract.extract(b"host 10.0.0.1 connected")
# ["10.0.0.1"]

Performance

ipextract is significantly faster than native Python regex for scanning logs and large files because it uses a compiled DFA (Deterministic Finite Automaton).

Compared against Python re + ipaddress.ip_address() validation (a fair apples-to-apples comparison where both sides extract and validate):

Scenario re + ipaddress (ms) ipextract (ms) Speedup
Sparse Logs (1000 IPs in noise) 17.1ms 4.2ms 4x
Pure Text (100KB with zero IPs) 20.0ms 2.7ms 7x
Dense IPs (1000 back-to-back) 1.3ms 1.8ms 0.7x

Features

  • Blazing Fast: Up to 7x faster than regex for negative scanning (text with no IPs).
  • Configurable: Filter for public-only, ignore loopback, or skip IPv6 entirely.
  • Zero Dependencies: Ships as a self-contained wheel.
  • Strict: Eliminates false positives like 1.2.3.4.5 or 123.456.78.9.
  • Defang Support: Automatically handles and normalizes defanged IPs like 192[.]168[.]1[.]1.

Advanced Usage

For processing many lines, create a reusable Extractor:

# Configure once
extractor = ipextract.Extractor(private=False, ipv6=False)

# Reuse many times to avoid initialization overhead
for line in log_lines:
    ips = extractor.extract(line)

Configuration Options

Method Description
.only_public() Exclude private, loopback, and broadcast
.ignore_private() Exclude RFC 1918 (IPv4) and ULA/link-local (IPv6)
.ignore_loopback() Exclude 127.0.0.0/8 and ::1
.ignore_broadcast() Exclude 255.255.255.255 and link-local ranges
.ipv4(False) Skip IPv4 entirely
.ipv6(False) Skip IPv6 entirely

License

MIT OR Unlicense

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

ipextract-0.1.1.tar.gz (45.0 kB view details)

Uploaded Source

Built Distributions

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

ipextract-0.1.1-cp310-abi3-win_amd64.whl (150.8 kB view details)

Uploaded CPython 3.10+Windows x86-64

ipextract-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (243.2 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

ipextract-0.1.1-cp310-abi3-macosx_11_0_arm64.whl (227.4 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

ipextract-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl (236.8 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

ipextract-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (250.6 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file ipextract-0.1.1.tar.gz.

File metadata

  • Download URL: ipextract-0.1.1.tar.gz
  • Upload date:
  • Size: 45.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ipextract-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0f6ffb40f2bc6a302e4a2f1f3b59576fa6ff5a2d81a98d902ecf7416f50cbfab
MD5 9b8203a9fd16b932213c1b44c8f5f943
BLAKE2b-256 7bb1dac35f9cd5bb8aafdace617b0f416ae174ad07f87931ef4e2efc2781c613

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipextract-0.1.1.tar.gz:

Publisher: publish-ipextract.yml on erichutchins/geoipsed

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ipextract-0.1.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: ipextract-0.1.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 150.8 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ipextract-0.1.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9a64d98c76865afe09c0fb726f6d0d78197a6ba3aa6a888605cb3abec322210a
MD5 87ef84627b90adb8fab4cd30df28cf88
BLAKE2b-256 7a204579fe1a92e45ef418a386b735e77d61e818fab0cc7f04044fa12b5037e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipextract-0.1.1-cp310-abi3-win_amd64.whl:

Publisher: publish-ipextract.yml on erichutchins/geoipsed

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ipextract-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ipextract-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fcca80e236eacbd007c9b5773d7423f940628d0f8fd8278656d05d06316d2c2a
MD5 f440ea7b09311392589bb0ddde24e6ba
BLAKE2b-256 f00f176fdfdf0304bfe94d82f185e8b0546031812927c676443560bbf23ed3a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipextract-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-ipextract.yml on erichutchins/geoipsed

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ipextract-0.1.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ipextract-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3241abfb8b8a757d639e48839837ce640dffbdc381268deeb13ccffb4fd08379
MD5 8c4e39078d15506bd65cc450e0c74f51
BLAKE2b-256 47875ee1d57b0300d275a8c45c5241edb47842e3836c5e316b2f8324266572f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipextract-0.1.1-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: publish-ipextract.yml on erichutchins/geoipsed

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ipextract-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ipextract-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4e436069420675ed5cb35a3a65b24a65fbf82f616f6f69eb187dceb3d04d108a
MD5 b8d4f223c957c2be2fd897ccbc9325a5
BLAKE2b-256 a9806c01cfe19a7a885b1abc2f314ab1576cb6edeaff49ff6eec18400cc39254

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipextract-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: publish-ipextract.yml on erichutchins/geoipsed

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ipextract-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ipextract-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3bc93762035df872d25d3b2acefdba41d77aa9aceac446626a85531206ebfbd1
MD5 603181c070d177b041430a4ccb3611a1
BLAKE2b-256 880f5bbbdf1c2ec208671a5a66d6f912987458da3d63d5f0d578a445ac520e19

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipextract-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-ipextract.yml on erichutchins/geoipsed

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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