Skip to content

Commit

Permalink
skip subprotocol validation when configured (#443)
Browse files Browse the repository at this point in the history
Co-authored-by: lbbrhzn <lbbrhzn>
  • Loading branch information
lbbrhzn authored Mar 16, 2022
1 parent 605b4c7 commit aa2558b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion custom_components/ocpp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit aa2558b

Please sign in to comment.