mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-08 17:13:56 +00:00
commit
66849ec770
1 changed files with 5 additions and 0 deletions
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue