freebind-py
Bind Linux IPv4/IPv6 TCP and UDP sockets to a chosen source address, including a nonlocal address. The core uses Python's standard library; Requests, aiohttp, and HTTPX integrations are optional. Import the package anywhere, but Freebind socket operations require Linux. The compatibility workflow targets Python 3.11–3.14. Async support targets asyncio; Trio is not supported.
Install
Requires Python 3.11 or newer. Socket operations require Linux.
Install the core or the integration you need from PyPI:
python -m pip install freebind-py
python -m pip install 'freebind-py[requests]'
python -m pip install 'freebind-py[aiohttp]'
python -m pip install 'freebind-py[httpx]'
python -m pip install 'freebind-py[all]'
The distribution is named freebind-py; import it as freebind.
Quick start
Use a source address your network routes to this machine. This example uses loopback so it can run locally without configuring nonlocal routes:
import socket
from freebind import Source, new_socket
with new_socket(Source("127.0.0.1"), type=socket.SOCK_DGRAM) as sock:
print(sock.getsockname())
For a routed prefix, create a policy and pass it to a socket helper or HTTP integration. Replace the documentation address and URL with your own:
import requests
from freebind import Source
from freebind.requests import FreebindAdapter
source = Source("198.51.100.17")
with requests.Session() as client:
client.trust_env = False
client.mount("https://", FreebindAdapter(source))
response = client.get("https://service.example/", timeout=5)
response.raise_for_status()
Install the requests extra to use this example. aiohttp and HTTPX integrations
also support asyncio; HTTPX provides both sync and async transports.
Source policies and connections
- An IP selects a fixed source address.
- A CIDR selects a random address for each new socket.
Source(prefix, mode="sticky")selects one address per configured family and reuses it for that policy.bits=controls how many leading host bits are randomized.- HTTP clients pool connections by default. Pass
fresh=Trueto an adapter, connector, or transport to create a new connection per request.
Freebind allows binding nonlocal addresses; it does not configure routing.
The machine needs a local route for the source prefix, the peer needs a return
route, and the upstream network must carry the traffic. A successful bind alone
does not establish reachability. Explicit HTTP proxies are unsupported; disable
environment proxies with trust_env=False.
Documentation
The user guide
covers IPv4/IPv6 source selection, TCP/UDP sockets, asyncio, Requests, aiohttp,
HTTPX, TLS, pooling, process-wide patching, and troubleshooting.
Documentation and runnable examples are also included in the source distribution
under docs/ and examples/.
See contributing and releases for local setup, linting, tests, and publishing.
See the changelog for release notes.
License
GPL-3.0-only. The original C Freebind project is also GPL-3.0. The AGPL-3.0 freebind.js project informed behavior only; no JavaScript implementation code was copied into this package.
Metadata
Release files for freebind-py 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| freebind_py-0.1.0.tar.gz | 69.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| freebind_py-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 97.2 kB
Release files / freebind_py-0.1.0.tar.gz
| Download URL | freebind_py-0.1.0.tar.gz |
|---|---|
| Size | 69.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e6086d041608b49abd72a6f978bda703b0190e4abec4e9ea964d288021f2adde
|
|
BLAKE2b-256 checksum How to use checksums |
6e7566a9f0c1eb73f73e00a06b9f1de9cb0c4b4fbd51b2a1d0cb24f48ae7bf4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / freebind_py-0.1.0-py3-none-any.whl
| Download URL | freebind_py-0.1.0-py3-none-any.whl |
|---|---|
| Size | 27.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
be9cbf9817f697f6cddc899e90ccf71e8401d803b7c99f0cefab57cc03f38dd2
|
|
BLAKE2b-256 checksum How to use checksums |
486e41b6321b5b94efc1c079cc26e7c9d6671abf808525ca53e446e3e497a401
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency log