src/dcc.c File Reference

#include "main.h"
#include <ctype.h>
#include <errno.h>
#include "modules.h"
#include "tandem.h"
#include "md5/md5.h"
Include dependency graph for dcc.c:

Go to the source code of this file.

Functions

static void dcc_telnet_hostresolved (int)
static void dcc_telnet_got_ident (int, char *)
static void dcc_telnet_pass (int, int)
static int detect_telnet (unsigned char *buf)
static char * escape_telnet (char *s)
static void strip_telnet (int sock, char *buf, int *len)
static void greet_new_bot (int idx)
static void bot_version (int idx, char *par)
void failed_link (int idx)
static void cont_link (int idx, char *buf, int i)
static void dcc_bot_digest (int idx, char *challenge, char *password)
static void dcc_bot_new (int idx, char *buf, int x)
static void eof_dcc_bot_new (int idx)
static void timeout_dcc_bot_new (int idx)
static void display_dcc_bot_new (int idx, char *buf)
static int expmem_dcc_bot_ (void *x)
static void free_dcc_bot_ (int n, void *x)
static void dcc_bot (int idx, char *code, int i)
static void eof_dcc_bot (int idx)
static void display_dcc_bot (int idx, char *buf)
static void display_dcc_fork_bot (int idx, char *buf)
static int dcc_bot_check_digest (int idx, char *remote_digest)
static void dcc_chat_pass (int idx, char *buf, int atr)
static void eof_dcc_general (int idx)
static void tout_dcc_chat_pass (int idx)
static void display_dcc_chat_pass (int idx, char *buf)
static int expmem_dcc_general (void *x)
static void kill_dcc_general (int idx, void *x)
void strip_mirc_codes (int flags, char *text)
static void append_line (int idx, char *line)
static void out_dcc_general (int idx, char *buf, void *x)
int check_ansi (char *v)
static void eof_dcc_chat (int idx)
static void dcc_chat (int idx, char *buf, int i)
static void display_dcc_chat (int idx, char *buf)
static int detect_telnet_flood (char *floodhost)
static void dcc_telnet (int idx, char *buf, int i)
static void eof_dcc_telnet (int idx)
static void display_telnet (int idx, char *buf)
static void eof_dcc_dupwait (int idx)
static void dcc_dupwait (int idx, char *buf, int i)
static void timeout_dupwait (int idx)
static void display_dupwait (int idx, char *buf)
static int expmem_dupwait (void *x)
static void kill_dupwait (int idx, void *x)
void dupwait_notify (char *who)
static void dcc_telnet_id (int idx, char *buf, int atr)
static void eof_dcc_telnet_id (int idx)
static void timeout_dcc_telnet_id (int idx)
static void display_dcc_telnet_id (int idx, char *buf)
static void dcc_telnet_new (int idx, char *buf, int x)
static void dcc_telnet_pw (int idx, char *buf, int x)
static void eof_dcc_telnet_new (int idx)
static void eof_dcc_telnet_pw (int idx)
static void tout_dcc_telnet_new (int idx)
static void tout_dcc_telnet_pw (int idx)
static void display_dcc_telnet_new (int idx, char *buf)
static void display_dcc_telnet_pw (int idx, char *buf)
static int call_tcl_func (char *name, int idx, char *args)
static void dcc_script (int idx, char *buf, int len)
static void eof_dcc_script (int idx)
static void display_dcc_script (int idx, char *buf)
static int expmem_dcc_script (void *x)
static void kill_dcc_script (int idx, void *x)
static void out_dcc_script (int idx, char *buf, void *x)
static void dcc_socket (int idx, char *buf, int len)
static void eof_dcc_socket (int idx)
static void display_dcc_socket (int idx, char *buf)
static void display_dcc_lost (int idx, char *buf)
void dcc_identwait (int idx, char *buf, int len)
void eof_dcc_identwait (int idx)
static void display_dcc_identwait (int idx, char *buf)
void dcc_ident (int idx, char *buf, int len)
void eof_dcc_ident (int idx)
static void display_dcc_ident (int idx, char *buf)

Variables

struct userrecuserlist
struct chanset_tchanset
Tcl_Interpinterp
time_t now
char botnetnick []
char ver []
char origbotname []
char notify_new []
int egg_numver
int connect_timeout
int conmask
int backgrd
int max_dcc
int make_userfile
int default_flags
int raw_log
int ignore_time
int par_telnet_flood
struct dcc_tdcc = 0
int dcc_total = 0
char tempdir [121] = ""
int require_p = 0
int allow_new_telnets = 0
int stealth_telnets = 0
int use_telnet_banner = 0
char network [41] = "unknown-net"
int password_timeout = 180
int bot_timeout = 60
int identtimeout = 5
int dupwait_timeout = 5
int protect_telnet = 1
int flood_telnet_thr = 5
int flood_telnet_time = 60
char bannerfile [121] = "text/banner"
struct dcc_table DCC_BOT_NEW
botcmd_t C_bot []
struct dcc_table DCC_BOT
struct dcc_table DCC_FORK_BOT
struct dcc_table DCC_CHAT_PASS
struct dcc_table DCC_CHAT
static int lasttelnets
static char lasttelnethost [81]
static time_t lasttelnettime
struct dcc_table DCC_TELNET
struct dcc_table DCC_DUPWAIT
struct dcc_table DCC_TELNET_ID
struct dcc_table DCC_TELNET_NEW
struct dcc_table DCC_TELNET_PW
struct dcc_table DCC_SCRIPT
struct dcc_table DCC_SOCKET
struct dcc_table DCC_LOST
struct dcc_table DCC_IDENTWAIT
struct dcc_table DCC_IDENT

Function Documentation

static void append_line ( int  idx,
char *  line 
) [static]

Definition at line 794 of file dcc.c.

References botnetnick, chat_info::buffer, file_info::chat, dcc_t::chat, chat_info::current_lines, DCC_CHAT, do_boot(), dcc_t::file, get_data_ptr, msgq::len, chat_info::line_count, chat_info::max_line, msgq::msg, msgq::next, nfree, NULL, STAT_PAGE, dcc_t::status, tputs, dcc_t::type, and dcc_t::u.

Referenced by out_dcc_general().

