473,473 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

check for maximum connections per IP

1 New Member
const char *GetParsedIP(const char *ipadd)
{
// code by Dan Pop, http://bytes.com/forum/thread212174.html
unsigned b1, b2, b3, b4, port = 0;
unsigned char c;
int rc;
static char ipge[20];

if(!Q_strncmp(ipadd,"localhost",strlen("localhost" )))
return "localhost";

rc = sscanf(ipadd, "%3u.%3u.%3u.%3u:%u%c", &b1, &b2, &b3, &b4, &port, &c);
if (rc < 4 || rc > 5)
return NULL;
if ( (b1 | b2 | b3 | b4) > 255 || port > 65535)
return NULL;
if (strspn(ipadd, "0123456789.:") < strlen(ipadd))
return NULL;
sprintf(ipge, "%u.%u.%u.%u", b1, b2, b3, b4);
return ipge;
}
if(count == 0 ){//== 0
return "Missing IP in userinfo.";
} else if(count > 1){
return "Too many IP fields in userinfo";
} else {
if (GetParsedIP(Info_ValueForKey(userinfo, "ip")) == NULL)
return "Malformed IP in userinfo.";
}
count = 0;
// quad: check for maximum connections per IP
// based on reyalp's combinedfixes.lua and Invaderzim's patch
// (prevents fakeplayers DOS http://aluigi.altervista.org/fakep.htm )
conn_per_ip = 1;
// value = Info_ValueForKey (userinfo, "ip"); // Dens: value is already the ip
Q_strncpyz(ip, GetParsedIP(value), sizeof(ip));
for (i=0; i<level.numConnectedClients; i++) {
clientNum2 = level.sortedClients[i];
if(clientNum == clientNum2) continue;
if(isBot || g_entities[clientNum2].r.svFlags & SVF_BOT) continue; // IGNORE BOTS
trap_GetUserinfo(clientNum2,
userinfo2,
sizeof(userinfo2));
value = Info_ValueForKey (userinfo2, "ip");
Q_strncpyz(ip2, GetParsedIP(value), sizeof(ip2));
if (strcmp(ip, ip2)==0) {
conn_per_ip++;
}
}
if (conn_per_ip > g_maxIPconnections.integer) {
G_LogPrintf("RtCW: Possible DoS attack, rejecting client from %s "
"(%d connections already)\n", ip, g_maxIPconnections.integer);
return "Too many connections from your IP.";
}

Hi

I found the code on assambla site and i put in wolf rtcw source but when i connect to server and server is in warmup i get this meassage Q_strncpyz: NULL src
also when server goes to next map Q_strncpyz: NULL src
i search in web but the answers there i found didnt help
i hope here is somebody who can help me
Feb 26 '12 #1
0 1191

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: PAUL MENARD | last post by:
--0-1370207171-1058366654=:75594 Content-Type: text/plain; charset=us-ascii Good morning all, I have a problem with inceasing connection to my database that eventually result in connections...
8
by: Maddman | last post by:
Newbie here. I've got my database set up in SQL 2000, and have started an Access adp for a front end. I have 10 licenses, and at the moment the only accesses are the server through Remote...
5
by: daniel.shaya | last post by:
I'll try and keep this brief so in a nutshell: I have large distributed java system running on a Windows 2003 server (4cpu 8Gb memory). Periodically the following exceptions occurs in the...
3
by: Raghu Rudra | last post by:
By default, the machine.config contains following information: <system.net> ....... <connectionManagement> <add address="*" maxconnection="2"/> </connectionManagement> </system.net> This...
2
by: Mythran | last post by:
I am quite familiar with C/C++ network handling on *nux boxes and it's blocking/non-blocking I/O. What I need to do in VB.Net is very similar. I need to take a single server application and allow...
4
by: ed | last post by:
Hi, how do i check if other applications is already connected to an access database (.mdb file)? Let's say I have an application that opens an mdb file, for example - test.mdb. Then I opened another...
0
by: Aaron Pfeifer | last post by:
Hi, I'm currently running a load test in Visual Studio 2005 (Academic) / .NET 2.0 against a web service written in c# (.NET 1.1). However, I'm only able to hit the web service with a maximum of...
0
by: Aaron Pfeifer | last post by:
Hi, I'm currently running a load test in Visual Studio 2005 (Academic) / .NET 2.0 against a web service written in c# (.NET 1.1). However, I'm only able to hit the web service with a maximum of...
3
by: Venkat | last post by:
Hi, We have a windows application developed in c# and SQL Server 2005. Our application need to execute more than one command (ExecuteReader and ExecuteScalar) at a single time. Till now we have...
0
by: dolittle | last post by:
Hi, I`m using apache as a proxy to solve cross domain security restriction of javascript. The client sends AJAX requests to a JAVA based jabber server and the Apache serves as a proxy so the...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.