A SOCKS proxy that balances traffic between network interfaces
Project description
dispatch-py
A SOCKS proxy that balances traffic between network interfaces.
Should work on macOS, Windows, and Linux.
This is a python rewrite of dispatch a rust rewrite of dispatch-proxy, originally written in CoffeeScript and targeting Node.js.
What dispatch-py IS and IS NOT
What dispatch-py IS:
- A SOCKS proxy that distributes connections across multiple network interfaces
- A way to utilize multiple internet connections simultaneously (e.g., Ethernet and Wi-Fi)
- Effective for scenarios with multiple concurrent connections (downloads, torrents, browsing)
- A simple solution that works at the application level without special hardware or admin rights
What dispatch-py IS NOT:
- NOT true channel bonding/link aggregation (doesn't combine interfaces at hardware level)
- NOT able to increase the speed of a single connection (each connection uses only one interface)
- NOT a VPN or IP masking solution (your traffic will still use your actual IP addresses)
Installation
From PyPI
pip install dispatch-proxy
From source
You'll need Python 3.7 or later.
git clone https://github.com/tboy1337/dispatch-py.git
cd dispatch-py
pip install -r requirements.txt
Rationale
You often find yourself with multiple unused internet connections—be it 5G mobile hotspot or a free Wi-Fi network—that your system won't let you use alongside your primary one.
For instance, you might have a cabled and wireless internet access, each separately capped at a specific bandwidth. By combining all of these with dispatch-py and a download manager, you can achieve a higher effective bandwidth!
How It Works
Whenever the SOCKS proxy server receives a connection request to an address or domain, it selects one of the provided local addresses using the Weighted Round Robin algorithm. All further connection traffic will then go through the interface corresponding to the selected local address.
Important: Unlike true channel bonding, each individual connection only uses one interface. The bandwidth improvement comes from distributing multiple connections across multiple interfaces.
Example: If you have a 100Mbps Ethernet and a 50Mbps Wi-Fi:
- A single download will max out at either 100Mbps OR 50Mbps (whichever interface it's assigned to)
- Multiple downloads running concurrently can use up to 150Mbps combined
Beware: If the requested address or domain resolves to an IPv4 (resp. IPv6) address, an IPv4 (resp. IPv6) local address must be provided.
Use cases
The possibilities are endless:
- Use it with a download manager or a BitTorrent client, combining multiple connections' bandwidth when downloading single files
- Combine as many interfaces as you have access to into a single load-balanced interface
- Run different apps on separate interfaces with multiple proxies (e.g. for balancing download/upload)
- Create a hotspot proxy at home that connects through Ethernet and your 5G card for all your mobile devices
- etc.
Usage
$ dispatch --help
Usage: dispatch [OPTIONS] COMMAND [ARGS]...
A SOCKS proxy that balances traffic between network interfaces.
Options:
-d, --debug Write debug logs to stdout instead of a file
--version Show the version and exit.
--help Show this message and exit.
Commands:
list Lists all available network interfaces
start Starts the SOCKS proxy server.
$ dispatch start --help
Usage: dispatch start [OPTIONS] ADDRESSES...
Starts the SOCKS proxy server.
Options:
--ip TEXT Which IP to accept connections from
--port INTEGER Which port to listen to for connections
--help Show this message and exit.
Examples
$ dispatch list
Lists all available network interfaces.
$ dispatch start 10.0.0.0 fdaa:bbcc:ddee:0:1:2:3:4
Dispatch incoming connections to local addresses 10.0.0.0 and fdaa:bbcc:ddee:0:1:2:3:4.
$ dispatch start 10.0.0.0/7 10.0.0.1/3
Dispatch incoming connections to 10.0.0.0 7 times out of 10 and to 10.0.0.1 3 times out of 10.
Quick Start
If you don't want to install the package, you can run directly using:
python run_dispatch.py list
or
python run_dispatch.py start 10.0.0.0
Simulated Network Testing
For testing dispatch-py without requiring multiple physical network interfaces, a simulated network testing framework is included. This allows testing the load balancing functionality across multiple virtual interfaces with configurable properties:
- Bandwidth limits
- Latency/ping time
- Packet loss rates
- Interface failures
Running Simulated Tests
To run the simulated network tests:
python run_simulated_tests.py
Options:
--verbose/-v: Set verbosity level (0-3)--fail-fast/-f: Stop on first test failure--all/-a: Run all tests, not just the simulated ones--test/-t: Run a specific test module (e.g.,test_network_simulator)
How It Works
The simulated network testing works by:
- Creating virtual network interfaces with configurable properties
- Patching Python's socket implementation to intercept network operations
- Routing traffic through the virtual interfaces
- Applying simulated network conditions (bandwidth, latency, packet loss)
- Running the dispatch proxy with these virtual interfaces
This allows comprehensive testing of dispatch's behavior with different network conditions without requiring multiple physical connections.
License
This project is licensed under the terms of the CRL license LICENSE.md.
Running Tests
To run all tests, use:
pytest
Ensure all dependencies are installed with:
pip install -r requirements.txt
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 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 dispatch_proxy-1.0.9.tar.gz.
File metadata
- Download URL: dispatch_proxy-1.0.9.tar.gz
- Upload date:
- Size: 38.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1a2e70b95030834bfe3ed3c1617a596ef20e62784a1ccdd2a112c37b5a81b03
|
|
| MD5 |
25792fe5b7c2d89b70b8ccc014d18133
|
|
| BLAKE2b-256 |
3fc84077be62c3cfbb6821918f5fa4ab0947d07847ceaaa79eccd9ee3d8cdbef
|
File details
Details for the file dispatch_proxy-1.0.9-py3-none-any.whl.
File metadata
- Download URL: dispatch_proxy-1.0.9-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8ec24d92058d2c151663bb507b4fbf09352104681a27bfffcfb5eba42a404a1
|
|
| MD5 |
85204058f852bffc463cf75df335566c
|
|
| BLAKE2b-256 |
05f66fb48f4bc8444a2d89f0555e4cac823dea7b521aa884e078b1d4ccc3e9cf
|