forked from NEU-SNS/revtrvp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_reverse_traceroute.py
54 lines (41 loc) · 1.36 KB
/
test_reverse_traceroute.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
51
52
from typing import Reversible
import requests
import sys
import argparse
import time
def run_revtr_to_source(source):
'''
curl -XPOST -k -H "Revtr-Key:dummy" https://revtr.ccs.neu.edu/api/v1/revtr --data '{"revtrs":[{"src":"216.66.68.179", "dst":"ple2.planet-lab.eu"}]}'
'''
revtr_key = "dummy"
while True:
resp = requests.post(
f"https://revtr.ccs.neu.edu/api/v1/revtr",
headers={"Revtr-Key":"dummy"},
json={
"revtrs": [
{
"src": source,
"dst": "1.1.1.1",
}
],
},
)
if resp.status_code == 200:
print(resp.json())
break
else:
print(resp.text)
time.sleep(30)
if __name__ == "__main__":
######################################################################
## Parameters
######################################################################
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--source", help="source to which run reverse traceroutes, format X.X.X.X", type=str)
args = parser.parse_args()
if not args.source:
print(parser.error("source is mandatory"))
exit(1)
source = args.source
run_revtr_to_source(source)