From aa2558b1aa317f61154ac69e58f8802030217d78 Mon Sep 17 00:00:00 2001 From: lbbrhzn Date: Wed, 16 Mar 2022 15:51:16 +0100 Subject: [PATCH] skip subprotocol validation when configured (#443) Co-authored-by: lbbrhzn --- custom_components/ocpp/api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/custom_components/ocpp/api.py b/custom_components/ocpp/api.py index 34803516..2018cf2f 100644 --- a/custom_components/ocpp/api.py +++ b/custom_components/ocpp/api.py @@ -55,6 +55,7 @@ CONF_METER_INTERVAL, CONF_MONITORED_VARIABLES, CONF_PORT, + CONF_SKIP_SCHEMA_VALIDATION, CONF_SUBPROTOCOL, CONF_WEBSOCKET_CLOSE_TIMEOUT, CONF_WEBSOCKET_PING_INTERVAL, @@ -69,6 +70,7 @@ DEFAULT_METER_INTERVAL, DEFAULT_PORT, DEFAULT_POWER_UNIT, + DEFAULT_SKIP_SCHEMA_VALIDATION, DEFAULT_SUBPROTOCOL, DEFAULT_WEBSOCKET_CLOSE_TIMEOUT, DEFAULT_WEBSOCKET_PING_INTERVAL, @@ -177,7 +179,9 @@ async def on_connect( self, websocket: websockets.server.WebSocketServerProtocol, path: str ): """Request handler executed for every new OCPP connection.""" - + if self.config.get(CONF_SKIP_SCHEMA_VALIDATION, DEFAULT_SKIP_SCHEMA_VALIDATION): + _LOGGER.warning("Skipping websocket subprotocol validation") + return try: requested_protocols = websocket.request_headers["Sec-WebSocket-Protocol"] except KeyError: