Browse Source

Moved resolution to OnPlayerCreate().

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

12
RenX.DNS/RenX_DNS.cpp

@ -17,11 +17,19 @@
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)
{
if (player->isBot == false)
{ {
Jupiter::ReferenceString host = Jupiter::ReferenceString(Jupiter::Socket::resolveHostname(Jupiter::CStringS(player->ip).c_str(), 0)); Jupiter::ReferenceString host = Jupiter::ReferenceString(Jupiter::Socket::resolveHostname(Jupiter::CStringS(player->ip).c_str(), 0));
const_cast<RenX::PlayerInfo *>(player)->varData.set(RenX_DNSPlugin::name, STRING_LITERAL_AS_REFERENCE("Host"), host); const_cast<RenX::PlayerInfo *>(player)->varData.set(RenX_DNSPlugin::name, STRING_LITERAL_AS_REFERENCE("Host"), host);
}
}
void RenX_DNSPlugin::RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *player)
{
if (player->isBot == false)
{
logFuncType func; logFuncType func;
if (RenX_DNSPlugin::resolveAdmin) if (RenX_DNSPlugin::resolveAdmin)
{ {
@ -33,9 +41,11 @@ void RenX_DNSPlugin::RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *p
func = &RenX::Server::sendPubChan; func = &RenX::Server::sendPubChan;
else return; else return;
const Jupiter::ReadableString &host = player->varData.get(RenX_DNSPlugin::name, STRING_LITERAL_AS_REFERENCE("Host"), Jupiter::ReferenceString::empty);
Jupiter::ReadableString &name = RenX::getFormattedPlayerName(player); 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()); (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