myl-discovery 0.3.0__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: myl-discovery
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: email autodiscovery
5
5
  Author-email: Philipp Schmitt <philipp@schmitt.co>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: myl-discovery
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: email autodiscovery
5
5
  Author-email: Philipp Schmitt <philipp@schmitt.co>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -1,5 +1,7 @@
1
1
  import logging
2
+ import os
2
3
  import re
4
+ import shutil
3
5
 
4
6
  import dns.resolver
5
7
  import requests
@@ -8,9 +10,33 @@ import xmltodict
8
10
  LOGGER = logging.getLogger(__name__)
9
11
 
10
12
 
13
+ def is_termux():
14
+ if os.getenv("TERMUX_VERSION"):
15
+ return True
16
+
17
+ return shutil.which("termux-info") is not None
18
+
19
+
20
+ def resolve(*args, **kwargs):
21
+ termux = is_termux()
22
+ dns.resolver.default_resolver = dns.resolver.Resolver(
23
+ # Do not attempt to read /etc/resolv.conf on Termux
24
+ configure=not termux
25
+ )
26
+ if termux:
27
+ # Default to Google DNS on Termux
28
+ dns.resolver.default_resolver.nameservers = [
29
+ "8.8.8.8",
30
+ "2001:4860:4860::8888",
31
+ "8.8.4.4",
32
+ "2001:4860:4860::8844",
33
+ ]
34
+ return dns.resolver.resolve(*args, **kwargs)
35
+
36
+
11
37
  def resolve_txt(domain, criteria="^mailconf="):
12
38
  regex = re.compile(criteria)
13
- answers = dns.resolver.resolve(domain, "TXT")
39
+ answers = resolve(domain, "TXT")
14
40
  for rdata in answers:
15
41
  for txt_string in rdata.strings:
16
42
  txt_record = txt_string.decode("utf-8")
@@ -19,7 +45,7 @@ def resolve_txt(domain, criteria="^mailconf="):
19
45
 
20
46
 
21
47
  def resolve_srv(domain):
22
- answers = dns.resolver.resolve(domain, "SRV")
48
+ answers = resolve(domain, "SRV")
23
49
  data = []
24
50
  for rdata in answers:
25
51
  entry = {
@@ -21,7 +21,7 @@ dependencies = [
21
21
  "rich",
22
22
  "xmltodict"
23
23
  ]
24
- version = "0.3.0"
24
+ version = "0.3.1"
25
25
 
26
26
  [project.scripts]
27
27
  myl-discovery = "myldiscovery:main"
File without changes
File without changes
File without changes
File without changes