mirror of
https://github.com/chatmail/relay.git
synced 2026-05-11 16:34:39 +00:00
Compare commits
1 Commits
version-pe
...
link2xt/si
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9456be5bc |
@@ -37,21 +37,15 @@ class DNS:
|
|||||||
|
|
||||||
def get(self, typ: str, domain: str) -> str | None:
|
def get(self, typ: str, domain: str) -> str | None:
|
||||||
"""Get a DNS entry"""
|
"""Get a DNS entry"""
|
||||||
dig_result = self.shell(f"dig {typ} {domain}")
|
dig_result = self.shell(f"dig -r -q {domain} -t {typ} +short")
|
||||||
line_num = 0
|
line = dig_result.partition("\n")[0]
|
||||||
for line in dig_result.splitlines():
|
if line:
|
||||||
line_num += 1
|
return line
|
||||||
if line.strip() == ";; ANSWER SECTION:":
|
|
||||||
return dig_result.splitlines()[line_num].split("\t")[-1]
|
|
||||||
|
|
||||||
def check_ptr_record(self, ip: str, mail_domain) -> str:
|
def check_ptr_record(self, ip: str, mail_domain) -> bool:
|
||||||
"""Check the PTR record for an IPv4 or IPv6 address."""
|
"""Check the PTR record for an IPv4 or IPv6 address."""
|
||||||
result = self.get("-x", ip)
|
result = self.shell(f"dig -r -x {ip} +short").rstrip()
|
||||||
if result:
|
return result == f"{mail_domain}."
|
||||||
if ip_address(ip).version == 6:
|
|
||||||
result = result.split()[-1]
|
|
||||||
if result[:-1] == mail_domain:
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def show_dns(args, out):
|
def show_dns(args, out):
|
||||||
|
|||||||
Reference in New Issue
Block a user