diff --git a/pddnsc/sources/wtfismyip.py b/pddnsc/sources/wtfismyip.py new file mode 100644 index 0000000..b6205c6 --- /dev/null +++ b/pddnsc/sources/wtfismyip.py @@ -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