myl-discovery 0.2.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.
- {myl-discovery-0.2.0 → myl-discovery-0.3.1}/PKG-INFO +1 -1
- {myl-discovery-0.2.0 → myl-discovery-0.3.1}/myl_discovery.egg-info/PKG-INFO +1 -1
- {myl-discovery-0.2.0 → myl-discovery-0.3.1}/myl_discovery.egg-info/SOURCES.txt +5 -1
- myl-discovery-0.3.1/myl_discovery.egg-info/entry_points.txt +2 -0
- {myl-discovery-0.2.0 → myl-discovery-0.3.1}/myl_discovery.egg-info/requires.txt +1 -0
- myl-discovery-0.3.1/myldiscovery/__init__.py +4 -0
- myl-discovery-0.3.1/myldiscovery/__main__.py +4 -0
- myl-discovery-0.2.0/myldiscovery/__init__.py → myl-discovery-0.3.1/myldiscovery/discovery.py +29 -3
- myl-discovery-0.3.1/myldiscovery/main.py +64 -0
- {myl-discovery-0.2.0 → myl-discovery-0.3.1}/pyproject.toml +5 -1
- {myl-discovery-0.2.0 → myl-discovery-0.3.1}/.github/dependabot.yml +0 -0
- {myl-discovery-0.2.0 → myl-discovery-0.3.1}/.github/workflows/lint.yaml +0 -0
- {myl-discovery-0.2.0 → myl-discovery-0.3.1}/.github/workflows/release.yaml +0 -0
- {myl-discovery-0.2.0 → myl-discovery-0.3.1}/.gitignore +0 -0
- {myl-discovery-0.2.0 → myl-discovery-0.3.1}/LICENSE +0 -0
- {myl-discovery-0.2.0 → myl-discovery-0.3.1}/README.md +0 -0
- {myl-discovery-0.2.0 → myl-discovery-0.3.1}/myl_discovery.egg-info/dependency_links.txt +0 -0
- {myl-discovery-0.2.0 → myl-discovery-0.3.1}/myl_discovery.egg-info/top_level.txt +0 -0
- {myl-discovery-0.2.0 → myl-discovery-0.3.1}/setup.cfg +0 -0
@@ -8,6 +8,10 @@ pyproject.toml
|
|
8
8
|
myl_discovery.egg-info/PKG-INFO
|
9
9
|
myl_discovery.egg-info/SOURCES.txt
|
10
10
|
myl_discovery.egg-info/dependency_links.txt
|
11
|
+
myl_discovery.egg-info/entry_points.txt
|
11
12
|
myl_discovery.egg-info/requires.txt
|
12
13
|
myl_discovery.egg-info/top_level.txt
|
13
|
-
myldiscovery/__init__.py
|
14
|
+
myldiscovery/__init__.py
|
15
|
+
myldiscovery/__main__.py
|
16
|
+
myldiscovery/discovery.py
|
17
|
+
myldiscovery/main.py
|
myl-discovery-0.2.0/myldiscovery/__init__.py → myl-discovery-0.3.1/myldiscovery/discovery.py
RENAMED
@@ -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 =
|
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 =
|
48
|
+
answers = resolve(domain, "SRV")
|
23
49
|
data = []
|
24
50
|
for rdata in answers:
|
25
51
|
entry = {
|
@@ -73,7 +99,7 @@ def autodiscover(email_addr, srv_only=False):
|
|
73
99
|
# 465 -> starttls
|
74
100
|
# 587 -> no
|
75
101
|
"starttls": False,
|
76
|
-
}
|
102
|
+
},
|
77
103
|
}
|
78
104
|
|
79
105
|
res = requests.get(autoconfig)
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
import argparse
|
5
|
+
import logging
|
6
|
+
|
7
|
+
from rich import print_json
|
8
|
+
from rich.console import Console
|
9
|
+
from rich.logging import RichHandler
|
10
|
+
from rich.table import Table
|
11
|
+
|
12
|
+
from myldiscovery import autodiscover
|
13
|
+
|
14
|
+
LOGGER = logging.getLogger(__name__)
|
15
|
+
|
16
|
+
|
17
|
+
def parse_args():
|
18
|
+
parser = argparse.ArgumentParser()
|
19
|
+
parser.add_argument("-j", "--json", action="store_true", default=False)
|
20
|
+
parser.add_argument("-d", "--debug", action="store_true", default=False)
|
21
|
+
parser.add_argument("EMAIL")
|
22
|
+
return parser.parse_args()
|
23
|
+
|
24
|
+
|
25
|
+
def main():
|
26
|
+
console = Console()
|
27
|
+
args = parse_args()
|
28
|
+
|
29
|
+
logging.basicConfig(
|
30
|
+
handlers=[RichHandler(console=console, show_time=False)],
|
31
|
+
level=logging.DEBUG if args.debug else logging.INFO,
|
32
|
+
)
|
33
|
+
LOGGER.debug(args)
|
34
|
+
|
35
|
+
try:
|
36
|
+
res = autodiscover(args.EMAIL)
|
37
|
+
if args.json:
|
38
|
+
print_json(data=res)
|
39
|
+
else:
|
40
|
+
table = Table(
|
41
|
+
expand=True,
|
42
|
+
show_header=True,
|
43
|
+
header_style="bold",
|
44
|
+
show_lines=False,
|
45
|
+
box=None,
|
46
|
+
)
|
47
|
+
table.add_column("Service", style="red")
|
48
|
+
table.add_column("Host", style="blue")
|
49
|
+
table.add_column("Port", style="green")
|
50
|
+
table.add_column("TLS", style="yellow")
|
51
|
+
for svc in ["imap", "smtp"]:
|
52
|
+
table.add_row(
|
53
|
+
svc,
|
54
|
+
res[svc]["server"],
|
55
|
+
str(res[svc]["port"]),
|
56
|
+
"starttls" if res[svc]["starttls"] else "tls",
|
57
|
+
)
|
58
|
+
console.print(table)
|
59
|
+
except Exception:
|
60
|
+
console.print_exception(show_locals=True)
|
61
|
+
|
62
|
+
|
63
|
+
if __name__ == "__main__":
|
64
|
+
main()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|