SOCKS client and server based on asyncio
Project description
gera2ld.socks
This is a SOCKS server and client package built with asyncio
(requires Python 3.5+).
Installation
$ pip3 install gera2ld.socks
Usage
-
SOCKS server
shell command:
# Start a server $ python3 -m gera2ld.socks.server -b 127.0.0.1:1080
or python script:
from gera2ld.pyserve import run_forever from gera2ld.socks.server import Config, SOCKSServer config = Config('127.0.0.1:1080') run_forever(SOCKSServer(config).start_server())
-
SOCKS client
import asyncio from gera2ld.socks.client import create_client client = create_client('socks5://127.0.0.1:1080') loop = asyncio.get_event_loop() loop.run_until_complete(client.handle_connect(('www.google.com', 80))) client.writer.write(b'...') print(loop.run_until_complete(client.reader.read()))
-
SOCKS handler for
urllib
from urllib import request from gera2ld.socks.client.handler import SOCKSProxyHandler handler = SOCKSProxyHandler('socks5://127.0.0.1:1080') opener = request.build_opener(handler) r = opener.open('https://www.example.com') print(r.read().decode())
-
SOCKS client for UDP
import asyncio from gera2ld.socks.client import create_client async def main(): client = create_client('socks5://127.0.0.1:1080') udp = await client.handle_udp() udp.write_data(b'\xc9\xa7\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03www\x06google\x03com\x00\x00\xff\x00\x01', ('114.114.114.114', 53)) print(await udp.results.get()) loop = asyncio.get_event_loop() loop.run_until_complete(main())
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
gera2ld.socks-0.4.2.tar.gz
(10.4 kB
view hashes)
Built Distribution
Close
Hashes for gera2ld.socks-0.4.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 512f1f679ce68389be4956db802cd75a83c026607b581d3a68bbf5aff8b9da5a |
|
MD5 | dbe04d586b0f89231d62d5b0f1bbb07c |
|
BLAKE2b-256 | fb4d2457a5885c01510c005fa8e7e9fa98c84191ecb8ee9062e1c791ff85a0e7 |