Browse Source

steamFormat is now unsigned; SteamID 2 format added; SteamID 3 format added; pidbug and mustSanitize ServerProfile fields utilized.

pull/3/head
JustinAJ 10 years ago
parent
commit
777242952c
  1. 36
      RenX.Core/RenX_Server.cpp
  2. 2
      RenX.Core/RenX_Server.h

36
RenX.Core/RenX_Server.cpp

@ -94,6 +94,7 @@ int RenX::Server::send(const Jupiter::ReadableString &command)
for (size_t i = 0; i != command.size(); i++) t[i + 1] = command.get(i); for (size_t i = 0; i != command.size(); i++) t[i + 1] = command.get(i);
t[command.size() + 1] = '\n'; t[command.size() + 1] = '\n';
int r; int r;
if (RenX::Server::profile->mustSanitize)
RenX::sanitizeString(t); RenX::sanitizeString(t);
r = RenX::Server::sock.send(t, command.size() + 2); r = RenX::Server::sock.send(t, command.size() + 2);
delete[] t; delete[] t;
@ -106,6 +107,7 @@ int RenX::Server::sendMessage(const Jupiter::ReadableString &message)
strcpy(t, "csay "); strcpy(t, "csay ");
for (size_t i = 0; i != message.size(); i++) t[i + 5] = message.get(i); for (size_t i = 0; i != message.size(); i++) t[i + 5] = message.get(i);
t[message.size() + 5] = '\n'; t[message.size() + 5] = '\n';
if (RenX::Server::profile->mustSanitize)
RenX::sanitizeString(t); RenX::sanitizeString(t);
int r = RenX::Server::sock.send(t, message.size() + 6); int r = RenX::Server::sock.send(t, message.size() + 6);
delete[] t; delete[] t;
@ -184,13 +186,19 @@ Jupiter::StringS RenX::Server::formatSteamID(uint64_t id)
default: default:
case 16: case 16:
return Jupiter::StringS::Format("0x%.16llX", id); return Jupiter::StringS::Format("0x%.16llX", id);
break;
case 10: case 10:
return Jupiter::StringS::Format("%llu", id); return Jupiter::StringS::Format("%llu", id);
break;
case 8: case 8:
return Jupiter::StringS::Format("0%llo", id); return Jupiter::StringS::Format("0%llo", id);
break; case -2:
id -= 0x0110000100000000ULL;
if (id % 2 == 1)
return Jupiter::StringS::Format("STEAM_1:1:%llu", id / 2ULL);
else
return Jupiter::StringS::Format("STEAM_1:0:%llu", id / 2ULL);
case -3:
id -= 0x0110000100000000ULL;
return Jupiter::StringS::Format("[U:1:%llu]", id);
} }
} }
@ -201,33 +209,41 @@ void RenX::Server::kickPlayer(int id)
void RenX::Server::kickPlayer(const RenX::PlayerInfo *player) void RenX::Server::kickPlayer(const RenX::PlayerInfo *player)
{ {
if (this->profile->pidbug)
{
if (player->isBot) if (player->isBot)
RenX::Server::sock.send(Jupiter::StringS::Format("cadminkick %.*s\n", player->name.size(), player->name.ptr())); RenX::Server::sock.send(Jupiter::StringS::Format("cadminkick %.*s\n", player->name.size(), player->name.ptr()));
else if (player->id < 1000 || this->rconVersion > 2) else if (player->id < 1000)
RenX::Server::kickPlayer(player->id); RenX::Server::kickPlayer(player->id);
else if (player->name.contains('|') == false) else if (player->name.contains('|') == false)
RenX::Server::sock.send(Jupiter::StringS::Format("cadminkick %.*s\n", player->name.size(), player->name.ptr())); RenX::Server::sock.send(Jupiter::StringS::Format("cadminkick %.*s\n", player->name.size(), player->name.ptr()));
else else
RenX::Server::kickPlayer(player->id); RenX::Server::kickPlayer(player->id);
}
else
RenX::Server::kickPlayer(player->id);
} }
void RenX::Server::banPlayer(int id) void RenX::Server::banPlayer(int id)
{ {
Jupiter::StringS msg; RenX::Server::sock.send(Jupiter::StringS::Format("cadminkickban pid%d\n", id));
msg.format("cadminkickban pid%d\n", id);
RenX::Server::sock.send(msg);
} }
void RenX::Server::banPlayer(const RenX::PlayerInfo *player) void RenX::Server::banPlayer(const RenX::PlayerInfo *player)
{ {
if (this->profile->pidbug)
{
if (player->isBot) if (player->isBot)
RenX::Server::sock.send(Jupiter::StringS::Format("cadminkickban %.*s\n", player->name.size(), player->name.ptr())); RenX::Server::sock.send(Jupiter::StringS::Format("cadminkickban %.*s\n", player->name.size(), player->name.ptr()));
else if (player->id < 1000 || this->rconVersion > 2) else if (player->id < 1000)
RenX::Server::sock.send(Jupiter::StringS::Format("cadminkickban pid%d\n", player->id)); RenX::Server::banPlayer(player->id);
else if (player->name.contains('|') == false) else if (player->name.contains('|') == false)
RenX::Server::sock.send(Jupiter::StringS::Format("cadminkickban %.*s\n", player->name.size(), player->name.ptr())); RenX::Server::sock.send(Jupiter::StringS::Format("cadminkickban %.*s\n", player->name.size(), player->name.ptr()));
else else
RenX::Server::sock.send(Jupiter::StringS::Format("cadminkickban pid%d\n", player->id)); RenX::Server::banPlayer(player->id);
}
else
RenX::Server::banPlayer(player->id);
} }
bool RenX::Server::removePlayer(int id) bool RenX::Server::removePlayer(int id)

2
RenX.Core/RenX_Server.h

@ -444,7 +444,7 @@ namespace RenX
int adminLogChanType; int adminLogChanType;
time_t lastAttempt = 0; time_t lastAttempt = 0;
time_t delay; time_t delay;
unsigned int steamFormat; /** 16 = hex, 10 = base 10, 8 = octal */ int steamFormat; /** 16 = hex, 10 = base 10, 8 = octal, -2 = SteamID 2, -3 = SteamID 3 */
unsigned int uuidMode; /** 0 = steam, 1 = nickname */ unsigned int uuidMode; /** 0 = steam, 1 = nickname */
Jupiter::TCPSocket sock; Jupiter::TCPSocket sock;
Jupiter::CStringS clientHostname; Jupiter::CStringS clientHostname;

Loading…
Cancel
Save