File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 5
5
6
6
7
7
class Result (NamedTuple ):
8
- name : str
8
+ domain : str
9
9
found : bool
10
10
11
11
12
- async def probe (loop : asyncio .AbstractEventLoop , name : str ) -> Result :
12
+ async def probe (loop : asyncio .AbstractEventLoop , domain : str ) -> Result :
13
13
try :
14
- await loop .getaddrinfo (name , None )
14
+ await loop .getaddrinfo (domain , None )
15
15
except socket .gaierror :
16
- return Result (name , False )
17
- return Result (name , True )
16
+ return Result (domain , False )
17
+ return Result (domain , True )
18
18
19
19
20
- async def multi_probe (names : Iterable [str ]) -> AsyncIterator [Result ]:
20
+ async def multi_probe (domains : Iterable [str ]) -> AsyncIterator [Result ]:
21
21
loop = asyncio .get_running_loop ()
22
- coros = [probe (loop , name ) for name in names ]
22
+ coros = [probe (loop , domain ) for domain in domains ]
23
23
for coro in asyncio .as_completed (coros ):
24
24
result = await coro
25
25
yield result
Original file line number Diff line number Diff line change @@ -11,9 +11,9 @@ async def main(tld: str) -> None:
11
11
tld = tld .strip ('.' )
12
12
names = (kw for kw in kwlist if len (kw ) <= 4 )
13
13
domains = (f'{ name } .{ tld } ' .lower () for name in names )
14
- async for name , found in multi_probe (domains ):
14
+ async for domain , found in multi_probe (domains ):
15
15
mark = '.' if found else '?\t \t '
16
- print (f'{ mark } { name } ' )
16
+ print (f'{ mark } { domain } ' )
17
17
18
18
19
19
if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments