10 lines
616 B
Python
10 lines
616 B
Python
import asyncio,json,os
|
|
from aioice.turn import create_turn_endpoint
|
|
async def main():
|
|
for address in [os.environ['TURN_EXTERNAL_IP'],os.environ['TURN_PRIVATE_IP']]:
|
|
try:
|
|
transport,protocol=await asyncio.wait_for(create_turn_endpoint(asyncio.DatagramProtocol,(address,3478),os.environ['TURN_USERNAME'],os.environ['TURN_PASSWORD'],transport='tcp'),15)
|
|
print(json.dumps({'address':address,'allocated':True})); transport.close()
|
|
except Exception as ex: print(json.dumps({'address':address,'allocated':False,'errorType':type(ex).__name__,'error':str(ex)}))
|
|
asyncio.run(main())
|