forked from USC-NSL/ripe-atlas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
atlas_dns.py
50 lines (38 loc) · 1.56 KB
/
atlas_dns.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python
import measure_baseclass
class DNS(MeasurementBase):
def __init__(self, query_class, query_type, query_arg, target, key, sess=None):
super(DNS, self).__init__(target, key, sess)
self.measurement_type = 'dns'
self.query_class = query_class
self.query_type = query_type
self.query_arg = query_arg
def setup_definitions(self):
definitions = super(DNS, self).setup_definitions()
definitions['query_class'] = self.query_class
definitions['query_type'] = self.query_type
definitions['query_argument'] = self.query_arg
def config_argparser()
parser = measure_baseclass.config_argparser('Issue DNS measurements to RIPE Atlas')
parser.
return parser
if __name__ == '__main__':
parser = config_argparser()
args = parser.parse_args()
try:
key_file = args.key_file[0]
key = readkey(key_file) #read in Atlas API key
except:
sys.stderr.write('Error reading key file at '+key_file)
sys.exit(1)
args.probe_file
if hasattr(args, 'target_'): #run single target command
data = handle_single_target(args)
response = run(key, data)
response_output = format_response(response)
print(response_output)
else: #run multiple target command
target_file = args.target_list_file[0]
output_file = args.output_file[0]
target_dict = load_input(target_file)
handle_multi_targets(key, args, target_dict, output_file)