add wtfismyip source

This commit is contained in:
Dmitry Belyaev 2024-02-20 23:49:57 +03:00
parent 8a1ba06c88
commit 3e9142cd54
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3
1 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,20 @@
import httpx
from pddnsc.base import BaseSourceProvider
# https://wtfismyip.com/
# https://gitlab.com/wtfismyip/wtfismyip
class WTFIsMyIP(BaseSourceProvider):
async def fetch_v4(self) -> str:
async with httpx.AsyncClient(transport=self.ipv4t) as client:
response = await client.get("https://text.ipv4.myip.wtf")
if response.is_success:
result = response.text.strip() or None
return result
async def fetch_v6(self) -> str:
async with httpx.AsyncClient(transport=self.ipv6t) as client:
response = await client.get("https://text.ipv6.myip.wtf")
if response.is_success:
result = response.text.strip() or None
return result