Overview
IPForce is a Python library that provides HTTP adapters for forcing specific IP protocol versions (IPv4 or IPv6) during HTTP requests. It's particularly useful for testing network connectivity, ensuring compatibility with specific network configurations, and controlling which IP protocol version is used for DNS resolution and connections.
| PyPI Counter | |
| Github Stars |
| Branch | main | dev |
| CI |
| Code Quality |
Installation
Source Code
- Download Version 0.2 or Latest Source
pip install .
PyPI
- Check Python Packaging User Guide
pip install ipforce==0.2
Usage
Enforce IPv4
Use when you need to ensure connections only use IPv4 addresses, useful for legacy systems that don't support IPv6, networks with IPv4-only infrastructure, or testing IPv4 connectivity.
from ipforce import IPForceAdapter, IPVersion, IPForceMethod
import requests
session = requests.Session()
adapter = IPForceAdapter(IPVersion.V4, IPForceMethod.LOCK)
session.mount('http://', adapter)
session.mount('https://', adapter)
response = session.get('https://ifconfig.co/json')
Enforce IPv6
Use when you need to ensure connections only use IPv6 addresses, useful for modern networks with IPv6 infrastructure, testing IPv6 connectivity, or applications requiring IPv6-specific features.
from ipforce import IPForceAdapter, IPVersion, IPForceMethod
import requests
session = requests.Session()
adapter = IPForceAdapter(IPVersion.V6, IPForceMethod.LOCK)
session.mount('http://', adapter)
session.mount('https://', adapter)
response = session.get('https://ifconfig.co/json')
Using IPForceSession
from ipforce import IPForceSession, IPVersion
with IPForceSession(IPVersion.V4) as session:
response = session.get('https://ifconfig.co/json')
Available Methods
| Method | Description |
|---|---|
IPForceMethod.LOCK |
Thread-safe — global lock serialization (default) |
IPForceMethod.GLOBAL |
Non-thread-safe — temporary getaddrinfo patch |
Direct Class Usage (Deprecated)
The following direct class usage still works but is deprecated in favor of the unified API above:
from ipforce import IPv4LockAdapter, IPv6LockAdapter
session = requests.Session()
session.mount('http://', IPv4LockAdapter()) # or IPv6LockAdapter()
session.mount('https://', IPv4LockAdapter()) # or IPv6LockAdapter()
response = session.get('https://ifconfig.co/json')
Issues & Bug Reports
Just fill an issue and describe it. We'll check it ASAP!
- Please complete the issue template
You can also join our discord server
Show Your Support
Star This Repo
Give a ⭐️ if this project helped you!
Donate to Our Project
If you do like our project and we hope that you do, can you please support us? Our project is not and is never going to be working for profit. We need the money just so we can continue doing what we do ;-)
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
Unreleased
0.2 - 2026-09-14
Added
IPForceAdapterunified factory functionIPForceSessionunified session classIPVersionenum (V4,V6)IPForceMethodenum (GLOBAL,LOCK)IPv6LockAdapterclassIPv4LockAdapterclass- Logo
Changed
README.mdupdated- Dependencies structure modified
0.1 - 2026-02-16
Added
IPv6TransportAdapterclassIPv4TransportAdapterclass- Test system
Metadata
Release files for ipforce 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ipforce-0.2.tar.gz | 12.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ipforce-0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.4 kB
Release files / ipforce-0.2.tar.gz
| Download URL | ipforce-0.2.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aa7a27ae6ec3074888f9c562fc4ef4ce390872527ac1e98deb1bcaf3c1317d57
|
|
BLAKE2b-256 checksum How to use checksums |
19870e46a83a37fa04d350bc1657fc2ca00fd671ea4ab8c5766e92ebb32da930
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / ipforce-0.2-py3-none-any.whl
| Download URL | ipforce-0.2-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7a5f798b9167d8af447a14dd23c69b07ada93102c618eae7c35bd61f70ebfd8e
|
|
BLAKE2b-256 checksum How to use checksums |
5b692843050e4e1aafd9d0d99f08ca9ea126e0f1f0eefdd319fad6948c6e7001
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|