1
0
Fork 0
mirror of https://github.com/sileht/bird-lg.git synced 2024-11-22 06:54:43 +01:00

Force ip source in traceroute

This commit is contained in:
Mehdi Abaakouk 2012-02-07 15:38:23 +01:00
parent d29ccc9290
commit 713af83340
2 changed files with 12 additions and 3 deletions

View file

@ -1,2 +1,4 @@
ACCESS_LIST = ["91.224.149.206", "178.33.111.110"] ACCESS_LIST = ["91.224.149.206", "178.33.111.110"]
IPV4_SOURCE="91.224.148.1"
IPV6_SOURCE="2a01:6600:8000::1"

View file

@ -39,13 +39,20 @@ def check_accesslist():
def traceroute(): def traceroute():
check_accesslist() check_accesslist()
if request.path == '/traceroute6': o= "-6" if request.path == '/traceroute6':
else: o = "-4" o = "-6"
if app.config.get("IPV6_SOURCE",""):
src = [ "-s", app.config.get("IPV6_SOURCE") ]
else:
o = "-4"
if app.config.get("IPV4_SOURCE",""):
src = [ "-s", app.config.get("IPV4_SOURCE") ]
query = request.args.get("q","") query = request.args.get("q","")
query = unquote(query) query = unquote(query)
command = [ 'traceroute', o, '-A', '-q1', '-w1', query] command = [ 'traceroute' , o ] + src + [ '-A', '-q1', '-N32', '-w1', '-m15', query ]
result = subprocess.Popen( command , stdout=subprocess.PIPE).communicate()[0].decode('utf-8', 'ignore').replace("\n","<br>") result = subprocess.Popen( command , stdout=subprocess.PIPE).communicate()[0].decode('utf-8', 'ignore').replace("\n","<br>")
return result return result