Re: AW: Drop connection when tcpserver -c limit is reached, Is it posible?
Jimmy Spam <[email protected]> Tue, 27 Jul 2010 13:21:08 +0200
| Newsgroups | gmane.mail.qmail.ldap |
|---|---|
| Message-ID | <[email protected]> |
Hi,
really I didn't write a patch as it, only done a little modification.
Download the original patch from:
http://qmail.jms1.net/ucspi-tcp/tcpserver-limits-2007-12-22.patch
find this block of code:
------------------------------------------------
if (!flagdeny && (maxconnip != -1 || maxconnc != -1)) {
unsigned long u;
long c1=0, cc=0;
for (u=0; u < limit; u++) if (child[u].pid != 0) {
if ((child[u].ip[0] == remoteip[0]) &&
(child[u].ip[1] == remoteip[1]) &&
(child[u].ip[2] == remoteip[2]) ) {
cc++;
if (child[u].ip[3] == remoteip[3]) c1++;
}
}
if (maxconnc != -1 && (cc >= maxconnc)) flagdeny = 4;
if (maxconnip != -1 && (c1 >= maxconnip)) flagdeny = 3;
}
------------------------------------------------------
modify it:
-------------------------------------------------------------
if (!flagdeny && (maxconnip != -1 || maxconnc != -1)) {
unsigned long u;
long c1=0, cc=0;
for (u=0; u < limit; u++) if (child[u].pid != 0) {
cc++;
if ((child[u].ip[0] == remoteip[0]) &&
(child[u].ip[1] == remoteip[1]) &&
(child[u].ip[2] == remoteip[2]) &&
(child[u].ip[3] == remoteip[3])) {
c1++;
}
}
if (maxconnc != -1 && (cc >= maxconnc)) flagdeny = 4;
if (maxconnip != -1 && (c1 >= maxconnip)) flagdeny = 3;
}
---------------------------------------------------------------
Really, this is a very "fast-modification" wich can be improved, for
example adding a new parameter instead of use the parameter defined
for C-Class block of IP, as I did. Or better, adding support for
specify address in CIDR format.
Regards,
Spamis
Berger Stefan <[email protected]> escribió:
> Hi ,
>
> Can you share your patch ?
>
> Regards
> Steve
>
>
>> Hi friends,
>>
>> I've already fixed this problem. My solution:
>>
>> Modify the tcpserver limits patch (http://qmail.jms1.net/ucspi-tcp/)
>> for add a "global limit" instead of only a "per IP" and "per C-Class
>> block" limit, recompile tcpserver.c and use the new binary of tcpserver.
>>
>>
>> Regards,
>> Spamis
>