Use identity check in hassio websocket ingress (#109672)

This commit is contained in:
J. Nick Koston 2024-02-05 01:55:19 -06:00 committed by GitHub
parent a5bd0292da
commit 57f4f061a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -288,13 +288,13 @@ async def _websocket_forward(
"""Handle websocket message directly.""" """Handle websocket message directly."""
try: try:
async for msg in ws_from: async for msg in ws_from:
if msg.type == aiohttp.WSMsgType.TEXT: if msg.type is aiohttp.WSMsgType.TEXT:
await ws_to.send_str(msg.data) await ws_to.send_str(msg.data)
elif msg.type == aiohttp.WSMsgType.BINARY: elif msg.type is aiohttp.WSMsgType.BINARY:
await ws_to.send_bytes(msg.data) await ws_to.send_bytes(msg.data)
elif msg.type == aiohttp.WSMsgType.PING: elif msg.type is aiohttp.WSMsgType.PING:
await ws_to.ping() await ws_to.ping()
elif msg.type == aiohttp.WSMsgType.PONG: elif msg.type is aiohttp.WSMsgType.PONG:
await ws_to.pong() await ws_to.pong()
elif ws_to.closed: elif ws_to.closed:
await ws_to.close(code=ws_to.close_code, message=msg.extra) # type: ignore[arg-type] await ws_to.close(code=ws_to.close_code, message=msg.extra) # type: ignore[arg-type]