Parameterise listening port and address

Uses tornado.options to `define` the port and ip address on which tai-server listens.

Default options maintain current functionality (i.e. listen on 0.0.0.0:8889)
pull/2/head
DocArmoryTech 2020-11-03 11:51:01 +00:00 committed by GitHub
parent af9764bee1
commit 14376c39c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -1,12 +1,17 @@
import tornado.ioloop
import tornado.web
from tornado.escape import json_decode, json_encode
from tornado.options import define, options
import os.path
import sys
import json
import datetime
define('port', default=8889, help='port to listen on')
define('address', default='0.0.0.0', help='address to listen on')
class Query(tornado.web.RequestHandler):
def prepare(self):
@ -102,6 +107,6 @@ for threat_actor in threat_actors['values']:
tai_country[threat_actor['meta']['country'].lower()].append(threat_actor['uuid'])
if __name__ == "__main__":
application.listen(8889)
tornado.options.parse_command_line()
application.listen(options.port, address=options.address)
tornado.ioloop.IOLoop.instance().start()