@@ -49,17 +49,17 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) # noqa: DUO
49
49
50
50
51
51
def DEFAULT (f ):
52
- setattr ( f , " _is_default_test" , True )
52
+ f . _is_default_test = True
53
53
return f
54
54
55
55
56
56
def INFO (f ):
57
- setattr ( f , " _is_info_test" , True )
57
+ f . _is_info_test = True
58
58
return f
59
59
60
60
61
61
def HOSTNAME (f ):
62
- setattr ( f , " _is_hostname_test" , True )
62
+ f . _is_hostname_test = True
63
63
return f
64
64
65
65
@@ -78,11 +78,10 @@ def pout(cause, url, misc="", noisymsg=False):
78
78
duplicate_preventer .append (dup_check )
79
79
if args .json :
80
80
json_out .append ({"cause" : cause , "url" : url , "misc" : misc })
81
+ elif misc :
82
+ print (f"[{ cause } ] { url } { misc } " )
81
83
else :
82
- if misc :
83
- print (f"[{ cause } ] { url } { misc } " )
84
- else :
85
- print (f"[{ cause } ] { url } " )
84
+ print (f"[{ cause } ] { url } " )
86
85
87
86
88
87
def randstring ():
@@ -100,8 +99,7 @@ def fetcher(fullurl, binary=False, getredir=False, geterrpage=False):
100
99
r = pool .request ("GET" , fullurl , retries = False , redirect = False )
101
100
if getredir :
102
101
headers = {k .lower (): v for k , v in r .headers .items ()}
103
- if "location" in headers :
104
- redir = headers ["location" ]
102
+ redir = headers .get ("location" , "" )
105
103
elif (r .status != 200 and not geterrpage ):
106
104
data = ""
107
105
elif binary :
@@ -192,10 +190,7 @@ def getmainpage(url):
192
190
else :
193
191
data = ""
194
192
headers = {k .lower (): v for k , v in r .headers .items ()}
195
- if "location" in headers :
196
- redir = headers ["location" ]
197
- else :
198
- redir = ""
193
+ redir = headers .get ("location" , "" )
199
194
except (urllib3 .exceptions .HTTPError , UnicodeError ,
200
195
ConnectionRefusedError ):
201
196
mainpage_cache [url ] = {}
@@ -813,8 +808,8 @@ def test_axfr(qhost):
813
808
ConnectionResetError , ConnectionRefusedError ,
814
809
EOFError , socket .gaierror , TimeoutError , OSError ):
815
810
return
816
- for r in ns .rrset :
817
- r = str (r )
811
+ for rr in ns .rrset :
812
+ r = str (rr )
818
813
ipv4 = []
819
814
ipv6 = []
820
815
try :
@@ -1039,7 +1034,7 @@ if not args.nowww:
1039
1034
hosts .append ("www." + h )
1040
1035
1041
1036
for i , h in enumerate (hosts ):
1042
- if h .startswith ("http://" ) or h . startswith ( "https://" ):
1037
+ if h .startswith (( "http://" , "https://" ) ):
1043
1038
print ("ERROR: Please run snallygaster with a hostname, not a URL." )
1044
1039
sys .exit (1 )
1045
1040
try :
0 commit comments