use generic provider for ipfy + wtfismyip
This commit is contained in:
parent
38923fec9e
commit
c0d1d4b38d
@ -1,19 +1,9 @@
|
||||
import httpx
|
||||
from pddnsc.sources.http import GenericHttpSource
|
||||
|
||||
from pddnsc.base import BaseSourceProvider
|
||||
|
||||
# https://www.ipify.org/
|
||||
class IPIFYSource(BaseSourceProvider):
|
||||
async def fetch_v4(self) -> str:
|
||||
async with httpx.AsyncClient(transport=self.ipv4t) as client:
|
||||
response = await client.get("https://api4.ipify.org")
|
||||
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://api6.ipify.org")
|
||||
if response.is_success:
|
||||
result = response.text.strip() or None
|
||||
return result
|
||||
class IPIFYSource(GenericHttpSource):
|
||||
def post_init(self):
|
||||
super().post_init()
|
||||
self.url_v4 = "https://api4.ipify.org"
|
||||
self.url_v6 = "https://api6.ipify.org"
|
||||
|
@ -1,20 +1,10 @@
|
||||
import httpx
|
||||
from pddnsc.sources.http import GenericHttpSource
|
||||
|
||||
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
|
||||
class WTFIsMyIP(GenericHttpSource):
|
||||
def post_init(self):
|
||||
super().post_init()
|
||||
self.url_v4 = "https://text.ipv4.myip.wtf"
|
||||
self.url_v6 = "https://text.ipv6.myip.wtf"
|
||||
|
Loading…
Reference in New Issue
Block a user