Compare commits
No commits in common. "3e9142cd5408ebe226d3b6197a4c37b0b9737454" and "6949baf12e61079433d1d1c346210ba51b90925b" have entirely different histories.
3e9142cd54
...
6949baf12e
pddnsc/sources
@ -2,18 +2,20 @@ import httpx
|
||||
|
||||
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
|
||||
response = await client.get("https://api4.ipify.org/?format=json")
|
||||
if response.status_code == httpx.codes.OK:
|
||||
data = response.json()
|
||||
result = None if not isinstance(data, dict) else data.get("ip")
|
||||
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
|
||||
response = await client.get("https://api6.ipify.org/?format=json")
|
||||
if response.status_code == httpx.codes.OK:
|
||||
data = response.json()
|
||||
result = None if not isinstance(data, dict) else data.get("ip")
|
||||
return result
|
||||
|
@ -1,20 +0,0 @@
|
||||
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
|
Loading…
x
Reference in New Issue
Block a user