diff --git a/aiogram/dispatcher/webhook.py b/aiogram/dispatcher/webhook.py index 8e483255..bee635ae 100644 --- a/aiogram/dispatcher/webhook.py +++ b/aiogram/dispatcher/webhook.py @@ -5,6 +5,7 @@ import functools import ipaddress import itertools import typing +import logging from typing import Dict, List, Optional, Union from aiohttp import web @@ -35,6 +36,8 @@ TELEGRAM_SUBNET_2 = ipaddress.IPv4Network('91.108.4.0/22') allowed_ips = set() +log = logging.getLogger(__name__) + def _check_ip(ip: str) -> bool: """ @@ -258,7 +261,9 @@ class WebhookRequestHandler(web.View): if self.request.app.get('_check_ip', False): ip_address, accept = self.check_ip() if not accept: + log.warning(f"Blocking request from an unauthorized IP: {ip_address}") raise web.HTTPUnauthorized() + # context.set_value('TELEGRAM_IP', ip_address)