Re: tcpsvd - Allow only x connections from somebody/hour

"Clemens Fischer" <[email protected]>
Newsgroups gmane.comp.misc.pape.general
Message-ID <[email protected]>
* 2004-08-26 Gerrit Pape:

> On Wed, Aug 25, 2004 at 03:27:26PM +0200, Maurice Lucas wrote:
>> I want to adjust my tcpsvd service to allow only a fixed amount of maximum
>> connections from an IP address a hour.
>
>> Is there some way to do this using tcpsvd?
>
> It's not a built-in feature of tcpsvd, no.  But it should be possible to do
> such things with a separate program put into the process chain between
> tcpsvd and the service program.  It gathers the necessary information, and
> execs into the service program, or doesn't, based on this information.

i just thought about this.  what would be the best database-implementation to
keep the IP/connection# tuples?  maurice, do you have less than a few dozen or
more than thousands of IPs connecting?  anyway, it might be easy to make a
little program keeping those tuples in a hash and do the exec(2)'ing, as the
relevant information is readily available:

  $ env - /command/tcpsvd 0 8181 /usr/bin/env
  
  $ mconnect 0 8181
  PROTO=TCP
  TCPLOCALIP=127.0.0.1
  TCPLOCALPORT=8181
  TCPLOCALHOST=localhost
  TCPREMOTEIP=127.0.0.1
  TCPREMOTEPORT=2340

(btw gerrit:  neither the man pages nor the ipsvd web pages mention
UCSPI-TCP!)

should the hash table ever get filled up, well the remote IP looses.  the
table size should be a runtime option.  as the information isn't huge, it can
be kept in memory, unless persistence or privacy are required.

  clemens
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.