Changeset 159
- Timestamp:
- 04/03/10 23:57:32 (5 months ago)
- Location:
- trunk/misc
- Files:
-
- 4 added
- 1 modified
-
dns-o-matic.py (modified) (5 diffs)
-
icons (added)
-
icons/error.png (added)
-
icons/info.png (added)
-
icons/warning.png (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/misc/dns-o-matic.py
r158 r159 82 82 'status' : r.header['status'], 83 83 'subrecords' : [], 84 'problems' : [], 84 85 } 85 86 data.append(answer) … … 99 100 'status' : r.header['status'], 100 101 'subrecords' : [], 102 'problems' : [], 101 103 } 102 104 data.append(answer) … … 130 132 131 133 132 def FindValidLoops(data): 133 # do a depth-first search for request loops and mark these records as valid 134 num = 0 135 for result in data['results']: 136 new_num = FindValidLoops(result) 137 if new_num > num: 138 num = new_num 139 if not data['status']: 140 data['valid'] = True 141 return 2 142 else: 143 if num > 0: 144 data['valid'] = True 145 return num - 1 146 else: 147 data['valid'] = False 148 return 0 134 #def FindValidLoops(data): 135 # # do a depth-first search for request loops and mark these records as valid 136 # num = 0 137 # for result in data['results']: 138 # new_num = FindValidLoops(result) 139 # if new_num > num: 140 # num = new_num 141 # if not data['status']: 142 # data['valid'] = True 143 # return 2 144 # else: 145 # if num > 0: 146 # data['valid'] = True 147 # return num - 1 148 # else: 149 # data['valid'] = False 150 # return 0 151 152 153 def FindDanglingPointers(data): 154 for rec in data['subrecords']: 155 if rec['status'] == 'NXDOMAIN': 156 problem = { 157 'icon':'error', 158 'text':'Dangling pointer (PTR) record detected for %s!\n\n' % data['lookup_of'] + \ 159 'Perhaps it was left behind when the address (A) record for %s was deleted.' % data['resolves_to'], 160 } 161 rec['problems'].append(problem) 149 162 150 163 … … 176 189 sys.stderr.write("\n") 177 190 178 # iterate through all addresses for which we have results179 #for address in data['addresses']:180 # for ns_result in address['results']:181 # FindValidLoops(ns_result)191 # detect dangling pointers 192 for address in data['addresses']: 193 for result in address['results']: 194 FindDanglingPointers(result) 182 195 return data 183 196 … … 186 199 # display the record we're looking up 187 200 if data['resolves_to'] != '': 188 print " <p style='padding-left:%spx'><span class='record'>%s</span> resolves to : <span class='record'>%s</span></p>" % (`level * 20`, data['lookup_of'], data['resolves_to'])201 print " <p style='padding-left:%spx'><span class='record'>%s</span> resolves to <span class='record'>%s</span>" % (`level * 20`, data['lookup_of'], data['resolves_to']) 189 202 else: 190 print " <p style='padding-left:%spx'><span class='record'>%s</span> does not resolve to anything!</p>" % (`level * 20`, data['lookup_of']) 203 print " <p style='padding-left:%spx'><span class='record'>%s</span> does not resolve to anything!" % (`level * 20`, data['lookup_of']) 204 205 # display any problems associated with the record 206 for prob in data['problems']: 207 print " <img src='icons/%s.png' />" % prob['icon'] 208 print " </p>" 191 209 192 210 # recursively display subrecords