From c9a46a1f9b5f933e219a683fd77a4c54c7251e2b Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Fri, 15 Mar 2024 14:47:30 -0400 Subject: [PATCH 1/3] Remove http handler from codebase --- app/classes/web/http_handler.py | 42 ---------------------------- app/classes/web/http_handler_page.py | 33 ---------------------- app/classes/web/tornado_handler.py | 27 ------------------ 3 files changed, 102 deletions(-) delete mode 100644 app/classes/web/http_handler.py delete mode 100644 app/classes/web/http_handler_page.py diff --git a/app/classes/web/http_handler.py b/app/classes/web/http_handler.py deleted file mode 100644 index 32676d59..00000000 --- a/app/classes/web/http_handler.py +++ /dev/null @@ -1,42 +0,0 @@ -import logging -import requests - -from app.classes.web.base_handler import BaseHandler - -logger = logging.getLogger(__name__) - - -class HTTPHandler(BaseHandler): - def get(self): - url = str(self.request.host) - port = 443 - url_list = url.split(":") - if url_list[0] != "": - url = "https://" + url_list[0] - else: - url = "https://" + url - db_port = self.helper.get_setting("https_port") - try: - resp = requests.head(url + ":" + str(port), timeout=(0.5, 5)) - resp.raise_for_status() - except Exception: - port = db_port - self.redirect(url + ":" + str(port)) - - -class HTTPHandlerPage(BaseHandler): - def get(self): - url = str(self.request.host) - port = 443 - url_list = url.split(":") - if url_list[0] != "": - url = "https://" + url_list[0] - else: - url = "https://" + url - db_port = self.helper.get_setting("https_port") - try: - resp = requests.head(url + ":" + str(port), timeout=(0.5, 5)) - resp.raise_for_status() - except Exception: - port = db_port - self.redirect(url + ":" + str(port)) diff --git a/app/classes/web/http_handler_page.py b/app/classes/web/http_handler_page.py deleted file mode 100644 index 77161577..00000000 --- a/app/classes/web/http_handler_page.py +++ /dev/null @@ -1,33 +0,0 @@ -import logging -import requests -from app.classes.web.base_handler import BaseHandler - -logger = logging.getLogger(__name__) - - -class HTTPHandlerPage(BaseHandler): - def get(self): - url = self.request.full_url - port = 443 - if url[len(url) - 1] == "/": - url = url.strip(url[len(url) - 1]) - url_list = url.split("/") - if url_list[0] != "": - primary_url = url_list[0] + ":" + str(port) + "/" - backup_url = ( - url_list[0] + ":" + str(self.helper.get_setting("https_port")) + "/" - ) - for i in range(len(url_list) - 1): - primary_url += url_list[i + 1] - backup_url += url_list[i + 1] - else: - primary_url = url + str(port) - backup_url = url + str(self.helper.get_setting("https_port")) - - try: - resp = requests.head(primary_url, timeout=(0.5, 5)) - resp.raise_for_status() - url = primary_url - except Exception: - url = backup_url - self.redirect("https://" + url + ":" + str(port)) diff --git a/app/classes/web/tornado_handler.py b/app/classes/web/tornado_handler.py index fbcf970f..f65f4fca 100644 --- a/app/classes/web/tornado_handler.py +++ b/app/classes/web/tornado_handler.py @@ -25,7 +25,6 @@ from app.classes.web.server_handler import ServerHandler from app.classes.web.websocket_handler import WebSocketHandler from app.classes.web.static_handler import CustomStaticHandler from app.classes.web.upload_handler import UploadHandler -from app.classes.web.http_handler import HTTPHandler, HTTPHandlerPage from app.classes.web.status_handler import StatusHandler @@ -44,7 +43,6 @@ class Webserver: file_helper: FileHelpers, ): self.ioloop = None - self.http_server = None self.https_server = None self.helper = helper self.controller = controller @@ -173,30 +171,6 @@ class Webserver: static_handler_class=CustomStaticHandler, serve_traceback=debug_errors, ) - http_handers = [ - (r"/", HTTPHandler, handler_args), - (r"/(.+)", HTTPHandlerPage, handler_args), - ] - http_app = tornado.web.Application( - http_handers, - template_path=os.path.join(self.helper.webroot, "templates"), - static_path=os.path.join(self.helper.webroot, "static"), - debug=debug_errors, - cookie_secret=cookie_secret, - xsrf_cookies=True, - autoreload=False, - log_function=self.log_function, - default_handler_class=HTTPHandler, - login_url="/login", - serve_traceback=debug_errors, - ) - - if http_port != 0: - self.http_server = tornado.httpserver.HTTPServer(http_app) - self.http_server.listen(http_port) - else: - logger.info("http port disabled by config") - self.https_server = tornado.httpserver.HTTPServer(app, ssl_options=cert_objects) self.https_server.listen(https_port) @@ -218,7 +192,6 @@ class Webserver: logger.info("Shutting Down Web Server") Console.info("Shutting Down Web Server") self.ioloop.stop() - self.http_server.stop() self.https_server.stop() logger.info("Web Server Stopped") Console.info("Web Server Stopped") From 6eea6a15d7c0b8c73831bc21101967a71c620702 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Fri, 15 Mar 2024 14:49:31 -0400 Subject: [PATCH 2/3] Remove http port from config --- app/classes/shared/helpers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/classes/shared/helpers.py b/app/classes/shared/helpers.py index 6b821f9d..0427da11 100644 --- a/app/classes/shared/helpers.py +++ b/app/classes/shared/helpers.py @@ -496,7 +496,6 @@ class Helpers: # Config.json was removed from the repo to make it easier for users # To make non-breaking changes to the file. return { - "http_port": 8000, "https_port": 8443, "language": "en_EN", "cookie_expire": 30, From 68d9ed03e32d22c09edc8d72d0f65bea0db5372e Mon Sep 17 00:00:00 2001 From: Zedifus Date: Mon, 18 Mar 2024 23:38:23 +0000 Subject: [PATCH 3/3] Update changelog !730 --- CHANGELOG.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bee1408..56251f24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,10 @@ # Changelog ## --- [4.3.1] - 2024/TBD -### New features -TBD ### Bug fixes - Fix Server ID Rework for backups, schedules, and roles (INT ID to UUID migration) ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/729)) ### Tweaks -TBD -### Lang -TBD +- Remove http re-direct handler. Users should implement nginx configurations for port 80 redirects ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/730)) +

## --- [4.3.0] - 2024/03/09