/rtpengine_calls.py Secret
Last active
February 17, 2023 15:18
-
-
Save kt351b/44e7e82fa4f700b62f79a42217b6cda7 to your computer and use it in GitHub Desktop.
List call from rtpengine python asyncio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import aiohttp | |
import asyncio | |
import bencodepy | |
import random | |
async def main(): | |
headers = {'content-type': 'application/x-rtpengine-ng'} | |
async with aiohttp.ClientSession(headers=headers) as session: | |
cookie = f"0_{random.randint(1000, 9999)}_1" | |
bdata = bencodepy.encode({'command': 'list'}).decode('utf-8') | |
data = f"{cookie} {bdata}" | |
async with session.post('http://xxx.xxx.xxx.xxx:xxx/ng', data=data) as response: | |
result = await response.text() | |
result = result.split(" ", 1) | |
result_bytes = result[1].encode('utf-8') | |
r = bencodepy.decode(result_bytes) | |
print(r) | |
print("Calls: " + str(len(r[b'calls']))) | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment