connect to the IRC server immediately. Any errors and debug information can be
found in bopm.log.
+ You can tell bopm to use a different config file with the -c argument,
+this works the same way that wgmon's -c argument does, just give the name of
+the config file not including the ".conf". This also affects the log and PID
+files i.e. ./bopm -c myserver will read from myserver.conf, log to myserver.log
+and write PID to myserver.pid. If you do not use -c, the files bopm.conf,
+bopm.log and bopm.pid will be used by default. This can be altered in
+options.h.
+
Further debugging can be enabled by using one or more -d switches. One or
more -d switches will cause the bot to not fork on startup, and it will send
all log messages to stederr (i.e., your terminal) instead of its logfile. It
will also cause extra debugging information that is not normally of interest to
be sent to stderr. Two or more -d switches will enable logging of all IRC
traffic received and sent.
+
+ The -c and -d arguments may appear in any order.
-------
Erik Fears <strtok@blitzed.org>
- Main Developer.
+ - Main Developer.
Andy Smith <grifferz@blitzed.org>
- Developed operator interface, interface to DNSbl, makefile
- trickery, poking people with sticks until they did things,
- debugging.
+ - Developed operator interface
+ - Interface to DNSbl
+ - Makefile trickery
+ - Poking people with sticks until they did things
+ - Debugging
+ - Evil bopchecker hack
David Leadbeater <dg@blitzed.org>
- Developed perl script (see proxy-tools in Blitzed CVS repository)
- to test BOPM's support for scanning many clients at once.
+ - Developed perl script (see proxy-tools in Blitzed CVS repository) to
+ test BOPM's support for scanning many clients at once
+ Sotiris Tsimbonis <stsimb@irc.gr>
+ - Added -c command line argument
+ - Idea to make bopm set umode -h on oper
For support, irc.blitzed.org #blitzed before emailing a developer. Thank you.
extern struct scan_struct *CONNECTIONS;
int OPT_DEBUG = 1;
+char *CONFNAME = DEFAULTNAME;
+char *CONFFILE;
int main(int argc, char **argv)
{
struct hostent *he;
- char *ip;
+ char *ip, *host;
struct scan_struct *ss;
-
- if (argc != 2) {
+ int len, c;
+
+ while (1) {
+ c = getopt(argc, argv, "+c:");
+
+ if (c == -1)
+ break;
+
+ switch (c) {
+ case 'c':
+ CONFNAME = strdup(optarg);
+ break;
+ case '?':
+ default:
+ /* unknown arg, just do nothing */
+ break;
+ }
+ }
+
+ if (argc - optind != 1) {
usage(argv);
return(EXIT_FAILURE);
}
signal(SIGPIPE, SIG_IGN);
- config_load(LOGFILE);
+ len = strlen(CONFNAME) + strlen(CONFEXT) + 2;
+ CONFFILE = (char *) malloc(len * sizeof(char));
+ snprintf(CONFFILE, len, "%s.%s", CONFNAME, CONFEXT);
+
+ config_load(CONFFILE);
do_scan_init();
- if(!(he = gethostbyname(argv[1]))) {
+ if (optind > 0)
+ host = argv[optind];
+ else
+ host = argv[1];
+
+ if(!(he = gethostbyname(host))) {
switch(h_errno) {
case HOST_NOT_FOUND:
- fprintf(stderr, "Host '%s' is unknown.",
- argv[1]);
+ fprintf(stderr, "Host '%s' is unknown.\n",
+ host);
return(1);
case NO_ADDRESS:
fprintf(stderr, "The specified name '%s' "
- "exists, but has no address.",
- argv[1]);
+ "exists, but has no address.\n",
+ host);
return(1);
case NO_RECOVERY:
fprintf(stderr, "An unrecoverable error "
- "occured whilst resolving '%s'.",
- argv[1]);
+ "occured whilst resolving '%s'.\n",
+ host);
return(1);
case TRY_AGAIN:
fprintf(stderr, "A temporary error "
"occurred on an authoritative name "
- "server.");
+ "server.\n");
return(1);
default:
fprintf(stderr, "Unknown error resolving "
- "'%s'.", argv[1]);
+ "'%s'.\n", host);
return(EXIT_FAILURE);
}
}
ip = inet_ntoa(*((struct in_addr *) he->h_addr));
- fprintf(stderr, "Checking %s [%s] for open proxies\n", argv[1], ip);
+ fprintf(stderr, "Checking %s [%s] for open proxies\n", host, ip);
- scan_connect(ip, argv[1], "*", "*", 1, 0); /* Scan using verbose */
+ scan_connect(ip, host, "*", "*", 1, 0); /* Scan using verbose */
do {
int still_alive = 0;
void usage(char **argv)
{
- fprintf(stderr, "Usage: %s <host>\n", argv[0]);
+ fprintf(stderr, "Usage: %s [-c configname] <host>\n", argv[0]);
}
void log(char *data,...)
extern int CONF_PORT;
extern int CONF_SCANPORT;
+ extern int CONF_PING;
extern int OPT_DEBUG;
#include "options.h"
#include "version.h"
+extern char *CONFFILE;
+
/* Certain variables we don't want to allocate memory for over and over again
* so global scope is given */
if(IRC_FD <= 0) /* No socket open */
{
- config_load(LOGFILE); /* Reload config */
+ config_load(CONFFILE); /* Reload config */
irc_init(); /* Resolve remote host */
irc_connect(); /* Connect to remote host */
}
if(!strcasecmp(token[1], "001"))
{
irc_send("OPER %s", CONF_OPER);
- irc_send("MODE %s +c", CONF_NICK);
+ irc_send("MODE %s +c-h", CONF_NICK);
if(CONF_AWAY)
irc_send("AWAY :%s (/msg %s INFO)", CONF_AWAY, CONF_NICK);
do_perform();
int ALARMED = 0;
int OPT_DEBUG = 0;
+char *CONFNAME = DEFAULTNAME;
+
+char *CONFFILE, *LOGFILE, *PIDFILE;
struct sigaction ALARMACTION;
struct sigaction INTACTION;
{
FILE *pidout;
- int pid, c;
+ int pid, c, lenc, lenl, lenp;
char spid[16];
do_stats_init();
do_scan_init();
+
while(1)
{
- c = getopt(argc, argv, "d");
+ c = getopt(argc, argv, "dc:");
if(c == -1)
break;
switch(c)
{
+ case 'c':
+ CONFNAME = strdup(optarg);
+ break;
case 'd':
OPT_DEBUG++;
break;
}
}
+ lenc = strlen(CONFNAME) + strlen(CONFEXT) + 2;
+ lenl = strlen(CONFNAME) + strlen(LOGEXT) + 2;
+ lenp = strlen(CONFNAME) + strlen(PIDEXT) + 2;
+
+ CONFFILE = (char *) malloc(lenc * sizeof(char));
+ LOGFILE = (char *) malloc(lenl * sizeof(char));
+ PIDFILE = (char *) malloc(lenp * sizeof(char));
+
+ snprintf(CONFFILE, lenc, "%s.%s", CONFNAME, CONFEXT);
+ snprintf(LOGFILE, lenl, "%s.%s", CONFNAME, LOGEXT);
+ snprintf(PIDFILE, lenp, "%s.%s", CONFNAME, PIDEXT);
+
/* Fork off */
if(!OPT_DEBUG)
}
else if(pid != 0)
{
- pidout = fopen("bopm.pid", "w");
+ pidout = fopen(PIDFILE, "w");
snprintf(spid, 16, "%d", pid);
if(pidout)
close(STDOUT_FILENO);
close(STDERR_FILENO);
- log_open("bopm.log");
+ log_open(LOGFILE);
}
else
{
log("MAIN -> BOPM %s started.", VERSION);
log("MAIN -> Reading configuration file...");
- config_load(LOGFILE);
+ config_load(CONFFILE);
/* Setup alarm & int handlers */
#ifndef OPTIONS_H
#define OPTIONS_H
- #define LOGFILE "bopm.conf"
- /* Defines time in which bot will timeout
- * if no data is received (default 15 min) */
- #define NODATA_TIMEOUT 900
+/* The default name for conf, log, pid files */
+#define DEFAULTNAME "bopm"
+
+/* file extensions */
+/* config */
+#define CONFEXT "conf"
+/* log file */
+#define LOGEXT "log"
+/* PID file */
+#define PIDEXT "pid"
+
+/* Defines time in which bot will timeout * if no data is received
+ * (default 15 min) */
+#define NODATA_TIMEOUT 900
#endif