From 14376c39c7784425454fb3a9ccd165409076bd04 Mon Sep 17 00:00:00 2001 From: DocArmoryTech Date: Tue, 3 Nov 2020 11:51:01 +0000 Subject: [PATCH] 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) --- bin/tai-server.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/tai-server.py b/bin/tai-server.py index 189585a..c1c1f59 100644 --- a/bin/tai-server.py +++ b/bin/tai-server.py @@ -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() -