Skip to main content

IPForce: Force IPv4/IPv6 in Python HTTP Requests

Project description

IPForce: Force IPv4/IPv6 in Python HTTP Requests


PyPI version built with Python3 GitHub repo size

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 CodeFactor

Installation

Source Code

PyPI

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.

import requests
from ipforce import IPv4TransportAdapter

# Create a session that will only use IPv4 addresses
session = requests.Session()
session.mount('http://', IPv4TransportAdapter())
session.mount('https://', IPv4TransportAdapter())

# All requests through this session will only resolve to IPv4 addresses
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.

import requests
from ipforce import IPv6TransportAdapter

# Create a session that will only use IPv6 addresses
session = requests.Session()
session.mount('http://', IPv6TransportAdapter())
session.mount('https://', IPv6TransportAdapter())

# All requests through this session will only resolve to IPv6 addresses
response = session.get('https://ifconfig.co/json')

[!WARNING] Current adapters are NOT thread-safe! They modify the global socket.getaddrinfo function, which can cause issues in multi-threaded applications.

Issues & Bug Reports

Just fill an issue and describe it. We'll check it ASAP!

  • Please complete the issue template

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 ;-)

IPForce Donation

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.1 - 2026-02-16

Added

  • IPv6TransportAdapter class
  • IPv4TransportAdapter class
  • Test system

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

ipforce-0.1.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

ipforce-0.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file ipforce-0.1.tar.gz.

File metadata

  • Download URL: ipforce-0.1.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for ipforce-0.1.tar.gz
Algorithm Hash digest
SHA256 d8694367bdcc430c535483092445277200e6545a4f6e7ca254df132f505e1cee
MD5 c73f3db28bd823585dc5b0de391fbd70
BLAKE2b-256 f7730cf06b94d8b1be69a213d3a69c566240af66cf69682bbe8029cde04b0256

See more details on using hashes here.

File details

Details for the file ipforce-0.1-py3-none-any.whl.

File metadata

  • Download URL: ipforce-0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for ipforce-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 205c8565ca66ee82366adb4efbc86e095931288add55da254a1f9981af798469
MD5 ff28978a696c9e7ef37452c708ce3d18
BLAKE2b-256 ee75108593aa6698393b0542d70fd5ae2b4d32d33404f44f9ccdab6ee0a5de8c

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