]> jfr.im git - irc/ircd-hybrid/bopm.git/commitdiff
bopchecker.h:
authorandy <redacted>
Sun, 27 Jan 2002 14:17:00 +0000 (14:17 +0000)
committerandy <redacted>
Sun, 27 Jan 2002 14:17:00 +0000 (14:17 +0000)
Added bitmasks for the types of proxy.  HTTP is 1, Wingate 2,
SOCKS4 is 4 and SOCKS5 8.

bopchecker.c:
Now returns a bitmask of the types of proxies found back to the
shell. THIS MEANS THAT VALUES > 1 MEAN A PROXY WAS FOUND AND 0
MEANS NO PROXY WAS FOUND, THIS IS THE EXACT OPPOSITE TO PRIOR
VERSIONS OF THIS PROGRAM!

bopchecker.c
bopchecker.h

index 2b0322c064a51d071e6ca9281dc70a89f98c57d5..20e03654274a6d033889684a58cb48ee9ec6b894 100644 (file)
@@ -43,6 +43,7 @@ extern struct scan_struct *CONNECTIONS;
 int OPT_DEBUG = 1;
 char *CONFNAME = DEFAULTNAME;
 char *CONFFILE;
+int RC = 0;
 
 int main(int argc, char **argv)
 {
@@ -70,7 +71,7 @@ int main(int argc, char **argv)
 
        if (argc - optind != 1) {
                usage(argv);
-               return(EXIT_FAILURE);
+               exit(0);
        }
 
        signal(SIGPIPE, SIG_IGN);
@@ -92,26 +93,26 @@ int main(int argc, char **argv)
                        case HOST_NOT_FOUND:
                                fprintf(stderr, "Host '%s' is unknown.\n",
                                        host);
-                               return(1);
+                               exit(0);
                        case NO_ADDRESS:
                                fprintf(stderr, "The specified name '%s' "
                                        "exists, but has no address.\n",
                                        host);
-                               return(1);
+                               exit(0);
                        case NO_RECOVERY:
                                fprintf(stderr, "An unrecoverable error "
                                        "occured whilst resolving '%s'.\n",
                                        host);
-                               return(1);
+                               exit(0);
                        case TRY_AGAIN:
                                fprintf(stderr, "A temporary error "
                                        "occurred on an authoritative name "
                                        "server.\n");
-                               return(1);
+                               exit(0);
                        default:
                                fprintf(stderr, "Unknown error resolving "
                                        "'%s'.\n", host);
-                               return(EXIT_FAILURE);
+                               exit(0);
                }
        }
 
@@ -124,18 +125,31 @@ int main(int argc, char **argv)
        do {
                int still_alive = 0;
                
-               scan_cycle();
                scan_timer();
+               scan_cycle();
 
                for (ss = CONNECTIONS; ss; ss = ss->next) {
-                       if (ss->protocol->stat_numopen)
-                               return(EXIT_SUCCESS);
+                       if (ss->protocol->stat_numopen) {
+                               if (strcasecmp("http", ss->protocol->type) == 0)
+                                       RC |= PROXY_HTTP;
+                               else if (strcasecmp("socks4", ss->protocol->type) == 0)
+                                       RC |= PROXY_SOCKS4;
+                               else if (strcasecmp("socks5", ss->protocol->type) == 0)
+                                       RC |= PROXY_SOCKS5;
+                               else if (strcasecmp("wingate", ss->protocol->type) == 0)
+                                       RC |= PROXY_WINGATE;
+                               else {
+                                       fprintf(stderr, "Unknown type %s!", ss->protocol->type);
+                               }
+                       }
+
                        if (ss->state != STATE_CLOSED)
                                still_alive++;
                }
 
-               if (!still_alive)
-                       return(EXIT_FAILURE);
+               if (!still_alive) {
+                       exit(RC);
+               }
        } while(1);
 }
 
index 5f5c56cfd1b057378708f8e2296bc4080b08e2d3..e60e45e16aa81e60cc3d87078bea1d71f909cf13 100644 (file)
@@ -1,6 +1,11 @@
 #ifndef BOPCHECKER_H
 #define BOPCHECKER_H
 
+#define PROXY_HTTP    0x1
+#define PROXY_WINGATE 0x2
+#define PROXY_SOCKS4  0x4
+#define PROXY_SOCKS5  0x8
+
 void usage(char **argv);
 void log(char *data,...);
 void irc_kline(char *addr, char *ip);