SocketSwap is a python package that allows to proxy any third-party libraries traffic through a local TCP Proxy
Project description
SocketSwap
SocketSwap is a tool that allows to proxy any third-party libraries traffic through a TCP SOCKS5 Proxy.
Some Python libaries support proxing out of the box like requests. For all other libaries especially ones not natively written in python, you can use SocketSwap to redirect traffic via a proxy.
Usage:
There are two ways to use SwapSock.
- Via a Context Manager that starts the proxy in a daemon process
- Directly as a blocking script
Context Manager
import socket
from socketswap import ProxySwapContext
def conn_factory():
target_host = "localhost"
target_port = 5432
remote_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
remote_socket.connect((target_host, target_port))
return remote_socket
def main():
with ProxySwapContext(conn_factory, "127.0.0.1", 2222):
# do something you want to proxy
The ProxySwapContext takes essentially 3 mandatory arguments.
Credits:
The TCP Proxy part is a slim modified version of https://github.com/ickerwx/tcpproxy.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
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 SocketSwap-0.1.2-py2.py3-none-any.whl.
File metadata
- Download URL: SocketSwap-0.1.2-py2.py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc7a0fb99d2ccee813370f7bbfcceb2e93ad0a1717b90ca6ac6cef2b04eb8858
|
|
| MD5 |
b663f77c78d5b88eba92c67e8a00e6ec
|
|
| BLAKE2b-256 |
de82f4283190f4370db1c7c9d8846b2abc2aaa5db055829bac75d06cad0bc107
|