try
{
ServerInstance->Log(DEBUG,"Passing instance: %08x",this->ServerInstance);
- res_reverse = new UserResolver(this->ServerInstance, this, this->GetIPString(), false);
+ res_reverse = new UserResolver(this->ServerInstance, this, this->GetIPString(), DNS_QUERY_REVERSE);
this->ServerInstance->AddResolver(res_reverse);
}
catch (ModuleException& e)
}
}
-UserResolver::UserResolver(InspIRCd* Instance, userrec* user, std::string to_resolve, bool forward) :
- Resolver(Instance, to_resolve, forward ? DNS_QUERY_FORWARD : DNS_QUERY_REVERSE), bound_user(user)
+UserResolver::UserResolver(InspIRCd* Instance, userrec* user, std::string to_resolve, QueryType qt) :
+ Resolver(Instance, to_resolve, qt), bound_user(user)
{
- this->fwd = forward;
+ this->fwd = (qt == DNS_QUERY_A || qt == DNS_QUERY_AAAA);
this->bound_fd = user->GetFd();
}
/* Check we didnt time out */
if (this->bound_user->registered != REG_ALL)
{
- bound_user->res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, true);
+ const char *ip = this->bound_user->GetIPString();
+ bound_user->res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, (strstr(ip,"0::ffff:") == ip ? DNS_QUERY_A : DNS_QUERY_AAAA));
this->ServerInstance->AddResolver(bound_user->res_forward);
}
}
else if ((this->fwd) && (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user))
{
/* Both lookups completed */
- if (this->bound_user->GetIPString() == result)
+ std::string result2 = "0::ffff:";
+ result2.append(result);
+ if (this->bound_user->GetIPString() == result || this->bound_user->GetIPString() == result2)
{
std::string hostname = this->bound_user->stored_host;
if (hostname.length() < 65)
*password = *nick = *ident = *host = *dhost = *fullname = *awaymsg = *oper = 0;
server = (char*)Instance->FindServerNamePtr(Instance->Config->ServerName);
reset_due = ServerInstance->Time();
+ age = ServerInstance->Time(true);
lines_in = lastping = signon = idle_lastmsg = nping = registered = 0;
ChannelCount = timeout = flood = bytes_in = bytes_out = cmds_in = cmds_out = 0;
haspassed = dns_done = false;
}
}
-/* XXX - minor point, other *Host functions return a char *, this one creates it. Might be nice to be consistant? */
-void userrec::MakeHost(char* nhost)
+char* userrec::MakeHost()
{
+ static char nhost[MAXBUF];
/* This is much faster than snprintf */
char* t = nhost;
for(char* n = ident; *n; n++)
for(char* n = host; *n; n++)
*t++ = *n;
*t = 0;
+ return nhost;
+}
+
+char* userrec::MakeHostIP()
+{
+ static char ihost[MAXBUF];
+ /* This is much faster than snprintf */
+ char* t = ihost;
+ for(char* n = ident; *n; n++)
+ *t++ = *n;
+ *t++ = '@';
+ for(const char* n = this->GetIPString(); *n; n++)
+ *t++ = *n;
+ *t = 0;
+ return ihost;
}
void userrec::CloseSocket()
/* IP addresses starting with a : on irc are a Bad Thing (tm) */
if (*buf == ':')
{
- strlcpy(&temp[1], buf, sizeof(temp));
+ strlcpy(&temp[1], buf, sizeof(temp) - 1);
*temp = '0';
return temp;
}
/* IP addresses starting with a : on irc are a Bad Thing (tm) */
if (*buf == ':')
{
- strlcpy(&temp[1], buf, sizeof(temp));
+ strlcpy(&temp[1], buf, sizeof(temp) - 1);
*temp = '0';
strlcpy(buf, temp, sizeof(temp));
}
this->FlushWriteBuf();
break;
case EVENT_ERROR:
- this->SetWriteError(strerror(errornum));
+ this->SetWriteError(errornum ? strerror(errornum) : "EOF from client");
break;
}
}