From 4fc2116dcb6eea2bfb703dbccb2f41be44d2224d Mon Sep 17 00:00:00 2001
From: Dmitry <b4tm4n@mail.ru>
Date: Tue, 20 Feb 2024 12:57:40 +0300
Subject: [PATCH] refactor base + ignore .env

---
 .gitignore     |  3 ++-
 pddnsc/base.py | 17 +++++++++++++----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/.gitignore b/.gitignore
index d9442db..c5ca132 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
 .venv/
 state/*
-__pycache__
\ No newline at end of file
+__pycache__
+.env*
diff --git a/pddnsc/base.py b/pddnsc/base.py
index c5ca739..aa9eaaf 100644
--- a/pddnsc/base.py
+++ b/pddnsc/base.py
@@ -21,6 +21,9 @@ class BaseSourceProvider(ABC):
             ipv4t,
             ipv6t,
         )
+        self.post_init()
+
+    def post_init(self): ...
 
     def __str__(self):
         return f"{self.__class__.__name__}: {self.name}"
@@ -68,6 +71,9 @@ class BaseOutputProvider(ABC):
     def __init__(self, name, config, ipv4t, ipv6t):
         self.name, self.config = name, config
         self.ipv4t, self.ipv6t = ipv4t, ipv6t
+        self.post_init()
+
+    def post_init(self): ...
 
     def __init_subclass__(cls) -> None:
         BaseOutputProvider._childs[cls.__name__] = cls
@@ -76,10 +82,10 @@ class BaseOutputProvider(ABC):
     def __str__(self):
         return f"{self.__class__.__name__}: {self.name}"
 
-    def best_client(self, addr_v4, addr_v6):
-        if addr_v6 is None and addr_v4 is not None:
-            return self.ipv4t
-        return self.ipv6t
+    def best_transport(self, addr_v4, addr_v6):
+        if addr_v6:
+            return self.ipv6t
+        return self.ipv4t
 
     @classmethod
     def validate_source_config(cls, name, config):
@@ -111,6 +117,9 @@ class BaseFilterProvider(ABC):
     def __init__(self, name, config, ipv4t, ipv6t):
         self.name, self.config = name, config
         self.ipv4t, self.ipv6t = ipv4t, ipv6t
+        self.post_init()
+
+    def post_init(self): ...
 
     def __init_subclass__(cls) -> None:
         BaseFilterProvider._childs[cls.__name__] = cls