From 3c677b8d1b30ca02f9c15a38e737cbea7f610d3f Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 11 Dec 2015 11:59:41 +0000 Subject: allow listening on only HTTP or only HTTPS --- yubiserve.cfg | 2 +- yubiserve.py | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/yubiserve.cfg b/yubiserve.cfg index 569ade1..7ee344c 100644 --- a/yubiserve.cfg +++ b/yubiserve.cfg @@ -1,5 +1,5 @@ yubiservePORT = 8700; -yubiserveSSLPORT = 8701; +#yubiserveSSLPORT = 8701; yubiserveHOST = '127.0.0.1'; yubiDB = 'sqlite'; #yubiDB = 'mysql'; diff --git a/yubiserve.py b/yubiserve.py index 43f0d29..226f8c9 100755 --- a/yubiserve.py +++ b/yubiserve.py @@ -393,20 +393,19 @@ if config['yubiDB'] == 'mysql' and (config['yubiMySQLHost'] == '' or config['yub print "Cannot continue without any MySQL configuration.\nPlease read README.\n\n" quit() -yubiserveHTTP = ThreadingHTTPServer((config['yubiserveHOST'], config['yubiservePORT']), YubiServeHandler) -yubiserveSSL = ThreadingHTTPSServer((config['yubiserveHOST'], config['yubiserveSSLPORT']), YubiServeHandler) - -http_thread = Thread(target=yubiserveHTTP.serve_forever) -ssl_thread = Thread(target=yubiserveSSL.serve_forever) - -http_thread.setDaemon(True) -ssl_thread.setDaemon(True) - -http_thread.start() -ssl_thread.start() - -print "HTTP Server is running." +if config.has_key('yubiservePORT'): + yubiserveHTTP = ThreadingHTTPServer((config['yubiserveHOST'], config['yubiservePORT']), YubiServeHandler) + http_thread = Thread(target=yubiserveHTTP.serve_forever) + http_thread.setDaemon(True) + http_thread.start() + print "HTTP Server is listening on %s:%d" % (config['yubiserveHOST'],config['yubiservePORT']) + +if config.has_key('yubiserveSSLPORT'): + yubiserveSSL = ThreadingHTTPSServer((config['yubiserveHOST'], config['yubiserveSSLPORT']), YubiServeHandler) + ssl_thread = Thread(target=yubiserveSSL.serve_forever) + ssl_thread.setDaemon(True) + ssl_thread.start() + print "HTTPS Server is listening on %s:%d" % (config['yubiserveHOST'],config['yubiserveSSLPORT']) while 1: time.sleep(1) - -- cgit v1.2.3