/* dccutil.c -- handles: lots of little functions to send formatted text to varying types of connections '.who', '.whom', and '.dccstat' code memory management for dcc structures timeout checking for dcc connections dprintf'ized, 28aug95 */ #if HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include /* hpux needs for ntohl */ #include "eggdrop.h" #include "proto.h" extern struct dcc_t dcc[]; extern int dcc_total; extern char tempdir[]; extern char botname[]; extern char origbotname[]; extern char botchan[]; extern char ver[]; extern char version[]; extern char os[]; extern char admin[]; extern int isolate; extern int serv; /* file where the motd for dcc chat is stored */ char motdfile[121]="motd"; int expmem_dccutil() { int tot,i,j; tot=0; for (i=0; iaway!=NULL) tot+=strlen(dcc[i].u.chat->away)+1; } if ((j==DCC_FILES) || (j==DCC_FILES_PASS)) { tot+=sizeof(struct file_info)+sizeof(struct chat_info); if (dcc[i].u.file->chat->away!=NULL) tot+=strlen(dcc[i].u.file->chat-> away)+1; } if (j==DCC_EDIT) { tot+=sizeof(struct edit_info)+sizeof(struct chat_info); if (dcc[i].u.edit->chat->away!=NULL) tot+=strlen(dcc[i].u.edit->chat-> away)+1; } if ((j==DCC_SEND) || (j==DCC_GET) || (j==DCC_GET_PENDING)) tot+=sizeof(struct xfer_info); if ((j==DCC_TANDEM) || (j==DCC_TANDEM_NEW)) tot+=sizeof(struct tand_info); if ((j==DCC_RELAY) || (j==DCC_RELAYING)) { tot+=sizeof(struct relay_info)+sizeof(struct chat_info); if (dcc[i].u.relay->chat->away!=NULL) tot+=strlen(dcc[i].u.relay->chat-> away)+1; } if (j==DCC_FORK) { tot+=sizeof(struct fork_info); switch(dcc[i].u.fork->type) { case DCC_FORK: case DCC_EDIT: case DCC_CHAT: tot+=sizeof(struct chat_info); break; case DCC_FILES: tot+=sizeof(struct file_info)+sizeof(struct chat_info); break; case DCC_SEND: tot+=sizeof(struct xfer_info); break; case DCC_TANDEM: tot+=sizeof(struct tand_info); break; case DCC_RELAY: tot+=sizeof(struct relay_info)+sizeof(struct chat_info); break; } } if (j==DCC_SCRIPT) { tot+=sizeof(struct script_info); switch(dcc[i].u.script->type) { case DCC_CHAT: tot+=sizeof(struct chat_info); break; case DCC_FILES: tot+=sizeof(struct file_info)+sizeof(struct chat_info); break; } } } return tot; } /* better than tprintf, it can differentiate between socket types since you give it a dcc index instead of a socket number. in the future, more and more things will call this INSTEAD of tprintf. yes, it's slower and more cpu intensive, but it does linefeeds correctly for telnet users. */ void dprintf(va_alist) va_dcl { static char s[1024]; char *format,*p,*q; int idx,cr; va_list va; va_start(va); idx=va_arg(va,int); format=va_arg(va,char *); vsprintf(s,format,va); cr=0; /* telnet people get a special linefeed type -- !!!!UGH!!!! */ switch (dcc[idx].type) { case DCC_CHAT: case DCC_CHAT_PASS: case DCC_TELNET_ID: case DCC_TELNET_NEW: case DCC_TELNET_PW: if (dcc[idx].u.chat->status&STAT_TELNET) cr=1; break; case DCC_FILES: case DCC_FILES_PASS: if (dcc[idx].u.file->chat->status&STAT_TELNET) cr=1; break; case DCC_EDIT: if (dcc[idx].u.edit->chat->status&STAT_TELNET) cr=1; break; case DCC_RELAYING: if (dcc[idx].u.relay->chat->status&STAT_TELNET) cr=1; break; case DCC_SCRIPT: if (dcc[idx].u.script->type==DCC_FILES) { if (dcc[idx].u.script->u.file->chat->status&STAT_TELNET) cr=1; } { if (dcc[idx].u.script->u.chat->status&STAT_TELNET) cr=1; } break; } if (cr) { /* replace \n with \r\n */ for (p=s; *p!=0; p++) if (*p == '\n') { *p++='\r'; q=nmalloc(strlen(p)+1); strcpy(q,p); *p++='\n'; strcpy(p,q); nfree(q); p--; } } if (strlen(s)>510) s[510]=0; /* truncate to fit */ tputs(dcc[idx].sock,s); va_end(va); } void chatout(va_alist) va_dcl { int i; va_list va; char *format; char s[601]; va_start(va); format=va_arg(va,char *); vsprintf(s,format,va); for (i=0; ichannel==chan) tputs(dcc[i].sock,s); va_end(va); } void tandout(va_alist) va_dcl { int i; va_list va; char *format; char s[601]; va_start(va); format=va_arg(va,char *); vsprintf(s,format,va); for (i=0; istatus&STAT_SHARE) && (!(dcc[i].u.tand->status&STAT_GETTING)) && (!(dcc[i].u.tand->status&STAT_SENDING))) tputs(dcc[i].sock,s); q_resync(s); va_end(va); } void shareout_but(va_alist) va_dcl { int i,x; va_list va; char *format; char s[601]; va_start(va); x=va_arg(va,int); format=va_arg(va,char *); vsprintf(s,format,va); for (i=0; istatus&STAT_SHARE) && (!(dcc[i].u.tand->status&STAT_GETTING)) && (!(dcc[i].u.tand->status&STAT_SENDING))) tputs(dcc[i].sock,s); q_resync(s); va_end(va); } /* print to all but one */ void chatout_but(va_alist) va_dcl { int i,x; va_list va; char *format; char s[601]; va_start(va); x=va_arg(va,int); format=va_arg(va,char *); vsprintf(s,format,va); for (i=0; ichannel==chan) tputs(dcc[i].sock,s); va_end(va); } /* ditto for tandem bots */ void tandout_but(va_alist) va_dcl { int i,x; va_list va; char *format; char s[601]; va_start(va); x=va_arg(va,int); format=va_arg(va,char *); vsprintf(s,format,va); for (i=0; ichannel>=0)) || ((chan>=0) && (dcc[i].u.chat->channel==chan))) tprintf(z,"whom %s %s%c%s %s %s%s%s\n",nick,(dcc[i].u.chat->channel==0) &&(chan==(-1))?"+":"",dcc[i].u.chat->status&STAT_MASTER?'*': (dcc[i].u.chat->status&STAT_PARTY?'-':'@'),dcc[i].nick, origbotname,dcc[i].host,dcc[i].u.chat->away==NULL?"":" [AWAY]", now-dcc[i].u.chat->timer>300?" [idle]":""); } void answer_local_whom(idx,chan) int idx,chan; { int i; time_t now=time(NULL); if (chan==(-1)) dprintf(idx,"Users across the bot network (+: party line)\n"); else if (chan>0) dprintf(idx,"Users listening on channel %d:\n",chan); dprintf(idx,"%-10s %-9s Host\n","Nick","Bot"); dprintf(idx,"---------- --------- ------------------------------\n"); for (i=0; i=0) && (dcc[i].u.chat->channel==chan))) dprintf(idx,"%c%-9s %c %-9s %s%s%s\n",dcc[i].u.chat->status&STAT_MASTER? '*':(dcc[i].u.chat->status&STAT_PARTY?' ':'@'),dcc[i].nick, (dcc[i].u.chat->channel==0)&&(chan==(-1))?'+':' ',origbotname, dcc[i].host,(dcc[i].u.chat->away!=NULL)?" [AWAY]":"", now-dcc[i].u.chat->timer>300?" [idle]":""); } if (isolate) dprintf(idx,"This bot is isolated from any joint party line.\n"); } void tell_tandem_info(z,nick) int z; char *nick; { #ifdef TCL tprintf(z,"priv %s %s Channel: %s (%s +Tcl)\n",origbotname,nick, botchan,ver); #else tprintf(z,"priv %s %s Channel: %s (%s)\n",origbotname,nick,botchan, ver); #endif if (admin[0]) tprintf(z,"priv %s %s Admin: %s\n",origbotname,nick,admin); if (isolate) tprintf(z,"priv %s %s (I'm isolated from the joint party line.)\n", origbotname,nick); } void tell_tandem_who(z,nick,chan) int z; char *nick; int chan; { int i,k,ok=0; char s[121]; time_t tt; tt=time(NULL); tell_tandem_info(z,nick); if (!isolate) { if (chan==0) tprintf(z,"priv %s %s Party line members: (* = master, @ = op)\n", origbotname,nick); else tprintf(z,"priv %s %s People on channel %d: (* = master, @ = op)\n", origbotname,nick,chan); for (i=0; ichannel==chan) { sprintf(s,"| %c%-10s %s",dcc[i].u.chat->status&STAT_MASTER? '*':(dcc[i].u.chat->status&STAT_PARTY?' ':'@'),dcc[i].nick, dcc[i].host); if (tt - dcc[i].u.chat->timer > 300) { k=(tt-dcc[i].u.chat->timer)/60; if (k<60) sprintf(&s[strlen(s)]," (idle %dm)",k); else sprintf(&s[strlen(s)]," (idle %dh%dm)",k/60,k%60); } tprintf(z,"priv %s %s %s\n",origbotname,nick,s); if (dcc[i].u.chat->away!=NULL) tprintf(z,"priv %s %s | AWAY: %s\n",origbotname,nick, dcc[i].u.chat->away); } } for (i=0; i status&STAT_CALLED?"<-":"->",dcc[i].u.tand->status&STAT_SHARE? '+':' ',dcc[i].nick,dcc[i].u.tand->version); } ok=0; for (i=0; ichannel!=chan) { if (!ok) { ok=1; tprintf(z,"priv %s %s Other people on the bot:\n",origbotname, nick); } sprintf(s," %c%-10s %s",dcc[i].u.chat->status&STAT_MASTER?'*': (dcc[i].u.chat->status&STAT_PARTY?' ':'@'),dcc[i].nick, dcc[i].host); if (tt - dcc[i].u.chat->timer > 300) { k=(tt-dcc[i].u.chat->timer)/60; if (k<60) sprintf(&s[strlen(s)]," (idle %dm)",k); else sprintf(&s[strlen(s)]," (idle %dh%dm)",k/60,k%60); } tprintf(z,"priv %s %s |%s\n",origbotname,nick,s); if (dcc[i].u.chat->away!=NULL) tprintf(z,"priv %s %s | AWAY: %s\n",origbotname,nick, dcc[i].u.chat->away); } } void tell_who(idx,chan) int idx,chan; { int i,k,ok=0; char s[121]; time_t tt; tt=time(NULL); if (chan==0) dprintf(idx,"Party line members: (* = master, @ = op)\n"); else dprintf(idx,"People on channel %d: (* = master, @ = op)\n",chan); for (i=0; ichannel==chan) { sprintf(s," %c%-10s %s",dcc[i].u.chat->status&STAT_MASTER?'*': (dcc[i].u.chat->status&STAT_PARTY?' ':'@'),dcc[i].nick, dcc[i].host); if (dcc[idx].u.chat->status&STAT_MASTER) { if (dcc[i].u.chat->con_flags) sprintf(&s[strlen(s)]," (con:%s)",masktype(dcc[i].u.chat-> con_flags)); if (dcc[i].u.chat->status&STAT_TALK) strcat(s," (talk)"); } if (tt - dcc[i].u.chat->timer > 300) { k=(tt-dcc[i].u.chat->timer)/60; if (k<60) sprintf(&s[strlen(s)]," (idle %dm)",k); else sprintf(&s[strlen(s)]," (idle %dh%dm)",k/60,k%60); } dprintf(idx,"%s\n",s); if (dcc[i].u.chat->away!=NULL) dprintf(idx," AWAY: %s\n",dcc[i].u.chat->away); } for (i=0; itimer)); strcpy(s,&s[1]); s[9]=0; strcpy(s,&s[7]); s[2]=' '; strcpy(&s[7],&s[10]); s[12]=0; dprintf(idx," %s%c%-10s (%s) %s\n",dcc[i].u.tand->status&STAT_CALLED? "<-":"->",dcc[i].u.tand->status&STAT_SHARE?'+':' ',dcc[i].nick, s,dcc[i].u.tand->version); } ok=0; for (i=0; ichannel!=chan)) { if (!ok) { ok=1; dprintf(idx,"Other people on the bot:\n"); } sprintf(s," %c%-10s ",dcc[i].u.chat->status&STAT_MASTER?'*': (dcc[i].u.chat->status&STAT_PARTY?' ':'@'),dcc[i].nick); if (dcc[idx].u.chat->status&STAT_MASTER) { if (dcc[i].u.chat->channel<0) strcat(s,"(-OFF-) "); else if (dcc[i].u.chat->channel==0) strcat(s,"(party) "); else sprintf(&s[strlen(s)],"(%5d) ",dcc[i].u.chat->channel); } strcat(s,dcc[i].host); if (dcc[idx].u.chat->status&STAT_MASTER) { if (dcc[i].u.chat->con_flags) sprintf(&s[strlen(s)]," (con:%s)",masktype(dcc[i].u.chat-> con_flags)); if (dcc[i].u.chat->status&STAT_TALK) strcat(s," (talk)"); } if (tt - dcc[i].u.chat->timer > 300) { k=(tt-dcc[i].u.chat->timer)/60; if (k<60) sprintf(&s[strlen(s)]," (idle %dm)",k); else sprintf(&s[strlen(s)]," (idle %dh%dm)",k/60,k%60); } dprintf(idx,"%s\n",s); if (dcc[i].u.chat->away!=NULL) dprintf(idx," AWAY: %s\n",dcc[i].u.chat->away); } if (dcc[i].type==DCC_FILES) { if (!ok) { ok=1; dprintf(idx,"Other people on the bot:\n"); } sprintf(s," %c%-10s (files) %s",dcc[i].u.file->chat->status&STAT_CHAT? '+':' ',dcc[i].nick,dcc[i].host); dprintf(idx,"%s\n",s); } } } void dcc_chatter(idx) int idx; { int i; dprintf(idx,"Connected to %s, running %s\n",botname,version); show_motd(idx); /* tell_who(idx); */ dprintf(idx,"Commands start with '.' (like '.quit' or '.help')\n"); dprintf(idx,"Everything else goes out to the party line.\n\n"); chanout(dcc[idx].u.chat->channel,"*** %s (%s) joined the party line.\n", dcc[idx].nick,dcc[idx].host); if (!isolate) tandout("chan %s %d %s joined the party line.\n",origbotname, dcc[idx].u.chat->channel,dcc[idx].nick); notes_read(dcc[idx].nick,"",-1,idx); } /* remove entry from dcc list */ void lostdcc(n) int n; { int i; switch(dcc[n].type) { case DCC_CHAT: case DCC_TELNET_ID: case DCC_CHAT_PASS: case DCC_TELNET_NEW: case DCC_TELNET_PW: if (dcc[n].u.chat->away!=NULL) nfree(dcc[n].u.chat->away); nfree(dcc[n].u.chat); break; case DCC_FILES_PASS: case DCC_FILES: nfree(dcc[n].u.file->chat); nfree(dcc[n].u.file); break; case DCC_EDIT: nfree(dcc[n].u.edit->chat); nfree(dcc[n].u.edit); break; case DCC_SEND: case DCC_GET: case DCC_GET_PENDING: nfree(dcc[n].u.xfer); break; case DCC_TANDEM: case DCC_TANDEM_NEW: nfree(dcc[n].u.tand); break; case DCC_RELAY: case DCC_RELAYING: nfree(dcc[n].u.relay->chat); nfree(dcc[n].u.relay); break; case DCC_FORK: switch (dcc[n].u.fork->type) { case DCC_EDIT: case DCC_FORK: case DCC_CHAT: nfree(dcc[n].u.fork->u.chat); break; case DCC_FILES: nfree(dcc[n].u.fork->u.file->chat); nfree(dcc[n].u.fork->u.file); break; case DCC_TANDEM: nfree(dcc[n].u.fork->u.tand); break; case DCC_RELAY: nfree(dcc[n].u.fork->u.relay->chat); nfree(dcc[n].u.fork->u.relay); break; case DCC_SEND: nfree(dcc[n].u.fork->u.xfer); break; } nfree(dcc[n].u.fork); break; case DCC_SCRIPT: switch(dcc[n].u.script->type) { case DCC_CHAT: nfree(dcc[n].u.script->u.chat); break; case DCC_FILES: nfree(dcc[n].u.script->u.file->chat); nfree(dcc[n].u.script->u.file); break; } nfree(dcc[n].u.script); break; } dcc_total--; for (i=n; i17) strcpy(s,&dcc[i].host[strlen(dcc[i].host)-17]); else strcpy(s,dcc[i].host); switch (dcc[i].type) { case DCC_CHAT: strcpy(x,"chat"); sprintf(other,"flags: %s/%d",stat_str(dcc[i].u.chat->status), dcc[i].u.chat->channel); break; case DCC_CHAT_PASS: strcpy(x,"pass"); sprintf(other,"waited %lus",now-dcc[i].u.chat->timer); break; case DCC_SEND: strcpy(x,"send"); sprintf(other,"%lu/%lu",dcc[i].u.xfer->sent,dcc[i].u.xfer->length); break; case DCC_GET: strcpy(x,"get "); sprintf(other,"%lu/%lu",dcc[i].u.xfer->sent,dcc[i].u.xfer->length); break; case DCC_GET_PENDING: strcpy(x,"getp"); sprintf(other,"waited %lus",now-dcc[i].u.xfer->pending); break; case DCC_TELNET: strcpy(x,"teln"); other[0]=0; break; case DCC_TELNET_ID: strcpy(x,"t-in"); sprintf(other,"waited %lus",now-dcc[i].u.chat->timer); break; case DCC_FILES: strcpy(x,"file"); sprintf(other,"flags: %s",stat_str(dcc[i].u.file->chat->status)); break; case DCC_EDIT: strcpy(x,"edit"); sprintf(other,"BROKEN"); break; case DCC_TANDEM: strcpy(x,"tand"); sprintf(other,"flags: %s",stat_str2(dcc[i].u.tand->status)); break; case DCC_TANDEM_NEW: strcpy(x,"tnd*"); sprintf(other,"waited %lus",now-dcc[i].u.tand->timer); break; case DCC_RELAY: strcpy(x,"rela"); sprintf(other,"-> sock %d",dcc[i].u.relay->sock); break; case DCC_RELAYING: strcpy(x,">rly"); sprintf(other,"-> sock %d",dcc[i].u.relay->sock); break; case DCC_FORK: strcpy(x,"fork"); switch(dcc[i].u.fork->type) { case DCC_CHAT: strcpy(other,"chat"); break; case DCC_FILES: strcpy(other,"file"); break; case DCC_TANDEM: strcpy(other,"tand"); break; case DCC_RELAY: strcpy(other,"rela"); break; case DCC_SEND: strcpy(other,"send"); break; } break; case DCC_FILES_PASS: strcpy(x,"fpas"); sprintf(other,"waited %lus",now-dcc[i].u.file->chat->timer); break; case DCC_TELNET_NEW: strcpy(x,"new "); sprintf(other,"waited %lus",now-dcc[i].u.chat->timer); break; case DCC_TELNET_PW: strcpy(x,"newp"); sprintf(other,"waited %lus",now-dcc[i].u.chat->timer); break; case DCC_SCRIPT: strcpy(x,"scri"); strcpy(other,dcc[i].u.script->command); break; case DCC_LOST: strcpy(x,"LOST"); sprintf(other,"(zombie)"); break; default: sprintf(x,"?:%02d",dcc[i].type); sprintf(other,"!! ERROR !!"); break; } if (dcc[i].type==DCC_FORK) { if (zidx<0) tprintf(-zidx,"%2d %08X %5d %-9s %-17s %-4s %s\n",i,dcc[i].addr, dcc[i].port,dcc[i].nick,s,x,other); else dprintf(zidx,"%2d %08X %5d %-9s %-17s %-4s %s\n",i,dcc[i].addr, dcc[i].port,dcc[i].nick,s,x,other); } else { if (zidx<0) tprintf(-zidx,"%2d %-4d %08X %5d %-9s %-17s %-4s %s\n",i,dcc[i].sock, dcc[i].addr,dcc[i].port,dcc[i].nick,s,x,other); else dprintf(zidx,"%2d %-4d %08X %5d %-9s %-17s %-4s %s\n",i,dcc[i].sock, dcc[i].addr,dcc[i].port,dcc[i].nick,s,x,other); } if ((dcc[i].type==DCC_SEND) || (dcc[i].type==DCC_GET) || (dcc[i].type==DCC_GET_PENDING)) { if (zidx<0) tprintf(-zidx," Filename: %s\n",dcc[i].u.xfer->filename); else dprintf(zidx," Filename: %s\n",dcc[i].u.xfer->filename); } if (dcc[i].type==DCC_FORK) tell_dcc_proc(zidx,i); } } /* mark someone on dcc chat as no longer away */ void not_away(idx) int idx; { int i; if (dcc[idx].u.chat->away==NULL) { dprintf(idx,"You weren't away!\n"); return; } if (dcc[idx].u.chat->channel>=0) { chanout(dcc[idx].u.chat->channel,"*** %s is no longer away.\n", dcc[idx].nick); if (!isolate) tandout("chan %s %d %s is no longer away.\n",origbotname, dcc[idx].u.chat->channel,dcc[idx].nick); } dprintf(idx,"You're not away any more.\n"); nfree(dcc[idx].u.chat->away); dcc[idx].u.chat->away=NULL; notes_read(dcc[idx].nick,"",-1,idx); } void set_away(idx,s) int idx; char *s; { if (s==NULL) { not_away(idx); return; } if (!s[0]) { not_away(idx); return; } if (dcc[idx].u.chat->away!=NULL) nfree(dcc[idx].u.chat->away); dcc[idx].u.chat->away=(char *)nmalloc(strlen(s)+1); strcpy(dcc[idx].u.chat->away,s); if (dcc[idx].u.chat->channel>=0) { chanout(dcc[idx].u.chat->channel,"*** %s is now away: %s\n",dcc[idx].nick, s); if (!isolate) tandout("chan %s %d %s is now away: %s\n",origbotname, dcc[idx].u.chat->channel,dcc[idx].nick,s); } dprintf(idx,"You are now away; notes will be stored.\n"); } /* assumes it was chat type before! */ void set_files(idx) int idx; { struct chat_info *ci; ci=dcc[idx].u.chat; dcc[idx].u.file=(struct file_info *)nmalloc(sizeof(struct file_info)); dcc[idx].u.file->chat=ci; } void set_tand(idx) int idx; { dcc[idx].u.tand=(struct tand_info *)nmalloc(sizeof(struct tand_info)); } void set_chat(idx) int idx; { dcc[idx].u.chat=(struct chat_info *)nmalloc(sizeof(struct chat_info)); } void set_xfer(idx) int idx; { dcc[idx].u.xfer=(struct xfer_info *)nmalloc(sizeof(struct xfer_info)); } void get_file_ptr(p) struct file_info **p; { (*p)=(struct file_info *)nmalloc(sizeof(struct file_info)); } void get_chat_ptr(p) struct chat_info **p; { (*p)=(struct chat_info *)nmalloc(sizeof(struct chat_info)); } void get_xfer_ptr(p) struct xfer_info **p; { (*p)=(struct xfer_info *)nmalloc(sizeof(struct xfer_info)); } void set_fork(idx) int idx; { void *hold; hold=dcc[idx].u.other; dcc[idx].u.fork=(struct fork_info *)nmalloc(sizeof(struct fork_info)); dcc[idx].u.fork->u.other=hold; dcc[idx].u.fork->type=dcc[idx].type; dcc[idx].type=DCC_FORK; } void set_script(idx) int idx; { void *hold; hold=dcc[idx].u.other; dcc[idx].u.script=(struct script_info *)nmalloc(sizeof(struct script_info)); dcc[idx].u.script->u.other=hold; dcc[idx].u.script->type=dcc[idx].type; dcc[idx].type=DCC_SCRIPT; } void set_relay(idx) int idx; { dcc[idx].u.relay=(struct relay_info *)nmalloc(sizeof(struct relay_info)); } void set_new_relay(idx) int idx; { set_relay(idx); dcc[idx].u.relay->chat=(struct chat_info *)nmalloc(sizeof(struct chat_info)); } /* make a password, 6-9 random letters and digits */ void makepass(s) char *s; { int i,j,k; i=6+(random()%4); for (j=0; jpending > 300) { strcpy(xx,dcc[i].u.xfer->filename); p=strrchr(xx,'/'); mprintf(serv,"NOTICE %s :Timeout on dcc send %s.\n",dcc[i].nick,p+1); log(LOG_FILES,"DCC timeout: GET %s (%s)",p+1,dcc[i].nick); wipe_tmp_file(i); strcpy(xx,dcc[i].nick); close(dcc[i].sock); shutdown(dcc[i].sock,2); lostdcc(i); i--; if (!at_limit(xx)) send_next_file(xx); } } else if (dcc[i].type==DCC_GET) { if (now-dcc[i].u.xfer->pending > WAIT_DCC_XFER) { strcpy(xx,dcc[i].u.xfer->filename); p=strrchr(xx,'/'); mprintf(serv,"NOTICE %s :Timeout during transfer, aborting %s.\n", dcc[i].nick,p+1); log(LOG_FILES,"DCC timeout: GET %s (%s) at %lu/%lu",p+1,dcc[i].nick, dcc[i].u.xfer->sent,dcc[i].u.xfer->length); wipe_tmp_file(i); strcpy(xx,dcc[i].nick); close(dcc[i].sock); shutdown(dcc[i].sock,2); lostdcc(i); i--; if (!at_limit(xx)) send_next_file(xx); } } else if (dcc[i].type==DCC_SEND) { if (now-dcc[i].u.xfer->pending > WAIT_DCC_XFER) { mprintf(serv,"NOTICE %s :Timeout during transfer, aborting %s.\n", dcc[i].nick,dcc[i].u.xfer->filename); log(LOG_FILES,"DCC timeout: SEND %s (%s) at %lu/%lu",dcc[i].u.xfer-> filename,dcc[i].nick,dcc[i].u.xfer->sent,dcc[i].u.xfer->length); sprintf(xx,"%s%s",tempdir,dcc[i].u.xfer->filename); unlink(xx); close(dcc[i].sock); shutdown(dcc[i].sock,2); lostdcc(i); i--; } } else if (dcc[i].type==DCC_CHAT_PASS) { if (now-dcc[i].u.chat->timer > 180) { dprintf(i,"Timeout.\n"); log(LOG_MISC,"Password timeout on dcc chat: [%s]%s",dcc[i].nick, dcc[i].host); close(dcc[i].sock); shutdown(dcc[i].sock,2); lostdcc(i); i--; } } else if (dcc[i].type==DCC_FILES_PASS) { if (now-dcc[i].u.file->chat->timer > 180) { dprintf(i,"Timeout.\n"); log(LOG_MISC,"Password timeout on dcc chat: [%s]%s",dcc[i].nick, dcc[i].host); close(dcc[i].sock); shutdown(dcc[i].sock,2); lostdcc(i); i--; } } else if (dcc[i].type==DCC_TELNET_ID) { if (now-dcc[i].u.chat->timer > 180) { dprintf(i,"Timeout.\n"); log(LOG_MISC,"Ident timeout on telnet: %s",dcc[i].host); close(dcc[i].sock); shutdown(dcc[i].sock,2); lostdcc(i); i--; } } else if (dcc[i].type==DCC_TANDEM_NEW) { if (now-dcc[i].u.tand->timer > 60) { log(LOG_MISC,"Timeout: Tandem link to %s at %s:%d",dcc[i].nick, dcc[i].host,dcc[i].port); close(dcc[i].sock); shutdown(dcc[i].sock,2); lostdcc(i); i--; } } else if (dcc[i].type==DCC_TELNET_NEW) { if (now-dcc[i].u.chat->timer > 180) { dprintf(i,"Guess you're not there. Bye.\n"); log(LOG_MISC,"Timeout on new telnet user: %s/%d",dcc[i].host, dcc[i].port); close(dcc[i].sock); shutdown(dcc[i].sock,2); lostdcc(i); i--; } } else if (dcc[i].type==DCC_TELNET_PW) { if (now-dcc[i].u.chat->timer > 180) { dprintf(i,"Guess you're not there. Bye.\n"); log(LOG_MISC,"Timeout on new telnet user: [%s]%s/%d",dcc[i].nick, dcc[i].host,dcc[i].port); close(dcc[i].sock); shutdown(dcc[i].sock,2); lostdcc(i); i--; } } } }