00795 {
00796   int l = strlen(line);
00797   struct msgq *p, *q;
00798   struct chat_info *c = (dcc[idx].type == &DCC_CHAT) ? dcc[idx].u.chat :
00799                         dcc[idx].u.file->chat;
00800 
00801   if (c->current_lines > 1000) {
00802     /* They're probably trying to fill up the bot nuke the sods :) */
00803     for (p = c->buffer; p; p = q) {
00804       q = p->next;
00805       nfree(p->msg);
00806       nfree(p);
00807     }
00808     c->buffer = 0;
00809     dcc[idx].status &= ~STAT_PAGE;
00810     do_boot(idx, botnetnick, "too many pages - sendq full");
00811     return;
00812   }
00813   if ((c->line_count < c->max_line) && (c->buffer == NULL)) {
00814     c->line_count++;
00815     tputs(dcc[idx].sock, line, l);
00816   } else {
00817     c->current_lines++;
00818     if (c->buffer == NULL)
00819       q = NULL;
00820     else
00821       for (q = c->buffer; q->next; q = q->next);
00822 
00823     p = get_data_ptr(sizeof(struct msgq));
00824 
00825     p->len = l;
00826     p->msg = get_data_ptr(l + 1);
00827     p->next = NULL;
00828     strcpy(p->msg, line);
00829     if (q == NULL)
00830       c->buffer = p;
00831     else
00832       q->next = p;
00833   }
00834 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void bot_version ( int  idx,
char *  par 
) [static]

Definition at line 183 of file dcc.c.

References addbot(), b_numver, dcc_t::bot, bot_share(), botnet_send_nlinked(), botnetnick, chatout, check_tcl_link(), DCC_BOT, DCC_LINKED, dprintf, dump_links(), egg_snprintf, HANDLEN, in_chain, killsock, LOG_BOTS, lostdcc, NEAT_BOTNET, newsplit, dcc_t::nick, now, bot_info::numver, putlog, dcc_t::sock, strncpyz, dcc_t::timeval, touch_laston, dcc_t::type, dcc_t::u, and user.

Referenced by dcc_bot_new().

00184 {
00185   char x[1024];
00186   int l;
00187 
00188   dcc[idx].timeval = now;
00189   if (in_chain(dcc[idx].nick)) {
00190     dprintf(idx, "error Sorry, already connected.\n");
00191     dprintf(idx, "bye\n");
00192     killsock(dcc[idx].sock);
00193     lostdcc(idx);
00194     return;
00195   }
00196   if ((par[0] >= '0') && (par[0] <= '9')) {
00197     char *work;
00198 
00199     work = newsplit(&par);
00200     dcc[idx].u.bot->numver = atoi(work);
00201   } else
00202     dcc[idx].u.bot->numver = 0;
00203 
00204 #ifndef NO_OLD_BOTNET
00205   if (b_numver(idx) < NEAT_BOTNET) {
00206 #if HANDLEN != 9
00207     putlog(LOG_BOTS, "*", "Non-matching handle lengths with %s, they use 9 "
00208            "characters.", dcc[idx].nick);
00209     dprintf(idx, "error Non-matching handle length: mine %d, yours 9\n",
00210             HANDLEN);
00211     dprintf(idx, "bye %s\n", "bad handlen");
00212     killsock(dcc[idx].sock);
00213     lostdcc(idx);
00214     return;
00215 #else
00216     dprintf(idx, "thisbot %s\n", botnetnick);
00217 #endif
00218   } else {
00219 #endif
00220     dprintf(idx, "tb %s\n", botnetnick);
00221     l = atoi(newsplit(&par));
00222     if (l != HANDLEN) {
00223       putlog(LOG_BOTS, "*", "Non-matching handle lengths with %s, they use %d "
00224              "characters.", dcc[idx].nick, l);
00225       dprintf(idx, "error Non-matching handle length: mine %d, yours %d\n",
00226               HANDLEN, l);
00227       dprintf(idx, "bye %s\n", "bad handlen");
00228       killsock(dcc[idx].sock);
00229       lostdcc(idx);
00230       return;
00231     }
00232 #ifndef NO_OLD_BOTNET
00233   }
00234 #endif
00235   strncpyz(dcc[idx].u.bot->version, par, 120);
00236   putlog(LOG_BOTS, "*", DCC_LINKED, dcc[idx].nick);
00237   chatout("*** Linked to %s\n", dcc[idx].nick);
00238   botnet_send_nlinked(idx, dcc[idx].nick, botnetnick, '!',
00239                       dcc[idx].u.bot->numver);
00240   touch_laston(dcc[idx].user, "linked", now);
00241   dump_links(idx);
00242   dcc[idx].type = &DCC_BOT;
00243   addbot(dcc[idx].nick, dcc[idx].nick, botnetnick, '-', dcc[idx].u.bot->numver);
00244   check_tcl_link(dcc[idx].nick, botnetnick);
00245   egg_snprintf(x, sizeof x, "v %d", dcc[idx].u.bot->numver);
00246   bot_share(idx, x);
00247   dprintf(idx, "el\n");
00248 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int call_tcl_func ( char *  name,
int  idx,
char *  args 
) [static]

Definition at line 1763 of file dcc.c.

References DCC_TCLERROR, interp, LOG_MISC, NULL, putlog, tcl_resultint(), and tcl_resultstring().

Referenced by dcc_script(), and eof_dcc_script().

01764 {
01765   char s[11];
01766 
01767   sprintf(s, "%d", idx);
01768   Tcl_SetVar(interp, "_n", s, 0);
01769   Tcl_SetVar(interp, "_a", args, 0);
01770   if (Tcl_VarEval(interp, name, " $_n $_a", NULL) == TCL_ERROR) {
01771     putlog(LOG_MISC, "*", DCC_TCLERROR, name, tcl_resultstring());
01772     return -1;
01773   }
01774   return tcl_resultint();
01775 }

Here is the call graph for this function:

Here is the caller graph for this function:

int check_ansi ( char *  v  ) 

Definition at line 865 of file dcc.c.

References count.

00866 {
00867   int count = 2;
00868 
00869   if (*v++ != '\033')
00870     return 1;
00871   if (*v++ != '[')
00872     return 1;
00873   while (*v) {
00874     if (*v == 'm')
00875       return 0;
00876     if ((*v != ';') && ((*v < '0') || (*v > '9')))
00877       return count;
00878     v++;
00879     count++;
00880   }
00881   return count;
00882 }

static void cont_link ( int  idx,
char *  buf,
int  i 
) [static]

Definition at line 282 of file dcc.c.

References dcc_t::bot, BOT_ALT, bot_flags, BOT_HUB, botnet_send_unlinked, botnetnick, bots_in_subtree, chatout, DCC_BOT_NEW, DCC_FORK_BOT, dcc_total, dprintf, egg_snprintf, findbot(), in_chain, killsock, lostdcc, nextbot, dcc_t::nick, bot_info::numver, dcc_t::sock, dcc_t::type, dcc_t::u, user, and users_in_subtree.

00283 {
00284   char x[1024];
00285   int atr = bot_flags(dcc[idx].user);
00286   int users, bots;
00287 
00288   if (atr & BOT_HUB) {
00289     /* Disconnect all +a bots because we just got a hub */
00290     for (i = 0; i < dcc_total; i++) {
00291       if ((i != idx) && (bot_flags(dcc[i].user) & BOT_ALT)) {
00292         if ((dcc[i].type == &DCC_FORK_BOT) || (dcc[i].type == &DCC_BOT_NEW)) {
00293           killsock(dcc[i].sock);
00294           lostdcc(i);
00295         }
00296       }
00297     }
00298     /* Just those currently in the process of linking */
00299     if (in_chain(dcc[idx].nick)) {
00300       i = nextbot(dcc[idx].nick);
00301       if (i > 0) {
00302         bots = bots_in_subtree(findbot(dcc[idx].nick));
00303         users = users_in_subtree(findbot(dcc[idx].nick));
00304         egg_snprintf(x, sizeof x,
00305                      "Unlinked %s (restructure) (lost %d bot%s and %d user%s)",
00306                      dcc[i].nick, bots, (bots != 1) ? "s" : "",
00307                      users, (users != 1) ? "s" : "");
00308         chatout("*** %s\n", x);
00309         botnet_send_unlinked(i, dcc[i].nick, x);
00310         dprintf(i, "bye %s\n", "restructure");
00311         killsock(dcc[i].sock);
00312         lostdcc(i);
00313       }
00314     }
00315   }
00316   dcc[idx].type = &DCC_BOT_NEW;
00317   dcc[idx].u.bot->numver = 0;
00318 
00319   /* Don't send our password here, just the username. The code later on
00320    * will determine if the password needs to be sent in cleartext or if
00321    * we can send an MD5 digest. <cybah>
00322    */
00323   dprintf(idx, "%s\n", botnetnick);
00324   return;
00325 }

Here is the call graph for this function:

static void dcc_bot ( int  idx,
char *  code,
int  i 
) [static]

Definition at line 435 of file dcc.c.

References egg_strcasecmp, botcmd_t::func, LOG_BOTNET, LOG_BOTSHARE, dcc_table::name, botcmd_t::name, putlog, and raw_log.

00436 {
00437   char *msg;
00438   int f;
00439 
00440   if (raw_log) {
00441     if (code[0] == 's')
00442       putlog(LOG_BOTSHARE, "*", "{%s} %s", dcc[idx].nick, code + 2);
00443     else
00444       putlog(LOG_BOTNET, "*", "[%s] %s", dcc[idx].nick, code);
00445   }
00446   msg = strchr(code, ' ');
00447   if (msg) {
00448     *msg = 0;
00449     msg++;
00450   } else
00451     msg = "";
00452   for (f = i = 0; C_bot[i].name && !f; i++) {
00453     int y = egg_strcasecmp(code, C_bot[i].name);
00454 
00455     if (!y) {
00456       /* Found a match */
00457       (C_bot[i].func) (idx, msg);
00458       f = 1;
00459     } else if (y < 0)
00460       return;
00461   }
00462 }

static int dcc_bot_check_digest ( int  idx,
char *  remote_digest 
) [static]

Definition at line 537 of file dcc.c.

References botnetnick, egg_snprintf, get_user, LOG_BOTS, MD5_Final, MD5_Init, MD5_Update, putlog, user, and USERENTRY_PASS.

Referenced by dcc_chat_pass().

00538 {
00539   MD5_CTX md5context;
00540   char digest_string[33];       /* 32 for digest in hex + null */
00541   unsigned char digest[16];
00542   int i;
00543   char *password = get_user(&USERENTRY_PASS, dcc[idx].user);
00544 
00545   if (!password)
00546     return 1;
00547 
00548   MD5_Init(&md5context);
00549 
00550   egg_snprintf(digest_string, 33, "<%x%x@", getpid(),
00551                (unsigned int) dcc[idx].timeval);
00552   MD5_Update(&md5context, (unsigned char *) digest_string,
00553              strlen(digest_string));
00554   MD5_Update(&md5context, (unsigned char *) botnetnick, strlen(botnetnick));
00555   MD5_Update(&md5context, (unsigned char *) ">", 1);
00556   MD5_Update(&md5context, (unsigned char *) password, strlen(password));
00557 
00558   MD5_Final(digest, &md5context);
00559 
00560   for (i = 0; i < 16; i++)
00561     sprintf(digest_string + (i * 2), "%.2x", digest[i]);
00562 
00563   if (!strcmp(digest_string, remote_digest))
00564     return 1;
00565 
00566   putlog(LOG_BOTS, "*", "Response (password hash) from %s incorrect",
00567          dcc[idx].nick);
00568   return 0;
00569 }

Here is the caller graph for this function:

static void dcc_bot_digest ( int  idx,
char *  challenge,
char *  password 
) [static]

Definition at line 330 of file dcc.c.

References dprintf, LOG_BOTS, MD5_Final, MD5_Init, MD5_Update, dcc_t::nick, and putlog.

Referenced by dcc_bot_new().

00331 {
00332   MD5_CTX md5context;
00333   char digest_string[33];       /* 32 for digest in hex + null */
00334   unsigned char digest[16];
00335   int i;
00336 
00337   MD5_Init(&md5context);
00338   MD5_Update(&md5context, (unsigned char *) challenge, strlen(challenge));
00339   MD5_Update(&md5context, (unsigned char *) password, strlen(password));
00340   MD5_Final(digest, &md5context);
00341 
00342   for (i = 0; i < 16; i++)
00343     sprintf(digest_string + (i * 2), "%.2x", digest[i]);
00344   dprintf(idx, "digest %s\n", digest_string);
00345   putlog(LOG_BOTS, "*", "Received challenge from %s... sending response ...",
00346          dcc[idx].nick);
00347 }

Here is the caller graph for this function:

static void dcc_bot_new ( int  idx,
char *  buf,
int  x 
) [static]

Definition at line 349 of file dcc.c.

References bot_version(), DCC_BADPASS, dcc_bot_digest(), DCC_LINKERROR, DCC_PASSREQ, dprintf, egg_strcasecmp, get_user, get_user_by_handle, greet_new_bot(), LOG_BOTS, newsplit, putlog, and USERENTRY_PASS.

00350 {
00351   struct userrec *u = get_user_by_handle(userlist, dcc[idx].nick);
00352   char *code;
00353 
00354   code = newsplit(&buf);
00355   if (!egg_strcasecmp(code, "*hello!"))
00356     greet_new_bot(idx);
00357   else if (!egg_strcasecmp(code, "version") || !egg_strcasecmp(code, "v"))
00358     bot_version(idx, buf);
00359   else if (!egg_strcasecmp(code, "badpass"))
00360     /* We entered the wrong password */
00361     putlog(LOG_BOTS, "*", DCC_BADPASS, dcc[idx].nick);
00362   else if (!egg_strcasecmp(code, "passreq")) {
00363     char *pass = get_user(&USERENTRY_PASS, u);
00364 
00365     if (!pass || !strcmp(pass, "-")) {
00366       putlog(LOG_BOTS, "*", DCC_PASSREQ, dcc[idx].nick);
00367       dprintf(idx, "-\n");
00368     } else {
00369       /* Determine if the other end supports an MD5 digest instead of a
00370        * cleartext password. <Cybah>
00371        */
00372       if (buf && buf[0] && strchr(buf, '<') && strchr(buf + 1, '>'))
00373         dcc_bot_digest(idx, buf, pass);
00374       else
00375         dprintf(idx, "%s\n", pass);
00376     }
00377   } else if (!egg_strcasecmp(code, "error"))
00378     putlog(LOG_BOTS, "*", DCC_LINKERROR, dcc[idx].nick, buf);
00379   /* Ignore otherwise */
00380 }

Here is the call graph for this function:

static void dcc_chat ( int  idx,
char *  buf,
int  i 
) [static]

Definition at line 901 of file dcc.c.

References chat_info::away, backgrd, botnet_send_chan, botnet_send_join_idx, botnet_send_part_idx, botnetnick, chat_info::channel, chanout_but, dcc_t::chat, check_ansi, check_tcl_chat, check_tcl_chof, check_tcl_chpt(), check_tcl_dcc(), check_tcl_filt, DCC_CHAT, dcc_chatter(), DCC_CLOSED, dcc_total, DCT_CHAT, DCT_MASTER, detect_dcc_flood, DP_STDOUT, dprintf, userrec::flags, flush_lines, get_user_by_handle, GLOBAL_CHANS, killsock, LOG_MISC, lostdcc, newsplit, nfree, dcc_t::nick, not_away(), now, NULL, putlog, rmspace, STAT_ECHO, STAT_PAGE, STAT_TELNET, dcc_t::status, STDOUT, strip_telnet(), strncpyz, chat_info::su_nick, dcc_t::timeval, dcc_t::type, dcc_t::u, dcc_t::user, and USER_MASTER.

00902 {
00903   int nathan = 0, doron = 0, fixed = 0;
00904   char *v, *d, filtbuf[2048];
00905 
00906   if (dcc[idx].status & STAT_TELNET)
00907     strip_telnet(dcc[idx].sock, buf, &i);
00908   if (buf[0] && (buf[0] != '.') &&
00909       detect_dcc_flood(&dcc[idx].timeval, dcc[idx].u.chat, idx))
00910     return;
00911   dcc[idx].timeval = now;
00912   if (buf[0]) {
00913     const char *filt = check_tcl_filt(idx, buf);
00914     if (filt != buf) {
00915       strncpyz(filtbuf, filt, sizeof(filtbuf));
00916       buf = filtbuf;
00917     }
00918   }
00919   if (buf[0]) {
00920     /* Check for beeps and cancel annoying ones */
00921     v = buf;
00922     d = buf;
00923     while (*v)
00924       switch (*v) {
00925       case 7:                  /* Beep - no more than 3 */
00926         nathan++;
00927         if (nathan > 3)
00928           v++;
00929         else
00930           *d++ = *v++;
00931         break;
00932       case 8:                  /* Backspace - for lame telnet's :) */
00933         if (d > buf) {
00934           d--;
00935         }
00936         v++;
00937         break;
00938       case 27:                 /* ESC - ansi code? */
00939         doron = check_ansi(v);
00940         /* If it's valid, append a return-to-normal code at the end */
00941         if (!doron) {
00942           *d++ = *v++;
00943           fixed = 1;
00944         } else
00945           v += doron;
00946         break;
00947       case '\r':               /* Weird pseudo-linefeed */
00948         v++;
00949         break;
00950       default:
00951         *d++ = *v++;
00952       }
00953     if (fixed)
00954       strcpy(d, "\033[0m");
00955     else
00956       *d = 0;
00957     if (buf[0]) {               /* Nothing to say - maybe paging... */
00958       if ((buf[0] == '.') || (dcc[idx].u.chat->channel < 0)) {
00959         if (buf[0] == '.')
00960           buf++;
00961         v = newsplit(&buf);
00962         rmspace(buf);
00963         if (check_tcl_dcc(v, idx, buf)) {
00964           if (dcc[idx].u.chat->channel >= 0)
00965             check_tcl_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock,
00966                            dcc[idx].u.chat->channel);
00967           check_tcl_chof(dcc[idx].nick, dcc[idx].sock);
00968           dprintf(idx, "*** Ja mata!\n");
00969           flush_lines(idx, dcc[idx].u.chat);
00970           putlog(LOG_MISC, "*", DCC_CLOSED, dcc[idx].nick, dcc[idx].host);
00971           if (dcc[idx].u.chat->channel >= 0) {
00972             chanout_but(-1, dcc[idx].u.chat->channel,
00973                         "*** %s left the party line%s%s\n",
00974                         dcc[idx].nick, buf[0] ? ": " : ".", buf);
00975             if (dcc[idx].u.chat->channel < GLOBAL_CHANS)
00976               botnet_send_part_idx(idx, buf);
00977           }
00978           if (dcc[idx].u.chat->su_nick) {
00979             dcc[idx].user = get_user_by_handle(userlist,
00980                                                dcc[idx].u.chat->su_nick);
00981             strcpy(dcc[idx].nick, dcc[idx].u.chat->su_nick);
00982             dcc[idx].type = &DCC_CHAT;
00983             dprintf(idx, "Returning to real nick %s!\n",
00984                     dcc[idx].u.chat->su_nick);
00985             nfree(dcc[idx].u.chat->su_nick);
00986             dcc[idx].u.chat->su_nick = NULL;
00987             dcc_chatter(idx);
00988             if (dcc[idx].u.chat->channel < GLOBAL_CHANS &&
00989                 dcc[idx].u.chat->channel >= 0)
00990               botnet_send_join_idx(idx, -1);
00991             return;
00992           } else if ((dcc[idx].sock != STDOUT) || backgrd) {
00993             killsock(dcc[idx].sock);
00994             lostdcc(idx);
00995             return;
00996           } else {
00997             dprintf(DP_STDOUT, "\n### SIMULATION RESET\n\n");
00998             dcc_chatter(idx);
00999             return;
01000           }
01001         }
01002       } else if (buf[0] == ',') {
01003         int me = 0;
01004 
01005         if ((buf[1] == 'm') && (buf[2] == 'e') && buf[3] == ' ')
01006           me = 1;
01007         for (i = 0; i < dcc_total; i++) {
01008           int ok = 0;
01009 
01010           if ((dcc[i].type->flags & DCT_MASTER) &&
01011               ((dcc[i].type != &DCC_CHAT) || (dcc[i].u.chat->channel >= 0)) &&
01012               ((i != idx) || (dcc[idx].status & STAT_ECHO)))
01013             ok = 1;
01014           if (ok) {
01015             struct userrec *u = get_user_by_handle(userlist, dcc[i].nick);
01016 
01017             if (u && (u->flags & USER_MASTER)) {
01018               if (me)
01019                 dprintf(i, "-> %s%s\n", dcc[idx].nick, buf + 3);
01020               else
01021                 dprintf(i, "-%s-> %s\n", dcc[idx].nick, buf + 1);
01022             }
01023           }
01024         }
01025       } else if (buf[0] == '\'') {
01026         int me = 0;
01027 
01028         if ((buf[1] == 'm') && (buf[2] == 'e') &&
01029             ((buf[3] == ' ') || (buf[3] == '\'') || (buf[3] == ',')))
01030           me = 1;
01031         for (i = 0; i < dcc_total; i++) {
01032           if (dcc[i].type->flags & DCT_CHAT) {
01033             if (me)
01034               dprintf(i, "=> %s%s\n", dcc[idx].nick, buf + 3);
01035             else
01036               dprintf(i, "=%s=> %s\n", dcc[idx].nick, buf + 1);
01037           }
01038         }
01039       } else {
01040         if (dcc[idx].u.chat->away != NULL)
01041           not_away(idx);
01042         if (dcc[idx].status & STAT_ECHO)
01043           chanout_but(-1, dcc[idx].u.chat->channel,
01044                       "<%s> %s\n", dcc[idx].nick, buf);
01045         else
01046           chanout_but(idx, dcc[idx].u.chat->channel, "<%s> %s\n",
01047                       dcc[idx].nick, buf);
01048         botnet_send_chan(-1, botnetnick, dcc[idx].nick,
01049                          dcc[idx].u.chat->channel, buf);
01050         check_tcl_chat(dcc[idx].nick, dcc[idx].u.chat->channel, buf);
01051       }
01052     }
01053   }
01054   if (dcc[idx].type == &DCC_CHAT)       /* Could have change to files */
01055     if (dcc[idx].status & STAT_PAGE)
01056       flush_lines(idx, dcc[idx].u.chat);
01057 }

Here is the call graph for this function:

static void dcc_chat_pass ( int  idx,
char *  buf,
int  atr 
) [static]

Definition at line 571 of file dcc.c.

References chat_info::away, dcc_t::bot, botnet_send_join_idx, chat_info::channel, chanout_but, dcc_t::chat, chat_info::con_flags, conmask, DCC_BADLOGIN, dcc_bot_check_digest(), DCC_CHAT, dcc_chatter(), DCC_HOUSTON, DCC_JOIN, DCC_LOGGEDIN, detect_telnet(), dprintf, egg_strncasecmp, userrec::flags, get_data_ptr, get_user_by_handle, GLOBAL_CHANS, greet_new_bot(), killsock, LOG_MISC, lostdcc, nfree, dcc_t::nick, NULL, putlog, STAT_CALLED, STAT_CHAT, STAT_TELNET, dcc_t::status, strip_telnet(), chat_info::su_nick, TLN_ECHO_C, TLN_IAC_C, TLN_WONT_C, tputs, dcc_t::type, dcc_t::u, u_pass_match, user, dcc_t::user, USER_BOT, and USER_MASTER.

00572 {
00573   if (!atr)
00574     return;
00575   if (dcc[idx].status & STAT_TELNET)
00576     strip_telnet(dcc[idx].sock, buf, &atr);
00577   else if (detect_telnet((unsigned char *) buf))
00578     buf += 3; /* 'IAC','DO(DONT)','STATUS' */
00579   atr = dcc[idx].user ? dcc[idx].user->flags : 0;
00580 
00581   /* Check for MD5 digest from remote _bot_. <cybah> */
00582   if ((atr & USER_BOT) && !egg_strncasecmp(buf, "digest ", 7)) {
00583     if (dcc_bot_check_digest(idx, buf + 7)) {
00584       nfree(dcc[idx].u.chat);
00585       dcc[idx].type = &DCC_BOT_NEW;
00586       dcc[idx].u.bot = get_data_ptr(sizeof(struct bot_info));
00587       dcc[idx].status = STAT_CALLED;
00588       dprintf(idx, "*hello!\n");
00589       greet_new_bot(idx);
00590       return;
00591     } else {
00592       /* Invalid password/digest */
00593       dprintf(idx, "badpass\n");
00594       putlog(LOG_MISC, "*", DCC_BADLOGIN, dcc[idx].nick, dcc[idx].host,
00595              dcc[idx].port);
00596       killsock(dcc[idx].sock);
00597       lostdcc(idx);
00598       return;
00599     }
00600   }
00601 
00602   if (u_pass_match(dcc[idx].user, buf)) {
00603     if (atr & USER_BOT) {
00604       nfree(dcc[idx].u.chat);
00605       dcc[idx].type = &DCC_BOT_NEW;
00606       dcc[idx].u.bot = get_data_ptr(sizeof(struct bot_info));
00607 
00608       dcc[idx].status = STAT_CALLED;
00609       dprintf(idx, "*hello!\n");
00610       greet_new_bot(idx);
00611     } else {
00612       /* Log entry for successful login -slennox 3/28/1999 */
00613       putlog(LOG_MISC, "*", DCC_LOGGEDIN, dcc[idx].nick,
00614              dcc[idx].host, dcc[idx].port);
00615       if (dcc[idx].u.chat->away) {
00616         nfree(dcc[idx].u.chat->away);
00617         dcc[idx].u.chat->away = NULL;
00618       }
00619       dcc[idx].type = &DCC_CHAT;
00620       dcc[idx].status &= ~STAT_CHAT;
00621       dcc[idx].u.chat->con_flags = (atr & USER_MASTER) ? conmask : 0;
00622       dcc[idx].u.chat->channel = -2;
00623       /* Turn echo back on for telnet sessions (send IAC WON'T ECHO). */
00624       if (dcc[idx].status & STAT_TELNET)
00625         tputs(dcc[idx].sock, TLN_IAC_C TLN_WONT_C TLN_ECHO_C "\n", 4);
00626       dcc_chatter(idx);
00627     }
00628   } else {
00629     if (atr & USER_BOT)
00630       dprintf(idx, "badpass\n");
00631     else
00632       dprintf(idx, DCC_HOUSTON);
00633     putlog(LOG_MISC, "*", DCC_BADLOGIN, dcc[idx].nick,
00634            dcc[idx].host, dcc[idx].port);
00635     if (dcc[idx].u.chat->away) {        /* su from a dumb user */
00636       /* Turn echo back on for telnet sessions (send IAC WON'T ECHO). */
00637       if (dcc[idx].status & STAT_TELNET)
00638         tputs(dcc[idx].sock, TLN_IAC_C TLN_WONT_C TLN_ECHO_C "\n", 4);
00639       dcc[idx].user = get_user_by_handle(userlist, dcc[idx].u.chat->away);
00640       strcpy(dcc[idx].nick, dcc[idx].u.chat->away);
00641       nfree(dcc[idx].u.chat->away);
00642       nfree(dcc[idx].u.chat->su_nick);
00643       dcc[idx].u.chat->away = NULL;
00644       dcc[idx].u.chat->su_nick = NULL;
00645       dcc[idx].type = &DCC_CHAT;
00646       if (dcc[idx].u.chat->channel < GLOBAL_CHANS)
00647         botnet_send_join_idx(idx, -1);
00648       chanout_but(-1, dcc[idx].u.chat->channel, DCC_JOIN, dcc[idx].nick);
00649     } else {
00650       killsock(dcc[idx].sock);
00651       lostdcc(idx);
00652     }
00653   }
00654 }

Here is the call graph for this function:

static void dcc_dupwait ( int  idx,
char *  buf,
int  i 
) [static]

Definition at line 1278 of file dcc.c.

01279 {
01280   /* We just ignore any data at this point. */
01281   return;
01282 }

void dcc_ident ( int  idx,
char *  buf,
int  len 
)

Definition at line 1984 of file dcc.c.

References dcc_telnet_got_ident(), dcc_total, dcc_t::ident_sock, killsock, lostdcc, now, dcc_t::other, rmspace, simple_sprintf, dcc_t::timeval, dcc_t::u, and UHOSTLEN.

01985 {
01986   char response[512], uid[512], buf1[UHOSTLEN];
01987   int i;
01988 
01989   *response = *uid = '\0';
01990   sscanf(buf, "%*[^:]:%[^:]:%*[^:]:%[^\n]\n", response, uid);
01991   rmspace(response);
01992   if (response[0] != 'U') {
01993     dcc[idx].timeval = now;
01994     return;
01995   }
01996   rmspace(uid);
01997   uid[20] = 0;                  /* 20 character ident max */
01998   for (i = 0; i < dcc_total; i++)
01999     if ((dcc[i].type == &DCC_IDENTWAIT) &&
02000         (dcc[i].sock == dcc[idx].u.ident_sock)) {
02001       simple_sprintf(buf1, "%s@%s", uid, dcc[idx].host);
02002       dcc_telnet_got_ident(i, buf1);
02003     }
02004   dcc[idx].u.other = 0;
02005   killsock(dcc[idx].sock);
02006   lostdcc(idx);
02007 }

Here is the call graph for this function:

void dcc_identwait ( int  idx,
char *  buf,
int  len 
)

Definition at line 1940 of file dcc.c.

01941 {
01942   /* Ignore anything now */
01943 }

static void dcc_script ( int  idx,
char *  buf,
int  len 
) [static]

Definition at line 1777 of file dcc.c.

References botnet_send_join_idx, botnetnick, call_tcl_func(), chat_info::channel, chanout_but, dcc_t::chat, check_tcl_chjn, check_tcl_chon, script_info::command, DCC_JOIN, DCC_SOCKET, geticon, killsock, lostdcc, max_dcc, nfree, dcc_t::nick, now, NULL, dcc_t::other, script_info::other, dcc_t::script, dcc_t::sock, STAT_TELNET, strip_telnet(), dcc_t::timeval, script_info::type, dcc_t::type, script_info::u, and dcc_t::u.

01778 {
01779   long oldsock;
01780 
01781   if (dcc[idx].status & STAT_TELNET)
01782     strip_telnet(dcc[idx].sock, buf, &len);
01783   if (!len)
01784     return;
01785 
01786   dcc[idx].timeval = now;
01787   oldsock = dcc[idx].sock;      /* Remember the socket number.  */
01788   if (call_tcl_func(dcc[idx].u.script->command, dcc[idx].sock, buf)) {
01789     void *old_other = NULL;
01790 
01791     /* Check whether the socket and dcc entry are still valid. They
01792      * might have been killed by `killdcc'. */
01793     if (dcc[idx].sock != oldsock || idx > max_dcc)
01794       return;
01795 
01796     old_other = dcc[idx].u.script->u.other;
01797     dcc[idx].type = dcc[idx].u.script->type;
01798     nfree(dcc[idx].u.script);
01799     dcc[idx].u.other = old_other;
01800     if (dcc[idx].type == &DCC_SOCKET) {
01801       /* Kill the whole thing off */
01802       killsock(dcc[idx].sock);
01803       lostdcc(idx);
01804       return;
01805     }
01806     if (dcc[idx].type == &DCC_CHAT) {
01807       if (dcc[idx].u.chat->channel >= 0) {
01808         chanout_but(-1, dcc[idx].u.chat->channel, DCC_JOIN, dcc[idx].nick);
01809         if (dcc[idx].u.chat->channel < 10000)
01810           botnet_send_join_idx(idx, -1);
01811         check_tcl_chjn(botnetnick, dcc[idx].nick, dcc[idx].u.chat->channel,
01812                        geticon(idx), dcc[idx].sock, dcc[idx].host);
01813       }
01814       check_tcl_chon(dcc[idx].nick, dcc[idx].sock);
01815     }
01816   }
01817 }

Here is the call graph for this function:

static void dcc_socket ( int  idx,
char *  buf,
int  len 
) [static]

Definition at line 1894 of file dcc.c.

01895 {
01896 }

static void dcc_telnet ( int  idx,
char *  buf,
int  i 
) [static]

Definition at line 1124 of file dcc.c.

References dcc_t::addr, answer, DCC_BADSRC, dcc_dnshostbyip, DCC_DNSWAIT, DCC_FAILED, DCC_IDENTWAIT, dcc_telnet_hostresolved(), dcc_total, dcc_t::dns, dns_info::dns_failure, dns_info::dns_success, dns_info::dns_type, dprintf, EGG_OPTION_SET, dns_info::ibuf, increase_socks_max, dns_info::ip, killsock, LOG_BOTS, LOG_MISC, max_dcc, neterror, new_dcc, now, dcc_t::port, putlog, RES_HOSTBYIP, dcc_t::sock, SOCK_BUFFER, sockoptions, dcc_t::timeval, dns_info::type, dcc_t::u, and UHOSTLEN.

01125 {
01126   unsigned long ip;
01127   unsigned short port;
01128   int j = 0, sock;
01129   char s[UHOSTLEN + 1];
01130 
01131   if (dcc_total + 1 > max_dcc && increase_socks_max()) {
01132     j = answer(dcc[idx].sock, s, &ip, &port, 0);
01133     if (j != -1) {
01134       dprintf(-j, "Sorry, too many connections already.\r\n");
01135       killsock(j);
01136     }
01137     return;
01138   }
01139   sock = answer(dcc[idx].sock, s, &ip, &port, 0);
01140   while ((sock == -1) && (errno == EAGAIN))
01141     sock = answer(sock, s, &ip, &port, 0);
01142   if (sock < 0) {
01143     neterror(s);
01144     putlog(LOG_MISC, "*", DCC_FAILED, s);
01145     return;
01146   }
01147   /* Buffer data received on this socket.  */
01148   sockoptions(sock, EGG_OPTION_SET, SOCK_BUFFER);
01149 
01150 #if (SIZEOF_SHORT == 2)
01151   if (port < 1024) {
01152 #else
01153   if (port < 1024 || port > 65535) {
01154 #endif
01155     putlog(LOG_BOTS, "*", DCC_BADSRC, s, port);
01156     killsock(sock);
01157     return;
01158   }
01159 
01160   i = new_dcc(&DCC_DNSWAIT, sizeof(struct dns_info));
01161   dcc[i].sock = sock;
01162   dcc[i].addr = ip;
01163   dcc[i].port = port;
01164   dcc[i].timeval = now;
01165   strcpy(dcc[i].nick, "*");
01166   dcc[i].u.dns->ip = ip;
01167   dcc[i].u.dns->dns_success = dcc_telnet_hostresolved;
01168   dcc[i].u.dns->dns_failure = dcc_telnet_hostresolved;
01169   dcc[i].u.dns->dns_type = RES_HOSTBYIP;
01170   dcc[i].u.dns->ibuf = dcc[idx].sock;
01171   dcc[i].u.dns->type = &DCC_IDENTWAIT;
01172   dcc_dnshostbyip(ip);
01173 }

Here is the call graph for this function:

static void dcc_telnet_got_ident ( int  i,
char *  host 
) [static]

Definition at line 2044 of file dcc.c.

References allow_new_telnets, dcc_t::chat, check_tcl_listen(), chat_info::con_chan, DCC_LOSTIDENT, DCC_NOACCESS, dcc_total, chanset_t::dname, dprintf, egg_bzero, EGG_OPTION_UNSET, egg_snprintf, userrec::flags, get_data_ptr, get_user_by_host, HANDLEN, dcc_t::ident_sock, killsock, LOG_MISC, lostdcc, LSTN_PUBLIC, make_userfile, match_ignore, MISC_BANNER, MISC_BANNER_STEALTH, now, NULL, dcc_t::other, protect_telnet, putlog, require_p, show_banner(), SOCK_BUFFER, sockoptions, STAT_BOTONLY, STAT_ECHO, STAT_TELNET, STAT_USRONLY, dcc_t::status, stealth_telnets, strncpyz, sub_lang, dcc_t::timeval, TLN_IAC_C, TLN_STATUS_C, TLN_WILL_C, dcc_t::type, dcc_t::u, UHOSTLEN, use_telnet_banner, USER_BOT, USER_OP, and USER_PARTY.

Referenced by dcc_ident(), dcc_telnet_hostresolved(), and eof_dcc_ident().

02045 {
02046   int idx;
02047   char x[1024];
02048 
02049   for (idx = 0; idx < dcc_total; idx++)
02050     if ((dcc[idx].type == &DCC_TELNET) &&
02051         (dcc[idx].sock == dcc[i].u.ident_sock))
02052       break;
02053   dcc[i].u.other = 0;
02054   if (dcc_total == idx) {
02055     putlog(LOG_MISC, "*", DCC_LOSTIDENT);
02056     killsock(dcc[i].sock);
02057     lostdcc(i);
02058     return;
02059   }
02060   strncpyz(dcc[i].host, host, UHOSTLEN);
02061   egg_snprintf(x, sizeof x, "-telnet!%s", dcc[i].host);
02062   if (protect_telnet && !make_userfile) {
02063     struct userrec *u;
02064     int ok = 1;
02065 
02066     u = get_user_by_host(x);
02067     /* Not a user or +p & require p OR +o */
02068     if (!u)
02069       ok = 0;
02070     else if (require_p && !(u->flags & USER_PARTY))
02071       ok = 0;
02072     else if (!require_p && !(u->flags & USER_OP))
02073       ok = 0;
02074     if (!ok && u && (u->flags & USER_BOT))
02075       ok = 1;
02076     if (!ok && (dcc[idx].status & LSTN_PUBLIC))
02077       ok = 1;
02078     if (!ok) {
02079       putlog(LOG_MISC, "*", DCC_NOACCESS, dcc[i].host);
02080       killsock(dcc[i].sock);
02081       lostdcc(i);
02082       return;
02083     }
02084   }
02085   if (match_ignore(x)) {
02086     killsock(dcc[i].sock);
02087     lostdcc(i);
02088     return;
02089   }
02090   /* Script? */
02091   if (!strcmp(dcc[idx].nick, "(script)")) {
02092     dcc[i].type = &DCC_SOCKET;
02093     dcc[i].u.other = NULL;
02094     strcpy(dcc[i].nick, "*");
02095     check_tcl_listen(dcc[idx].host, dcc[i].sock);
02096     return;
02097   }
02098   /* Do not buffer data anymore. All received and stored data is passed
02099    * over to the dcc functions from now on.  */
02100   sockoptions(dcc[i].sock, EGG_OPTION_UNSET, SOCK_BUFFER);
02101 
02102   dcc[i].type = &DCC_TELNET_ID;
02103   dcc[i].u.chat = get_data_ptr(sizeof(struct chat_info));
02104   egg_bzero(dcc[i].u.chat, sizeof(struct chat_info));
02105 
02106   /* Note: we don't really care about telnet status here. We use the
02107    * STATUS option as a hopefully harmless way to detect if the other
02108    * side is a telnet client or not. */
02109   dprintf(i, TLN_IAC_C TLN_WILL_C TLN_STATUS_C "\n");
02110 
02111   /* Copy acceptable-nick/host mask */
02112   dcc[i].status = STAT_TELNET | STAT_ECHO;
02113   if (!strcmp(dcc[idx].nick, "(bots)"))
02114     dcc[i].status |= STAT_BOTONLY;
02115   if (!strcmp(dcc[idx].nick, "(users)"))
02116     dcc[i].status |= STAT_USRONLY;
02117   /* Copy acceptable-nick/host mask */
02118   strncpyz(dcc[i].nick, dcc[idx].host, HANDLEN);
02119   dcc[i].timeval = now;
02120   strcpy(dcc[i].u.chat->con_chan, chanset ? chanset->dname : "*");
02121   /* Displays a customizable banner. */
02122   if (use_telnet_banner)
02123     show_banner(i);
02124   /* This is so we dont tell someone doing a portscan anything
02125    * about ourselves. <cybah>
02126    */
02127   if (stealth_telnets)
02128     sub_lang(i, MISC_BANNER_STEALTH);
02129   else {
02130     dprintf(i, "\n\n");
02131     sub_lang(i, MISC_BANNER);
02132   }
02133   if (allow_new_telnets)
02134     dprintf(i, "(If you are new, enter 'NEW' here.)\n");
02135 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void dcc_telnet_hostresolved ( int  i  )  [static]

Definition at line 1175 of file dcc.c.

References dcc_t::addr, changeover_dcc, DCC_BADHOST, DCC_IDENT, DCC_IDENTFAIL, DCC_IDENTWAIT, DCC_TELCONN, DCC_TELNET, dcc_telnet_got_ident(), dcc_total, detect_telnet_flood(), dcc_t::dns, dprintf, dns_info::host, dns_info::ibuf, dcc_t::ident_sock, iptostr, killsock, LOG_BOTS, LOG_MISC, lostdcc, match_ignore, neterror, new_dcc, now, open_telnet, dcc_t::port, putlog, dcc_t::sock, strncpyz, dcc_t::timeval, dcc_t::u, UHOSTLEN, and wild_match.

Referenced by dcc_telnet().

01176 {
01177   int idx;
01178   int j = 0, sock;
01179   char s[UHOSTLEN], s2[UHOSTLEN + 20];
01180 
01181   strncpyz(dcc[i].host, dcc[i].u.dns->host, UHOSTLEN);
01182 
01183   for (idx = 0; idx < dcc_total; idx++)
01184     if ((dcc[idx].type == &DCC_TELNET) &&
01185         (dcc[idx].sock == dcc[i].u.dns->ibuf)) {
01186       break;
01187     }
01188   if (dcc_total == idx) {
01189     putlog(LOG_BOTS, "*", "Lost listening socket while resolving %s",
01190            dcc[i].host);
01191     killsock(dcc[i].sock);
01192     lostdcc(i);
01193     return;
01194   }
01195   if (dcc[idx].host[0] == '@') {
01196     /* Restrict by hostname */
01197     if (!wild_match(dcc[idx].host + 1, dcc[i].host)) {
01198       putlog(LOG_BOTS, "*", DCC_BADHOST, dcc[i].host);
01199       killsock(dcc[i].sock);
01200       lostdcc(i);
01201       return;
01202     }
01203   }
01204   sprintf(s2, "-telnet!telnet@%s", dcc[i].host);
01205   if (match_ignore(s2) || detect_telnet_flood(s2)) {
01206     killsock(dcc[i].sock);
01207     lostdcc(i);
01208     return;
01209   }
01210 
01211   changeover_dcc(i, &DCC_IDENTWAIT, 0);
01212   dcc[i].timeval = now;
01213   dcc[i].u.ident_sock = dcc[idx].sock;
01214   sock = open_telnet(iptostr(htonl(dcc[i].addr)), 113);
01215   putlog(LOG_MISC, "*", DCC_TELCONN, dcc[i].host, dcc[i].port);
01216   s[0] = 0;
01217   if (sock < 0) {
01218     if (sock == -2)
01219       strcpy(s, "DNS lookup failed for ident");
01220     else
01221       neterror(s);
01222   } else {
01223     j = new_dcc(&DCC_IDENT, 0);
01224     if (j < 0) {
01225       killsock(sock);
01226       strcpy(s, "No Free DCC's");
01227     }
01228   }
01229   if (s[0]) {
01230     putlog(LOG_MISC, "*", DCC_IDENTFAIL, dcc[i].host, s);
01231     sprintf(s, "telnet@%s", dcc[i].host);
01232     dcc_telnet_got_ident(i, s);
01233     return;
01234   }
01235   dcc[j].sock = sock;
01236   dcc[j].port = 113;
01237   dcc[j].addr = dcc[i].addr;
01238   strcpy(dcc[j].host, dcc[i].host);
01239   strcpy(dcc[j].nick, "*");
01240   dcc[j].u.ident_sock = dcc[i].sock;
01241   dcc[j].timeval = now;
01242   dprintf(j, "%d, %d\n", dcc[i].port, dcc[idx].port);
01243 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void dcc_telnet_id ( int  idx,
char *  buf,
int  atr 
) [static]

Definition at line 1360 of file dcc.c.

References allow_new_telnets, dupwait_info::atr, botnetnick, chan_op, dupwait_info::chat, dcc_t::chat, correct_handle(), DCC_BADNICK, DCC_INVHANDLE, DCC_MYBOTNETNICK, DCC_NONBOT, DCC_NONUSER, DCC_TELNET_NEW, dcc_telnet_pass(), detect_telnet(), dprintf, dcc_t::dupwait, egg_strcasecmp, FR_ANYWH, FR_CHAN, FR_GLOBAL, get_data_ptr, get_user_by_handle, get_user_flagrec, glob_bot, glob_party, HANDLEN, in_chain, IRC_TELNET, IRC_TELNET1, killsock, LOG_BOTS, lostdcc, make_userfile, now, NULL, putlog, require_p, STAT_BOTONLY, STAT_TELNET, STAT_USRONLY, dcc_t::status, strip_telnet(), dcc_t::timeval, dcc_t::type, dcc_t::u, user, dcc_t::user, and wild_match.

01361 {
01362   int ok = 0;
01363   struct flag_record fr = { FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0 };
01364 
01365   if (detect_telnet((unsigned char *) buf)) {
01366     dcc[idx].status |= STAT_TELNET;
01367     strip_telnet(dcc[idx].sock, buf, &atr);
01368   } else
01369     dcc[idx].status &= ~STAT_TELNET;
01370   buf[HANDLEN] = 0;
01371   /* Toss out bad nicknames */
01372   if (dcc[idx].nick[0] != '@' && !wild_match(dcc[idx].nick, buf)) {
01373     dprintf(idx, "Sorry, that nickname format is invalid.\n");
01374     putlog(LOG_BOTS, "*", DCC_BADNICK, dcc[idx].host);
01375     killsock(dcc[idx].sock);
01376     lostdcc(idx);
01377     return;
01378   }
01379   dcc[idx].user = get_user_by_handle(userlist, buf);
01380   get_user_flagrec(dcc[idx].user, &fr, NULL);
01381   /* Make sure users-only/bots-only connects are honored */
01382   if ((dcc[idx].status & STAT_BOTONLY) && !glob_bot(fr)) {
01383     dprintf(idx, "This telnet port is for bots only.\n");
01384     putlog(LOG_BOTS, "*", DCC_NONBOT, dcc[idx].host);
01385     killsock(dcc[idx].sock);
01386     lostdcc(idx);
01387     return;
01388   }
01389   if ((dcc[idx].status & STAT_USRONLY) && glob_bot(fr)) {
01390     dprintf(idx, "error Only users may connect at this port.\n");
01391     putlog(LOG_BOTS, "*", DCC_NONUSER, dcc[idx].host);
01392     killsock(dcc[idx].sock);
01393     lostdcc(idx);
01394     return;
01395   }
01396   dcc[idx].status &= ~(STAT_BOTONLY | STAT_USRONLY);
01397   if (!egg_strcasecmp(buf, "NEW") && (allow_new_telnets || make_userfile)) {
01398     dcc[idx].type = &DCC_TELNET_NEW;
01399     dcc[idx].timeval = now;
01400     dprintf(idx, "\n");
01401     dprintf(idx, IRC_TELNET, botnetnick);
01402     dprintf(idx, IRC_TELNET1);
01403     dprintf(idx, "\nEnter the nickname you would like to use.\n");
01404     return;
01405   }
01406   if (chan_op(fr)) {
01407     if (!require_p)
01408       ok = 1;
01409   }
01410   if (!ok && (glob_party(fr) || glob_bot(fr)))
01411     ok = 1;
01412 
01413   if (!ok) {
01414     dprintf(idx, "You don't have access.\n");
01415     putlog(LOG_BOTS, "*", DCC_INVHANDLE, dcc[idx].host, buf);
01416     killsock(dcc[idx].sock);
01417     lostdcc(idx);
01418     return;
01419   }
01420   correct_handle(buf);
01421   strcpy(dcc[idx].nick, buf);
01422   if (glob_bot(fr)) {
01423     if (!egg_strcasecmp(botnetnick, dcc[idx].nick)) {
01424       dprintf(idx, "error You cannot link using my botnetnick.\n");
01425       putlog(LOG_BOTS, "*", DCC_MYBOTNETNICK, dcc[idx].host);
01426       killsock(dcc[idx].sock);
01427       lostdcc(idx);
01428       return;
01429     } else if (in_chain(dcc[idx].nick)) {
01430       struct chat_info *ci;
01431 
01432       ci = dcc[idx].u.chat;
01433       dcc[idx].type = &DCC_DUPWAIT;
01434       dcc[idx].u.dupwait = get_data_ptr(sizeof(struct dupwait_info));
01435       dcc[idx].u.dupwait->chat = ci;
01436       dcc[idx].u.dupwait->atr = atr;
01437       return;
01438     }
01439   }
01440   dcc_telnet_pass(idx, atr);
01441 }

Here is the call graph for this function:

static void dcc_telnet_new ( int  idx,
char *  buf,
int  x 
) [static]

Definition at line 1574 of file dcc.c.

References add_note, adduser, BADHANDCHARS, botnetnick, check_dcc_attrs, DCC_INSTCOMPL, DCC_TELNET_PW, default_flags, dprintf, egg_strcasecmp, get_user_by_handle, HANDLEN, IRC_LIMBO, LOG_MISC, make_userfile, now, NULL, putlog, reaffirm_owners, sanity_check, simple_sprintf, STAT_ECHO, STAT_TELNET, dcc_t::status, strip_telnet(), dcc_t::timeval, dcc_t::type, user, dcc_t::user, USER_MASTER, USER_OWNER, USER_PARTY, and write_userfile.

01575 {
01576   int ok = 1;
01577   char work[1024], *p, *q, *r;
01578 
01579   buf[HANDLEN] = 0;
01580   if (dcc[idx].status & STAT_TELNET)
01581     strip_telnet(dcc[idx].sock, buf, &x);
01582   dcc[idx].timeval = now;
01583   for (x = 0; x < strlen(buf); x++)
01584     if (buf[x] <= 32)
01585       ok = 0;
01586   if (!ok) {
01587     dprintf(idx, "\nYou can't use weird symbols in your nick.\n");
01588     dprintf(idx, "Try another one please:\n");
01589   } else if (strchr(BADHANDCHARS, buf[0]) != NULL) {
01590     dprintf(idx, "\nYou can't start your nick with the character '%c'\n",
01591             buf[0]);
01592     dprintf(idx, "Try another one please:\n");
01593   } else if (get_user_by_handle(userlist, buf)) {
01594     dprintf(idx, "\nSorry, that nickname is taken already.\n");
01595     dprintf(idx, "Try another one please:\n");
01596     return;
01597   } else if (!egg_strcasecmp(buf, botnetnick))
01598     dprintf(idx, "Sorry, can't use my name for a nick.\n");
01599   else {
01600     strcpy(dcc[idx].nick, buf);
01601     if (make_userfile)
01602       userlist = adduser(userlist,
01603                  buf, "-telnet!*@*", "-", sanity_check(default_flags |
01604                  USER_PARTY | USER_MASTER | USER_OWNER));
01605     else {
01606       p = strchr(dcc[idx].host, '@');
01607       if (p) {
01608         q = p;
01609         *q = 0;
01610         p++;
01611         r = strchr(p, '.');
01612         if (!r)
01613           simple_sprintf(work, "-telnet!%s@%s", dcc[idx].host, p);
01614         else
01615           simple_sprintf(work, "-telnet!%s@*%s", dcc[idx].host, r);
01616         *q = '@';
01617       } else
01618         simple_sprintf(work, "-telnet!*@*%s", dcc[idx].host);
01619       userlist = adduser(userlist, buf, work, "-",
01620                          sanity_check(USER_PARTY | default_flags));
01621     }
01622     reaffirm_owners();
01623     dcc[idx].status = STAT_ECHO | STAT_TELNET;
01624     dcc[idx].type = &DCC_CHAT;  /* Just so next line will work */
01625     dcc[idx].user = get_user_by_handle(userlist, buf);
01626     check_dcc_attrs(dcc[idx].user, USER_PARTY | default_flags);
01627     dcc[idx].type = &DCC_TELNET_PW;
01628     if (make_userfile) {
01629       dprintf(idx, "\nYOU ARE THE MASTER/OWNER ON THIS BOT NOW\n");
01630       dprintf(idx, IRC_LIMBO);
01631       putlog(LOG_MISC, "*", DCC_INSTCOMPL, buf);
01632       make_userfile = 0;
01633       write_userfile(-1);
01634       add_note(buf, botnetnick, "Welcome to eggdrop! :)", -1, 0);
01635     }
01636     dprintf(idx, "\nOkay, now choose and enter a password:\n");
01637     dprintf(idx, "(Only the first 15 letters are significant.)\n");
01638   }
01639 }

Here is the call graph for this function:

static void dcc_telnet_pass ( int  idx,
int  atr 
) [static]

Definition at line 1443 of file dcc.c.

References botnetnick, chan_op, changeover_dcc, file_info::chat, dcc_t::chat, dupwait_info::chat, DCC_ENTERPASS, DCC_NOPASS, dprintf, dcc_t::dupwait, escape_telnet(), dcc_t::file, FR_ANYWH, FR_CHAN, FR_GLOBAL, get_data_ptr, get_user_flagrec, glob_bot, glob_botmast, glob_party, greet_new_bot(), killsock, LOG_BOTS, LOG_MISC, lostdcc, makepass, nfree, now, NULL, putlog, require_p, set_user, STAT_CALLED, STAT_PARTY, STAT_TELNET, dcc_t::status, dcc_t::timeval, TLN_ECHO_C, TLN_IAC_C, TLN_WILL_C, tputs, dcc_t::type, dcc_t::u, u_pass_match, user, and USERENTRY_PASS.

Referenced by dcc_telnet_id(), dupwait_notify(), and timeout_dupwait().

01444 {
01445   int ok = 0;
01446   struct flag_record fr = { FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0 };
01447 
01448   get_user_flagrec(dcc[idx].user, &fr, NULL);
01449   /* No password set? */
01450   if (u_pass_match(dcc[idx].user, "-")) {
01451     if (glob_bot(fr)) {
01452       char ps[20];
01453 
01454       makepass(ps);
01455       set_user(&USERENTRY_PASS, dcc[idx].user, ps);
01456       changeover_dcc(idx, &DCC_BOT_NEW, sizeof(struct bot_info));
01457 
01458       dcc[idx].status = STAT_CALLED;
01459       dprintf(idx, "*hello!\n");
01460       greet_new_bot(idx);
01461 #ifdef NO_OLD_BOTNET
01462       dprintf(idx, "h %s\n", ps);
01463 #else
01464       dprintf(idx, "handshake %s\n", ps);
01465 #endif
01466       return;
01467     }
01468     dprintf(idx, "Can't telnet until you have a password set.\n");
01469     putlog(LOG_MISC, "*", DCC_NOPASS, dcc[idx].nick, dcc[idx].host);
01470     killsock(dcc[idx].sock);
01471     lostdcc(idx);
01472     return;
01473   }
01474   ok = 0;
01475   if (dcc[idx].type == &DCC_DUPWAIT) {
01476     struct chat_info *ci;
01477 
01478     ci = dcc[idx].u.dupwait->chat;
01479     nfree(dcc[idx].u.dupwait);
01480     dcc[idx].u.chat = ci;
01481   }
01482   dcc[idx].type = &DCC_CHAT_PASS;
01483   dcc[idx].timeval = now;
01484   if (glob_botmast(fr))
01485     ok = 1;
01486   else if (chan_op(fr)) {
01487     if (!require_p)
01488       ok = 1;
01489     else if (glob_party(fr))
01490       ok = 1;
01491   } else if (glob_party(fr)) {
01492     ok = 1;
01493     dcc[idx].status |= STAT_PARTY;
01494   }
01495   if (glob_bot(fr))
01496     ok = 1;
01497   if (!ok) {
01498     struct chat_info *ci;
01499 
01500     ci = dcc[idx].u.chat;
01501     dcc[idx].u.file = get_data_ptr(sizeof(struct file_info));
01502     dcc[idx].u.file->chat = ci;
01503   }
01504 
01505   if (glob_bot(fr)) {
01506     /* Must generate a string consisting of our process ID and the current
01507      * time. The bot will add it's password to the end and use it to generate
01508      * an MD5 checksum (always 128bit). The checksum is sent back and this
01509      * end does the same. The remote bot is only allowed access if the
01510      * checksums match.
01511      *
01512      * Please don't fuck with 'timeval', or the digest we generate later for
01513      * authentication will not be correct - you've been warned ;)
01514      * <Cybah>
01515      */
01516     putlog(LOG_BOTS, "*", "Challenging %s...", dcc[idx].nick);
01517     dprintf(idx, "passreq <%x%x@%s>\n", getpid(), dcc[idx].timeval, botnetnick);
01518   } else {
01519     /* NOTE: The MD5 digest used above to prevent cleartext passwords being
01520      *       sent across the net will _only_ work when we have the cleartext
01521      *       password. User passwords are encrypted (with blowfish usually)
01522      *       so the same thing cant be done. Botnet passwords are always
01523      *       stored in cleartext, or at least something that can be reversed.
01524      *       <Cybah>
01525      */
01526 
01527     /* Turn off remote telnet echo (send IAC WILL ECHO). */
01528     if (dcc[idx].status & STAT_TELNET) {
01529       char buf[1030];
01530       snprintf(buf, sizeof buf, "\n%s%s\r\n", escape_telnet(DCC_ENTERPASS),
01531                TLN_IAC_C TLN_WILL_C TLN_ECHO_C);
01532       tputs(dcc[idx].sock, buf, strlen(buf));
01533     } else
01534       dprintf(idx, "\n%s\n", DCC_ENTERPASS);
01535   }
01536 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void dcc_telnet_pw ( int  idx,
char *  buf,
int  x 
) [static]

Definition at line 1641 of file dcc.c.

References add_note, botnetnick, chat_info::channel, dcc_t::chat, dcc_chatter(), DCC_NEWUSER, dprintf, LOG_MISC, newsplit, notify_new, putlog, rmspace, set_user, splitc, STAT_TELNET, strip_telnet(), dcc_t::type, dcc_t::u, user, and USERENTRY_PASS.

01642 {
01643   char *newpass;
01644   int ok;
01645 
01646   if (dcc[idx].status & STAT_TELNET)
01647     strip_telnet(dcc[idx].sock, buf, &x);
01648   buf[16] = 0;
01649   ok = 1;
01650   if (strlen(buf) < 4) {
01651     dprintf(idx, "\nTry to use at least 4 characters in your password.\n");
01652     dprintf(idx, "Choose and enter a password:\n");
01653     return;
01654   }
01655   for (x = 0; x < strlen(buf); x++)
01656     if ((buf[x] <= 32) || (buf[x] == 127))
01657       ok = 0;
01658   if (!ok) {
01659     dprintf(idx, "\nYou can't use weird symbols in your password.\n");
01660     dprintf(idx, "Try another one please:\n");
01661     return;
01662   }
01663   putlog(LOG_MISC, "*", DCC_NEWUSER, dcc[idx].nick, dcc[idx].host,
01664          dcc[idx].port);
01665   if (notify_new[0]) {
01666     char s[121], s1[121], s2[121];
01667 
01668     sprintf(s, "Introduced to %s, %s", dcc[idx].nick, dcc[idx].host);
01669     strcpy(s1, notify_new);
01670     splitc(s2, s1, ',');
01671     while (s2[0]) {
01672       rmspace(s2);
01673       add_note(s2, botnetnick, s, -1, 0);
01674       splitc(s2, s1, ',');
01675     }
01676     rmspace(s1);
01677     add_note(s1, botnetnick, s, -1, 0);
01678   }
01679   newpass = newsplit(&buf);
01680   set_user(&USERENTRY_PASS, dcc[idx].user, newpass);
01681   dprintf(idx, "\nRemember that!  You'll need it next time you log in.\n");
01682   dprintf(idx, "You now have an account on %s...\n\n\n", botnetnick);
01683   dcc[idx].type = &DCC_CHAT;
01684   dcc[idx].u.chat->channel = -2;
01685   dcc_chatter(idx);
01686 }

Here is the call graph for this function:

static int detect_telnet ( unsigned char *  buf  )  [static]

Definition at line 76 of file dcc.c.

References TLN_DO, TLN_DONT, TLN_IAC, and TLN_STATUS.

Referenced by dcc_chat_pass(), and dcc_telnet_id().

00077 {
00078   if (!buf || !buf[0] || !buf[1])
00079     return 0;
00080   while (buf[2]) {
00081     if (buf[0] == TLN_IAC && (buf[1] == TLN_DO || buf[1] == TLN_DONT) &&
00082         buf[2] == TLN_STATUS)
00083       return 1;
00084     buf++;
00085   }
00086   return 0;
00087 }

Here is the caller graph for this function:

static int detect_telnet_flood ( char *  floodhost  )  [static]

Definition at line 1091 of file dcc.c.

References addignore, egg_strcasecmp, flood_telnet_thr, flood_telnet_time, FR_ANYWH, FR_CHAN, FR_GLOBAL, get_user_by_host, get_user_flagrec, glob_friend, ignore_time, IRC_TELNETFLOOD, lasttelnethost, lasttelnets, lasttelnettime, LOG_MISC, now, NULL, origbotname, par_telnet_flood, and putlog.

Referenced by dcc_telnet_hostresolved().

01092 {
01093   struct flag_record fr = { FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0 };
01094 
01095   get_user_flagrec(get_user_by_host(floodhost), &fr, NULL);
01096   if (!flood_telnet_thr || (glob_friend(fr) && !par_telnet_flood))
01097     return 0;                   /* No flood protection */
01098   if (egg_strcasecmp(lasttelnethost, floodhost)) {      /* New... */
01099     strcpy(lasttelnethost, floodhost);
01100     lasttelnettime = now;
01101     lasttelnets = 0;
01102     return 0;
01103   }
01104   if (lasttelnettime < now - flood_telnet_time) {
01105     /* Flood timer expired, reset it */
01106     lasttelnettime = now;
01107     lasttelnets = 0;
01108     return 0;
01109   }
01110   lasttelnets++;
01111   if (lasttelnets >= flood_telnet_thr) {        /* FLOOD! */
01112     /* Reset counters */
01113     lasttelnets = 0;
01114     lasttelnettime = 0;
01115     lasttelnethost[0] = 0;
01116     putlog(LOG_MISC, "*", IRC_TELNETFLOOD, floodhost);
01117     addignore(floodhost, origbotname, "Telnet connection flood",
01118               now + (60 * ignore_time));
01119     return 1;
01120   }
01121   return 0;
01122 }

Here is the caller graph for this function:

static void display_dcc_bot ( int  idx,
char *  buf 
) [static]

Definition at line 482 of file dcc.c.

References b_status, simple_sprintf, STAT_AGGRESSIVE, STAT_CALLED, STAT_GETTING, STAT_LEAF, STAT_LINKING, STAT_OFFERED, STAT_PINGED, STAT_SENDING, STAT_SHARE, and STAT_WARNED.

00483 {
00484   int i = simple_sprintf(buf, "bot   flags: ");
00485 
00486   buf[i++] = b_status(idx) & STAT_PINGED ? 'P' : 'p';
00487   buf[i++] = b_status(idx) & STAT_SHARE ? 'U' : 'u';
00488   buf[i++] = b_status(idx) & STAT_CALLED ? 'C' : 'c';
00489   buf[i++] = b_status(idx) & STAT_OFFERED ? 'O' : 'o';
00490   buf[i++] = b_status(idx) & STAT_SENDING ? 'S' : 's';
00491   buf[i++] = b_status(idx) & STAT_GETTING ? 'G' : 'g';
00492   buf[i++] = b_status(idx) & STAT_WARNED ? 'W' : 'w';
00493   buf[i++] = b_status(idx) & STAT_LEAF ? 'L' : 'l';
00494   buf[i++] = b_status(idx) & STAT_LINKING ? 'I' : 'i';
00495   buf[i++] = b_status(idx) & STAT_AGGRESSIVE ? 'a' : 'A';
00496   buf[i++] = 0;
00497 }

static void display_dcc_bot_new ( int  idx,
char *  buf 
) [static]

Definition at line 397 of file dcc.c.

References now, and dcc_t::timeval.

00398 {
00399   long tv;
00400 
00401   tv = now - dcc[idx].timeval;
00402   sprintf(buf, "bot*  waited %lis", tv);
00403 }

static void display_dcc_chat ( int  idx,
char *  buf 
) [static]

Definition at line 1059 of file dcc.c.

References chat_info::channel, dcc_t::chat, simple_sprintf, STAT_CHAT, STAT_ECHO, STAT_PAGE, STAT_PARTY, STAT_TELNET, and dcc_t::status.

01060 {
01061   int i = simple_sprintf(buf, "chat  flags: ");
01062 
01063   buf[i++] = dcc[idx].status & STAT_CHAT ? 'C' : 'c';
01064   buf[i++] = dcc[idx].status & STAT_PARTY ? 'P' : 'p';
01065   buf[i++] = dcc[idx].status & STAT_TELNET ? 'T' : 't';
01066   buf[i++] = dcc[idx].status & STAT_ECHO ? 'E' : 'e';
01067   buf[i++] = dcc[idx].status & STAT_PAGE ? 'P' : 'p';
01068   simple_sprintf(buf + i, "/%d", dcc[idx].u.chat->channel);
01069 }

static void display_dcc_chat_pass ( int  idx,
char *  buf 
) [static]

Definition at line 672 of file dcc.c.

References now, and dcc_t::timeval.

00673 {
00674   long tv;
00675 
00676   tv = now - dcc[idx].timeval;
00677   sprintf(buf, "pass  waited %lis", tv);
00678 }

static void display_dcc_fork_bot ( int  idx,
char *  buf 
) [static]

Definition at line 499 of file dcc.c.

00500 {
00501   sprintf(buf, "conn  bot");
00502 }

static void display_dcc_ident ( int  idx,
char *  buf 
) [static]

Definition at line 2026 of file dcc.c.

References dcc_t::ident_sock.

02027 {
02028   sprintf(buf, "idnt  (sock %d)", dcc[idx].u.ident_sock);
02029 }

static void display_dcc_identwait ( int  idx,
char *  buf 
) [static]

Definition at line 1963 of file dcc.c.

References now, and dcc_t::timeval.

01964 {
01965   long tv;
01966 
01967   tv = now - dcc[idx].timeval;
01968   sprintf(buf, "idtw  waited %lis", tv);
01969 }

static void display_dcc_lost ( int  idx,
char *  buf 
) [static]

Definition at line 1922 of file dcc.c.

01923 {
01924   strcpy(buf, "lost");
01925 }

static void display_dcc_script ( int  idx,
char *  buf 
) [static]

Definition at line 1847 of file dcc.c.

References script_info::command, and dcc_t::script.

01848 {
01849   sprintf(buf, "scri  %s", dcc[idx].u.script->command);
01850 }

static void display_dcc_socket ( int  idx,
char *  buf 
) [static]

Definition at line 1904 of file dcc.c.

01905 {
01906   strcpy(buf, "sock  (stranded)");
01907 }

static void display_dcc_telnet_id ( int  idx,
char *  buf 
) [static]

Definition at line 1553 of file dcc.c.

References now, and dcc_t::timeval.

01554 {
01555   long tv;
01556 
01557   tv = now - dcc[idx].timeval;
01558   sprintf(buf, "t-in  waited %lis", tv);
01559 }

static void display_dcc_telnet_new ( int  idx,
char *  buf 
) [static]

Definition at line 1721 of file dcc.c.

References now, and dcc_t::timeval.

01722 {
01723   long tv;
01724 
01725   tv = now - dcc[idx].timeval;
01726   sprintf(buf, "new   waited %lis", tv);
01727 }

static void display_dcc_telnet_pw ( int  idx,
char *  buf 
) [static]

Definition at line 1729 of file dcc.c.

References now, and dcc_t::timeval.

01730 {
01731   long tv;
01732 
01733   tv = now - dcc[idx].timeval;
01734   sprintf(buf, "newp  waited %lis", tv);
01735 }

static void display_dupwait ( int  idx,
char *  buf 
) [static]

Definition at line 1304 of file dcc.c.

01305 {
01306   sprintf(buf, "wait  duplicate?");
01307 }

static void display_telnet ( int  idx,
char *  buf 
) [static]

Definition at line 1252 of file dcc.c.

References LSTN_PUBLIC.

01253 {
01254   sprintf(buf, "lstn  %d%s", dcc[idx].port,
01255           (dcc[idx].status & LSTN_PUBLIC) ? " pub" : "");
01256 }

void dupwait_notify ( char *  who  ) 

Definition at line 1347 of file dcc.c.

References Assert, dupwait_info::atr, dcc_telnet_pass(), dcc_total, dcc_t::dupwait, and egg_strcasecmp.

Referenced by rembot().

01348 {
01349   register int idx;
01350 
01351   Assert(who);
01352   for (idx = 0; idx < dcc_total; idx++)
01353     if ((dcc[idx].type == &DCC_DUPWAIT) &&
01354         !egg_strcasecmp(dcc[idx].nick, who)) {
01355       dcc_telnet_pass(idx, dcc[idx].u.dupwait->atr);
01356       break;
01357     }
01358 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void eof_dcc_bot ( int  idx  )  [static]

Definition at line 464 of file dcc.c.

References botnet_send_unlinked, bots_in_subtree, chatout, egg_snprintf, findbot(), killsock, LOG_BOTS, lostdcc, putlog, and users_in_subtree.

00465 {
00466   char x[1024];
00467   int bots, users;
00468 
00469   bots = bots_in_subtree(findbot(dcc[idx].nick));
00470   users = users_in_subtree(findbot(dcc[idx].nick));
00471   egg_snprintf(x, sizeof x,
00472                "Lost bot: %s (lost %d bot%s and %d user%s)",
00473                dcc[idx].nick, bots, (bots != 1) ? "s" : "", users,
00474                (users != 1) ? "s" : "");
00475   putlog(LOG_BOTS, "*", "%s.", x);
00476   chatout("*** %s\n", x);
00477   botnet_send_unlinked(idx, dcc[idx].nick, x);
00478   killsock(dcc[idx].sock);
00479   lostdcc(idx);
00480 }

Here is the call graph for this function:

static void eof_dcc_bot_new ( int  idx  )  [static]

Definition at line 382 of file dcc.c.

References DCC_LOSTBOT, killsock, LOG_BOTS, lostdcc, and putlog.

00383 {
00384   putlog(LOG_BOTS, "*", DCC_LOSTBOT, dcc[idx].nick, dcc[idx].port);
00385   killsock(dcc[idx].sock);
00386   lostdcc(idx);
00387 }

static void eof_dcc_chat ( int  idx  )  [static]

Definition at line 884 of file dcc.c.

References botnet_send_part_idx, botnetnick, chat_info::channel, chanout_but, dcc_t::chat, check_tcl_chof, check_tcl_chpt(), DCC_LOSTDCC, GLOBAL_CHANS, killsock, LOG_MISC, lostdcc, dcc_t::nick, and putlog.

00885 {
00886   putlog(LOG_MISC, "*", DCC_LOSTDCC, dcc[idx].nick,
00887          dcc[idx].host, dcc[idx].port);
00888   if (dcc[idx].u.chat->channel >= 0) {
00889     chanout_but(idx, dcc[idx].u.chat->channel, "*** %s lost dcc link.\n",
00890                 dcc[idx].nick);
00891     if (dcc[idx].u.chat->channel < GLOBAL_CHANS)
00892       botnet_send_part_idx(idx, "lost dcc link");
00893     check_tcl_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock,
00894                    dcc[idx].u.chat->channel);
00895   }
00896   check_tcl_chof(dcc[idx].nick, dcc[idx].sock);
00897   killsock(dcc[idx].sock);
00898   lostdcc(idx);
00899 }

Here is the call graph for this function:

static void eof_dcc_dupwait ( int  idx  )  [static]

Definition at line 1271 of file dcc.c.

References DCC_LOSTDUP, killsock, LOG_BOTS, lostdcc, and putlog.

01272 {
01273   putlog(LOG_BOTS, "*", DCC_LOSTDUP, dcc[idx].host);
01274   killsock(dcc[idx].sock);
01275   lostdcc(idx);
01276 }

static void eof_dcc_general ( int  idx  )  [static]

Definition at line 656 of file dcc.c.

References DCC_LOSTDCC, killsock, LOG_MISC, lostdcc, and putlog.

00657 {
00658   putlog(LOG_MISC, "*", DCC_LOSTDCC, dcc[idx].nick,
00659          dcc[idx].host, dcc[idx].port);
00660   killsock(dcc[idx].sock);
00661   lostdcc(idx);
00662 }

void eof_dcc_ident ( int  idx  ) 

Definition at line 2009 of file dcc.c.

References DCC_EOFIDENT, dcc_telnet_got_ident(), dcc_total, dcc_t::ident_sock, killsock, LOG_MISC, lostdcc, dcc_t::other, putlog, simple_sprintf, dcc_t::u, and UHOSTLEN.

02010 {
02011   char buf[UHOSTLEN];
02012   int i;
02013 
02014   for (i = 0; i < dcc_total; i++)
02015     if ((dcc[i].type == &DCC_IDENTWAIT) &&
02016         (dcc[i].sock == dcc[idx].u.ident_sock)) {
02017       putlog(LOG_MISC, "*", DCC_EOFIDENT);
02018       simple_sprintf(buf, "telnet@%s", dcc[idx].host);
02019       dcc_telnet_got_ident(i, buf);
02020     }
02021   killsock(dcc[idx].sock);
02022   dcc[idx].u.other = 0;
02023   lostdcc(idx);
02024 }

Here is the call graph for this function:

void eof_dcc_identwait ( int  idx  ) 

Definition at line 1945 of file dcc.c.

References DCC_IDENT, DCC_LOSTCONN, dcc_total, dcc_t::ident_sock, killsock, LOG_MISC, lostdcc, dcc_t::other, putlog, dcc_t::sock, and dcc_t::u.

01946 {
01947   int i;
01948 
01949   putlog(LOG_MISC, "*", DCC_LOSTCONN, dcc[idx].host, dcc[idx].port);
01950   for (i = 0; i < dcc_total; i++)
01951     if ((dcc[i].type == &DCC_IDENT) &&
01952         (dcc[i].u.ident_sock == dcc[idx].sock)) {
01953       killsock(dcc[i].sock);    /* Cleanup ident socket */
01954       dcc[i].u.other = 0;
01955       lostdcc(i);
01956       break;
01957     }
01958   killsock(dcc[idx].sock);      /* Cleanup waiting socket */
01959   dcc[idx].u.other = 0;
01960   lostdcc(idx);
01961 }

static void eof_dcc_script ( int  idx  )  [static]

Definition at line 1819 of file dcc.c.

References call_tcl_func(), script_info::command, DCC_DEADSOCKET, DCT_VALIDIDX, dcc_table::eof, dcc_table::flags, killsock, LOG_MISC, lostdcc, nfree, dcc_t::other, script_info::other, putlog, dcc_t::script, dcc_t::sock, script_info::type, dcc_t::type, script_info::u, and dcc_t::u.

01820 {
01821   void *old;
01822   int oldflags;
01823 
01824   /* This will stop a killdcc from working, incase the script tries
01825    * to kill it's controlling socket while handling an EOF <cybah>
01826    */
01827   oldflags = dcc[idx].type->flags;
01828   dcc[idx].type->flags &= ~(DCT_VALIDIDX);
01829   /* Tell the script they're gone: */
01830   call_tcl_func(dcc[idx].u.script->command, dcc[idx].sock, "");
01831   /* Restore the flags */
01832   dcc[idx].type->flags = oldflags;
01833   old = dcc[idx].u.script->u.other;
01834   dcc[idx].type = dcc[idx].u.script->type;
01835   nfree(dcc[idx].u.script);
01836   dcc[idx].u.other = old;
01837   /* Then let it fall thru to the real one */
01838   if (dcc[idx].type && dcc[idx].type->eof)
01839     dcc[idx].type->eof(idx);
01840   else {
01841     putlog(LOG_MISC, "*", DCC_DEADSOCKET, dcc[idx].sock, dcc[idx].type->name);
01842     killsock(dcc[idx].sock);
01843     lostdcc(idx);
01844   }
01845 }

Here is the call graph for this function:

static void eof_dcc_socket ( int  idx  )  [static]

Definition at line 1898 of file dcc.c.

References killsock, and lostdcc.

01899 {
01900   killsock(dcc[idx].sock);
01901   lostdcc(idx);
01902 }

static void eof_dcc_telnet ( int  idx  )  [static]

Definition at line 1245 of file dcc.c.

References DCC_PORTDIE, killsock, LOG_MISC, lostdcc, and putlog.

01246 {
01247   putlog(LOG_MISC, "*", DCC_PORTDIE, dcc[idx].port);
01248   killsock(dcc[idx].sock);
01249   lostdcc(idx);
01250 }

static void eof_dcc_telnet_id ( int  idx  )  [static]

Definition at line 1538 of file dcc.c.

References DCC_LOSTCON, killsock, LOG_MISC, lostdcc, and putlog.

01539 {
01540   putlog(LOG_MISC, "*", DCC_LOSTCON, dcc[idx].host, dcc[idx].port);
01541   killsock(dcc[idx].sock);
01542   lostdcc(idx);
01543 }

static void eof_dcc_telnet_new ( int  idx  )  [static]

Definition at line 1688 of file dcc.c.

References DCC_LOSTNEWUSER, killsock, LOG_MISC, lostdcc, and putlog.

01689 {
01690   putlog(LOG_MISC, "*", DCC_LOSTNEWUSER, dcc[idx].host, dcc[idx].port);
01691   killsock(dcc[idx].sock);
01692   lostdcc(idx);
01693 }

static void eof_dcc_telnet_pw ( int  idx  )  [static]

Definition at line 1695 of file dcc.c.

References DCC_LOSTNEWUSR2, deluser, killsock, LOG_MISC, lostdcc, and putlog.

01696 {
01697   putlog(LOG_MISC, "*", DCC_LOSTNEWUSR2, dcc[idx].nick, dcc[idx].host,
01698          dcc[idx].port);
01699   deluser(dcc[idx].nick);
01700   killsock(dcc[idx].sock);
01701   lostdcc(idx);
01702 }

static char* escape_telnet ( char *  s  )  [static]

Definition at line 90 of file dcc.c.

References TLN_IAC.

Referenced by dcc_telnet_pass(), and out_dcc_general().

00091 {
00092   static char buf[1024];
00093   char *p;
00094 
00095   for (p = buf; *s && (p < (buf + sizeof(buf) - 2)); *p++ = *s++)
00096     if ((unsigned char) *s == TLN_IAC)
00097       *p++ = *s;
00098     else if (*s == '\n')
00099       *p++ = '\r';
00100   *p = 0;
00101 
00102   return buf;
00103 }

Here is the caller graph for this function:

static int expmem_dcc_bot_ ( void *  x  )  [static]

Definition at line 405 of file dcc.c.

00406 {
00407   return sizeof(struct bot_info);
00408 }

static int expmem_dcc_general ( void *  x  )  [static]

Definition at line 680 of file dcc.c.

References chat_info::away, chat_info::buffer, msgq::len, msgq::next, and chat_info::su_nick.

00681 {
00682   register struct chat_info *p = (struct chat_info *) x;
00683   int tot = sizeof(struct chat_info);
00684 
00685   if (p->away)
00686     tot += strlen(p->away) + 1;
00687   if (p->buffer) {
00688     struct msgq *q = p->buffer;
00689 
00690     while (q) {
00691       tot += sizeof(struct list_type);
00692 
00693       tot += q->len + 1;
00694       q = q->next;
00695     }
00696   }
00697   if (p->su_nick)
00698     tot += strlen(p->su_nick) + 1;
00699   return tot;
00700 }

static int expmem_dcc_script ( void *  x  )  [static]

Definition at line 1852 of file dcc.c.

References dcc_table::expmem, script_info::other, script_info::type, and script_info::u.

01853 {
01854   register struct script_info *p = (struct script_info *) x;
01855   int tot = sizeof(struct script_info);
01856 
01857   if (p->type && p->u.other)
01858     tot += p->type->expmem(p->u.other);
01859   return tot;
01860 }

static int expmem_dupwait ( void *  x  )  [static]

Definition at line 1309 of file dcc.c.

References dupwait_info::chat, and dcc_table::expmem.

01310 {
01311   register struct dupwait_info *p = (struct dupwait_info *) x;
01312   int tot = sizeof(struct dupwait_info);
01313 
01314   if (p && p->chat && DCC_CHAT.expmem)
01315     tot += DCC_CHAT.expmem(p->chat);
01316   return tot;
01317 }

void failed_link ( int  idx  ) 

Definition at line 250 of file dcc.c.

References add_note, dcc_t::addr, autolink_cycle(), botnetnick, DCC_LINKFAIL, egg_snprintf, failed_link(), getsock, dcc_t::host, iptostr, killsock, LOG_BOTS, lostdcc, dcc_t::nick, now, open_telnet_raw(), dcc_t::port, putlog, dcc_t::sock, SOCK_STRONGCONN, dcc_t::timeval, and dcc_t::u.

Referenced by botlink_resolve_success(), and failed_link().

00251 {
00252   char s[81], s1[512];
00253 
00254   if (dcc[idx].port >= dcc[idx].u.bot->port + 3) {
00255     if (dcc[idx].u.bot->linker[0]) {
00256       egg_snprintf(s, sizeof s, "Couldn't link to %s.", dcc[idx].nick);
00257       strcpy(s1, dcc[idx].u.bot->linker);
00258       add_note(s1, botnetnick, s, -2, 0);
00259     }
00260     if (dcc[idx].u.bot->numver >= -1)
00261       putlog(LOG_BOTS, "*", DCC_LINKFAIL, dcc[idx].nick);
00262     killsock(dcc[idx].sock);
00263     strcpy(s, dcc[idx].nick);
00264     lostdcc(idx);
00265     autolink_cycle(s);          /* Check for more auto-connections */
00266     return;
00267   }
00268 
00269   /* Try next port */
00270   killsock(dcc[idx].sock);
00271   dcc[idx].sock = getsock(SOCK_STRONGCONN);
00272   dcc[idx].port++;
00273   dcc[idx].timeval = now;
00274   if (dcc[idx].sock < 0 ||
00275       open_telnet_raw(dcc[idx].sock, dcc[idx].addr ?
00276                       iptostr(htonl(dcc[idx].addr)) : dcc[idx].host,
00277                       dcc[idx].port) < 0) {
00278     failed_link(idx);
00279   }
00280 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void free_dcc_bot_ ( int  n,
void *  x 
) [static]

Definition at line 410 of file dcc.c.

References DCC_BOT, findbot(), nfree, rembot(), and unvia().

00411 {
00412   if (dcc[n].type == &DCC_BOT) {
00413     unvia(n, findbot(dcc[n].nick));
00414     rembot(dcc[n].nick);
00415   }
00416   nfree(x);
00417 }

Here is the call graph for this function:

static void greet_new_bot ( int  idx  )  [static]

Definition at line 153 of file dcc.c.

References dcc_t::bot, bot_flags, BOT_LEAF, BOT_REJECT, DCC_FORK_BOT, DCC_REJECT, dcc_total, dprintf, egg_numver, HANDLEN, killsock, LOG_BOTS, lostdcc, network, dcc_t::nick, now, bot_info::numver, putlog, dcc_t::sock, STAT_LEAF, STAT_LINKING, dcc_t::status, dcc_t::timeval, dcc_t::type, dcc_t::u, user, ver, and bot_info::version.

Referenced by dcc_bot_new(), dcc_chat_pass(), and dcc_telnet_pass().

00154 {
00155   int bfl = bot_flags(dcc[idx].user);
00156   int i;
00157 
00158   dcc[idx].timeval = now;
00159   dcc[idx].u.bot->version[0] = 0;
00160   dcc[idx].u.bot->numver = 0;
00161   if (bfl & BOT_REJECT) {
00162     putlog(LOG_BOTS, "*", DCC_REJECT, dcc[idx].nick);
00163     dprintf(idx, "bye %s\n", "rejected");
00164     killsock(dcc[idx].sock);
00165     lostdcc(idx);
00166     return;
00167   }
00168   if (bfl & BOT_LEAF)
00169     dcc[idx].status |= STAT_LEAF;
00170   dcc[idx].status |= STAT_LINKING;
00171 #ifndef NO_OLD_BOTNET
00172   dprintf(idx, "version %d %d %s <%s>\n", egg_numver, HANDLEN, ver, network);
00173 #else
00174   dprintf(idx, "v %d %d %s <%s>\n", egg_numver, HANDLEN, ver, network);
00175 #endif
00176   for (i = 0; i < dcc_total; i++)
00177     if (dcc[i].type == &DCC_FORK_BOT) {
00178       killsock(dcc[i].sock);
00179       lostdcc(i);
00180     }
00181 }

Here is the caller graph for this function:

static void kill_dcc_general ( int  idx,
void *  x 
) [static]

Definition at line 702 of file dcc.c.

References chat_info::away, chat_info::buffer, dcc_t::chat, msgq::msg, msgq::next, and nfree.

00703 {
00704   register struct chat_info *p = (struct chat_info *) x;
00705 
00706   if (p) {
00707     if (p->buffer) {
00708       struct msgq *r, *q;
00709 
00710       for (r = dcc[idx].u.chat->buffer; r; r = q) {
00711         q = r->next;
00712         nfree(r->msg);
00713         nfree(r);
00714       }
00715     }
00716     if (p->away) {
00717       nfree(p->away);
00718     }
00719     nfree(p);
00720   }
00721 }

static void kill_dcc_script ( int  idx,
void *  x 
) [static]

Definition at line 1862 of file dcc.c.

References dcc_table::kill, nfree, script_info::other, script_info::type, and script_info::u.

01863 {
01864   register struct script_info *p = (struct script_info *) x;
01865 
01866   if (p->type && p->u.other)
01867     p->type->kill(idx, p->u.other);
01868   nfree(p);
01869 }

static void kill_dupwait ( int  idx,
void *  x 
) [static]

Definition at line 1319 of file dcc.c.

References dupwait_info::chat, dcc_table::kill, and nfree.

01320 {
01321   register struct dupwait_info *p = (struct dupwait_info *) x;
01322 
01323   if (p) {
01324     if (p->chat && DCC_CHAT.kill)
01325       DCC_CHAT.kill(idx, p->chat);
01326     nfree(p);
01327   }
01328 }

static void out_dcc_general ( int  idx,
char *  buf,
void *  x 
) [static]

Definition at line 837 of file dcc.c.

References append_line(), escape_telnet(), STAT_PAGE, STAT_TELNET, chat_info::strip_flags, strip_mirc_codes, and tputs.

00838 {
00839   register struct chat_info *p = (struct chat_info *) x;
00840   char *y = buf;
00841 
00842   strip_mirc_codes(p->strip_flags, buf);
00843   if (dcc[idx].status & STAT_TELNET)
00844     y = escape_telnet(buf);
00845   if (dcc[idx].status & STAT_PAGE)
00846     append_line(idx, y);
00847   else
00848     tputs(dcc[idx].sock, y, strlen(y));
00849 }

Here is the call graph for this function:

static void out_dcc_script ( int  idx,
char *  buf,
void *  x 
) [static]

Definition at line 1871 of file dcc.c.

References script_info::other, dcc_table::output, tputs, script_info::type, and script_info::u.

01872 {
01873   register struct script_info *p = (struct script_info *) x;
01874 
01875   if (p && p->type && p->u.other)
01876     p->type->output(idx, buf, p->u.other);
01877   else
01878     tputs(dcc[idx].sock, buf, strlen(buf));
01879 }

void strip_mirc_codes ( int  flags,
char *  text 
)

Definition at line 728 of file dcc.c.

References egg_isdigit, STRIP_ANSI, STRIP_BELLS, STRIP_BOLD, STRIP_COLOR, STRIP_REV, and STRIP_UNDER.

00729 {
00730   char *dd = text;
00731 
00732   while (*text) {
00733     switch (*text) {
00734     case 2:                    /* Bold text */
00735       if (flags & STRIP_BOLD) {
00736         text++;
00737         continue;
00738       }
00739       break;
00740     case 3:                    /* mIRC colors? */
00741       if (flags & STRIP_COLOR) {
00742         if (egg_isdigit(text[1])) { /* Is the first char a number? */
00743           text += 2;            /* Skip over the ^C and the first digit */
00744           if (egg_isdigit(*text))
00745             text++;             /* Is this a double digit number? */
00746           if (*text == ',') {   /* Do we have a background color next? */
00747             if (egg_isdigit(text[1]))
00748               text += 2;        /* Skip over the first background digit */
00749             if (egg_isdigit(*text))
00750               text++;           /* Is it a double digit? */
00751           }
00752         } else
00753           text++;
00754         continue;
00755       }
00756       break;
00757     case 7:
00758       if (flags & STRIP_BELLS) {
00759         text++;
00760         continue;
00761       }
00762       break;
00763     case 0x16:                 /* Reverse video */
00764       if (flags & STRIP_REV) {
00765         text++;
00766         continue;
00767       }
00768       break;
00769     case 0x1f:                 /* Underlined text */
00770       if (flags & STRIP_UNDER) {
00771         text++;
00772         continue;
00773       }
00774       break;
00775     case 033:
00776       if (flags & STRIP_ANSI) {
00777         text++;
00778         if (*text == '[') {
00779           text++;
00780           while ((*text == ';') || egg_isdigit(*text))
00781             text++;
00782           if (*text)
00783             text++;             /* also kill the following char */
00784         }
00785         continue;
00786       }
00787       break;
00788     }
00789     *dd++ = *text++;            /* Move on to the next char */
00790   }
00791   *dd = 0;
00792 }

static void strip_telnet ( int  sock,
char *  buf,
int *  len 
) [static]

Definition at line 105 of file dcc.c.

References TLN_AYT, TLN_DO, TLN_DONT, TLN_DONT_C, TLN_ECHO, TLN_IAC, TLN_IAC_C, TLN_WILL, and TLN_WONT_C.

Referenced by dcc_chat(), dcc_chat_pass(), dcc_script(), dcc_telnet_id(), dcc_telnet_new(), and dcc_telnet_pw().

00106 {
00107   unsigned char *p = (unsigned char *) buf, *o = (unsigned char *) buf;
00108   int mark;
00109 
00110   while (*p != 0) {
00111     while ((*p != TLN_IAC) && (*p != 0))
00112       *o++ = *p++;
00113     if (*p == TLN_IAC) {
00114       p++;
00115       mark = 2;
00116       if (!*p)
00117         mark = 1;               /* bogus */
00118       if ((*p >= TLN_WILL) && (*p <= TLN_DONT)) {
00119         mark = 3;
00120         if (!*(p + 1))
00121           mark = 2;             /* bogus */
00122       } else if (*p == TLN_WILL) {
00123         /* WILL X -> response: DONT X */
00124         /* except WILL ECHO which we just smile and ignore */
00125         if (*(p + 1) != TLN_ECHO) {
00126           write(sock, TLN_IAC_C TLN_DONT_C, 2);
00127           write(sock, p + 1, 1);
00128         }
00129       } else if (*p == TLN_DO) {
00130         /* DO X -> response: WONT X */
00131         /* except DO ECHO which we just smile and ignore */
00132         if (*(p + 1) != TLN_ECHO) {
00133           write(sock, TLN_IAC_C TLN_WONT_C, 2);
00134           write(sock, p + 1, 1);
00135         }
00136       } else if (*p == TLN_AYT) {
00137         /* "Are You There?" */
00138         /* response is: "Hell, yes!" */
00139         write(sock, "\r\nHell, yes!\r\n", 14);
00140       } else if (*p == TLN_IAC) {
00141         /* IAC character in data, escaped with another IAC */
00142         *o++ = *p++;
00143         mark = 1;
00144       }
00145       /* Anything else can probably be ignored */
00146       p += mark - 1;
00147       *len = *len - mark;
00148     }
00149   }
00150   *o = *p;
00151 }

Here is the caller graph for this function:

static void timeout_dcc_bot_new ( int  idx  )  [static]

Definition at line 389 of file dcc.c.

References DCC_TIMEOUT, killsock, LOG_BOTS, lostdcc, and putlog.

00390 {
00391   putlog(LOG_BOTS, "*", DCC_TIMEOUT, dcc[idx].nick,
00392          dcc[idx].host, dcc[idx].port);
00393   killsock(dcc[idx].sock);
00394   lostdcc(idx);
00395 }

static void timeout_dcc_telnet_id ( int  idx  )  [static]

Definition at line 1545 of file dcc.c.

References DCC_TTIMEOUT, dprintf, killsock, LOG_MISC, lostdcc, and putlog.

01546 {
01547   dprintf(idx, "Timeout.\n");
01548   putlog(LOG_MISC, "*", DCC_TTIMEOUT, dcc[idx].host);
01549   killsock(dcc[idx].sock);
01550   lostdcc(idx);
01551 }

static void timeout_dupwait ( int  idx  )  [static]

Definition at line 1287 of file dcc.c.

References dupwait_info::atr, DCC_DUPLICATE, dcc_telnet_pass(), dprintf, dcc_t::dupwait, egg_snprintf, in_chain, killsock, LOG_BOTS, lostdcc, and putlog.

01288 {
01289   char x[100];
01290 
01291   /* Still duplicate? */
01292   if (in_chain(dcc[idx].nick)) {
01293     egg_snprintf(x, sizeof x, "%s!%s", dcc[idx].nick, dcc[idx].host);
01294     dprintf(idx, "error Already connected.\n");
01295     putlog(LOG_BOTS, "*", DCC_DUPLICATE, x);
01296     killsock(dcc[idx].sock);
01297     lostdcc(idx);
01298   } else {
01299     /* Ha! Now it's gone and we can grant this bot access. */
01300     dcc_telnet_pass(idx, dcc[idx].u.dupwait->atr);
01301   }
01302 }

Here is the call graph for this function:

static void tout_dcc_chat_pass ( int  idx  )  [static]

Definition at line 664 of file dcc.c.

References DCC_PWDTIMEOUT, dprintf, killsock, LOG_MISC, lostdcc, and putlog.

00665 {
00666   dprintf(idx, "Timeout.\n");
00667   putlog(LOG_MISC, "*", DCC_PWDTIMEOUT, dcc[idx].nick, dcc[idx].host);
00668   killsock(dcc[idx].sock);
00669   lostdcc(idx);
00670 }

static void tout_dcc_telnet_new ( int  idx  )  [static]

Definition at line 1704 of file dcc.c.

References DCC_TIMEOUTUSER, dprintf, killsock, LOG_MISC, lostdcc, and putlog.

01705 {
01706   dprintf(idx, "Guess you're not there.  Bye.\n");
01707   putlog(LOG_MISC, "*", DCC_TIMEOUTUSER, dcc[idx].host, dcc[idx].port);
01708   killsock(dcc[idx].sock);
01709   lostdcc(idx);
01710 }

static void tout_dcc_telnet_pw ( int  idx  )  [static]

Definition at line 1712 of file dcc.c.

References DCC_TIMEOUTUSR2, dprintf, killsock, LOG_MISC, lostdcc, and putlog.

01713 {
01714   dprintf(idx, "Guess you're not there.  Bye.\n");
01715   putlog(LOG_MISC, "*", DCC_TIMEOUTUSR2, dcc[idx].nick,
01716          dcc[idx].host, dcc[idx].port);
01717   killsock(dcc[idx].sock);
01718   lostdcc(idx);
01719 }


Variable Documentation

Definition at line 52 of file dcc.c.

Referenced by dcc_telnet_got_ident(), and dcc_telnet_id().

int backgrd

Definition at line 106 of file main.c.

char bannerfile[121] = "text/banner"

Definition at line 65 of file dcc.c.

Referenced by show_banner().

int bot_timeout = 60

Definition at line 58 of file dcc.c.

char botnetnick[]

Definition at line 45 of file botnet.c.

Definition at line 1459 of file botcmd.c.

struct chanset_t* chanset

Definition at line 60 of file chanprog.c.

int conmask

Definition at line 66 of file misc.c.

Definition at line 44 of file dccutil.c.

struct dcc_t* dcc = 0

Definition at line 46 of file dcc.c.

Initial value:

Definition at line 504 of file dcc.c.

Initial value:

Definition at line 419 of file dcc.c.

Referenced by botlink(), botunlink(), and cont_link().

Initial value:

Definition at line 1330 of file dcc.c.

Initial value:

Definition at line 2031 of file dcc.c.

Referenced by dcc_telnet_hostresolved(), and eof_dcc_identwait().

Initial value:
 {
  "IDENTWAIT",
  0,
  eof_dcc_identwait,
  dcc_identwait,
   0 ,
   0 ,
  display_dcc_identwait,
   0 ,
   0 ,
   0 
}

Definition at line 1971 of file dcc.c.

Referenced by dcc_telnet(), and dcc_telnet_hostresolved().

Initial value:
 {
  "LOST",
  0,
   0 ,
  dcc_socket,
   0 ,
   0 ,
  display_dcc_lost,
   0 ,
   0 ,
   0 
}

Definition at line 1927 of file dcc.c.

Initial value:

Definition at line 1881 of file dcc.c.

Initial value:
 {
  "SOCKET",
  DCT_VALIDIDX,
  eof_dcc_socket,
  dcc_socket,
   0 ,
   0 ,
  display_dcc_socket,
   0 ,
   0 ,
   0 
}

Definition at line 1909 of file dcc.c.

Referenced by dcc_script().

Initial value:
 {
  "TELNET",
  DCT_LISTEN,
  eof_dcc_telnet,
  dcc_telnet,
   0 ,
   0 ,
  display_telnet,
   0 ,
   0 ,
   0 
}

Definition at line 1258 of file dcc.c.

Referenced by dcc_telnet_hostresolved().

int dcc_total = 0

Definition at line 47 of file dcc.c.

Definition at line 103 of file main.c.

int dupwait_timeout = 5

Definition at line 60 of file dcc.c.

Definition at line 100 of file main.c.

Definition at line 62 of file dcc.c.

Referenced by detect_telnet_flood().

Definition at line 64 of file dcc.c.

Referenced by detect_telnet_flood().

int identtimeout = 5

Definition at line 59 of file dcc.c.

char lasttelnethost[81] [static]

Definition at line 1086 of file dcc.c.

Referenced by detect_telnet_flood().

int lasttelnets [static]

Definition at line 1085 of file dcc.c.

Referenced by detect_telnet_flood().

Definition at line 1087 of file dcc.c.

Referenced by detect_telnet_flood().

Definition at line 122 of file main.c.

int max_dcc

Definition at line 50 of file dccutil.c.

char network[41] = "unknown-net"

Definition at line 56 of file dcc.c.

char notify_new[]

Definition at line 102 of file main.c.

Definition at line 88 of file main.c.

char origbotname[]

Definition at line 62 of file chanprog.c.

Definition at line 83 of file tcl.c.

Referenced by detect_telnet_flood().

int password_timeout = 180

Definition at line 57 of file dcc.c.

int protect_telnet = 1

Definition at line 61 of file dcc.c.

Referenced by dcc_telnet_got_ident().

int raw_log

Definition at line 64 of file misc.c.

int require_p = 0

Definition at line 50 of file dcc.c.

int stealth_telnets = 0

Definition at line 54 of file dcc.c.

Referenced by dcc_telnet_got_ident().

char tempdir[121] = ""

Definition at line 48 of file dcc.c.

Definition at line 55 of file dcc.c.

Referenced by dcc_telnet_got_ident().

struct userrec* userlist
char ver[]

Definition at line 129 of file main.c.


Generated on 7 Sep 2016 for Eggdrop by  doxygen 1.6.1