Skip to main content

SOCKS client and server based on asyncio

Project description

gera2ld.socks

PyPI

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


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.4.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gera2ld.socks-0.4.4-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file gera2ld.socks-0.4.4.tar.gz.

File metadata

  • Download URL: gera2ld.socks-0.4.4.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.7.3 Linux/5.4.72-v7l+

File hashes

Hashes for gera2ld.socks-0.4.4.tar.gz
Algorithm Hash digest
SHA256 76ef348857fcae4ea99c0bf8a5e6dcc437d4ff7ec89b6d9f796f24f128c804fe
MD5 107a331ffd445844852e772f614cec66
BLAKE2b-256 ed560d502c2828a4a4a081f0120c26f8b1f6f280a2f1a97e8b44cbb105c20c64

See more details on using hashes here.

File details

Details for the file gera2ld.socks-0.4.4-py3-none-any.whl.

File metadata

  • Download URL: gera2ld.socks-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.7.3 Linux/5.4.72-v7l+

File hashes

Hashes for gera2ld.socks-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9b5e0fd8ea9c7c87a292d2d308c156aa053258a736be7b00d928e230dfe0f536
MD5 62b3ecda3bd883b3cbf9a8e31632186f
BLAKE2b-256 748bf8600adf4e04861372471ffebd84a6f277ab1230b8aa7d8d5acc1868dbf2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page