File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,19 +25,17 @@ def isdkim(rec):
2525
2626def getkey (host ):
2727 if args .prefix :
28- sdir = host .split ("._domainkey." , 1 )[- 1 ][0 ]
28+ sdir = host .split ("._domainkey." , 1 )[- 1 ][0 : 2 ]
2929 ofd = f"{ args .outdir } /{ sdir } "
3030 else :
3131 ofd = args .outdir
32- if not os .path .exists (ofd ):
33- os .makedirs (ofd , exist_ok = True )
3432 ofn = f"{ ofd } /{ host } "
3533 if os .path .exists (ofn ):
3634 if args .skipexisting :
3735 return
3836 ofn += "__" + secrets .token_urlsafe (3 )
3937 try :
40- rr = dns .resolver .resolve (host , "TXT" )
38+ rr = dns .resolver .resolve (host , "TXT" , lifetime = 2 )
4139 except (dns .resolver .NXDOMAIN , dns .resolver .NoAnswer ):
4240 return
4341 except (dns .resolver .NoNameservers , dns .resolver .LifetimeTimeout ,
@@ -50,6 +48,8 @@ def getkey(host):
5048 krec = b"" .join (rec .strings )
5149 if not isdkim (krec ):
5250 continue
51+ if not os .path .exists (ofd ):
52+ os .makedirs (ofd , exist_ok = True )
5353 if keycount > 0 :
5454 ofn = f"{ ofd } /{ host } __{ keycount } "
5555 pathlib .Path (ofn ).write_bytes (krec + b"\n " )
You can’t perform that action at this time.
0 commit comments