SOCKS5 proxy session with kill switch — if the proxy drops, your real IP is never exposed.
Project description
socks5-killswitch
SOCKS5 proxy session for Python with kill switch — if the proxy drops, your real IP is never exposed.
Built on top of requests.Session. If any request fails, the session permanently blocks all further requests instead of falling back to a direct connection.
Install
pip install socks5-killswitch
Quick start
from socks5_killswitch import create_session, ProxyError
session = create_session(
host="proxy.example.com",
port=1080,
username="your-socks5-user",
password="your-socks5-pass",
)
# All requests go through the proxy
resp = session.get("https://example.com")
# Periodic leak check — verifies visible IP != real IP
session.check_ip()
# If proxy fails — ProxyError is raised, all further requests blocked
How the kill switch works
- On
create_session()— detects your real IP, verifies the proxy gives a different one. - On any request failure — instantly blocks ALL further requests (no fallback to direct).
check_ip()— manual/periodic check that visible IP != real IP.
API
create_session(host, port, username, password, timeout=15, ip_check_url=...)
Factory that returns a verified SafeSession. Raises ProxyError if the proxy is unreachable or the IP leaks.
SafeSession
Extends requests.Session. Every request goes through the SOCKS5 proxy. On failure, the kill switch activates and all subsequent calls raise ProxyError.
check_ip() -> str— verify the session is behind the proxy. Returns the visible IP._killed: bool— kill switch state (read-only in practice).
ProxyError
Raised when the proxy fails or an IP leak is detected.
Notes
- Uses
socks5://(notsocks5h://) — DNS is resolved locally. - Supports binary POST data (e.g. AMF2 payloads).
- Pure library — no
.env, no config files. All parameters are passed explicitly.
License
MIT
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
Built Distribution
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 socks5_killswitch-0.0.1.tar.gz.
File metadata
- Download URL: socks5_killswitch-0.0.1.tar.gz
- Upload date:
- Size: 20.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.3 cpython/3.13.5 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
348de2d1335375c6cebcfc191a8992535ef5f8cd689d4fa720057a7605d689d0
|
|
| MD5 |
8cfa7d370153c2807154ad740ef6e8e2
|
|
| BLAKE2b-256 |
d6f10c69c2c18fd4609a3605c6653c31bd9a8c0ab7e1bcaeccaad278dd9b2f6b
|
File details
Details for the file socks5_killswitch-0.0.1-py3-none-any.whl.
File metadata
- Download URL: socks5_killswitch-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.3 cpython/3.13.5 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05931555f497e04c2d1417fe74457091dd47f11d1bf9faacb48b7c87fb147fe4
|
|
| MD5 |
841b4f0f5bce68c23f5a267f94d5c5a5
|
|
| BLAKE2b-256 |
f3dd3ddbd502d3c7710988898c36a96f9faa18961f9fbb41cf16ed2b89385e61
|