Improve logging for unregistered webhooks (#34882)
* Improve logging for unregistered webhooks * Address comment, KEY_REAL_IP * Address comment, read(64) * Lint
This commit is contained in:
parent
d4b66717a4
commit
6b16c34fd0
1 changed files with 9 additions and 1 deletions
|
@ -7,6 +7,7 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.components import websocket_api
|
||||
from homeassistant.components.http.view import HomeAssistantView
|
||||
from homeassistant.components.http.const import KEY_REAL_IP
|
||||
from homeassistant.const import HTTP_OK
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.loader import bind_hass
|
||||
|
@ -71,7 +72,14 @@ async def async_handle_webhook(hass, webhook_id, request):
|
|||
|
||||
# Always respond successfully to not give away if a hook exists or not.
|
||||
if webhook is None:
|
||||
_LOGGER.warning("Received message for unregistered webhook %s", webhook_id)
|
||||
peer_ip = request[KEY_REAL_IP]
|
||||
_LOGGER.warning(
|
||||
"Received message for unregistered webhook %s from %s", webhook_id, peer_ip
|
||||
)
|
||||
# Look at content to provide some context for received webhook
|
||||
# Limit to 64 chars to avoid flooding the log
|
||||
content = await request.content.read(64)
|
||||
_LOGGER.debug("%s...", content)
|
||||
return Response(status=HTTP_OK)
|
||||
|
||||
try:
|
||||
|
|
Loading…
Add table
Reference in a new issue