RSOCKS
RSOCKS is a reverse proxy server for transferring traffic of a specific host through a SOCKS 4/5 proxy. It is useful for using SOCKS 4/5 in applications that don’t have SOCKS proxy support.
Installation
$ pip install rsocks
Or
$ easy_install rsocks
To upgrade to latest version, you could execute:
$ pip install -U rsocks
Resources
Usage
First, we need to create a config file with following format:
# /path/to/rsocks.toml [servers.foo] proxy = "socks4://user:pass@192.168.1.10:1080" listen_host = "0.0.0.0" listen_port = 5025 upstream_host = "smtp.example.com" upstream_port = 25 upstream_ssl = false
There is an example for forwarding SMTP/IMAP of Gmail through a SOCKS5 proxy server:
[servers.imap] proxy = "socks5://localhost:1080" listen_port = 5993 upstream_host = "imap.gmail.com" upstream_port = 993 upstream_ssl = true [servers.smtp] proxy = "socks5://localhost:1080" listen_port = 5465 upstream_host = "smtp.gmail.com" upstream_port = 465 upstream_ssl = true
Next, we start the rsocks server:
$ rsocks --config=/path/to/rsocks.toml [14:24:44] rsocks.servers.smtp Using proxy server socks5://localhost:1080 [14:24:44] rsocks.servers.smtp Listening 127.0.0.1:5465 [14:24:44] rsocks.servers.imap Using proxy server socks5://localhost:1080 [14:24:44] rsocks.servers.imap Listening 127.0.0.1:5993 [14:24:44] rsocks.pool Prepared "smtp" [14:24:44] rsocks.pool Prepared "imap" [14:24:44] rsocks.servers.smtp Starting server... [14:24:44] rsocks.servers.imap Starting server...
Don’t stop it now, open your application (such as Airmail in OS X) and set the server option to local forwarding address:
SMTP: 127.0.0.1:5465 without SSL IMAP: 127.0.0.1:5993 without SSL
Now the application’s traffic will be forwarded through the proxy server (socks5://127.0.0.1:1080).
If you wish to run the rsocks server in background, please check the Platform Service Templates. For example, OS X users can create com.tonyseek.rsocks.plist file in ~/Library/LaunchAgents and load it as a service:
$ nano ~/.rsocks.toml # create a config file
$ wget https://github.com/tonyseek/rsocks/blob/master/misc/platforms/osx-launchd/com.tonyseek.rsocks.plist \
-O ~/Library/LaunchAgents/com.tonyseek.rsocks.plist
$ nano ~/Library/LaunchAgents/com.tonyseek.rsocks.plist # edit the template
$ launchctl load -w ~/Library/LaunchAgents/com.tonyseek.rsocks.plist
API Overview
There is an example for using API to build a server:
import os
from rsocks.pool import ServerPool
from rsocks.server import ReverseProxyServer
proxy = os.environ.get('SOCKS_PROXY', 'socks5://localhost:1080')
pool = ServerPool()
with pool.new_server(
name='IMAP',
server_class=ReverseProxyServer,
upstream=('imap.gmail.com', 993),
use_ssl=True) as server:
server.set_proxy(proxy)
server.listen(('127.0.0.1', 5993))
with pool.new_server(
name='SMTP',
server_class=ReverseProxyServer,
upstream=('smtp.gmail.com', 465),
use_ssl=True) as server:
server.set_proxy(proxy)
server.listen(('127.0.0.1', 5465))
if __name__ == '__main__':
pool.loop()
Metadata
Release files for rsocks 0.4.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 | Provenance | Actions |
|---|---|---|---|---|
| rsocks-0.4.0.tar.gz | 6.8 kB | Without provenance | Details for rsocks-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rsocks-0.4.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for rsocks-0.4.0-py2.py3-none-any.whl |
Total release size: 14.7 kB
Release files / rsocks-0.4.0.tar.gz
| Download URL | rsocks-0.4.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87e5af7fee7a95b7f5134d04a4d115d850b0c58d93373bd86ff9d653e79f4ea7
|
|
BLAKE2b-256 checksum How to use checksums |
932c1a39b63f4a9278b9f35aa6dfbf80a52a0d225b2b9ca9e3dd9be6236a4085
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Release files / rsocks-0.4.0-py2.py3-none-any.whl
| Download URL | rsocks-0.4.0-py2.py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
56a94ba6864a7b392f5c87cb258210de2f55638398d69b3b7f667a2d24dbee87
|
|
BLAKE2b-256 checksum How to use checksums |
1c9d6788dcf36e246b8ef836f1dcd774b8d162544642fb69d0926bc3a272f96f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Security for rsocks 0.4.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.