34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
""" модуль имитации получения IP аддресов """
|
|
|
|
import asyncio
|
|
|
|
from pddnsc.base import BaseSourceProvider
|
|
|
|
|
|
class DummySource(BaseSourceProvider):
|
|
"""имитация получения пустых адресов"""
|
|
|
|
async def fetch_v4(self) -> str:
|
|
result = await asyncio.sleep(self.config.get("delay", 1), result=None)
|
|
return result
|
|
|
|
async def fetch_v6(self) -> str:
|
|
result = await asyncio.sleep(self.config.get("delay", 1), result=None)
|
|
return result
|
|
|
|
|
|
class FakeSource(BaseSourceProvider):
|
|
"""имитация получения заданных в конфигурации адресов"""
|
|
|
|
async def fetch_v4(self) -> str:
|
|
result = await asyncio.sleep(
|
|
self.config.get("delay", 1), result=self.config.get("ipv4", "127.0.0.1")
|
|
)
|
|
return result
|
|
|
|
async def fetch_v6(self) -> str:
|
|
result = await asyncio.sleep(
|
|
self.config.get("delay", 1), result=self.config.get("ipv6", "::1")
|
|
)
|
|
return result
|