Skip to content

Commit 80f3fb1

Browse files
committed
initial tests whodap
1 parent 384be63 commit 80f3fb1

7 files changed

Lines changed: 3536 additions & 2 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ out
7979
lint.txt
8080
pylint.txt
8181
vtmp/
82+
*.1
83+
*.2

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ PY_FILES := *.py whoisdomain/
2222

2323
MYPY_INSTALL := \
2424
types-requests \
25-
types-python-dateutil redis tld
25+
types-python-dateutil
2626

2727
COMMON_VENV := rm -rf $(VENV); \
2828
$(MIN_PYTHON_VERSION) -m venv $(VENV); \
@@ -47,7 +47,7 @@ check:
4747

4848
mypy:
4949
$(COMMON_VENV) \
50-
$(PIP_INSTALL) mypy $(MYPY_INSTALL); \
50+
$(PIP_INSTALL) -r requirements.txt mypy $(MYPY_INSTALL); \
5151
mypy \
5252
--strict \
5353
--no-incremental \
@@ -61,3 +61,8 @@ build:
6161

6262
test:
6363
make -f Makefile.tests
64+
65+
t2:
66+
$(COMMON_VENV) \
67+
$(PIP_INSTALL) -r requirements.txt; \
68+
$(MIN_PYTHON_VERSION) t2.py 2>$@.2 | tee $@.1

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
whodap==0.1.15
2+
tld==0.13.2

t2.1

Lines changed: 2136 additions & 0 deletions
Large diffs are not rendered by default.

t2.2

Lines changed: 1345 additions & 0 deletions
Large diffs are not rendered by default.

t2.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import sys
2+
from typing import Any
3+
4+
import httpx
5+
import tld
6+
import whodap
7+
8+
import whoisdomain
9+
10+
client = httpx.Client(follow_redirects=True, timeout=10)
11+
dns_client = whodap.DNSClient.new_client(client)
12+
13+
14+
def do_one_domain(domain: str) -> dict[str, Any] | None:
15+
d = None
16+
try:
17+
fld = tld.get_fld(domain, fix_protocol=True, fail_silently=True)
18+
a = fld.split(".")
19+
dom = ".".join(a[:-1])
20+
xtld = a[-1]
21+
resp = dns_client.lookup(dom, xtld)
22+
d = resp.to_whois_dict()
23+
except Exception as e:
24+
print(f"Exception: {e}", file=sys.stderr)
25+
26+
return d
27+
28+
29+
def xmain() -> None:
30+
for k, v in whoisdomain.tldDb.tld_regexpr.ZZ.items():
31+
server = v.get("_server")
32+
test = v.get("_test")
33+
if not server:
34+
continue
35+
36+
print("##", k, server, test)
37+
fld = tld.get_fld(server, fix_protocol=True, fail_silently=True)
38+
rr = {}
39+
if fld not in rr:
40+
rr[fld] = do_one_domain(server)
41+
if rr[fld]:
42+
print(fld, rr[fld])
43+
44+
45+
xmain()

whoisdomain/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)