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 55
66
77class Result (NamedTuple ):
8- name : str
8+ domain : str
99 found : bool
1010
1111
12- async def probe (loop : asyncio .AbstractEventLoop , name : str ) -> Result :
12+ async def probe (loop : asyncio .AbstractEventLoop , domain : str ) -> Result :
1313 try :
14- await loop .getaddrinfo (name , None )
14+ await loop .getaddrinfo (domain , None )
1515 except socket .gaierror :
16- return Result (name , False )
17- return Result (name , True )
16+ return Result (domain , False )
17+ return Result (domain , True )
1818
1919
20- async def multi_probe (names : Iterable [str ]) -> AsyncIterator [Result ]:
20+ async def multi_probe (domains : Iterable [str ]) -> AsyncIterator [Result ]:
2121 loop = asyncio .get_running_loop ()
22- coros = [probe (loop , name ) for name in names ]
22+ coros = [probe (loop , domain ) for domain in domains ]
2323 for coro in asyncio .as_completed (coros ):
2424 result = await coro
2525 yield result
Original file line number Diff line number Diff line change @@ -11,9 +11,9 @@ async def main(tld: str) -> None:
1111 tld = tld .strip ('.' )
1212 names = (kw for kw in kwlist if len (kw ) <= 4 )
1313 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 ):
1515 mark = '.' if found else '?\t \t '
16- print (f'{ mark } { name } ' )
16+ print (f'{ mark } { domain } ' )
1717
1818
1919if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments