diff -ur ../iroffer1.4.b02.orig/Configure ./Configure --- ../iroffer1.4.b02.orig/Configure Mon Jan 17 00:17:40 2005 +++ ./Configure Sun Feb 6 12:40:48 2005 @@ -18,9 +18,9 @@ fi if [ $RELEASE -eq 1 ]; then - VERSIONLONG="$VERSION [$CSET]" + VERSIONLONG="$VERSION [$CSET] mod by Dinoex 1.3" else - VERSIONLONG="$VERSION [PRERELEASE $CSET]" + VERSIONLONG="$VERSION [PRERELEASE $CSET] mod by Dinoex 1.3" fi echo Only in .: Makefile Only in .: README.modDinoex Only in .: c.sh Only in .: convertxdccfile Only in .: d.sh Only in .: iroffer Only in .: m.sh Only in .: obj Only in .: p.sh Only in .: patch-dinoex-10 Only in .: r.sh diff -ur ../iroffer1.4.b02.orig/sample.config ./sample.config --- ../iroffer1.4.b02.orig/sample.config Mon Jan 17 00:17:40 2005 +++ ./sample.config Sat Feb 5 13:37:00 2005 @@ -163,6 +163,12 @@ #usenatip 123.456.789.123 ############################################################################## +### - automatic dcc ip translation - ### +### get my own IP from the ircserver, and uses thsi as value for usenatip ### +### set usenatip to a default value when using this option ### +#getipfromserver + +############################################################################## ### - excluded from auto-ignore - ### ### These hostmasks (one per line) will never be ignored. ### #autoignore_exclude nickserv!nickserv@services.domain.com diff -ur ../iroffer1.4.b02.orig/src/convertxdccfile.c ./src/convertxdccfile.c --- ../iroffer1.4.b02.orig/src/convertxdccfile.c Mon Jan 17 00:17:40 2005 +++ ./src/convertxdccfile.c Wed Jan 19 19:17:58 2005 @@ -25,10 +25,56 @@ static void usage(const char *progname) { - fprintf(stderr, "Usage: %s [-v] -x mybot.xdcc -s mybot.state\n", progname); + fprintf(stderr, "Usage: %s [-v] [-g] -x mybot.xdcc -s mybot.state\n", progname); exit(1); } +int splizzer; + +struct list_s { + struct list_s *l_next; + char *l_data; +} *seen_list; + +static struct list_s *seen_init(const char *data) +{ + struct list_s *new; + + new = malloc(sizeof(struct list_s)); + if (new == NULL) + return NULL; + new->l_next = NULL; + new->l_data = (data != NULL) ? strdup(data) : NULL; + return new; +} + +static int seen(const char *data) +{ + struct list_s *old; + struct list_s *new; + + if (seen_list == NULL) { + new = seen_init(data); + seen_list = new; + return 0; + } + old = seen_list; + while (old->l_next != NULL) { + if (old->l_data != NULL) { + if (strcasecmp(old->l_data,data) == 0) + return 1; + } + old = old->l_next; + } + + if (old->l_data != NULL) { + if (strcasecmp(old->l_data,data) == 0) + return 1; + } + new = seen_init(data); + old->l_next = new; + return 0; +} static void getxdccconfig(const char *filename) { char *templine1 = mycalloc(maxtextlength); @@ -37,6 +83,9 @@ char *templine4 = mycalloc(maxtextlength); char *templine5 = mycalloc(maxtextlength); char *templine6 = mycalloc(maxtextlength); + char *templine7 = mycalloc(maxtextlength); + char *templine8 = mycalloc(maxtextlength); + char *templine9 = mycalloc(maxtextlength); char *msg; int ok,i; int filedescriptor,xfiledescriptor; @@ -136,8 +185,16 @@ if (getfline(templine5,maxtextlength,filedescriptor,0) == NULL) ok++; if (getfline(templine6,maxtextlength,filedescriptor,0) == NULL) ok++; - if (ok) + if (splizzer != 0) { + if (getfline(templine7,maxtextlength,filedescriptor,0) == NULL) ok++; + if (getfline(templine8,maxtextlength,filedescriptor,0) == NULL) ok++; + if (getfline(templine9,maxtextlength,filedescriptor,0) == NULL) ok++; + } + + if (ok) { + printf("** ERROR: to read a XDCC file with group definitions use '-g'\n"); outerror(OUTERROR_TYPE_CRASH,"XDCC file syntax error (missing/extra line)"); + } for (i=strlen(templine1)-1; i>7 && templine1[i] == ' '; i--) templine1[i] = '\0'; @@ -151,6 +208,12 @@ templine5[i] = '\0'; for (i=strlen(templine6)-1; i>7 && templine6[i] == ' '; i--) templine6[i] = '\0'; + for (i=strlen(templine7)-1; i>7 && templine7[i] == ' '; i--) + templine7[i] = '\0'; + for (i=strlen(templine8)-1; i>7 && templine8[i] == ' '; i--) + templine8[i] = '\0'; + for (i=strlen(templine9)-1; i>7 && templine9[i] == ' '; i--) + templine9[i] = '\0'; if ((strlen(templine1) < 8) || strncmp(templine1+3,"file ",5)) ok++; if ((strlen(templine2) < 8) || strncmp(templine2+3,"desc ",5)) ok++; @@ -158,6 +221,13 @@ if ((strlen(templine4) < 8) || strncmp(templine4+3,"gets ",5)) ok++; if ((strlen(templine5) < 8) || strncmp(templine5+3,"mins ",5)) ok++; if ((strlen(templine6) < 8) || strncmp(templine6+3,"maxs ",5)) ok++; + if (splizzer != 0) { + if ((strlen(templine7) < 8) || strncmp(templine7+3,"data ",5)) ok++; + if ((strlen(templine8) < 8) || strncmp(templine8+3,"trig ",5)) ok++; + if ((strlen(templine9) < 8) || strncmp(templine9+3,"trno ",5)) ok++; + } + if (ok) + printf("error=%d, near file=%s\n", ok, templine1); if (ok) outerror(OUTERROR_TYPE_CRASH,"XDCC file syntax error (incorrect order?)"); @@ -176,6 +246,17 @@ xd->gets = atoi(templine4+8); + xd->group = NULL; + xd->group_desc = NULL; + if (splizzer != 0) { + xd->group = mycalloc(strlen(templine7+8)+1); + strcpy(xd->group,templine7+8); + if (seen(templine9+8) == 0) { + xd->group_desc = mycalloc(strlen(templine9+8)+1); + strcpy(xd->group_desc,templine9+8); + } + } + xd->minspeed = gdata.transferminspeed; if ( atof(templine5+8) > 0) xd->minspeed = atof(templine5+8); @@ -239,6 +320,10 @@ mydelete(templine4); mydelete(templine5); mydelete(templine6); + mydelete(templine6); + mydelete(templine7); + mydelete(templine8); + mydelete(templine9); } @@ -254,6 +339,8 @@ gdata.nocolor = 1; gdata.noscreen = 1; gdata.debug = 1; + splizzer = 0; + seen_list = NULL; #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64) /* 4GB max size */ @@ -267,12 +354,16 @@ gdata.startuptime = gdata.curtime = time(NULL); gdata.curtimems = ((unsigned long long)gdata.curtime) * 1000; - while ((callval_i = getopt(argc, argv, "vx:s:")) >= 0) + while ((callval_i = getopt(argc, argv, "vgx:s:")) >= 0) { switch (callval_i) { case 'v': gdata.debug++; + break; + + case 'g': + splizzer++; break; case 'x': diff -ur ../iroffer1.4.b02.orig/src/iroffer_admin.c ./src/iroffer_admin.c --- ../iroffer1.4.b02.orig/src/iroffer_admin.c Mon Jan 17 00:17:40 2005 +++ ./src/iroffer_admin.c Sun Feb 6 12:20:17 2005 @@ -28,6 +28,10 @@ u_respond(const userinput * const u, const char *format, ...); static void u_help(const userinput * const u); +static int u_xdl_space(void); +static void u_xdl_pack(char *tempstr, int i, int s, const xdcc *xd); +static void u_xdl_full(const userinput * const u); +static void u_xdl_group(const userinput * const u); static void u_xdl(const userinput * const u); static void u_xds(const userinput * const u); static void u_dcl(const userinput * const u); @@ -57,6 +61,11 @@ static void u_chmins(const userinput * const u); static void u_chmaxs(const userinput * const u); static void u_chgets(const userinput * const u); +static void u_lock(const userinput * const u); +static void u_unlock(const userinput * const u); +static void u_groupdesc(const userinput * const u); +static void u_group(const userinput * const u); +static void u_regroup(const userinput * const u); static void u_add(const userinput * const u); static void u_adddir(const userinput * const u); static void u_addnew(const userinput * const u); @@ -103,6 +112,8 @@ /* local info */ static const userinput_parse_t userinput_parse[] = { {1,method_allow_all,u_help, "HELP",NULL,"Shows Help"}, +{1,method_allow_all_xdl,u_xdl_full, "XDLFULL",NULL,"Lists All Offered Files"}, +{1,method_allow_all_xdl,u_xdl_group, "XDLGROUP","","Show "}, {1,method_allow_all_xdl,u_xdl, "XDL",NULL,"Lists Offered Files"}, {1,method_allow_all,u_xds, "XDS",NULL,"Save XDCC File"}, {1,method_allow_all,u_dcl, "DCL",NULL,"Lists Current Transfers"}, @@ -135,6 +146,11 @@ {3,method_allow_all,u_chmins, "CHMINS","n x","Change min speed of pack n to x KB"}, {3,method_allow_all,u_chmaxs, "CHMAXS","n x","Change max speed of pack n to x KB"}, {3,method_allow_all,u_chgets, "CHGETS","n x","Change the get count of a pack"}, +{3,method_allow_all,u_lock, "LOCK","n x","Lock the pack n with password x"}, +{3,method_allow_all,u_unlock, "UNLOCK","n","Unlock the pack n"}, +{3,method_allow_all,u_groupdesc, "GROUPDESC"," ","Change Desc of group to "}, +{3,method_allow_all,u_group, "GROUP","n ","Change Group of pack n to "}, +{3,method_allow_all,u_regroup, "REGROUP"," ","Change all packs of group to "}, {4,method_allow_all,u_msg, "MSG"," ","Send a message to a user"}, {4,method_allow_all,u_mesg, "MESG","","Sends msg to all users who are transferring"}, @@ -479,13 +495,131 @@ } +static int u_xdl_space(void) { + int i,s; + xdcc *xd; + + i = 0; + xd = irlist_get_head(&gdata.xdccs); + while(xd) + { + i = max2(i,xd->gets); + xd = irlist_get_next(xd); + } + s = 5; + if (i < 10000) s = 4; + if (i < 1000) s = 3; + if (i < 100) s = 2; + if (i < 10) s = 1; + return s; +} + +static void u_xdl_pack(char *tempstr, int i, int s, const xdcc *xd) { + char *sizestrstr; + int len; + + sizestrstr = sizestr(1, xd->st_size); + snprintf(tempstr, maxtextlength - 1, + "\2#%-2i\2 %*ix [%s] %s", + i, + s, xd->gets, + sizestrstr, + xd->desc); + len = strlen(tempstr); + mydelete(sizestrstr); + + if (xd->minspeed > 0 && xd->minspeed != gdata.transferminspeed) + { + snprintf(tempstr + len, maxtextlength - 1 - len, + " [%1.1fK Min]", + xd->minspeed); + len = strlen(tempstr); + } + + if (xd->maxspeed > 0 && xd->maxspeed != gdata.transfermaxspeed) + { + snprintf(tempstr + len, maxtextlength - 1 - len, + " [%1.1fK Max]", + xd->maxspeed); + len = strlen(tempstr); + } +} + +static void u_xdl_full(const userinput * const u) { + char *tempstr; + xdcc *xd; + int i,s; + + updatecontext(); + + tempstr = mycalloc(maxtextlength); + i = 1; + s = u_xdl_space(); + xd = irlist_get_head(&gdata.xdccs); + while(xd) + { + u_xdl_pack(tempstr,i,s,xd); + u_respond(u,"%s",tempstr); + i++; + xd = irlist_get_next(xd); + } + + mydelete(tempstr); +} + +static void u_xdl_group(const userinput * const u) { + char *tempstr; + char *msg3; + xdcc *xd; + int i,k,s; + + updatecontext(); + + msg3 = u->arg1; + if (msg3 == NULL) + return; + + tempstr = mycalloc(maxtextlength); + i = 1; + k = 0; + s = u_xdl_space(); + xd = irlist_get_head(&gdata.xdccs); + while(xd) + { + if (xd->group != NULL) + { + if (strcasecmp(xd->group,msg3) == 0 ) + { + if (xd->group_desc != NULL) + { + u_respond(u,"group: %s %s",msg3,xd->group_desc); + } + + u_xdl_pack(tempstr,i,s,xd); + u_respond(u,"%s",tempstr); + k++; + } + } + i++; + xd = irlist_get_next(xd); + } + + mydelete(tempstr); + if (!k) + { + u_respond(u,"Sorry, nothing was found, try a XDCC LIST"); + } +} + static void u_xdl(const userinput * const u) { char *tempstr; - const char *spaces[] = { ""," "," "," "," "," "," " }; + char *inlist; + static const char *spaces[] = { ""," "," "," "," "," "," " }; int a,i,m,m1,s; float toffered; int len; xdcc *xd; + irlist_t grplist = {}; ir_uint64 xdccsent; updatecontext(); @@ -607,64 +741,54 @@ return; } - s = 0; - xd = irlist_get_head(&gdata.xdccs); - while(xd) - { - s = max2(s,xd->gets); - xd = irlist_get_next(xd); - } - i = s; s = 5; - if (i < 10000) s = 4; - if (i < 1000) s = 3; - if (i < 100) s = 2; - if (i < 10) s = 1; - + s = u_xdl_space(); i = 1; toffered = 0; xd = irlist_get_head(&gdata.xdccs); while(xd) { - char *sizestrstr; toffered += (float)xd->st_size; - sizestrstr = sizestr(1, xd->st_size); - snprintf(tempstr, maxtextlength - 1, - "\2#%-2i\2 %*ix [%s] %s", - i, - s, xd->gets, - sizestrstr, - xd->desc); - len = strlen(tempstr); - mydelete(sizestrstr); - - if (xd->minspeed > 0 && xd->minspeed != gdata.transferminspeed) - { - snprintf(tempstr + len, maxtextlength - 1 - len, - " [%1.1fK Min]", - xd->minspeed); - len = strlen(tempstr); - } - - if (xd->maxspeed > 0 && xd->maxspeed != gdata.transfermaxspeed) + /* skip is group is set */ + if (xd->group == NULL) { - snprintf(tempstr + len, maxtextlength - 1 - len, - " [%1.1fK Max]", - xd->maxspeed); - len = strlen(tempstr); - } + u_xdl_pack(tempstr,i,s,xd); + u_respond(u,"%s",tempstr); - u_respond(u,"%s",tempstr); + if (xd->note && strlen(xd->note)) + { + u_respond(u," \2^-\2%s%s",spaces[s],xd->note); + } - if (xd->note && strlen(xd->note)) - { - u_respond(u," \2^-\2%s%s",spaces[s],xd->note); } - i++; xd = irlist_get_next(xd); } + i = 1; + xd = irlist_get_head(&gdata.xdccs); + while(xd) + { + /* groupe entry and entry is visible */ + if ((xd->group != NULL) && (xd->group_desc != NULL)) + { + snprintf(tempstr,maxtextlength-1, + "%s %s",xd->group,xd->group_desc); + inlist = irlist_add(&grplist, strlen(tempstr) + 1); + strcpy(inlist, tempstr); + } + i++; + xd = irlist_get_next(xd); + } + + irlist_sort(&grplist, irlist_sort_cmpfunc_string, NULL); + inlist = irlist_get_head(&grplist); + while (inlist) + { + u_respond(u,"group: %s",inlist); + inlist = irlist_delete(&grplist, inlist); + } + if (gdata.creditline) { u_respond(u,"\2**\2 %s \2**\2",gdata.creditline); @@ -1047,10 +1171,10 @@ i, pq->nick, getfilename(pq->xpack->file), - (gdata.curtime-pq->queuedtime)/60/60, - ((gdata.curtime-pq->queuedtime)/60)%60, - rtime/60/60, - (rtime/60)%60); + (long)((gdata.curtime-pq->queuedtime)/60/60), + (long)(((gdata.curtime-pq->queuedtime)/60)%60), + (long)(rtime/60/60), + (long)(rtime/60)%60); } else { @@ -1058,8 +1182,8 @@ i, pq->nick, getfilename(pq->xpack->file), - (gdata.curtime-pq->queuedtime)/60/60, - ((gdata.curtime-pq->queuedtime)/60)%60); + (long)((gdata.curtime-pq->queuedtime)/60/60), + (long)(((gdata.curtime-pq->queuedtime)/60)%60)); } pq = irlist_get_next(pq); i++; @@ -1471,7 +1595,7 @@ u_respond(u,"Sending %s pack %i",u->arg1,num); - sendxdccfile(u->arg1,"man","man",num,NULL); + sendxdccfile(u->arg1,"man","man",num,NULL,NULL); } @@ -2209,6 +2333,217 @@ xd->gets = atoi(u->arg2); + write_statefile(); + xdccsavetext(); +} + +static void u_lock(const userinput * const u) +{ + int num = 0; + xdcc *xd; + + updatecontext(); + + if (u->arg1) + { + num = atoi(u->arg1); + } + + if (num < 1 || num > irlist_size(&gdata.xdccs)) + { + u_respond(u,"Try Specifying a Valid Pack Number"); + return; + } + + if (!u->arg2 || !strlen(u->arg2)) + { + u_respond(u,"Try Specifying a Password"); + return; + } + + xd = irlist_get_nth(&gdata.xdccs, num-1); + + u_respond(u, "LOCK: [Pack %i] Password: %s", num, u->arg2e); + xd->lock = mycalloc(strlen(u->arg2e)+1); + strcpy(xd->lock,u->arg2e); + + write_statefile(); + xdccsavetext(); +} + +static void u_unlock(const userinput * const u) +{ + int num = 0; + xdcc *xd; + + updatecontext(); + + if (u->arg1) + { + num = atoi(u->arg1); + } + + if (num < 1 || num > irlist_size(&gdata.xdccs)) + { + u_respond(u,"Try Specifying a Valid Pack Number"); + return; + } + + xd = irlist_get_nth(&gdata.xdccs, num-1); + u_respond(u, "UNLOCK: [Pack %i]", num); + + mydelete(xd->lock); + xd->lock = NULL; + + write_statefile(); + xdccsavetext(); +} + +static void u_groupdesc(const userinput * const u) { + xdcc *xd; + int k; + + updatecontext(); + + if (!u->arg1 || !strlen(u->arg1)) + { + u_respond(u,"Try Specifying a Valid Group"); + return; + } + + k = 0; + xd = irlist_get_head(&gdata.xdccs); + while(xd) + { + if (xd->group != NULL) + { + if (strcasecmp(xd->group,u->arg1) == 0) + { + k++; + /* delete all matching entires */ + if (xd->group_desc != NULL) + mydelete(xd->group_desc); + /* write only the first entry */ + if (k == 1) + { + if (u->arg2e && strlen(u->arg2e)) + { + xd->group_desc = mycalloc(strlen(u->arg2e)+1); + strcpy(xd->group_desc,u->arg2e); + } + } + } + } + xd = irlist_get_next(xd); + } + + if (k == 0) + return; + + if (u->arg2e && strlen(u->arg2e)) + { + u_respond(u, "New GROUPDESC: %s",u->arg2e); + } + else + { + u_respond(u, "Removed GROUPDESC"); + } + write_statefile(); + xdccsavetext(); +} + +static void u_group(const userinput * const u) { + xdcc *xd; + const char *new; + int num = 0; + + updatecontext(); + + if (u->arg1) + { + num = atoi(u->arg1); + } + + if (num < 1 || num > irlist_size(&gdata.xdccs)) + { + u_respond(u,"Try Specifying a Valid Pack Number"); + return; + } + + xd = irlist_get_nth(&gdata.xdccs, num-1); + + new = u->arg2; + if (!u->arg2 || !strlen(u->arg2)) + { + if (xd->group == NULL) + { + u_respond(u,"Try Specifying a Group"); + return; + } + new = "MAIN"; + } + + if (xd->group != NULL) + { + u_respond(u, "GROUP: [Pack %i] Old: %s New: %s", + num,xd->group,new); + mydelete(xd->group); + } + else + { + u_respond(u, "GROUP: [Pack %i] New: %s", + num,u->arg2e); + } + + if (new == u->arg2) + { + xd->group = mycalloc(strlen(u->arg2e)+1); + strcpy(xd->group,u->arg2e); + } + + write_statefile(); + xdccsavetext(); +} + +static void u_regroup(const userinput * const u) { + xdcc *xd; + int k; + + updatecontext(); + + if (!u->arg1 || !strlen(u->arg1)) + { + u_respond(u,"Try Specifying a Valid Group"); + return; + } + + if (!u->arg2e || !strlen(u->arg2e)) + { + u_respond(u,"Try Specifying a Valid Group"); + return; + } + + k = 0; + xd = irlist_get_head(&gdata.xdccs); + while(xd) + { + if (xd->group != NULL) + { + if (strcasecmp(xd->group,u->arg1) == 0) + { + k++; + mydelete(xd->group); + xd->group = mycalloc(strlen(u->arg2e)+1); + strcpy(xd->group,u->arg2e); + } + xd = irlist_get_next(xd); + } + } + + if (k == 0) + return; + + u_respond(u, "GROUP: Old: %s New: %s", u->arg1, u->arg2e); write_statefile(); xdccsavetext(); } Only in ./src: iroffer_config.h diff -ur ../iroffer1.4.b02.orig/src/iroffer_globals.h ./src/iroffer_globals.h --- ../iroffer1.4.b02.orig/src/iroffer_globals.h Mon Jan 17 00:17:40 2005 +++ ./src/iroffer_globals.h Fri Jan 21 07:41:44 2005 @@ -85,6 +85,7 @@ char *restrictprivlistmsg; int punishslowusers; int nomd5sum; +int getipfromserver; char *nickserv_pass; int notifytime; int respondtochannelxdcc; diff -ur ../iroffer1.4.b02.orig/src/iroffer_headers.h ./src/iroffer_headers.h --- ../iroffer1.4.b02.orig/src/iroffer_headers.h Mon Jan 17 00:17:40 2005 +++ ./src/iroffer_headers.h Sun Feb 6 12:20:46 2005 @@ -142,6 +142,9 @@ typedef struct { char *file, *desc, *note; + char *group; + char *group_desc; + char *lock; int gets; float minspeed, maxspeed; @@ -409,7 +412,7 @@ /*------------ function declarations ------------- */ /* iroffer.c */ -void sendxdccfile(const char* nick, const char* hostname, const char* hostmask, int pack, const char* msg); +void sendxdccfile(const char* nick, const char* hostname, const char* hostmask, int pack, const char* msg, const char* pwd); void sendxdccinfo(const char* nick, const char* hostname, const char* hostmask, int pack, const char* msg); void sendaqueue(int type); @@ -611,6 +614,7 @@ const char *transferlimit_type_to_string(transferlimit_type_e type); /* misc.c */ +void update_natip (const char *var); void getconfig (void); void getconfig_set (const char *line, int rehash); void initirc(void); diff -ur ../iroffer1.4.b02.orig/src/iroffer_main.c ./src/iroffer_main.c --- ../iroffer1.4.b02.orig/src/iroffer_main.c Mon Jan 17 00:17:40 2005 +++ ./src/iroffer_main.c Sun Feb 6 12:38:39 2005 @@ -1787,6 +1787,16 @@ if ( !strcmp(part2,"001") ) { ioutput(CALLTYPE_NORMAL,OUT_S,COLOR_NO_COLOR,"Server welcome: %s",line); + mylog(CALLTYPE_NORMAL,"Server welcome: %s",line); + if (gdata.getipfromserver) + { + tptr = strchr(line, '@'); + if (tptr != NULL) + { + ioutput(CALLTYPE_NORMAL,OUT_S,COLOR_NO_COLOR,"IP From Server: %s",tptr+1); + update_natip(tptr+1); + } + } /* update server name */ mydelete(gdata.curserveractualname); @@ -2619,13 +2629,31 @@ } else { - user = irlist_add(&gdata.xlistqueue, strlen(nick) + 1); - strcpy(user,nick); + if (msg3) + { + userinput *pubplist; + char *tempstr = mycalloc(maxtextlength); + + snprintf(tempstr,maxtextlength-1,"A A A A A xdlgroup %s",msg3); + pubplist = mycalloc(sizeof(userinput)); + u_fillwith_msg(pubplist,nick,tempstr); + pubplist->method = method_xdl_user_notice; + u_parseit(pubplist); + mydelete(pubplist); + mydelete(tempstr); + j = 3; /* msg3 */ + } + else + { + user = irlist_add(&gdata.xlistqueue, strlen(nick) + 1); + strcpy(user,nick); + } } } } - ioutput(CALLTYPE_NORMAL,OUT_S|OUT_L|OUT_D,COLOR_YELLOW,"XDCC LIST %s: (%s)",(j==1?"ignored":(j==2?"denied":"queued")),hostmask); + ioutput(CALLTYPE_NORMAL,OUT_S|OUT_L|OUT_D,COLOR_YELLOW,"XDCC LIST %s: (%s)", + (j==1?"ignored":(j==2?"denied":(j==3?msg3:"queued"))),hostmask); } else if (gdata.caps_nick && !strcmp(gdata.caps_nick,dest)) @@ -2634,7 +2662,7 @@ if ( msg2 && msg3 && (!strcmp(msg2,"SEND") || !strcmp(msg2,"GET"))) { if (!gdata.attop) gototop(); ioutput(CALLTYPE_MULTI_FIRST,OUT_S|OUT_L|OUT_D,COLOR_YELLOW,"XDCC SEND %s",msg3); - sendxdccfile(nick, hostname, hostmask, packnumtonum(msg3), NULL); + sendxdccfile(nick, hostname, hostmask, packnumtonum(msg3), NULL, msg4); } else if ( msg2 && msg3 && (!strcmp(msg2,"INFO"))) { if (!gdata.attop) gototop(); @@ -2822,7 +2850,7 @@ snprintf(tempstr, strlen(gdata.autosend.message) + strlen(format) - 1, format, gdata.autosend.message); - sendxdccfile(nick, hostname, hostmask, gdata.autosend.pack, tempstr); + sendxdccfile(nick, hostname, hostmask, gdata.autosend.pack, tempstr, NULL); mydelete(tempstr); } @@ -2832,7 +2860,16 @@ } -void sendxdccfile(const char* nick, const char* hostname, const char* hostmask, int pack, const char* msg) +static int check_lock(const char* lockstr, const char* pwd) +{ + if (lockstr == NULL) + return 0; /* no lock */ + if (pwd == NULL) + return 1; /* locked */ + return strcmp(lockstr, pwd); +} + +void sendxdccfile(const char* nick, const char* hostname, const char* hostmask, int pack, const char* msg, const char* pwd) { int usertrans, userpackok, man; xdcc *xd; @@ -2872,6 +2909,12 @@ } xd = irlist_get_nth(&gdata.xdccs, pack-1); + if (check_lock(xd->lock, pwd) != 0) + { + ioutput(CALLTYPE_MULTI_MIDDLE,OUT_S|OUT_L|OUT_D,COLOR_YELLOW," Denied (pack locked): "); + notice(nick,"** XDCC SEND denied, this pack is locked"); + goto done; + } tr = irlist_get_head(&gdata.trans); while(tr) diff -ur ../iroffer1.4.b02.orig/src/iroffer_misc.c ./src/iroffer_misc.c --- ../iroffer1.4.b02.orig/src/iroffer_misc.c Mon Jan 17 00:17:40 2005 +++ ./src/iroffer_misc.c Fri Jan 21 16:09:38 2005 @@ -97,6 +97,7 @@ {"restrictprivlist", &gdata.restrictprivlist, &gdata.restrictprivlist }, {"restrictsend", &gdata.restrictsend, &gdata.restrictsend }, {"nomd5sum", &gdata.nomd5sum, &gdata.nomd5sum }, + {"getipfromserver", &gdata.getipfromserver, &gdata.getipfromserver }, }; typedef struct @@ -141,6 +142,56 @@ {"restrictprivlistmsg", &gdata.restrictprivlistmsg, &gdata.restrictprivlistmsg }, }; +void update_natip (const char *var) +{ + struct hostent *hp; + struct in_addr in; + struct in_addr old; + + if (var == NULL) + return; + + bzero((char *)&in, sizeof(in)); + if (inet_aton(var, &in) == 0) + { + hp = gethostbyname2(var, AF_INET); + if (hp == NULL) + { + outerror(OUTERROR_TYPE_WARN_LOUD,"Invalid NAT Host, Ignoring: %s",hstrerror(h_errno)); + return; + } + if ((unsigned)hp->h_length > sizeof(in) || hp->h_length < 0) + { + outerror(OUTERROR_TYPE_WARN_LOUD,"Invalid DNS response, Ignoring: %s",hstrerror(h_errno)); + return; + } + memcpy(&in, hp->h_addr_list[0], sizeof(in)); + } + + old.s_addr = htonl(gdata.ourip); + gdata.usenatip = 1; + if (old.s_addr == in.s_addr) + return; + + gdata.ourip = in.s_addr; + gdata.ourip = ntohl(in.s_addr); + mylog(CALLTYPE_NORMAL,"DCC IP changed from %s to %s", inet_ntoa(old), inet_ntoa(in)); + + if (gdata.debug > 0) ioutput(CALLTYPE_NORMAL,OUT_S,COLOR_YELLOW,"ip=0x%8.8lX\n",gdata.ourip); + + /* check for 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 */ + if (((gdata.ourip & 0xFF000000UL) == 0x0A000000UL) || + ((gdata.ourip & 0xFFF00000UL) == 0xAC100000UL) || + ((gdata.ourip & 0xFFFF0000UL) == 0xC0A80000UL)) + { + outerror(OUTERROR_TYPE_WARN_LOUD,"usenatip of %lu.%lu.%lu.%lu looks wrong, this is probably not what you want to do", + (gdata.ourip >> 24) & 0xFF, + (gdata.ourip >> 16) & 0xFF, + (gdata.ourip >> 8) & 0xFF, + (gdata.ourip ) & 0xFF); + } +} + void getconfig_set (const char *line, int rehash) { char *type; @@ -599,35 +650,7 @@ } else if ( ! strcmp(type,"usenatip")) { - unsigned long ipparts[4]; - if (sscanf(var, "%lu.%lu.%lu.%lu", &ipparts[0], &ipparts[1], &ipparts[2], &ipparts[3]) < 4) - { - outerror(OUTERROR_TYPE_WARN_LOUD,"Invalid NAT Host, Ignoring"); - } - else if ((ipparts[0] > 255) || (ipparts[1] > 255) || - (ipparts[2] > 255) || (ipparts[3] > 255)) - { - outerror(OUTERROR_TYPE_WARN_LOUD,"Invalid NAT Host, Ignoring"); - } - else - { - gdata.usenatip = 1; - gdata.ourip = (ipparts[0] << 24) | (ipparts[1] << 16) | (ipparts[2] << 8) | ipparts[3]; - - if (gdata.debug > 0) ioutput(CALLTYPE_NORMAL,OUT_S,COLOR_YELLOW,"ip=0x%8.8lX\n",gdata.ourip); - - /* check for 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 */ - if (((gdata.ourip & 0xFF000000UL) == 0x0A000000UL) || - ((gdata.ourip & 0xFFF00000UL) == 0xAC100000UL) || - ((gdata.ourip & 0xFFFF0000UL) == 0xC0A80000UL)) - { - outerror(OUTERROR_TYPE_WARN_LOUD,"usenatip of %lu.%lu.%lu.%lu looks wrong, this is probably not what you want to do", - (gdata.ourip >> 24) & 0xFF, - (gdata.ourip >> 16) & 0xFF, - (gdata.ourip >> 8) & 0xFF, - (gdata.ourip ) & 0xFF); - } - } + update_natip(var); mydelete(var); } else if ( ! strcmp(type,"local_vhost")) @@ -2323,6 +2346,7 @@ gdata.lowbdwth = 0; gdata.punishslowusers = 0; gdata.nomd5sum = 0; + gdata.getipfromserver = 0; gdata.transferminspeed = gdata.transfermaxspeed = 0.0; gdata.overallmaxspeed = gdata.overallmaxspeeddayspeed = 0; gdata.overallmaxspeeddaytimestart = gdata.overallmaxspeeddaytimeend = 0; diff -ur ../iroffer1.4.b02.orig/src/iroffer_statefile.c ./src/iroffer_statefile.c --- ../iroffer1.4.b02.orig/src/iroffer_statefile.c Mon Jan 17 00:17:40 2005 +++ ./src/iroffer_statefile.c Sun Feb 6 11:28:40 2005 @@ -74,6 +74,9 @@ STATEFILE_TAG_XDCCS_MINSPEED, STATEFILE_TAG_XDCCS_MAXSPEED, STATEFILE_TAG_XDCCS_MD5SUM_INFO, + STATEFILE_TAG_XDCCS_GROUP, + STATEFILE_TAG_XDCCS_GROUP_DESC, + STATEFILE_TAG_XDCCS_LOCK, STATEFILE_TAG_TLIMIT_DAILY_USED = 13 << 8, STATEFILE_TAG_TLIMIT_DAILY_ENDS, @@ -82,6 +85,11 @@ STATEFILE_TAG_TLIMIT_MONTHLY_USED, STATEFILE_TAG_TLIMIT_MONTHLY_ENDS, + STATEFILE_TAG_QUEUE = 14 << 8, + STATEFILE_TAG_QUEUE_PACK, + STATEFILE_TAG_QUEUE_NICK, + STATEFILE_TAG_QUEUE_HOST, + STATEFILE_TAG_QUEUE_TIME, } statefile_tag_t; typedef struct @@ -483,6 +491,18 @@ { length += ceiling(sizeof(statefile_item_md5sum_info_t), 4); } + if (xd->group != NULL) + { + length += sizeof(statefile_hdr_t) + ceiling(strlen(xd->group) + 1, 4); + } + if (xd->group_desc != NULL) + { + length += sizeof(statefile_hdr_t) + ceiling(strlen(xd->group_desc) + 1, 4); + } + if (xd->lock != NULL) + { + length += sizeof(statefile_hdr_t) + ceiling(strlen(xd->lock) + 1, 4); + } data = mycalloc(length); @@ -567,6 +587,37 @@ memcpy(md5sum_info->md5sum, xd->md5sum, sizeof(MD5Digest)); next = (unsigned char*)(&md5sum_info[1]); } + + if (xd->group != NULL) + { + /* group */ + hdr = (statefile_hdr_t*)next; + hdr->tag = htonl(STATEFILE_TAG_XDCCS_GROUP); + hdr->length = htonl(sizeof(statefile_hdr_t) + strlen(xd->group) + 1); + next = (unsigned char*)(&hdr[1]); + strcpy(next, xd->group); + next += ceiling(strlen(xd->group) + 1, 4); + } + if (xd->group_desc != NULL) + { + /* group_desc */ + hdr = (statefile_hdr_t*)next; + hdr->tag = htonl(STATEFILE_TAG_XDCCS_GROUP_DESC); + hdr->length = htonl(sizeof(statefile_hdr_t) + strlen(xd->group_desc) + 1); + next = (unsigned char*)(&hdr[1]); + strcpy(next, xd->group_desc); + next += ceiling(strlen(xd->group_desc) + 1, 4); + } + if (xd->lock != NULL) + { + /* group */ + hdr = (statefile_hdr_t*)next; + hdr->tag = htonl(STATEFILE_TAG_XDCCS_LOCK); + hdr->length = htonl(sizeof(statefile_hdr_t) + strlen(xd->lock) + 1); + next = (unsigned char*)(&hdr[1]); + strcpy(next, xd->lock); + next += ceiling(strlen(xd->lock) + 1, 4); + } write_statefile_item(&bout, data); @@ -622,6 +673,86 @@ item_monthly_ends.g_time = htonl(gdata.transferlimits[TRANSFERLIMIT_MONTHLY].ends); write_statefile_item(&bout, &item_monthly_ends); } + { + unsigned char *data; + unsigned char *next; + pqueue *pq; + xdcc *xd; + statefile_item_generic_int_t *g_int; + statefile_item_generic_time_t *g_time; + int pack; + + pq = irlist_get_head(&gdata.mainqueue); + + while (pq) + { + /* + * need room to write: + * pack int + * nick string + * hostname string + * queuedtime time + */ + length = sizeof(statefile_hdr_t) + + sizeof(statefile_item_generic_int_t) + + sizeof(statefile_hdr_t) + ceiling(strlen(pq->nick) + 1, 4) + + sizeof(statefile_hdr_t) + ceiling(strlen(pq->hostname) + 1, 4) + + sizeof(statefile_item_generic_time_t); + + data = mycalloc(length); + + /* outter header */ + hdr = (statefile_hdr_t*)data; + hdr->tag = STATEFILE_TAG_QUEUE; + hdr->length = length; + next = (unsigned char*)(&hdr[1]); + + pack = 1; + xd = irlist_get_head(&gdata.xdccs); + while(xd) + { + if (xd == pq->xpack) + break; + pack++; + xd = irlist_get_next(xd); + } + + /* pack */ + g_int = (statefile_item_generic_int_t*)next; + g_int->hdr.tag = htonl(STATEFILE_TAG_QUEUE_PACK); + g_int->hdr.length = htonl(sizeof(*g_int)); + g_int->g_int = htonl(pack); + next = (unsigned char*)(&g_int[1]); + + /* nick */ + hdr = (statefile_hdr_t*)next; + hdr->tag = htonl(STATEFILE_TAG_QUEUE_NICK); + hdr->length = htonl(sizeof(statefile_hdr_t) + strlen(pq->nick) + 1); + next = (unsigned char*)(&hdr[1]); + strcpy(next, pq->nick); + next += ceiling(strlen(pq->nick) + 1, 4); + + /* hostname */ + hdr = (statefile_hdr_t*)next; + hdr->tag = htonl(STATEFILE_TAG_QUEUE_HOST); + hdr->length = htonl(sizeof(statefile_hdr_t) + strlen(pq->hostname) + 1); + next = (unsigned char*)(&hdr[1]); + strcpy(next, pq->hostname); + next += ceiling(strlen(pq->hostname) + 1, 4); + + /* queuedtime */ + g_time = (statefile_item_generic_time_t*)next; + g_time->hdr.tag = htonl(STATEFILE_TAG_QUEUE_TIME); + g_time->hdr.length = htonl(sizeof(*g_time)); + g_time->g_time = htonl(pq->queuedtime); + next = (unsigned char*)(&g_time[1]); + + write_statefile_item(&bout, data); + + mydelete(data); + pq = irlist_get_next(pq); + } + } { MD5Digest digest = {}; @@ -1157,6 +1288,9 @@ xd->minspeed = gdata.transferminspeed; xd->maxspeed = gdata.transfermaxspeed; + xd->group = NULL; + xd->group_desc = NULL; + xd->lock = NULL; hdr->length -= sizeof(*hdr); ihdr = &hdr[1]; @@ -1276,6 +1410,51 @@ } break; + case STATEFILE_TAG_XDCCS_GROUP: + if (ihdr->length > sizeof(statefile_hdr_t)) + { + char *group = (char*)(&ihdr[1]); + group[ihdr->length-sizeof(statefile_hdr_t)-1] = '\0'; + xd->group = mycalloc(strlen(group)+1); + strcpy(xd->group,group); + } + else + { + outerror(OUTERROR_TYPE_WARN, "Ignoring Bad XDCC Desc Tag (len = %d)", + ihdr->length); + } + break; + + case STATEFILE_TAG_XDCCS_GROUP_DESC: + if (ihdr->length > sizeof(statefile_hdr_t)) + { + char *group_desc = (char*)(&ihdr[1]); + group_desc[ihdr->length-sizeof(statefile_hdr_t)-1] = '\0'; + xd->group_desc = mycalloc(strlen(group_desc)+1); + strcpy(xd->group_desc,group_desc); + } + else + { + outerror(OUTERROR_TYPE_WARN, "Ignoring Bad XDCC Desc Tag (len = %d)", + ihdr->length); + } + break; + + case STATEFILE_TAG_XDCCS_LOCK: + if (ihdr->length > sizeof(statefile_hdr_t)) + { + char *data = (char*)(&ihdr[1]); + data[ihdr->length-sizeof(statefile_hdr_t)-1] = '\0'; + xd->lock = mycalloc(strlen(data)+1); + strcpy(xd->lock,data); + } + else + { + outerror(OUTERROR_TYPE_WARN, "Ignoring Bad XDCC Lock Tag (len = %d)", + ihdr->length); + } + break; + default: outerror(OUTERROR_TYPE_WARN, "Ignoring Unknown XDCC Tag 0x%X (len=%d)", ihdr->tag, ihdr->length); @@ -1477,6 +1656,96 @@ } break; + case STATEFILE_TAG_QUEUE: + { + pqueue *pq; + statefile_hdr_t *ihdr; + statefile_item_generic_int_t *g_int; + statefile_item_generic_time_t *g_time; + char *text; + int num; + + pq = irlist_add(&gdata.mainqueue, sizeof(pqueue)); + + pq->xpack = NULL; + pq->nick = NULL; + pq->hostname = NULL; + pq->queuedtime = 0L; + pq->restrictsend_bad = gdata.curtime; + + hdr->length -= sizeof(*hdr); + ihdr = &hdr[1]; + + while (hdr->length >= sizeof(*hdr)) + { + ihdr->tag = ntohl(ihdr->tag); + ihdr->length = ntohl(ihdr->length); + switch (ihdr->tag) + { + case STATEFILE_TAG_QUEUE_PACK: + if (ihdr->length != sizeof(statefile_item_generic_int_t)) + { + outerror(OUTERROR_TYPE_WARN, "Ignoring Bad Queue Pack Tag (len = %d)", + ihdr->length); + break; + } + g_int = (statefile_item_generic_int_t*)ihdr; + num = ntohl(g_int->g_int); + if (num < 1 || num > irlist_size(&gdata.xdccs)) + { + outerror(OUTERROR_TYPE_WARN, "Ignoring Bad Queue Pack Nr (%d)", num); + break; + } + pq->xpack = irlist_get_nth(&gdata.xdccs, num-1); + break; + + case STATEFILE_TAG_QUEUE_NICK: + if (ihdr->length <= sizeof(statefile_hdr_t)) + { + outerror(OUTERROR_TYPE_WARN, "Ignoring Bad Queue Nick Tag (len = %d)", + ihdr->length); + break; + } + text = (char*)(&ihdr[1]); + text[ihdr->length-sizeof(statefile_hdr_t)-1] = '\0'; + pq->nick = mycalloc(strlen(text)+1); + strcpy(pq->nick,text); + break; + + case STATEFILE_TAG_QUEUE_HOST: + if (ihdr->length <= sizeof(statefile_hdr_t)) + { + outerror(OUTERROR_TYPE_WARN, "Ignoring Bad Queue Host Tag (len = %d)", + ihdr->length); + break; + } + text = (char*)(&ihdr[1]); + text[ihdr->length-sizeof(statefile_hdr_t)-1] = '\0'; + pq->hostname = mycalloc(strlen(text)+1); + strcpy(pq->hostname,text); + break; + + case STATEFILE_TAG_QUEUE_TIME: + if (ihdr->length != sizeof(statefile_item_generic_time_t)) + { + outerror(OUTERROR_TYPE_WARN, "Ignoring Bad Queue Time Tag (len = %d)", + ihdr->length); + break; + } + g_time = (statefile_item_generic_time_t*)ihdr; + pq->queuedtime = ntohl(g_time->g_time); + break; + + default: + outerror(OUTERROR_TYPE_WARN, "Ignoring Unknown XDCC Tag 0x%X (len=%d)", + ihdr->tag, ihdr->length); + } + hdr->length -= ceiling(ihdr->length, 4); + ihdr = (statefile_hdr_t*)(((char*)ihdr) + ceiling(ihdr->length, 4)); + } + } + break; + default: outerror(OUTERROR_TYPE_WARN, "Ignoring Unknown Tag 0x%X (len=%d)", hdr->tag, hdr->length); @@ -1514,6 +1783,14 @@ COLOR_NO_COLOR, " [Found %d Pack%s]", irlist_size(&gdata.xdccs), (irlist_size(&gdata.xdccs) == 1) ? "" : "s"); + } + + if ((gdata.debug > 0) || irlist_size(&gdata.mainqueue)) + { + ioutput(CALLTYPE_NORMAL, OUT_S|OUT_L|OUT_D, + COLOR_NO_COLOR, " [Found %d Queue%s]", + irlist_size(&gdata.mainqueue), + (irlist_size(&gdata.mainqueue) == 1) ? "" : "s"); } ioutput(CALLTYPE_NORMAL, OUT_S|OUT_L|OUT_D, diff -ur ../iroffer1.4.b02.orig/src/iroffer_utilities.c ./src/iroffer_utilities.c --- ../iroffer1.4.b02.orig/src/iroffer_utilities.c Mon Jan 17 00:17:40 2005 +++ ./src/iroffer_utilities.c Fri Jan 21 07:41:15 2005 @@ -1420,6 +1420,7 @@ gdata_print_int(maxqueueditemsperperson); gdata_print_int(punishslowusers); gdata_print_int(nomd5sum); + gdata_print_int(getipfromserver); /* downloadhost */ Only in .: t.sh Only in .: z.sh