• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisão0586dd40f30634e2257715925dff928f5a0d3963 (tree)
Hora2017-08-25 04:29:39
AutorLorenzo Isella <lorenzo.isella@gmai...>
CommiterLorenzo Isella

Mensagem de Log

A bash script to determine what is the best nordvpn server.

Mudança Sumário

Diff

diff -r 3a4ec496b4d2 -r 0586dd40f306 Bash-scripts/nordping.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Bash-scripts/nordping.sh Thu Aug 24 21:29:39 2017 +0200
@@ -0,0 +1,133 @@
1+#!/bin/bash
2+
3+# **************************************************************************
4+# * (C)opyright 2017 by Ruben Carlo Benante *
5+# * *
6+# * This program is free software; you can redistribute it and/or modify *
7+# * it under the terms of the GNU General Public License as published by *
8+# * the Free Software Foundation version 2 of the License. *
9+# * *
10+# * This program is distributed in the hope that it will be useful, *
11+# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13+# * GNU General Public License for more details. *
14+# * *
15+# * You should have received a copy of the GNU General Public License *
16+# * along with this program; if not, write to the *
17+# * Free Software Foundation, Inc., *
18+# * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19+# * *
20+# * Contact author at: *
21+# * Ruben Carlo Benante *
22+# * rcb@beco.cc *
23+# **************************************************************************
24+
25+# The help function
26+Help()
27+{
28+ cat << EOF
29+ nordping - Ping a bunch of NordVPN servers to test the fastest
30+ Usage: ${1} [-v] ( [-h|-V] | [-p TCP|UDP ] )
31+
32+ Options:
33+ -h, --help Show this help.
34+ -V, --version Show version.
35+ -v, --verbose Turn verbose mode on (cumulative).
36+ -p, --protocol Set the protocol to ping: TCP (default) or UDP
37+ -d, --directory Sets the directory where to find all *.ovpn files
38+ Exit status:
39+ 0, if ok.
40+ 1, some error occurred.
41+
42+ Todo:
43+ Long options not implemented yet.
44+
45+ Author:
46+ Written by Ruben Carlo Benante <rcb@beco.cc>
47+ 2017-02-18
48+EOF
49+ exit 1
50+}
51+
52+# The copyright function
53+Copyr()
54+{
55+ echo 'nordping - 20170218.210221'
56+ echo
57+ echo 'Copyright (C) 2017 Ruben Carlo Benante <rcb@beco.cc>, GNU GPL version 2'
58+ echo '<http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and'
59+ echo 'redistribute it. There is NO WARRANTY, to the extent permitted by law. USE IT AS IT IS. The author'
60+ echo 'takes no responsability to any damage this software may inflige in your data.'
61+ echo
62+ exit 1
63+}
64+
65+# The main function
66+main()
67+{
68+ verbose=0
69+ DIR="."
70+ #getopt example with switch/case
71+ while getopts "hVvp:d:" FLAG; do
72+ case $FLAG in
73+ h)
74+ Help
75+ ;;
76+ V)
77+ Copyr
78+ ;;
79+ v)
80+ let verbose=verbose+1
81+ ;;
82+ p)
83+ QNPROTO=$OPTARG
84+ ;;
85+ d)
86+ DIR=$OPTARG
87+ ;;
88+ *)
89+ Help
90+ ;;
91+ esac
92+ done
93+
94+ echo Starting nordping.sh script, by beco, version 20170804.014727...
95+ echo Verbose level: $verbose
96+ date
97+
98+ if [ "$QNPROTO" == "UDP" ]; then
99+ QPROTO="1194"
100+ else
101+ QPROTO="443"
102+ fi
103+
104+ if [ "$verbose" -gt "0" ]; then
105+ echo "Protocol: $QPROTO"
106+ fi
107+
108+ for F in "$DIR"/*.ovpn ; do
109+ [ ! -e $F ] && echo 'Please give a path with ovpn files' && break
110+ LIN=`grep "remote " $F`
111+ PROTO=`echo $LIN | cut -d' ' -f3`
112+ if [ "$PROTO" != "$QPROTO" ]; then
113+ continue
114+ fi
115+ IP=`echo $LIN | cut -d' ' -f2`
116+ DL=`ping -c3 -q $IP | tail -n2`
117+ if grep "100% packet loss" <(echo $DL) > /dev/null ; then
118+ echo -e "$F \t $IP \t 3000.333 \t error"
119+ else
120+ TI=`echo $DL | cut -d'/' -f5`
121+ echo -e "$F \t $IP \t $TI"
122+ fi
123+ done
124+}
125+
126+#Calling main with all args
127+main $*
128+exit 0
129+
130+#/* -------------------------------------------------------------------------- */
131+#/* vi: set ai et ts=4 sw=4 tw=0 wm=0 fo=croql : SHELL config for Vim modeline */
132+#/* Template by Dr. Beco <rcb at beco dot cc> Version 20160714.124739 */
133+