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.5or123.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ipextract-0.2.0.tar.gz.
File metadata
- Download URL: ipextract-0.2.0.tar.gz
- Upload date:
- Size: 47.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f159d4d2972204db9bae8efe55d2fb8d1d7893b5ea7e44dd3ce8af4d1675a38b
|
|
| MD5 |
5daca07ce47b2c4930e813b99bcef707
|
|
| BLAKE2b-256 |
aafd95f01ffdb92ef9101ebf6a3e5ed2508d1fcfa6c96faf2503a11a29eb7662
|
Provenance
The following attestation bundles were made for ipextract-0.2.0.tar.gz:
Publisher:
publish-ipextract.yml on erichutchins/geoipsed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipextract-0.2.0.tar.gz -
Subject digest:
f159d4d2972204db9bae8efe55d2fb8d1d7893b5ea7e44dd3ce8af4d1675a38b - Sigstore transparency entry: 1060841251
- Sigstore integration time:
-
Permalink:
erichutchins/geoipsed@33736cb655a5d8c041e030ce6cd3da8eccee21cb -
Branch / Tag:
refs/tags/ipextract-v0.2.0 - Owner: https://github.com/erichutchins
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-ipextract.yml@33736cb655a5d8c041e030ce6cd3da8eccee21cb -
Trigger Event:
push
-
Statement type:
File details
Details for the file ipextract-0.2.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: ipextract-0.2.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 150.9 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
059f52867818dae0822d30e2ca0f3e0613c00988591a47e02b3f886c8912eef7
|
|
| MD5 |
bb6fa61e12da69ca9d02086fc3fa679c
|
|
| BLAKE2b-256 |
73ab77b411c1c976390062b01ff98c0fbf4abfd5d92e5d0d3185b1af51c177c0
|
Provenance
The following attestation bundles were made for ipextract-0.2.0-cp310-abi3-win_amd64.whl:
Publisher:
publish-ipextract.yml on erichutchins/geoipsed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipextract-0.2.0-cp310-abi3-win_amd64.whl -
Subject digest:
059f52867818dae0822d30e2ca0f3e0613c00988591a47e02b3f886c8912eef7 - Sigstore transparency entry: 1060841497
- Sigstore integration time:
-
Permalink:
erichutchins/geoipsed@33736cb655a5d8c041e030ce6cd3da8eccee21cb -
Branch / Tag:
refs/tags/ipextract-v0.2.0 - Owner: https://github.com/erichutchins
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-ipextract.yml@33736cb655a5d8c041e030ce6cd3da8eccee21cb -
Trigger Event:
push
-
Statement type:
File details
Details for the file ipextract-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: ipextract-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 243.1 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9946f70f33feb27c4f7ceb7625aac309b07db3c92c057c89e96017466d1f35d8
|
|
| MD5 |
1cf9254c1a5d65df1c8aadf33cafac0d
|
|
| BLAKE2b-256 |
32c2aa62938ec381ce2bdb61f29321a9441f9f7e4828a7f040d7aa640909d188
|
Provenance
The following attestation bundles were made for ipextract-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish-ipextract.yml on erichutchins/geoipsed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipextract-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
9946f70f33feb27c4f7ceb7625aac309b07db3c92c057c89e96017466d1f35d8 - Sigstore transparency entry: 1060841905
- Sigstore integration time:
-
Permalink:
erichutchins/geoipsed@33736cb655a5d8c041e030ce6cd3da8eccee21cb -
Branch / Tag:
refs/tags/ipextract-v0.2.0 - Owner: https://github.com/erichutchins
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-ipextract.yml@33736cb655a5d8c041e030ce6cd3da8eccee21cb -
Trigger Event:
push
-
Statement type:
File details
Details for the file ipextract-0.2.0-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: ipextract-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 227.4 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9b62ce91ec54cb5109ce28c20e20193065bd5c4cc7c4238d8c68399a217ab2f
|
|
| MD5 |
a0a2bc8265f3f049bb733df135323d3e
|
|
| BLAKE2b-256 |
6ccd7db9977a7d442bf369ea7339bfba7b8330f0c97abeef175bff2569dd0cc3
|
Provenance
The following attestation bundles were made for ipextract-0.2.0-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
publish-ipextract.yml on erichutchins/geoipsed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipextract-0.2.0-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
f9b62ce91ec54cb5109ce28c20e20193065bd5c4cc7c4238d8c68399a217ab2f - Sigstore transparency entry: 1060841322
- Sigstore integration time:
-
Permalink:
erichutchins/geoipsed@33736cb655a5d8c041e030ce6cd3da8eccee21cb -
Branch / Tag:
refs/tags/ipextract-v0.2.0 - Owner: https://github.com/erichutchins
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-ipextract.yml@33736cb655a5d8c041e030ce6cd3da8eccee21cb -
Trigger Event:
push
-
Statement type:
File details
Details for the file ipextract-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: ipextract-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 236.9 kB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9f85238d86a8616366d1130d47354e1e92c21c59eb1db7fab8fbde308f3cf22
|
|
| MD5 |
483959de19f45aadac4b9d942d08ef0c
|
|
| BLAKE2b-256 |
d16b60ac61674e1c218c64f6339af0fecdb40c6d9da90ff04e4209ce2d9c29e4
|
Provenance
The following attestation bundles were made for ipextract-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl:
Publisher:
publish-ipextract.yml on erichutchins/geoipsed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipextract-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl -
Subject digest:
b9f85238d86a8616366d1130d47354e1e92c21c59eb1db7fab8fbde308f3cf22 - Sigstore transparency entry: 1060841592
- Sigstore integration time:
-
Permalink:
erichutchins/geoipsed@33736cb655a5d8c041e030ce6cd3da8eccee21cb -
Branch / Tag:
refs/tags/ipextract-v0.2.0 - Owner: https://github.com/erichutchins
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-ipextract.yml@33736cb655a5d8c041e030ce6cd3da8eccee21cb -
Trigger Event:
push
-
Statement type:
File details
Details for the file ipextract-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: ipextract-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 250.8 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ab7497a4e03cb8ec1f231a1c0d6158e5ce5156fa6460c6b71055af57d03948d
|
|
| MD5 |
5850055f9b47b942140d5ebb61d3fbf8
|
|
| BLAKE2b-256 |
773b11ead14d6e8be872382054677e72bf0a424c7cc106adf0af8b12565fd0b4
|
Provenance
The following attestation bundles were made for ipextract-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish-ipextract.yml on erichutchins/geoipsed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipextract-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
1ab7497a4e03cb8ec1f231a1c0d6158e5ce5156fa6460c6b71055af57d03948d - Sigstore transparency entry: 1060841808
- Sigstore integration time:
-
Permalink:
erichutchins/geoipsed@33736cb655a5d8c041e030ce6cd3da8eccee21cb -
Branch / Tag:
refs/tags/ipextract-v0.2.0 - Owner: https://github.com/erichutchins
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-ipextract.yml@33736cb655a5d8c041e030ce6cd3da8eccee21cb -
Trigger Event:
push
-
Statement type: