Skip to content

Commit

Permalink
Merge pull request #13 from dimrozakis/ping
Browse files Browse the repository at this point in the history
Change ping parser implementation
  • Loading branch information
pchristos authored Oct 6, 2017
2 parents a011e81 + 8ee6868 commit 6e49a2e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 130 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
django
netaddr
ipython
ipython==5
https://github.com/ssteinerx/pingparser/archive/master.zip
2 changes: 1 addition & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ apt-get install -yq --no-install-recommends \
python python-pip openvpn uwsgi uwsgi-plugin-python

pip install -U pip
pip install -U django netaddr ipython
pip install -r $DIR/vpn-proxy/requirements.txt

echo "VPN_SERVER_REMOTE_ADDRESS = \"$VPN_IP\"" > $DIR/vpn-proxy/conf.d/0000-vpn-ip.py
SOURCE_CIDRS=`echo "$SOURCE_CIDRS" | sed 's/ /", "/g'`
Expand Down
127 changes: 0 additions & 127 deletions vpn-proxy/app/pingparser.py

This file was deleted.

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 6e49a2e

Please sign in to comment.