Improving checkInternet to support proxies

This commit is contained in:
Alex Epstein 2017-07-14 13:29:47 -04:00
parent 4b0c2da14c
commit 29ab12cd0e
12 changed files with 22 additions and 94 deletions

View File

@ -38,13 +38,7 @@ httpGet()
checkInternet()
{
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
return 0
else
echo "Error: no active internet connection" >&2 #sent to stderr
return 1
fi
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
}
update()

View File

@ -26,13 +26,7 @@ getConfiguredClient()
checkInternet()
{
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
return 0
else
echo "Error: no active internet connection" >&2 #sent to stderr
return 1
fi
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
}
## Allows to call the users configured client without if statements everywhere

View File

@ -129,13 +129,7 @@ checkAmount()
checkInternet()
{
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1
if [ $? -eq 0 ]; then
return 0
else
echo "Error: no active internet connection" >&2
return 1
fi
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
}
## Grabs the exchange rate and does the math for converting the currency

View File

@ -38,13 +38,7 @@ httpGet()
checkInternet()
{
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
return 0
else
echo "Error: no active internet connection" >&2 #sent to stderr
return 1
fi
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
}
update()

View File

@ -177,13 +177,7 @@ update()
checkInternet()
{
echo "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
return 0
else
echo "Error: no active internet connection" >&2 #sent to stderr
return 1
fi
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
}

View File

@ -55,13 +55,7 @@ httpGet()
checkInternet()
{
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
return 0
else
echo "Error: no active internet connection" >&2 #sent to stderr
return 1
fi
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
}
## This function grabs information about a movie and using python parses the

View File

@ -84,13 +84,7 @@ makeMultiLineQr()
checkInternet()
{
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1
if [ $? -eq 0 ]; then
return 0
else
echo "Error: no active internet connect" >&2
return 1
fi
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
}
usage()

View File

@ -55,13 +55,7 @@ httpGet()
checkInternet()
{
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
return 0
else
echo "Error: no active internet connection" >&2 #sent to stderr
return 1
fi
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
}
update()

View File

@ -8,16 +8,16 @@ configuredPython=""
## This function determines which http get tool the system has installed and returns an error if there isnt one
getConfiguredClient()
{
if command -v curl &>/dev/null ; then
configuredClient="curl"
elif command -v wget &>/dev/null ; then
configuredClient="wget"
elif command -v fetch &>/dev/null ; then
configuredClient="fetch"
else
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
return 1
fi
if command -v curl &>/dev/null ; then
configuredClient="curl"
elif command -v wget &>/dev/null ; then
configuredClient="wget"
elif command -v fetch &>/dev/null ; then
configuredClient="fetch"
else
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
return 1
fi
}
@ -54,13 +54,7 @@ httpGet()
checkInternet()
{
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
return 0
else
echo "Error: no active internet connection" >&2 #sent to stderr
return 1
fi
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
}
## This function grabs information about a stock and using python parses the

View File

@ -58,13 +58,7 @@ httpGet()
checkInternet()
{
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
return 0
else
echo "Error: no active internet connection" >&2 #sent to stderr
return 1
fi
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
}
update()

View File

@ -55,13 +55,7 @@ getLocationWeather()
checkInternet()
{
echo "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
return 0
else
echo "Error: no active internet connection" >&2 #sent to stderr
return 1
fi
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
}
update()

View File

@ -26,13 +26,7 @@ getConfiguredClient()
checkInternet()
{
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
return 0
else
echo "Error: no active internet connection" >&2 #sent to stderr
return 1
fi
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
}
## Allows to call the users configured client without if statements everywhere