Update pruebaRed.sh
This commit is contained in:
parent
1d62cd3a86
commit
1cc828ec3d
@ -10,8 +10,7 @@ COLOR_RESET='\e[0m'
|
||||
# Control de salida con Ctrl + C
|
||||
function ctrl_c() {
|
||||
echo -e "${COLOR_RED}\n\n[!] Saliendo... \n${COLOR_RESET}"
|
||||
tput cnorm
|
||||
exit 1
|
||||
tput cnorm; exit 1
|
||||
}
|
||||
|
||||
# Ctrl+C
|
||||
@ -24,11 +23,11 @@ function print_title {
|
||||
local total_length=22
|
||||
|
||||
# Calcular el tamaño del margen izquierdo y derecho
|
||||
local margin_length=$(((total_length - title_length - 4) / 2))
|
||||
local margin_length=$(( (total_length - title_length - 4) / 2 ))
|
||||
|
||||
# Asegurarse de que el número total de almohadillas sea siempre 22
|
||||
local left_padding=$((margin_length))
|
||||
local right_padding=$((margin_length + (title_length % 2)))
|
||||
local left_padding=$(( margin_length ))
|
||||
local right_padding=$(( margin_length + (title_length % 2) ))
|
||||
|
||||
echo -e "${COLOR_BLUE}\n$(printf '#%.0s' $(seq 1 $left_padding))#### $title ####$(printf '#%.0s' $(seq 1 $right_padding))\n${COLOR_RESET}"
|
||||
}
|
||||
@ -64,10 +63,7 @@ print_network_table() {
|
||||
# Comprobación de dependencias
|
||||
check_dependencies() {
|
||||
for cmd in "jq" "nordvpn" "speedtest"; do
|
||||
command -v "$cmd" >/dev/null 2>&1 || {
|
||||
echo >&2 "${COLOR_RED}$cmd no está instalado. Instálalo con 'sudo apt-get install $cmd'${COLOR_RESET}"
|
||||
exit 1
|
||||
}
|
||||
command -v "$cmd" >/dev/null 2>&1 || { echo >&2 "${COLOR_RED}$cmd no está instalado. Instálalo con 'sudo apt-get install $cmd'${COLOR_RESET}"; exit 1; }
|
||||
done
|
||||
}
|
||||
|
||||
@ -83,7 +79,7 @@ network_info=()
|
||||
# Comprobar conexión
|
||||
check_connection() {
|
||||
print_title "COMPROBAR CONEXIÓN"
|
||||
if ping -c 1 -W 2 8.8.8.8 >/dev/null 2>&1; then
|
||||
if ping -c 1 -W 2 8.8.8.8 > /dev/null 2>&1; then
|
||||
echo -e "\t${COLOR_GREEN}Conexión exitosa con 8.8.8.8${COLOR_RESET}"
|
||||
else
|
||||
echo -e "\t${COLOR_RED}Error de conexión con 8.8.8.8${COLOR_RESET}"
|
||||
@ -93,7 +89,7 @@ check_connection() {
|
||||
|
||||
# Probar la conexión con el router
|
||||
router_ip=$(get_router_ip "$default_interface")
|
||||
if ping -c 1 -W 2 "$router_ip" >/dev/null 2>&1; then
|
||||
if ping -c 1 -W 2 "$router_ip" > /dev/null 2>&1; then
|
||||
echo -e "\t${COLOR_GREEN}Conexión exitosa con el router ($router_ip)${COLOR_RESET}"
|
||||
else
|
||||
echo -e "\t${COLOR_RED}Error de conexión con el router ($router_ip)${COLOR_RESET}"
|
||||
@ -127,6 +123,7 @@ check_websites() {
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# Obtener las interfaces de red
|
||||
get_interfaces() {
|
||||
print_title "TARJETAS DE RED"
|
||||
@ -140,7 +137,7 @@ get_interfaces() {
|
||||
# Obtener IP pública
|
||||
get_public_ip_info() {
|
||||
print_title "INFO IP WAN"
|
||||
curl -s https://ipinfo.io | jq -r 'to_entries[] | "\u001b[34m\(.key):\u001b[0m \u001b[32m\(.value)\u001b[0m"'
|
||||
curl -s https://ipinfo.io | jq -r 'to_entries[] | select(.key != "readme") | "\u001b[34m\(.key):\u001b[0m \u001b[32m\(.value)\u001b[0m"'
|
||||
}
|
||||
|
||||
# Estado de nordvpn
|
||||
@ -162,7 +159,7 @@ speed_test() {
|
||||
}
|
||||
|
||||
# Realizar traceroute
|
||||
traceroute() {
|
||||
traceroute(){
|
||||
print_title "TRACEROUTE"
|
||||
mtr -c 3 -n -r 8.8.8.8
|
||||
}
|
||||
@ -191,11 +188,7 @@ main_menu() {
|
||||
6) nordvpn_connect ;;
|
||||
7) speed_test ;;
|
||||
8) traceroute ;;
|
||||
9)
|
||||
echo -e "${COLOR_RED}\nSaliendo...\n${COLOR_RESET}"
|
||||
tput cnorm
|
||||
exit 0
|
||||
;;
|
||||
9) echo -e "${COLOR_RED}\nSaliendo...\n${COLOR_RESET}"; tput cnorm; exit 0 ;;
|
||||
*) echo -e "${COLOR_RED}\nOpción inválida. Inténtelo de nuevo.${COLOR_RESET}" ;;
|
||||
esac
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user