Well, you can rely on environmental variables to check the IP of the machine connecting to the server, as it's set by your local webserver. (assuming you trust your local webserver, that is.) Yes, there are issues, but I don't think it's worth ruling them out -- for authentication yes, not it can still be used for authorization, if you know where the problems are.

HTTP_ADDR is very reliable. However, the problem comes that it might not be the IP for the machine that the person is connecting from.

Many proxies will also set X_FORWARDED_FOR, but they're not required to, and those IP addresses aren't necesarily routable, which means that a collision in non-routable space may not be a collision for different proxy servers.

If you're just looking for _some_ sort of rate throtling (ie, better than nothing at all), I'd use a combination of HTTP_ADDR, and X_FORWARDED_FOR. I'd probably not worry about the issues with non-routable colisions, and keep track of the following:

if ( defined $ENV{'X_FORWARDED_FOR'} ) { &track(':'.$ENV{'X_FORWARDED_FOR'}); &track{$ENV{'HOST_ADDR'}.':'.$ENV{'X_FORWARDED_FOR'}); } else { &track{$ENV{'HOST_ADDR'}); }

(specific tracking code depends on what you're planning, how much memory you have, and what other resources (ie, database), you have available.)

Now, let's look at the flaw in my plan -- anyone can send whatever they want in X_FORWARDED_FOR, which would suggest they're a proxy server, and you'd not be rate limiting them if they put something random in it. (it's possible that the original poster would want to rate limit proxy servers at some smaller interval, just to keep the 10,000 possibility down).

Personally, I'd just impose extra sleep for those times of collisions in the case of a proxy -- if you slow it down to one every 30 seconds or so, it makes it less likely that it'll get abused. (and remember that in whatever tracking system you're using, log at the time that it comes in, but set the timestamp to the time that it's expected to run, so if something else comes in while it's sleeping, it won't just wait ($time), it'll wait $time past the current one finishing.

Just remember -- anything you can do will never making spamming impossible. You juat need to make things harder on the spammer so they'll try somewhere else -- hopefully, without imposing too much of a burder on your legitimate users.


In reply to Re^2: Limit submissions over time? by jhourcle
in thread Limit submissions over time? by deadbarnacle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.