diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-01 22:59:59 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-01 22:59:59 +0000 |
commit | e74bb16a4fcf67a44d1b63bc13d205717a38bb96 (patch) | |
tree | 1510c1fe6c7db19fcce0b19b631c385302986baf /src | |
parent | cc83231b9483a0938632caf41b4d7fbf6490a5cd (diff) |
Stuff to make user host resolving use class Resolver - not tested yet
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4626 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd_nick.cpp | 2 | ||||
-rw-r--r-- | src/inspircd.cpp | 2 | ||||
-rw-r--r-- | src/users.cpp | 43 |
3 files changed, 45 insertions, 2 deletions
diff --git a/src/cmd_nick.cpp b/src/cmd_nick.cpp index ddcb04940..17da0e8c8 100644 --- a/src/cmd_nick.cpp +++ b/src/cmd_nick.cpp @@ -149,7 +149,7 @@ void cmd_nick::Handle (const char** parameters, int pcnt, userrec *user) } else { - user->dns_done = (!lookup_dns(user->nick)); + user->StartDNSLookup(); if (user->dns_done) log(DEBUG,"Aborting dns lookup of %s because dns server experienced a failure.",user->nick); } diff --git a/src/inspircd.cpp b/src/inspircd.cpp index a72ee2534..7b298418e 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -827,7 +827,7 @@ void InspIRCd::DoOneIteration(bool process_module_sockets) case X_LISTEN: - log(DEBUG,"Type: X_LISTEN_MODULE: fd=%d",activefds[activefd]); + log(DEBUG,"Type: X_LISTEN: fd=%d",activefds[activefd]); /* It's a listener */ uslen = sizeof(sock_us); diff --git a/src/users.cpp b/src/users.cpp index 83d62ecf7..b6317a3f0 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -137,6 +137,48 @@ bool userrec::ProcessNoticeMasks(const char *sm) return true; } +void userrec::StartDNSLookup() +{ + log(DEBUG,"Commencing forward lookup"); + res_reverse = new UserResolver(this, insp_ntoa(this->ip4), false); +} + +void UserResolver::OnLookupComplete(const std::string &result) +{ + if ((!this->fwd) && (fd_ref_table[this->bound_fd] == this->bound_user)) + { + log(DEBUG,"Commencing reverse lookup"); + this->bound_user->stored_host = result; + bound_user->res_reverse = new UserResolver(this->bound_user, result, true); + } + else if ((this->fwd) && (fd_ref_table[this->bound_fd] == this->bound_user)) + { + /* Both lookups completed */ + if (insp_ntoa(this->bound_user->ip4) == result) + { + std::string hostname = this->bound_user->stored_host; + if (hostname.length() < 64) + { + WriteServ(this->bound_fd, "*** Found your hostname (%s)", this->bound_user->stored_host.c_str()); + this->bound_user->dns_done = true; + strlcpy(this->bound_user->dhost, hostname.c_str(),64); + strlcpy(this->bound_user->host, hostname.c_str(),64); + } + } + } +} + +void UserResolver::OnError(ResolverError e) +{ + if (fd_ref_table[this->bound_fd] == this->bound_user) + { + /* Error message here */ + WriteServ(this->bound_fd, "*** Could not resolve your hostname, using your IP address (%s) instead.", insp_ntoa(this->bound_user->ip4)); + this->bound_user->dns_done = true; + } +} + + bool userrec::IsNoticeMaskSet(unsigned char sm) { return (snomasks[sm-65]); @@ -198,6 +240,7 @@ userrec::userrec() haspassed = dns_done = false; recvq = ""; sendq = ""; + res_forward = res_reverse = NULL; chans.clear(); invites.clear(); chans.resize(MAXCHANS); |