forked from pexip/jostedal
-
Notifications
You must be signed in to change notification settings - Fork 2
/
turnd.py
executable file
·31 lines (26 loc) · 921 Bytes
/
turnd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env vpython3
import os
import sys
import json
import logging.config
from twisted.internet import reactor
from sturn.turn.server import TurnUdpServer
from sturn.stun.authentication import LongTermCredentialMechanism
try:
logging.config.fileConfig('logging.config')
except:
logging.basicConfig(level=logging.DEBUG, format="%(levelname)s: %(message)s")
logging.exception("Failed to load 'logging.config' file")
with open(sys.argv[1]) as fp:
config = json.load(fp)
software = config['software']
realm = bytes(config['realm'].encode('utf-8'))
users = config['users']
overrides = config.get('overrides') or {}
interface = config['turnhost']
port = config['turnport']
credential_mechanism = LongTermCredentialMechanism(realm, users)
server = TurnUdpServer(reactor, interface, port, software, credential_mechanism, overrides)
port = server.start()
logging.info("Started %r", server)
reactor.run()