Browse Source

Moved resolution to OnPlayerCreate().

pull/3/head
JustinAJ 10 years ago
parent
commit
1f5e05e3b7
  1. 38
      RenX.DNS/RenX_DNS.cpp
  2. 3
      RenX.DNS/RenX_DNS.h

38
RenX.DNS/RenX_DNS.cpp

@ -17,24 +17,34 @@
typedef void(RenX::Server::*logFuncType)(const char *fmt, ...) const; typedef void(RenX::Server::*logFuncType)(const char *fmt, ...) const;
void RenX_DNSPlugin::RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *player) void RenX_DNSPlugin::RenX_OnPlayerCreate(RenX::Server *server, const RenX::PlayerInfo *player)
{ {
Jupiter::ReferenceString host = Jupiter::ReferenceString(Jupiter::Socket::resolveHostname(Jupiter::CStringS(player->ip).c_str(), 0)); if (player->isBot == false)
const_cast<RenX::PlayerInfo *>(player)->varData.set(RenX_DNSPlugin::name, STRING_LITERAL_AS_REFERENCE("Host"), host);
logFuncType func;
if (RenX_DNSPlugin::resolveAdmin)
{ {
if (RenX_DNSPlugin::resolvePublic) Jupiter::ReferenceString host = Jupiter::ReferenceString(Jupiter::Socket::resolveHostname(Jupiter::CStringS(player->ip).c_str(), 0));
func = &RenX::Server::sendLogChan; const_cast<RenX::PlayerInfo *>(player)->varData.set(RenX_DNSPlugin::name, STRING_LITERAL_AS_REFERENCE("Host"), host);
else func = &RenX::Server::sendAdmChan;
} }
else if (RenX_DNSPlugin::resolvePublic) }
func = &RenX::Server::sendPubChan;
else return; void RenX_DNSPlugin::RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *player)
{
if (player->isBot == false)
{
logFuncType func;
if (RenX_DNSPlugin::resolveAdmin)
{
if (RenX_DNSPlugin::resolvePublic)
func = &RenX::Server::sendLogChan;
else func = &RenX::Server::sendAdmChan;
}
else if (RenX_DNSPlugin::resolvePublic)
func = &RenX::Server::sendPubChan;
else return;
Jupiter::ReadableString &name = RenX::getFormattedPlayerName(player); const Jupiter::ReadableString &host = player->varData.get(RenX_DNSPlugin::name, STRING_LITERAL_AS_REFERENCE("Host"), Jupiter::ReferenceString::empty);
(server->*func)(IRCCOLOR "03[DNS] " IRCBOLD "%.*s" IRCBOLD IRCCOLOR "'s hostname resolved to: " IRCBOLD IRCCOLOR "10%.*s" IRCBOLD, name.size(), name.ptr(), host.size(), host.ptr()); Jupiter::ReadableString &name = RenX::getFormattedPlayerName(player);
(server->*func)(IRCCOLOR "03[DNS] " IRCBOLD "%.*s" IRCBOLD IRCCOLOR "'s hostname resolved to: " IRCBOLD IRCCOLOR "10%.*s" IRCBOLD, name.size(), name.ptr(), host.size(), host.ptr());
}
} }
int RenX_DNSPlugin::OnRehash() int RenX_DNSPlugin::OnRehash()

3
RenX.DNS/RenX_DNS.h

@ -16,7 +16,8 @@
class RenX_DNSPlugin : public RenX::Plugin class RenX_DNSPlugin : public RenX::Plugin
{ {
public: // RenX::Plugin public: // RenX::Plugin
void RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *player); void RenX_OnPlayerCreate(RenX::Server *server, const RenX::PlayerInfo *player) override;
void RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *player) override;
public: // Jupiter::Plugin public: // Jupiter::Plugin
const Jupiter::ReadableString &getName() override { return name; } const Jupiter::ReadableString &getName() override { return name; }

Loading…
Cancel
Save