From 3aa5e6577c5af6c60926c8953576367197de8798 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Wed, 20 Dec 2023 03:40:28 -0300 Subject: [PATCH] I am dum --- anoyinginternetcheck.c | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 anoyinginternetcheck.c diff --git a/anoyinginternetcheck.c b/anoyinginternetcheck.c new file mode 100644 index 0000000..fdb674f --- /dev/null +++ b/anoyinginternetcheck.c @@ -0,0 +1,44 @@ +#include +#include +#include +#include + +#define RED "\x1b[31m" +#define GREEN "\x1b[32m" +#define YELLOW "\x1b[33m" +#define BLUE "\x1b[34m" +#define MAGENTA "\x1b[35m" +#define CYAN "\x1b[36m" +#define RESET "\x1b[0m" + +int main(int argc, char **argv) { + if (argc < 3) { + printf("Usage: %s [ip1] [ip2]\n", argv[0]); + exit(EXIT_FAILURE); + } + int i=0; + static char command[128] = "ping -c 1 "; + static char command2[128] = "ping -c 1 "; + setbuf(stdout, NULL); + strcat(command, argv[1]); + strcat(command2, argv[2]); + strcat(command, "> /dev/null"); + strcat(command2, "> /dev/null"); + while (1) { + int res = system(command); + sleep(1); + if (res != 0) { + printf(RED "No connection to %s, trying other host\n" RESET, argv[1]); + res = system(command2); + } if (res != 0) { + printf(RED "\nNo connection to %s either, beeping your shit\n" RESET, argv[2]); + while (i<20) { system("beep -f 2500 -l 200 -n -f 4000 -l 200"); i++; } i=0; + printf(MAGENTA "Checking again in 15 seconds\n" RESET); + sleep(15); + } else { + printf(GREEN "You have internet :), checking again in 1 minute\n" RESET); + sleep(60); + } + } + exit(EXIT_SUCCESS); +}