From 019c5fc416b6ee809d10f0e9ddde0176a62bcc84 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Wed, 4 Jan 2023 05:51:28 -0500 Subject: [PATCH] app: move reserved endpoints to klippy_connection Signed-off-by: Eric Callahan --- moonraker/app.py | 8 -------- moonraker/klippy_connection.py | 11 ++++++++++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/moonraker/app.py b/moonraker/app.py index 1798c03..1b40dc3 100644 --- a/moonraker/app.py +++ b/moonraker/app.py @@ -55,12 +55,6 @@ if TYPE_CHECKING: AuthComp = Optional[components.authorization.Authorization] APICallback = Callable[[WebRequest], Coroutine] -# These endpoints are reserved for klippy/server communication only and are -# not exposed via http or the websocket -RESERVED_ENDPOINTS = [ - "list_endpoints", "gcode/subscribe_output", - "register_remote_method" -] # 50 MiB Max Standard Body Size MAX_BODY_SIZE = 50 * 1024 * 1024 @@ -321,8 +315,6 @@ class MoonrakerApp: return self.api_cache def register_remote_handler(self, endpoint: str) -> None: - if endpoint in RESERVED_ENDPOINTS: - return api_def = self._create_api_definition(endpoint) if api_def.uri in self.registered_base_handlers: # reserved handler or already registered diff --git a/moonraker/klippy_connection.py b/moonraker/klippy_connection.py index f43d2dd..b05cddb 100644 --- a/moonraker/klippy_connection.py +++ b/moonraker/klippy_connection.py @@ -37,6 +37,14 @@ if TYPE_CHECKING: from components.machine import Machine FlexCallback = Callable[..., Optional[Coroutine]] +# These endpoints are reserved for klippy/moonraker communication only and are +# not exposed via http or the websocket +RESERVED_ENDPOINTS = [ + "list_endpoints", + "gcode/subscribe_output", + "register_remote_method", +] + INIT_TIME = .25 LOG_ATTEMPT_INTERVAL = int(2. / INIT_TIME + .5) MAX_LOG_ATTEMPTS = 10 * LOG_ATTEMPT_INTERVAL @@ -318,7 +326,8 @@ class KlippyConnection: endpoints = result.get('endpoints', []) app: MoonrakerApp = self.server.lookup_component("application") for ep in endpoints: - app.register_remote_handler(ep) + if ep not in RESERVED_ENDPOINTS: + app.register_remote_handler(ep) async def _check_ready(self) -> None: send_id = "identified" not in self.init_list