コード例 #1
0
/* check if a transfer will use more  connections per user than allowed */
static void t_check_duplicateip(transfer *const newtr)
{
    igninfo *ignore;
    char *bhostmask;
    transfer *tr;
    unsigned int found;
    unsigned int num;

    if (gdata.ignore_duplicate_ip == 0)
        return;

    if (gdata.maxtransfersperperson == 0)
        return;

    updatecontext();

    if (newtr->con.family != AF_INET)
        return;

    found = 0;
    for (tr = irlist_get_head(&gdata.trans);
            tr;
            tr = irlist_get_next(tr)) {
        if (tr->tr_status != TRANSFER_STATUS_SENDING)
            continue;
        if (tr->remoteip != newtr->remoteip)
            continue;
        if (!strcmp(tr->hostname, "man")) /* NOTRANSLATE */
            continue;

        ++found;
    }

    if (found <= gdata.maxtransfersperperson)
        return;

    num = gdata.ignore_duplicate_ip * 60; /* n hours */
    for (tr = irlist_get_head(&gdata.trans);
            tr;
            tr = irlist_get_next(tr)) {
        if (tr->tr_status != TRANSFER_STATUS_SENDING)
            continue;
        if (tr->remoteip != newtr->remoteip)
            continue;
        if (!strcmp(tr->hostname, "man")) /* NOTRANSLATE */
            continue;

        t_closeconn(tr, "You are being punished for parallel downloads", 0);
        queue_punish_abuse( "You are being punished for parallel downloads", tr->net, tr->nick);

        bhostmask = to_hostmask( "*", tr->hostname); /* NOTRANSLATE */
        ignore = get_ignore(bhostmask);
        ignore->flags |= IGN_IGNORING;
        ignore->flags |= IGN_MANUAL;
        ignore->bucket = (num*60)/gdata.autoignore_threshold;

        ioutput(OUT_S|OUT_L|OUT_D, COLOR_NO_COLOR,
                "same IP detected, Ignore activated for %s which will last %u min",
                bhostmask, num);
        mydelete(bhostmask);
    }

    write_statefile();
}
コード例 #2
0
void t_checkminspeed(transfer * const t) {
   char *hostmask;
   char *tempstr2;

   updatecontext();

   if (t->tr_status != TRANSFER_STATUS_SENDING)      return; /* no checking unless we're sending */
   if (t->con.connecttime+MIN_TL > gdata.curtime)    return; /* no checking until time has passed */
   if (t->nomin || (t->xpack->minspeed) == 0.0)      return; /* no minspeed for this transfer */
   if ( t->lastspeed+0.11 > t->xpack->minspeed )     return; /* over minspeed */
   
   if (gdata.no_minspeed_on_free)
     {
        if (irlist_size(&gdata.trans) < gdata.slotsmax) return; /* free slots */
     }
   
   tempstr2 = mymalloc(maxtextlength);
   snprintf(tempstr2, maxtextlength,
        "Under Min Speed Requirement, %2.1fK/sec is less than %2.1fK/sec",
         t->lastspeed,t->xpack->minspeed);
   t_closeconn(t,tempstr2,0);
   mydelete(tempstr2);
   
   if (gdata.punishslowusers)
     {
       igninfo *ignore;
       transfer *tr;
       gnetwork_t *backup;
       
       for (tr = irlist_get_head(&gdata.trans); tr; tr = irlist_get_next(tr))
         {
           if ((tr->tr_status != TRANSFER_STATUS_DONE) &&
               (strcasecmp(tr->nick,t->nick) == 0))
             {
               t_closeconn(tr, "You are being punished for your slowness", 0);
             }
         }
       
       queue_punish_abuse("You are being punished for your slowness", t->net, t->nick);
       
       hostmask = to_hostmask( "*", t->hostname);
       ignore = get_ignore(hostmask);
       mydelete(hostmask);
       ignore->flags |= IGN_IGNORING;
       ignore->bucket = (gdata.punishslowusers*60)/gdata.autoignore_threshold;
       
       backup = gnetwork;
       gnetwork = &(gdata.networks[t->net]);
       ioutput(OUT_S|OUT_L|OUT_D, COLOR_NO_COLOR,
               "Punish-ignore activated for (%s on %s) (%s) %u minutes",
               t->nick, gdata.networks[ t->net ].name,
               ignore->hostmask,
               gdata.punishslowusers);
       
       notice(t->nick, "Punish-ignore activated for %s (%s) %u minutes",
              t->nick,
              ignore->hostmask,
              gdata.punishslowusers);
       
       gnetwork = backup;
       write_statefile();
     }
   
   }