Skip to content

Commit

Permalink
Support num of pkts param in ping
Browse files Browse the repository at this point in the history
  • Loading branch information
dimrozakis committed Jul 16, 2017
1 parent 19d8503 commit 8ee6868
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion vpn-proxy/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,15 @@ def ping(request, tunnel_id, target):
hostname = tunnel.client
else:
hostname = target
cmd = ['ping', '-c', '10', '-i', '0.4', '-W', '1', '-q', '-I',
pkts = 10
if request.GET.get('pkts'):
try:
pkts = int(request.GET['pkts'])
except (ValueError, TypeError) as exc:
log.warning("Couldn't cast pkts param (%s) to int: %r",
request.GET['pkts'], exc)

cmd = ['ping', '-c', str(pkts), '-i', '0.4', '-W', '1', '-q', '-I',
str(tunnel.name), str(hostname)]
ping_output = subprocess.Popen(cmd, stdout=subprocess.PIPE)
ping_parsed = pingparser.parse(ping_output.stdout.read())
Expand Down

0 comments on commit 8ee6868

Please sign in to comment.