add ip addrs validation
This commit is contained in:
parent
0509ba9d63
commit
31564c22d5
@ -1,7 +1,8 @@
|
||||
import httpx
|
||||
import asyncio
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import NamedTuple
|
||||
from typing import NamedTuple, Optional
|
||||
from netaddr import valid_ipv4, valid_ipv6
|
||||
|
||||
|
||||
class IPAddreses(NamedTuple):
|
||||
@ -154,3 +155,11 @@ class BaseFilterProvider(ABC):
|
||||
|
||||
@abstractmethod
|
||||
async def check_imp(self, source_provider, addr_v4, addr_v6): ...
|
||||
|
||||
|
||||
def filter_ipv4(value: str) -> Optional[str]:
|
||||
return value and valid_ipv4(value) and value or None
|
||||
|
||||
|
||||
def filter_ipv6(value: str) -> Optional[str]:
|
||||
return value and valid_ipv6(value) and value or None
|
||||
|
@ -2,3 +2,4 @@ httpx[http2]>=0.26,<1.0
|
||||
asyncio>=3.4.3,<4
|
||||
aiofiles>=23,<24
|
||||
toml>=0.10,<1
|
||||
netaddr>=1,<2
|
Loading…
Reference in New Issue
Block a user