|
@@ -28,21 +28,23 @@
|
|
|
#include "src/mod/notes.mod/notes.h"
|
|
#include "src/mod/notes.mod/notes.h"
|
|
|
#include <stdarg.h>
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
-static struct portmap *root = NULL;
|
|
|
|
|
|
|
+static struct portmap *root = NULL;
|
|
|
|
|
|
|
|
-time_t connect_timeout = 40; /* How long to wait before a telnet connection times out */
|
|
|
|
|
-int max_dcc = 200;
|
|
|
|
|
|
|
+time_t connect_timeout = 40; /* How long to wait before a telnet connection times out */
|
|
|
|
|
+int max_dcc = 200;
|
|
|
|
|
|
|
|
-static int dcc_flood_thr = 3;
|
|
|
|
|
|
|
+static int dcc_flood_thr = 3;
|
|
|
|
|
|
|
|
-void init_dcc_max()
|
|
|
|
|
|
|
+void
|
|
|
|
|
+init_dcc_max()
|
|
|
{
|
|
{
|
|
|
int osock = MAXSOCKS;
|
|
int osock = MAXSOCKS;
|
|
|
|
|
+
|
|
|
if (max_dcc < 1)
|
|
if (max_dcc < 1)
|
|
|
max_dcc = 1;
|
|
max_dcc = 1;
|
|
|
if (dcc)
|
|
if (dcc)
|
|
|
dcc = (struct dcc_t *) realloc(dcc, sizeof(struct dcc_t) * max_dcc);
|
|
dcc = (struct dcc_t *) realloc(dcc, sizeof(struct dcc_t) * max_dcc);
|
|
|
- else
|
|
|
|
|
|
|
+ else
|
|
|
dcc = (struct dcc_t *) calloc(1, sizeof(struct dcc_t) * max_dcc);
|
|
dcc = (struct dcc_t *) calloc(1, sizeof(struct dcc_t) * max_dcc);
|
|
|
|
|
|
|
|
MAXSOCKS = max_dcc + 10;
|
|
MAXSOCKS = max_dcc + 10;
|
|
@@ -57,7 +59,8 @@ void init_dcc_max()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* Replace \n with \r\n */
|
|
/* Replace \n with \r\n */
|
|
|
-char *add_cr(char *buf)
|
|
|
|
|
|
|
+char *
|
|
|
|
|
+add_cr(char *buf)
|
|
|
{
|
|
{
|
|
|
static char WBUF[1024] = "";
|
|
static char WBUF[1024] = "";
|
|
|
char *p = NULL, *q = NULL;
|
|
char *p = NULL, *q = NULL;
|
|
@@ -71,86 +74,88 @@ char *add_cr(char *buf)
|
|
|
return WBUF;
|
|
return WBUF;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static void colorbuf(char *buf, size_t len, int idx)
|
|
|
|
|
|
|
+static void
|
|
|
|
|
+colorbuf(char *buf, size_t len, int idx)
|
|
|
{
|
|
{
|
|
|
// char *buf = *bufp;
|
|
// char *buf = *bufp;
|
|
|
int cidx = coloridx(idx);
|
|
int cidx = coloridx(idx);
|
|
|
- static int cflags;
|
|
|
|
|
- int schar = 0;
|
|
|
|
|
- char buf3[1024] = "", buf2[1024] = "", c = 0;
|
|
|
|
|
-
|
|
|
|
|
- for (size_t i = 0 ; i < len ; i++) {
|
|
|
|
|
- c = buf[i];
|
|
|
|
|
- buf2[0] = 0;
|
|
|
|
|
-
|
|
|
|
|
- if (schar) { /* These are for $X replacements */
|
|
|
|
|
- schar--; /* Unset identifier int */
|
|
|
|
|
-
|
|
|
|
|
- if (cidx) {
|
|
|
|
|
- switch (c) {
|
|
|
|
|
- case 'b':
|
|
|
|
|
- if (cflags & CFLGS_BOLD) {
|
|
|
|
|
- sprintf(buf2, "%s", BOLD_END(idx));
|
|
|
|
|
- cflags &= ~CFLGS_BOLD;
|
|
|
|
|
- } else {
|
|
|
|
|
- cflags |= CFLGS_BOLD;
|
|
|
|
|
- sprintf(buf2, "%s", BOLD(idx));
|
|
|
|
|
- }
|
|
|
|
|
- break;
|
|
|
|
|
- case 'u':
|
|
|
|
|
- if (cflags & CFLGS_UNDERLINE) {
|
|
|
|
|
- sprintf(buf2, "%s", UNDERLINE_END(idx));
|
|
|
|
|
- cflags &= ~CFLGS_UNDERLINE;
|
|
|
|
|
- } else {
|
|
|
|
|
- sprintf(buf2, "%s", UNDERLINE(idx));
|
|
|
|
|
- cflags |= CFLGS_UNDERLINE;
|
|
|
|
|
- }
|
|
|
|
|
- break;
|
|
|
|
|
- case 'f':
|
|
|
|
|
- if (cflags & CFLGS_FLASH) {
|
|
|
|
|
- sprintf(buf2, "%s", FLASH_END(idx));
|
|
|
|
|
- cflags &= ~CFLGS_FLASH;
|
|
|
|
|
- } else {
|
|
|
|
|
- sprintf(buf2, "%s", FLASH(idx));
|
|
|
|
|
- cflags |= CFLGS_FLASH;
|
|
|
|
|
- }
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- sprintf(buf2, "$%c", c); /* No identifier, put the '$' back in */
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- } else { /* These are character replacements */
|
|
|
|
|
- switch (c) {
|
|
|
|
|
- case '$':
|
|
|
|
|
- schar++;
|
|
|
|
|
- break;
|
|
|
|
|
- case ':':
|
|
|
|
|
- sprintf(buf2, "%s%c%s", LIGHTGREY(idx), c, COLOR_END(idx));
|
|
|
|
|
- break;
|
|
|
|
|
- case '@':
|
|
|
|
|
- sprintf(buf2, "%s%c%s", BOLD(idx), c, BOLD_END(idx));
|
|
|
|
|
- break;
|
|
|
|
|
- case '>':
|
|
|
|
|
- case ')':
|
|
|
|
|
- case '<':
|
|
|
|
|
- case '(':
|
|
|
|
|
- sprintf(buf2, "%s%c%s", GREEN(idx), c, COLOR_END(idx));
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- sprintf(buf2, "%c", c);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ static int cflags;
|
|
|
|
|
+ int schar = 0;
|
|
|
|
|
+ char buf3[1024] = "", buf2[1024] = "", c = 0;
|
|
|
|
|
+
|
|
|
|
|
+ for (size_t i = 0; i < len; i++) {
|
|
|
|
|
+ c = buf[i];
|
|
|
|
|
+ buf2[0] = 0;
|
|
|
|
|
+
|
|
|
|
|
+ if (schar) { /* These are for $X replacements */
|
|
|
|
|
+ schar--; /* Unset identifier int */
|
|
|
|
|
+
|
|
|
|
|
+ if (cidx) {
|
|
|
|
|
+ switch (c) {
|
|
|
|
|
+ case 'b':
|
|
|
|
|
+ if (cflags & CFLGS_BOLD) {
|
|
|
|
|
+ sprintf(buf2, "%s", BOLD_END(idx));
|
|
|
|
|
+ cflags &= ~CFLGS_BOLD;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ cflags |= CFLGS_BOLD;
|
|
|
|
|
+ sprintf(buf2, "%s", BOLD(idx));
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'u':
|
|
|
|
|
+ if (cflags & CFLGS_UNDERLINE) {
|
|
|
|
|
+ sprintf(buf2, "%s", UNDERLINE_END(idx));
|
|
|
|
|
+ cflags &= ~CFLGS_UNDERLINE;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sprintf(buf2, "%s", UNDERLINE(idx));
|
|
|
|
|
+ cflags |= CFLGS_UNDERLINE;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'f':
|
|
|
|
|
+ if (cflags & CFLGS_FLASH) {
|
|
|
|
|
+ sprintf(buf2, "%s", FLASH_END(idx));
|
|
|
|
|
+ cflags &= ~CFLGS_FLASH;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sprintf(buf2, "%s", FLASH(idx));
|
|
|
|
|
+ cflags |= CFLGS_FLASH;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ sprintf(buf2, "$%c", c); /* No identifier, put the '$' back in */
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- sprintf(buf3, "%s%s", (buf3 && buf3[0]) ? buf3 : "", (buf2 && buf2[0]) ? buf2 : "");
|
|
|
|
|
|
|
+ } else { /* These are character replacements */
|
|
|
|
|
+ switch (c) {
|
|
|
|
|
+ case '$':
|
|
|
|
|
+ schar++;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case ':':
|
|
|
|
|
+ sprintf(buf2, "%s%c%s", LIGHTGREY(idx), c, COLOR_END(idx));
|
|
|
|
|
+ break;
|
|
|
|
|
+ case '@':
|
|
|
|
|
+ sprintf(buf2, "%s%c%s", BOLD(idx), c, BOLD_END(idx));
|
|
|
|
|
+ break;
|
|
|
|
|
+ case '>':
|
|
|
|
|
+ case ')':
|
|
|
|
|
+ case '<':
|
|
|
|
|
+ case '(':
|
|
|
|
|
+ sprintf(buf2, "%s%c%s", GREEN(idx), c, COLOR_END(idx));
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ sprintf(buf2, "%c", c);
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
- buf3[strlen(buf3)] = 0;
|
|
|
|
|
- strcpy(buf, buf3);
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ sprintf(buf3, "%s%s", (buf3 && buf3[0]) ? buf3 : "", (buf2 && buf2[0]) ? buf2 : "");
|
|
|
|
|
+ }
|
|
|
|
|
+ buf3[strlen(buf3)] = 0;
|
|
|
|
|
+ strcpy(buf, buf3);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void dprintf(int idx, const char *format, ...)
|
|
|
|
|
|
|
+void
|
|
|
|
|
+dprintf(int idx, const char *format, ...)
|
|
|
{
|
|
{
|
|
|
static char buf[1024] = "";
|
|
static char buf[1024] = "";
|
|
|
size_t len;
|
|
size_t len;
|
|
@@ -167,7 +172,7 @@ void dprintf(int idx, const char *format, ...)
|
|
|
*/
|
|
*/
|
|
|
/* We actually can, since if it's < 0 or >= sizeof(buf), we know it wrote
|
|
/* We actually can, since if it's < 0 or >= sizeof(buf), we know it wrote
|
|
|
* sizeof(buf) bytes. But we're not doing that anyway.
|
|
* sizeof(buf) bytes. But we're not doing that anyway.
|
|
|
- */
|
|
|
|
|
|
|
+ */
|
|
|
buf[sizeof(buf) - 1] = 0;
|
|
buf[sizeof(buf) - 1] = 0;
|
|
|
len = strlen(buf);
|
|
len = strlen(buf);
|
|
|
|
|
|
|
@@ -177,33 +182,33 @@ void dprintf(int idx, const char *format, ...)
|
|
|
tputs(-idx, buf, len);
|
|
tputs(-idx, buf, len);
|
|
|
} else if (idx > 0x7FF0) {
|
|
} else if (idx > 0x7FF0) {
|
|
|
switch (idx) {
|
|
switch (idx) {
|
|
|
- case DP_LOG:
|
|
|
|
|
- putlog(LOG_MISC, "*", "%s", buf);
|
|
|
|
|
- break;
|
|
|
|
|
- case DP_STDOUT:
|
|
|
|
|
- tputs(STDOUT, buf, len);
|
|
|
|
|
- break;
|
|
|
|
|
- case DP_STDERR:
|
|
|
|
|
- tputs(STDERR, buf, len);
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ case DP_LOG:
|
|
|
|
|
+ putlog(LOG_MISC, "*", "%s", buf);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case DP_STDOUT:
|
|
|
|
|
+ tputs(STDOUT, buf, len);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case DP_STDERR:
|
|
|
|
|
+ tputs(STDERR, buf, len);
|
|
|
|
|
+ break;
|
|
|
#ifdef LEAF
|
|
#ifdef LEAF
|
|
|
- case DP_SERVER:
|
|
|
|
|
- case DP_HELP:
|
|
|
|
|
- case DP_MODE:
|
|
|
|
|
- case DP_MODE_NEXT:
|
|
|
|
|
- case DP_SERVER_NEXT:
|
|
|
|
|
- case DP_HELP_NEXT:
|
|
|
|
|
- queue_server(idx, buf, len);
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ case DP_SERVER:
|
|
|
|
|
+ case DP_HELP:
|
|
|
|
|
+ case DP_MODE:
|
|
|
|
|
+ case DP_MODE_NEXT:
|
|
|
|
|
+ case DP_SERVER_NEXT:
|
|
|
|
|
+ case DP_HELP_NEXT:
|
|
|
|
|
+ queue_server(idx, buf, len);
|
|
|
|
|
+ break;
|
|
|
#endif /* LEAF */
|
|
#endif /* LEAF */
|
|
|
}
|
|
}
|
|
|
return;
|
|
return;
|
|
|
- } else { /* normal chat text */
|
|
|
|
|
|
|
+ } else { /* normal chat text */
|
|
|
colorbuf(buf, len, idx);
|
|
colorbuf(buf, len, idx);
|
|
|
buf[sizeof(buf) - 1] = 0;
|
|
buf[sizeof(buf) - 1] = 0;
|
|
|
len = strlen(buf);
|
|
len = strlen(buf);
|
|
|
|
|
|
|
|
- if (len > 1000) { /* Truncate to fit */
|
|
|
|
|
|
|
+ if (len > 1000) { /* Truncate to fit */
|
|
|
buf[1000] = 0;
|
|
buf[1000] = 0;
|
|
|
strcat(buf, "\n");
|
|
strcat(buf, "\n");
|
|
|
len = 1001;
|
|
len = 1001;
|
|
@@ -231,7 +236,8 @@ void dprintf(int idx, const char *format, ...)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void chatout(const char *format, ...)
|
|
|
|
|
|
|
+void
|
|
|
|
|
+chatout(const char *format, ...)
|
|
|
{
|
|
{
|
|
|
char s[1025] = "", *p = NULL;
|
|
char s[1025] = "", *p = NULL;
|
|
|
va_list va;
|
|
va_list va;
|
|
@@ -251,7 +257,8 @@ void chatout(const char *format, ...)
|
|
|
|
|
|
|
|
/* Print to all on this channel but one.
|
|
/* Print to all on this channel but one.
|
|
|
*/
|
|
*/
|
|
|
-void chanout_but(int x, int chan, const char *format, ...)
|
|
|
|
|
|
|
+void
|
|
|
|
|
+chanout_but(int x, int chan, const char *format, ...)
|
|
|
{
|
|
{
|
|
|
char s[1025] = "", *p = NULL;
|
|
char s[1025] = "", *p = NULL;
|
|
|
va_list va;
|
|
va_list va;
|
|
@@ -269,21 +276,22 @@ void chanout_but(int x, int chan, const char *format, ...)
|
|
|
dprintf(i, "%s\n", s);
|
|
dprintf(i, "%s\n", s);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void dcc_chatter(int idx)
|
|
|
|
|
|
|
+void
|
|
|
|
|
+dcc_chatter(int idx)
|
|
|
{
|
|
{
|
|
|
int i;
|
|
int i;
|
|
|
int j;
|
|
int j;
|
|
|
- struct flag_record fr = {FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0 };
|
|
|
|
|
|
|
+ struct flag_record fr = { FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0 };
|
|
|
|
|
|
|
|
strcpy(dcc[idx].u.chat->con_chan, "***");
|
|
strcpy(dcc[idx].u.chat->con_chan, "***");
|
|
|
check_bind_chon(dcc[idx].nick, idx);
|
|
check_bind_chon(dcc[idx].nick, idx);
|
|
|
|
|
|
|
|
dprintf(idx, "Connected to %s, running %s\n", conf.bot->nick, version);
|
|
dprintf(idx, "Connected to %s, running %s\n", conf.bot->nick, version);
|
|
|
- show_banner(idx); /* check STAT_BANNER inside function */
|
|
|
|
|
|
|
+ show_banner(idx); /* check STAT_BANNER inside function */
|
|
|
|
|
|
|
|
get_user_flagrec(dcc[idx].user, &fr, NULL);
|
|
get_user_flagrec(dcc[idx].user, &fr, NULL);
|
|
|
if ((dcc[idx].status & STAT_BOTS) && glob_master(fr)) {
|
|
if ((dcc[idx].status & STAT_BOTS) && glob_master(fr)) {
|
|
|
- if ((tands+1) > 1)
|
|
|
|
|
|
|
+ if ((tands + 1) > 1)
|
|
|
dprintf(idx, "There are %s-%d- bots%s currently linked.\n", BOLD(idx), tands + 1, BOLD_END(idx));
|
|
dprintf(idx, "There are %s-%d- bots%s currently linked.\n", BOLD(idx), tands + 1, BOLD_END(idx));
|
|
|
else
|
|
else
|
|
|
dprintf(idx, "There is %s-%d- bot%s currently linked.\n", BOLD(idx), tands + 1, BOLD_END(idx));
|
|
dprintf(idx, "There is %s-%d- bot%s currently linked.\n", BOLD(idx), tands + 1, BOLD_END(idx));
|
|
@@ -304,10 +312,10 @@ void dcc_chatter(int idx)
|
|
|
|
|
|
|
|
notes_chon(idx);
|
|
notes_chon(idx);
|
|
|
if (glob_party(fr)) {
|
|
if (glob_party(fr)) {
|
|
|
- i = dcc[idx].u.chat->channel;
|
|
|
|
|
|
|
+ i = dcc[idx].u.chat->channel;
|
|
|
} else {
|
|
} else {
|
|
|
- dprintf(idx, "You don't have partyline chat access; commands only.\n\n");
|
|
|
|
|
- i = -1;
|
|
|
|
|
|
|
+ dprintf(idx, "You don't have partyline chat access; commands only.\n\n");
|
|
|
|
|
+ i = -1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
j = dcc[idx].sock;
|
|
j = dcc[idx].sock;
|
|
@@ -316,7 +324,7 @@ void dcc_chatter(int idx)
|
|
|
/* Still there? */
|
|
/* Still there? */
|
|
|
|
|
|
|
|
if ((idx >= dcc_total) || (dcc[idx].sock != j))
|
|
if ((idx >= dcc_total) || (dcc[idx].sock != j))
|
|
|
- return; /* Nope */
|
|
|
|
|
|
|
+ return; /* Nope */
|
|
|
|
|
|
|
|
if (dcc[idx].type == &DCC_CHAT) {
|
|
if (dcc[idx].type == &DCC_CHAT) {
|
|
|
if (!strcmp(dcc[idx].u.chat->con_chan, "***"))
|
|
if (!strcmp(dcc[idx].u.chat->con_chan, "***"))
|
|
@@ -327,14 +335,14 @@ void dcc_chatter(int idx)
|
|
|
* so dont bother sending them
|
|
* so dont bother sending them
|
|
|
*/
|
|
*/
|
|
|
if (i == -2)
|
|
if (i == -2)
|
|
|
- i = 0;
|
|
|
|
|
|
|
+ i = 0;
|
|
|
|
|
|
|
|
dcc[idx].u.chat->channel = i;
|
|
dcc[idx].u.chat->channel = i;
|
|
|
|
|
|
|
|
if (dcc[idx].u.chat->channel >= 0) {
|
|
if (dcc[idx].u.chat->channel >= 0) {
|
|
|
- if (dcc[idx].u.chat->channel < GLOBAL_CHANS) {
|
|
|
|
|
- botnet_send_join_idx(idx);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (dcc[idx].u.chat->channel < GLOBAL_CHANS) {
|
|
|
|
|
+ botnet_send_join_idx(idx);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
/* But *do* bother with sending it locally */
|
|
/* But *do* bother with sending it locally */
|
|
@@ -350,11 +358,12 @@ void dcc_chatter(int idx)
|
|
|
/* Mark an entry as lost and deconstruct it's contents. It will be securely
|
|
/* Mark an entry as lost and deconstruct it's contents. It will be securely
|
|
|
* removed from the dcc list in the main loop.
|
|
* removed from the dcc list in the main loop.
|
|
|
*/
|
|
*/
|
|
|
-void lostdcc(int n)
|
|
|
|
|
|
|
+void
|
|
|
|
|
+lostdcc(int n)
|
|
|
{
|
|
{
|
|
|
sdprintf("lostdcc(%d)", n);
|
|
sdprintf("lostdcc(%d)", n);
|
|
|
/* Make sure it's a valid dcc index. */
|
|
/* Make sure it's a valid dcc index. */
|
|
|
- if (n < 0 || n >= max_dcc)
|
|
|
|
|
|
|
+ if (n < 0 || n >= max_dcc)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
if (dcc[n].type && dcc[n].type->kill)
|
|
if (dcc[n].type && dcc[n].type->kill)
|
|
@@ -377,7 +386,8 @@ void lostdcc(int n)
|
|
|
/* Show list of current dcc's to a dcc-chatter
|
|
/* Show list of current dcc's to a dcc-chatter
|
|
|
* positive value: idx given -- negative value: sock given
|
|
* positive value: idx given -- negative value: sock given
|
|
|
*/
|
|
*/
|
|
|
-void tell_dcc(int idx)
|
|
|
|
|
|
|
+void
|
|
|
|
|
+tell_dcc(int idx)
|
|
|
{
|
|
{
|
|
|
int i;
|
|
int i;
|
|
|
size_t j, nicklen = 0;
|
|
size_t j, nicklen = 0;
|
|
@@ -385,52 +395,52 @@ void tell_dcc(int idx)
|
|
|
|
|
|
|
|
/* calculate max nicklen */
|
|
/* calculate max nicklen */
|
|
|
for (i = 0; i < dcc_total; i++) {
|
|
for (i = 0; i < dcc_total; i++) {
|
|
|
- if(dcc[i].type && strlen(dcc[i].nick) > (unsigned) nicklen)
|
|
|
|
|
- nicklen = strlen(dcc[i].nick);
|
|
|
|
|
|
|
+ if (dcc[i].type && strlen(dcc[i].nick) > (unsigned) nicklen)
|
|
|
|
|
+ nicklen = strlen(dcc[i].nick);
|
|
|
}
|
|
}
|
|
|
- if(nicklen < 9)
|
|
|
|
|
|
|
+ if (nicklen < 9)
|
|
|
nicklen = 9;
|
|
nicklen = 9;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
egg_snprintf(format, sizeof format, "%%-4s %%-4s %%-8s %%-5s %%-%us %%-40s %%s\n", nicklen);
|
|
egg_snprintf(format, sizeof format, "%%-4s %%-4s %%-8s %%-5s %%-%us %%-40s %%s\n", nicklen);
|
|
|
- dprintf(idx, format, "SOCK", "IDX", "ADDR", "PORT", "NICK", "HOST", "TYPE");
|
|
|
|
|
- dprintf(idx, format, "----", "---", "--------", "-----", "---------",
|
|
|
|
|
- "----------------------------------------", "----");
|
|
|
|
|
|
|
+ dprintf(idx, format, "SOCK", "IDX", "ADDR", "PORT", "NICK", "HOST", "TYPE");
|
|
|
|
|
+ dprintf(idx, format, "----", "---", "--------", "-----", "---------",
|
|
|
|
|
+ "----------------------------------------", "----");
|
|
|
|
|
|
|
|
egg_snprintf(format, sizeof format, "%%-4d %%-4d %%08X %%5ud %%-%us %%-40s %%s\n", nicklen);
|
|
egg_snprintf(format, sizeof format, "%%-4d %%-4d %%08X %%5ud %%-%us %%-40s %%s\n", nicklen);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
dprintf(idx, "dccn: %d, dcc_total: %d\n", dccn, dcc_total);
|
|
dprintf(idx, "dccn: %d, dcc_total: %d\n", dccn, dcc_total);
|
|
|
#ifdef LEAF
|
|
#ifdef LEAF
|
|
|
dprintf(idx, "dns_idx: %d, servidx: %d\n", dns_idx, servidx);
|
|
dprintf(idx, "dns_idx: %d, servidx: %d\n", dns_idx, servidx);
|
|
|
#endif /* LEAF */
|
|
#endif /* LEAF */
|
|
|
for (i = 0; i < dcc_total; i++) {
|
|
for (i = 0; i < dcc_total; i++) {
|
|
|
- if (dcc[i].type) {
|
|
|
|
|
- j = strlen(dcc[i].host);
|
|
|
|
|
- if (j > 40)
|
|
|
|
|
- j -= 40;
|
|
|
|
|
- else
|
|
|
|
|
- j = 0;
|
|
|
|
|
- if (dcc[i].type && dcc[i].type->display)
|
|
|
|
|
- dcc[i].type->display(i, other);
|
|
|
|
|
- else {
|
|
|
|
|
- sprintf(other, "?:%lX !! ERROR !!", (long) dcc[i].type);
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ if (dcc[i].type) {
|
|
|
|
|
+ j = strlen(dcc[i].host);
|
|
|
|
|
+ if (j > 40)
|
|
|
|
|
+ j -= 40;
|
|
|
|
|
+ else
|
|
|
|
|
+ j = 0;
|
|
|
|
|
+ if (dcc[i].type && dcc[i].type->display)
|
|
|
|
|
+ dcc[i].type->display(i, other);
|
|
|
|
|
+ else {
|
|
|
|
|
+ sprintf(other, "?:%lX !! ERROR !!", (long) dcc[i].type);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ dprintf(idx, format, dcc[i].sock, i, dcc[i].addr, dcc[i].port, dcc[i].nick, dcc[i].host + j, other);
|
|
|
}
|
|
}
|
|
|
- dprintf(idx, format, dcc[i].sock, i, dcc[i].addr, dcc[i].port, dcc[i].nick, dcc[i].host + j, other);
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* Mark someone on dcc chat as no longer away
|
|
/* Mark someone on dcc chat as no longer away
|
|
|
*/
|
|
*/
|
|
|
-void not_away(int idx)
|
|
|
|
|
|
|
+void
|
|
|
|
|
+not_away(int idx)
|
|
|
{
|
|
{
|
|
|
if (dcc[idx].u.chat->away == NULL) {
|
|
if (dcc[idx].u.chat->away == NULL) {
|
|
|
dprintf(idx, "You weren't away!\n");
|
|
dprintf(idx, "You weren't away!\n");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (dcc[idx].u.chat->channel >= 0) {
|
|
if (dcc[idx].u.chat->channel >= 0) {
|
|
|
- chanout_but(-1, dcc[idx].u.chat->channel,
|
|
|
|
|
- "*** %s is no longer away.\n", dcc[idx].nick);
|
|
|
|
|
|
|
+ chanout_but(-1, dcc[idx].u.chat->channel, "*** %s is no longer away.\n", dcc[idx].nick);
|
|
|
if (dcc[idx].u.chat->channel < GLOBAL_CHANS) {
|
|
if (dcc[idx].u.chat->channel < GLOBAL_CHANS) {
|
|
|
botnet_send_away(-1, conf.bot->nick, dcc[idx].sock, NULL, idx);
|
|
botnet_send_away(-1, conf.bot->nick, dcc[idx].sock, NULL, idx);
|
|
|
}
|
|
}
|
|
@@ -441,7 +451,8 @@ void not_away(int idx)
|
|
|
check_bind_away(conf.bot->nick, idx, NULL);
|
|
check_bind_away(conf.bot->nick, idx, NULL);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void set_away(int idx, char *s)
|
|
|
|
|
|
|
+void
|
|
|
|
|
+set_away(int idx, char *s)
|
|
|
{
|
|
{
|
|
|
if (s == NULL) {
|
|
if (s == NULL) {
|
|
|
not_away(idx);
|
|
not_away(idx);
|
|
@@ -467,12 +478,14 @@ void set_away(int idx, char *s)
|
|
|
|
|
|
|
|
/* Make a password, 10-14 random letters and digits
|
|
/* Make a password, 10-14 random letters and digits
|
|
|
*/
|
|
*/
|
|
|
-void makepass(char *s)
|
|
|
|
|
|
|
+void
|
|
|
|
|
+makepass(char *s)
|
|
|
{
|
|
{
|
|
|
make_rand_str(s, 10 + randint(5));
|
|
make_rand_str(s, 10 + randint(5));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void flush_lines(int idx, struct chat_info *ci)
|
|
|
|
|
|
|
+void
|
|
|
|
|
+flush_lines(int idx, struct chat_info *ci)
|
|
|
{
|
|
{
|
|
|
int c = ci->line_count;
|
|
int c = ci->line_count;
|
|
|
struct msgq *p = ci->buffer, *o;
|
|
struct msgq *p = ci->buffer, *o;
|
|
@@ -496,7 +509,8 @@ void flush_lines(int idx, struct chat_info *ci)
|
|
|
ci->line_count = 0;
|
|
ci->line_count = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-int new_dcc(struct dcc_table *type, int xtra_size)
|
|
|
|
|
|
|
+int
|
|
|
|
|
+new_dcc(struct dcc_table *type, int xtra_size)
|
|
|
{
|
|
{
|
|
|
if (dcc_total == max_dcc)
|
|
if (dcc_total == max_dcc)
|
|
|
return -1;
|
|
return -1;
|
|
@@ -513,7 +527,7 @@ int new_dcc(struct dcc_table *type, int xtra_size)
|
|
|
i = dcc_total;
|
|
i = dcc_total;
|
|
|
dcc_total++;
|
|
dcc_total++;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
dccn++;
|
|
dccn++;
|
|
|
|
|
|
|
|
/* empty out the memory for the entry */
|
|
/* empty out the memory for the entry */
|
|
@@ -529,7 +543,8 @@ int new_dcc(struct dcc_table *type, int xtra_size)
|
|
|
|
|
|
|
|
/* Changes the given dcc entry to another type.
|
|
/* Changes the given dcc entry to another type.
|
|
|
*/
|
|
*/
|
|
|
-void changeover_dcc(int i, struct dcc_table *type, int xtra_size)
|
|
|
|
|
|
|
+void
|
|
|
|
|
+changeover_dcc(int i, struct dcc_table *type, int xtra_size)
|
|
|
{
|
|
{
|
|
|
/* Free old structure. */
|
|
/* Free old structure. */
|
|
|
if (dcc[i].type && dcc[i].type->kill)
|
|
if (dcc[i].type && dcc[i].type->kill)
|
|
@@ -543,7 +558,8 @@ void changeover_dcc(int i, struct dcc_table *type, int xtra_size)
|
|
|
dcc[i].u.other = (char *) calloc(1, xtra_size);
|
|
dcc[i].u.other = (char *) calloc(1, xtra_size);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-int detect_dcc_flood(time_t * timer, struct chat_info *chat, int idx)
|
|
|
|
|
|
|
+int
|
|
|
|
|
+detect_dcc_flood(time_t * timer, struct chat_info *chat, int idx)
|
|
|
{
|
|
{
|
|
|
if (!dcc_flood_thr)
|
|
if (!dcc_flood_thr)
|
|
|
return 0;
|
|
return 0;
|
|
@@ -559,24 +575,23 @@ int detect_dcc_flood(time_t * timer, struct chat_info *chat, int idx)
|
|
|
/* FLOOD */
|
|
/* FLOOD */
|
|
|
dprintf(idx, "*** FLOOD: %s.\n", IRC_GOODBYE);
|
|
dprintf(idx, "*** FLOOD: %s.\n", IRC_GOODBYE);
|
|
|
/* Evil assumption here that flags&DCT_CHAT implies chat type */
|
|
/* Evil assumption here that flags&DCT_CHAT implies chat type */
|
|
|
- if ((dcc[idx].type->flags & DCT_CHAT) && chat &&
|
|
|
|
|
- (chat->channel >= 0)) {
|
|
|
|
|
- char x[1024];
|
|
|
|
|
-
|
|
|
|
|
- egg_snprintf(x, sizeof x, DCC_FLOODBOOT, dcc[idx].nick);
|
|
|
|
|
- chanout_but(idx, chat->channel, "*** %s", x);
|
|
|
|
|
- if (chat->channel < GLOBAL_CHANS)
|
|
|
|
|
- botnet_send_part_idx(idx, x);
|
|
|
|
|
|
|
+ if ((dcc[idx].type->flags & DCT_CHAT) && chat && (chat->channel >= 0)) {
|
|
|
|
|
+ char x[1024];
|
|
|
|
|
+
|
|
|
|
|
+ egg_snprintf(x, sizeof x, DCC_FLOODBOOT, dcc[idx].nick);
|
|
|
|
|
+ chanout_but(idx, chat->channel, "*** %s", x);
|
|
|
|
|
+ if (chat->channel < GLOBAL_CHANS)
|
|
|
|
|
+ botnet_send_part_idx(idx, x);
|
|
|
}
|
|
}
|
|
|
check_bind_chof(dcc[idx].nick, idx);
|
|
check_bind_chof(dcc[idx].nick, idx);
|
|
|
if ((dcc[idx].sock != STDOUT) || backgrd) {
|
|
if ((dcc[idx].sock != STDOUT) || backgrd) {
|
|
|
- killsock(dcc[idx].sock);
|
|
|
|
|
- lostdcc(idx);
|
|
|
|
|
|
|
+ killsock(dcc[idx].sock);
|
|
|
|
|
+ lostdcc(idx);
|
|
|
} else {
|
|
} else {
|
|
|
- dprintf(DP_STDOUT, "\n### SIMULATION RESET ###\n\n");
|
|
|
|
|
- dcc_chatter(idx);
|
|
|
|
|
|
|
+ dprintf(DP_STDOUT, "\n### SIMULATION RESET ###\n\n");
|
|
|
|
|
+ dcc_chatter(idx);
|
|
|
}
|
|
}
|
|
|
- return 1; /* <- flood */
|
|
|
|
|
|
|
+ return 1; /* <- flood */
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return 0;
|
|
return 0;
|
|
@@ -584,7 +599,8 @@ int detect_dcc_flood(time_t * timer, struct chat_info *chat, int idx)
|
|
|
|
|
|
|
|
/* Handle someone being booted from dcc chat.
|
|
/* Handle someone being booted from dcc chat.
|
|
|
*/
|
|
*/
|
|
|
-void do_boot(int idx, char *by, char *reason)
|
|
|
|
|
|
|
+void
|
|
|
|
|
+do_boot(int idx, char *by, char *reason)
|
|
|
{
|
|
{
|
|
|
int files = (dcc[idx].type != &DCC_CHAT);
|
|
int files = (dcc[idx].type != &DCC_CHAT);
|
|
|
|
|
|
|
@@ -613,13 +629,15 @@ void do_boot(int idx, char *by, char *reason)
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-port_t listen_all(port_t lport, bool off)
|
|
|
|
|
|
|
+port_t
|
|
|
|
|
+listen_all(port_t lport, bool off)
|
|
|
{
|
|
{
|
|
|
if (!lport)
|
|
if (!lport)
|
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
|
|
int idx = (-1);
|
|
int idx = (-1);
|
|
|
port_t port, realport;
|
|
port_t port, realport;
|
|
|
|
|
+
|
|
|
#ifdef USE_IPV6
|
|
#ifdef USE_IPV6
|
|
|
int i6 = 0;
|
|
int i6 = 0;
|
|
|
#endif /* USE_IPV6 */
|
|
#endif /* USE_IPV6 */
|
|
@@ -642,20 +660,20 @@ port_t listen_all(port_t lport, bool off)
|
|
|
if (pold)
|
|
if (pold)
|
|
|
pold->next = pmap->next;
|
|
pold->next = pmap->next;
|
|
|
else
|
|
else
|
|
|
- root = pmap->next;
|
|
|
|
|
- free(pmap);
|
|
|
|
|
|
|
+ root = pmap->next;
|
|
|
|
|
+ free(pmap);
|
|
|
}
|
|
}
|
|
|
#ifdef USE_IPV6
|
|
#ifdef USE_IPV6
|
|
|
if (sockprotocol(dcc[idx].sock) == AF_INET6)
|
|
if (sockprotocol(dcc[idx].sock) == AF_INET6)
|
|
|
putlog(LOG_DEBUG, "*", "Closing IPv6 listening port %d", dcc[idx].port);
|
|
putlog(LOG_DEBUG, "*", "Closing IPv6 listening port %d", dcc[idx].port);
|
|
|
else
|
|
else
|
|
|
-#endif /* USE_IPV6 */
|
|
|
|
|
|
|
+#endif /* USE_IPV6 */
|
|
|
putlog(LOG_DEBUG, "*", "Closing IPv4 listening port %d", dcc[idx].port);
|
|
putlog(LOG_DEBUG, "*", "Closing IPv4 listening port %d", dcc[idx].port);
|
|
|
killsock(dcc[idx].sock);
|
|
killsock(dcc[idx].sock);
|
|
|
lostdcc(idx);
|
|
lostdcc(idx);
|
|
|
return idx;
|
|
return idx;
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if (idx < 0) {
|
|
if (idx < 0) {
|
|
|
if (off) {
|
|
if (off) {
|
|
@@ -669,7 +687,7 @@ port_t listen_all(port_t lport, bool off)
|
|
|
#ifdef USE_IPV6
|
|
#ifdef USE_IPV6
|
|
|
i6 = open_listen_by_af(&port, AF_INET6);
|
|
i6 = open_listen_by_af(&port, AF_INET6);
|
|
|
if (i6 < 0) {
|
|
if (i6 < 0) {
|
|
|
- putlog(LOG_ERRORS, "*", "Can't open IPv6 listening port %d - %s", port,
|
|
|
|
|
|
|
+ putlog(LOG_ERRORS, "*", "Can't open IPv6 listening port %d - %s", port,
|
|
|
i6 == -1 ? "it's taken." : "couldn't assign ip.");
|
|
i6 == -1 ? "it's taken." : "couldn't assign ip.");
|
|
|
} else {
|
|
} else {
|
|
|
idx = new_dcc(&DCC_TELNET, 0);
|
|
idx = new_dcc(&DCC_TELNET, 0);
|
|
@@ -690,7 +708,7 @@ port_t listen_all(port_t lport, bool off)
|
|
|
putlog(LOG_ERRORS, "*", "Can't open IPv4 listening port %d - %s", port,
|
|
putlog(LOG_ERRORS, "*", "Can't open IPv4 listening port %d - %s", port,
|
|
|
i == -1 ? "it's taken." : "couldn't assign ip.");
|
|
i == -1 ? "it's taken." : "couldn't assign ip.");
|
|
|
} else {
|
|
} else {
|
|
|
- idx = (-1); /* now setup ipv4 listening port */
|
|
|
|
|
|
|
+ idx = (-1); /* now setup ipv4 listening port */
|
|
|
idx = new_dcc(&DCC_TELNET, 0);
|
|
idx = new_dcc(&DCC_TELNET, 0);
|
|
|
dcc[idx].addr = iptolong(getmyip());
|
|
dcc[idx].addr = iptolong(getmyip());
|
|
|
dcc[idx].port = port;
|
|
dcc[idx].port = port;
|
|
@@ -724,7 +742,8 @@ port_t listen_all(port_t lport, bool off)
|
|
|
return idx;
|
|
return idx;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void identd_open()
|
|
|
|
|
|
|
+void
|
|
|
|
|
+identd_open()
|
|
|
{
|
|
{
|
|
|
int idx;
|
|
int idx;
|
|
|
int i = -1;
|
|
int i = -1;
|
|
@@ -732,7 +751,7 @@ void identd_open()
|
|
|
|
|
|
|
|
for (idx = 0; idx < dcc_total; idx++)
|
|
for (idx = 0; idx < dcc_total; idx++)
|
|
|
if (dcc[idx].type == &DCC_IDENTD_CONNECT)
|
|
if (dcc[idx].type == &DCC_IDENTD_CONNECT)
|
|
|
- return; /* it's already open :) */
|
|
|
|
|
|
|
+ return; /* it's already open :) */
|
|
|
|
|
|
|
|
idx = -1;
|
|
idx = -1;
|
|
|
|
|
|
|
@@ -763,7 +782,8 @@ void identd_open()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void identd_close()
|
|
|
|
|
|
|
+void
|
|
|
|
|
+identd_close()
|
|
|
{
|
|
{
|
|
|
for (int idx = 0; idx < dcc_total; idx++) {
|
|
for (int idx = 0; idx < dcc_total; idx++) {
|
|
|
if (dcc[idx].type == &DCC_IDENTD_CONNECT) {
|
|
if (dcc[idx].type == &DCC_IDENTD_CONNECT) {
|
|
@@ -775,7 +795,8 @@ void identd_close()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-bool valid_idx(int idx)
|
|
|
|
|
|
|
+bool
|
|
|
|
|
+valid_idx(int idx)
|
|
|
{
|
|
{
|
|
|
if ((idx == -1) || (idx >= dcc_total) || (!dcc[idx].type))
|
|
if ((idx == -1) || (idx >= dcc_total) || (!dcc[idx].type))
|
|
|
return 0;
|
|
return 0;
|