SOCKS5 proxy session with kill switch — if the proxy drops, your real IP is never exposed.
Project description
socks5-killswitch
Your IP never leaks. Period.
SOCKS5 proxy session for Python built on requests.Session.
If the proxy drops — all requests are instantly killed. No fallback. No leaks.
The Problem
Standard requests + SOCKS5 proxy setup has a fatal flaw: if the proxy goes down, requests silently fall back to your real IP. You're exposed and don't even know it.
The Solution
Request ──► Proxy OK? ──► Yes ──► Send through proxy
│
No
│
KILL SWITCH ON
│
┌─────────┴─────────┐
│ All requests │
│ blocked forever │
│ ProxyError raised │
└───────────────────┘
Install
pip install socks5-killswitch
Quick Start
from socks5_killswitch import create_session, ProxyError
# Create a protected session — real IP is detected and verified automatically
session = create_session(
host="proxy.example.com",
port=1080,
username="your-socks5-user",
password="your-socks5-pass",
)
# All requests go through the proxy — just like normal requests.Session
resp = session.get("https://example.com")
# Periodic leak check — verifies visible IP != real IP
session.check_ip()
# If proxy ever fails:
# ❌ ProxyError raised
# ❌ ALL further requests blocked
# ❌ No fallback to direct connection
# ✅ Your real IP stays hidden
How It Works
| Event | What happens |
|---|---|
create_session() |
Detects real IP via ipify.org, connects through proxy, verifies proxy IP is different |
| Successful request | Passes through proxy as normal |
| Any request failure | Kill switch activates — _killed = True, ProxyError raised |
| Subsequent requests | Instantly raise ProxyError — zero network calls |
check_ip() |
Verifies visible IP != real IP (works even after kill switch!) |
API
create_session(host, port, username, password, **kwargs)
Factory that returns a verified SafeSession.
| Parameter | Type | Default | Description |
|---|---|---|---|
host |
str |
— | SOCKS5 proxy host |
port |
int |
— | SOCKS5 proxy port |
username |
str |
— | SOCKS5 username |
password |
str |
— | SOCKS5 password |
timeout |
int |
15 |
Default request timeout (seconds) |
ip_check_url |
str |
https://api.ipify.org |
IP detection service URL |
SafeSession
Extends requests.Session with kill switch protection.
session.get(url) # proxied request, kills on failure
session.post(url, data=b"…") # binary data works (AMF2, protobuf, etc.)
session.check_ip() # returns proxy IP or raises ProxyError
repr(session) # <SafeSession proxy=socks5://user:***@host:1080 killed=False>
ProxyError
Raised when proxy fails or IP leak is detected. Original exception is chained via __cause__.
Design Decisions
socks5://notsocks5h://— DNS is resolved locally (required for PIA and similar providers)- Pure library — no
.env, no config files, no side effects. All parameters passed explicitly check_ip()bypasses kill switch — intentional; leak detection must work even in degraded state- Password masked in
repr()—socks5://user:***@host:1080, safe for logging
License
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.2.tar.gz.
File metadata
- Download URL: socks5_killswitch-0.0.2.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8755bdd23dfeb4dd3caed4d6ef14d89f3fa353b2828e1dfae438ac9d114e4622
|
|
| MD5 |
79103e588eec4b8ca3a070023d9560c2
|
|
| BLAKE2b-256 |
64801f80c41475d0305211989228ef7e99e9538fba335f14e73020bff3690011
|
Provenance
The following attestation bundles were made for socks5_killswitch-0.0.2.tar.gz:
Publisher:
publish.yml on ponich/socks5-killswitch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
socks5_killswitch-0.0.2.tar.gz -
Subject digest:
8755bdd23dfeb4dd3caed4d6ef14d89f3fa353b2828e1dfae438ac9d114e4622 - Sigstore transparency entry: 924403447
- Sigstore integration time:
-
Permalink:
ponich/socks5-killswitch@d0e74d9c8252a6ce4f405cbc149639c208108b7c -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/ponich
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d0e74d9c8252a6ce4f405cbc149639c208108b7c -
Trigger Event:
release
-
Statement type:
File details
Details for the file socks5_killswitch-0.0.2-py3-none-any.whl.
File metadata
- Download URL: socks5_killswitch-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a286f1e989cef3ca2b544a0f7418cde8094d3dfef6e0fa1021653dd940f356cb
|
|
| MD5 |
d20ea78a299c6ba4bb54905587f02cf4
|
|
| BLAKE2b-256 |
d3d5e475bb69b735c8445f7ccbce299150fe6c99f452c8c1d8281f1266196197
|
Provenance
The following attestation bundles were made for socks5_killswitch-0.0.2-py3-none-any.whl:
Publisher:
publish.yml on ponich/socks5-killswitch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
socks5_killswitch-0.0.2-py3-none-any.whl -
Subject digest:
a286f1e989cef3ca2b544a0f7418cde8094d3dfef6e0fa1021653dd940f356cb - Sigstore transparency entry: 924403453
- Sigstore integration time:
-
Permalink:
ponich/socks5-killswitch@d0e74d9c8252a6ce4f405cbc149639c208108b7c -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/ponich
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d0e74d9c8252a6ce4f405cbc149639c208108b7c -
Trigger Event:
release
-
Statement type: