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