X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcommands%2Fcmd_hostname_lookup.cpp;h=f352443d0a501f5926d1223e1a91ab5b65309ca4;hb=86f650e6b8c969b31fae65ea1143644723279b82;hp=2b9b30d731b4c9d862b11bc9818b0c2a32d6a114;hpb=8428bbb387d4b1195156f0ab5a676d17b69b8d5f;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/commands/cmd_hostname_lookup.cpp b/src/commands/cmd_hostname_lookup.cpp index 2b9b30d73..f352443d0 100644 --- a/src/commands/cmd_hostname_lookup.cpp +++ b/src/commands/cmd_hostname_lookup.cpp @@ -28,7 +28,7 @@ namespace /** Derived from Resolver, and performs user forward/reverse lookups. */ -class CoreExport UserResolver : public DNS::Request +class UserResolver : public DNS::Request { /** UUID we are looking up */ const std::string uuid; @@ -92,9 +92,9 @@ class CoreExport UserResolver : public DNS::Request catch (DNS::Exception& e) { delete res_forward; - ServerInstance->Logs->Log("RESOLVER", LOG_DEBUG,"Error in resolver: %s",e.GetReason()); + ServerInstance->Logs->Log("RESOLVER", LOG_DEBUG, "Error in resolver: %s",e.GetReason()); - bound_user->WriteServ("NOTICE Auth :*** There was an internal error resolving your host, using your IP address (%s) instead.", bound_user->GetIPString().c_str()); + bound_user->WriteNotice("*** There was an internal error resolving your host, using your IP address (" + bound_user->GetIPString() + ") instead."); dl->set(bound_user, 0); } } @@ -130,7 +130,7 @@ class CoreExport UserResolver : public DNS::Request if (hostname == NULL) { ServerInstance->Logs->Log("RESOLVER", LOG_DEFAULT, "ERROR: User has no hostname attached when doing a forward lookup"); - bound_user->WriteServ("NOTICE Auth :*** There was an internal error resolving your host, using your IP address (%s) instead.", bound_user->GetIPString().c_str()); + bound_user->WriteNotice("*** There was an internal error resolving your host, using your IP address (" + bound_user->GetIPString() + ") instead."); return; } else if (hostname->length() < 65) @@ -139,7 +139,7 @@ class CoreExport UserResolver : public DNS::Request if ((*hostname)[0] == ':') hostname->insert(0, "0"); - bound_user->WriteServ("NOTICE Auth :*** Found your hostname (%s)%s", hostname->c_str(), (r->cached ? " -- cached" : "")); + bound_user->WriteNotice("*** Found your hostname (" + *hostname + (r->cached ? ") -- cached" : ")")); bound_user->host.assign(*hostname, 0, 64); bound_user->dhost = bound_user->host; @@ -148,14 +148,14 @@ class CoreExport UserResolver : public DNS::Request } else { - bound_user->WriteServ("NOTICE Auth :*** Your hostname is longer than the maximum of 64 characters, using your IP address (%s) instead.", bound_user->GetIPString().c_str()); + bound_user->WriteNotice("*** Your hostname is longer than the maximum of 64 characters, using your IP address (" + bound_user->GetIPString() + ") instead."); } ph->unset(bound_user); } else { - bound_user->WriteServ("NOTICE Auth :*** Your hostname does not match up with your IP address. Sorry, using your IP address (%s) instead.", bound_user->GetIPString().c_str()); + bound_user->WriteNotice("*** Your hostname does not match up with your IP address. Sorry, using your IP address (" + bound_user->GetIPString() + ") instead."); } } } @@ -168,7 +168,7 @@ class CoreExport UserResolver : public DNS::Request LocalUser* bound_user = (LocalUser*)ServerInstance->FindUUID(uuid); if (bound_user) { - bound_user->WriteServ("NOTICE Auth :*** Could not resolve your hostname: %s; using your IP address (%s) instead.", this->manager->GetErrorStr(query->error).c_str(), bound_user->GetIPString().c_str()); + bound_user->WriteNotice("*** Could not resolve your hostname: " + this->manager->GetErrorStr(query->error) + "; using your IP address (" + bound_user->GetIPString() + ") instead."); dl->set(bound_user, 0); ServerInstance->stats->statsDnsBad++; } @@ -177,7 +177,6 @@ class CoreExport UserResolver : public DNS::Request class ModuleHostnameLookup : public Module { - bool nouserdns; LocalIntExt dnsLookup; LocalStringExt ptrHosts; dynamic_reference DNS; @@ -194,28 +193,19 @@ class ModuleHostnameLookup : public Module void init() { - OnRehash(NULL); ServerInstance->Modules->AddService(this->dnsLookup); ServerInstance->Modules->AddService(this->ptrHosts); - - Implementation i[] = { I_OnUserInit, I_OnCheckReady, I_OnRehash }; - ServerInstance->Modules->Attach(i, this, sizeof(i) / sizeof(Implementation)); - } - - void OnRehash(User* user) - { - nouserdns = ServerInstance->Config->ConfValue("performance")->getBool("nouserdns"); } void OnUserInit(LocalUser *user) { - if (!DNS || nouserdns) + if (!DNS || !user->MyClass->resolvehostnames) { - user->WriteServ("NOTICE %s :*** Skipping host resolution (disabled by server administrator)", user->nick.c_str()); + user->WriteNotice("*** Skipping host resolution (disabled by server administrator)"); return; } - user->WriteServ("NOTICE Auth :*** Looking up your hostname..."); + user->WriteNotice("*** Looking up your hostname..."); UserResolver* res_reverse = new UserResolver(*this->DNS, this, user, user->GetIPString(), DNS::QUERY_PTR); try @@ -230,7 +220,7 @@ class ModuleHostnameLookup : public Module { this->dnsLookup.set(user, 0); delete res_reverse; - ServerInstance->Logs->Log("USERS", LOG_DEBUG,"Error in resolver: %s", e.GetReason()); + ServerInstance->Logs->Log("USERS", LOG_DEBUG, "Error in resolver: %s", e.GetReason()); ServerInstance->stats->statsDnsBad++; } }