Welcome, Guest. Please Login or Register.
November 29, 2024, 09:48:24 PM
Home Help Search Log in Register
News: If you are still using YaBB SE, please consider upgrading to SMF as soon as possible.

YaBB SE Community  |  English User Help  |  English Help  |  Flooding user causes lost connection to Mysql server during query « previous next »
Pages: [1] Reply Ignore Print
Author Topic: Flooding user causes lost connection to Mysql server during query  (Read 460 times)
Snoader
Noobie
*
Posts: 28


No guts, no glory.

WWW
Flooding user causes lost connection to Mysql server during query
« on: October 14, 2003, 10:41:33 AM »
Reply with quote

YaBB SE Version: 1.5.4
PHP Version:
MySQL Version:
Server Platform: Unix, Linux, or BSD
Link to Forum:

Problem Description:
Hi,

Suppose, a (banned) user is flooding a forum. He manages to send 6 or 7 calls to the forum within one second.

In the errorlog, we see this (multiple times):

Guest : x.x.x.x : Today at x:x:x
/forum/index.php?board=30;action=post;threadid=[...]
Database error: Lost connection to MySQL server during query
File: /opt/guide/www.mysite.com/HTML/forum/Sources/Security.php
Line: 50

This means, that the following query doesn't work well when a user is flooding the forum:

$request = mysql_query("SELECT value FROM {$db_prefix}banned WHERE (type='ip' AND (value='$remote_ip' OR value='$ipparts[0].$ipparts[1].$ipparts[2].*' OR value='$ipparts[0].$ipparts[1].*.*')) $registeredUserString;") or database_error(__FILE__, __LINE__);

As a result of this error, it won't be determined that the user causing this error is a banned user!! Not that he can do anything on the forum, but I don't like it that he can cause database_errors.

Is is possible to put an index on the banned-table?

Or is there any other way to make sure this query will perform well and doesn't lead to an error when stressed?

Thanks in advance!
Logged

[Unknown]
Global Moderator
YaBB God
*****
Posts: 7830


ICQ - 179721867unknownbrackets@hotmail.com WWW
Re:Flooding user causes lost connection to Mysql server during query
« Reply #1 on: October 15, 2003, 04:55:27 AM »
Reply with quote

Usually this is because of an unstable link to the MySQL server.  For best performance, I'd recommend having them - funny enough - on the same server. (web and database.)

-[Unknown]
Logged
Snoader
Noobie
*
Posts: 28


No guts, no glory.

WWW
Re:Flooding user causes lost connection to Mysql server during query
« Reply #2 on: October 15, 2003, 07:45:05 AM »
Reply with quote

Quote from: [Unknown] on October 15, 2003, 04:55:27 AM
Usually this is because of an unstable link to the MySQL server.  For best performance, I'd recommend having them - funny enough - on the same server. (web and database.)

Unfortunately, that's no option since the site is hosted somewhere else.

Suppose this is not because of an unstable link, are there any things I can do to prevent errors during the query?
Logged

[Unknown]
Global Moderator
YaBB God
*****
Posts: 7830


ICQ - 179721867unknownbrackets@hotmail.com WWW
Re:Flooding user causes lost connection to Mysql server during query
« Reply #3 on: October 16, 2003, 02:20:04 AM »
Reply with quote

If you have no banned users at all, I can tell you how to remove it ;).

Do you ban by IP, usually?  If you do, do you use wildcards (127.0.*.*) or the exact IP?

-[Unknown]
Logged
Snoader
Noobie
*
Posts: 28


No guts, no glory.

WWW
Re:Flooding user causes lost connection to Mysql server during query
« Reply #4 on: October 16, 2003, 02:43:01 PM »
Reply with quote

Because I had the idea that the query had performance problems, I made some changes to the code.

I took the Security.php from version 1.4.1 (with a triple ban-check, instead of the current check which contains 3 checks (IP, email and username) at once), and copied the code of the query to check for a banned IP.

I added the following to the current function banning():

Pseudo-code:

User = Guest?
then
  wait a small random amount of time
  check only for banned IP
else
 do normal check
end

Checking for banned usernames and email-adresses when the current user is a Guest is not necessary at all, and now our errorlog stays clean when the flooder is flooding the forum because the check-IP query works much better under high loads. :)

When the user stops his flooding attacks somewhere in the future, I'll remove the random amount of time-wait, because it (only) effects other guest-users (slower loading of pages).
Logged

Snoader
Noobie
*
Posts: 28


No guts, no glory.

WWW
Re:Flooding user causes lost connection to Mysql server during query
« Reply #5 on: October 16, 2003, 05:36:00 PM »
Reply with quote

By the way [Unknown], thanks for responding!
Logged

Pages: [1] Reply Ignore Print 
YaBB SE Community  |  English User Help  |  English Help  |  Flooding user causes lost connection to Mysql server during query « previous - next »
 


Powered by MySQL Powered by PHP YaBB SE Community | Powered by YaBB SE
© 2001-2003, YaBB SE Dev Team. All Rights Reserved.
SMF 2.1.4 © 2023, Simple Machines
Valid XHTML 1.0! Valid CSS

Page created in 0.021 seconds with 20 queries.