An open API service indexing awesome lists of open source software.

https://github.com/vizonex/aiohttp-tor

A aiohttp extension for using aiohttp with tor for hosting onionsites & client requests
https://github.com/vizonex/aiohttp-tor

aiohttp aiostem asyncio python-asyncio python3 stem tor

Last synced: about 1 month ago
JSON representation

A aiohttp extension for using aiohttp with tor for hosting onionsites & client requests

Awesome Lists containing this project

README

          

# Aiohttp-Tor

Inspired by the stem library from the tor-project, this project attempts to make
seemless transitions with aiohttp and tor. For both clients and hosting.

## Running Clients
```python
from aiohttp_tor import launch, MessageHandler
from aiohttp import ClientSession
import asyncio

# if you want to use the init_msg_handler here's the steps to follow.
handler = MessageHandler()

@handler.on_message
async def send_message(msg:str):
print(msg)

async def request_for_onionsite():
async with launch(ctrl_port=9051, socks_port=9050, init_msg_handler=handler) as process:
# NOTE: use connect() to avoid any annoying setups.
# there's nothing more stressful than remebering what ports to use.
async with ClientSession(connector=process.connect()) as session:
async with session.get("http://mf34jlghauz5pxjcmdymdqbe5pva4v24logeys446tdrgd5lpsrocmqd.onion/index.html") as resp:
data = await resp.read()
print(data)
# b'\n\n

Hi Grandma!