Skip to content

Commit

Permalink
Bit of code ordering for the DNS check operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Bayart committed Jul 24, 2024
1 parent 31cbbbb commit 55b0a2b
Show file tree
Hide file tree
Showing 6 changed files with 355 additions and 303 deletions.
10 changes: 10 additions & 0 deletions src/dns/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from .domain import Domain
from .dkim import DkimInfo
from .utils import get_ip_address, make_auth_resolver

__all__ = [
DkimInfo,
Domain,
get_ip_address,
make_auth_resolver,
]
303 changes: 0 additions & 303 deletions src/dns/check.py

This file was deleted.

33 changes: 33 additions & 0 deletions src/dns/dkim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

class DkimInfo:
v: str | None
h: str | None
k: str | None
p: str | None

def __init__(self, text: str):
if text.startswith('"'):
text = text.replace(" ","")
text = text.replace('"', "")
text = text.replace("\n", "")
text = text.replace("\t", "")
items = text.split(";")
for item in items:
print(f"Je regarde l'item {item}")
(key, val) = item.split("=", 1)
print(f"key = '{key}' et val = '{val}'")
setattr(self, key, val)
if self.v is None or self.h is None or self.k is None or self.p is None:
raise Exception("Invalid DKIM")

def __eq__(self, other) -> bool:
if not isinstance(other, DkimInfo):
return False
if self.v == other.v and self.h == other.h and self.k == other.k and self.p == other.p:
return True
return False

def __str__(self) -> str:
return f"DkimInfo(v={self.v}, h={self.h}, k={self.k}, p={self.p})"


Loading

0 comments on commit 55b0a2b

Please sign in to comment.