diff options
author | Adam <Adam@anope.org> | 2010-09-09 23:43:11 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-09-09 23:43:11 -0400 |
commit | 46813ccb8c6ab572b8a9ff0a39afb1d92dc4482b (patch) | |
tree | 562da502a102230ce207bbe921fdc978ee71e20c /src/users.cpp | |
parent | fdd196e50b4616ac377bd0ee0ae5ce6c57b657ee (diff) |
Added an asynchronous DNS system and m_dnsbl, which checks clients against DNS blacklists.
Rewrote internal handling of IPs, we now properly support users using IPv6.
Fixed a few problems with the UnrealIRCd protocol module.
Diffstat (limited to 'src/users.cpp')
-rw-r--r-- | src/users.cpp | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/users.cpp b/src/users.cpp index c9c5ce20e..36b32071b 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -186,7 +186,7 @@ User::~User() { Log(LOG_DEBUG_2) << "User::~User() called"; - Log(this, "disconnect") << " (" << this->realname << ") " << "disconnected from the network (" << this->server->GetName() << ")"; + Log(this, "disconnect") << "(" << this->realname << ") " << "disconnected from the network (" << this->server->GetName() << ")"; this->Logout(); @@ -642,16 +642,13 @@ User *finduser(const Anope::string &nick) /* Handle a server NICK command. */ -User *do_nick(const Anope::string &source, const Anope::string &nick, const Anope::string &username, const Anope::string &host, const Anope::string &server, const Anope::string &realname, time_t ts, uint32 ip, const Anope::string &vhost, const Anope::string &uid) +User *do_nick(const Anope::string &source, const Anope::string &nick, const Anope::string &username, const Anope::string &host, const Anope::string &server, const Anope::string &realname, time_t ts, const Anope::string &ip, const Anope::string &vhost, const Anope::string &uid) { User *user = NULL; Anope::string vhost2 = vhost; if (source.empty()) { - char ipbuf[16]; - struct in_addr addr; - if (ircd->nickvhost && !vhost2.empty() && vhost2.equals_cs("*")) { vhost2.clear(); @@ -660,12 +657,6 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop /* This is a new user; create a User structure for it. */ Log(LOG_DEBUG) << "new user: " << nick; - if (ircd->nickip) - { - addr.s_addr = htonl(ip); - ntoa(addr, ipbuf, sizeof(ipbuf)); - } - Server *serv = Server::Find(server); /* Allocate User structure and fill it in. */ @@ -677,14 +668,24 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop if (!vhost2.empty()) user->SetCloakedHost(vhost2); user->SetVIdent(username); - /* We now store the user's ip in the user_ struct, - * because we will use it in serveral places -- DrStein */ - if (ircd->nickip) - user->hostip = ipbuf; - else - user->hostip = ""; - Log(user, "connect") << (ircd->nickvhost && !vhost2.empty() ? Anope::string("(") + vhost2 + ")" : "") << ") (" << user->realname << ") " << (ircd->nickip ? Anope::string("[") + ipbuf + "] " : "") << "connected to the network (" << serv->GetName() << ")"; + if (!ip.empty()) + { + try + { + if (ip.find(':') != Anope::string::npos) + user->ip.pton(AF_INET6, ip); + else + user->ip.pton(AF_INET, ip); + } + catch (const SocketException &ex) + { + Log() << "Received an invalid IP for user " << user->nick << " (" << ip << ")"; + Log() << ex.GetReason(); + } + } + + Log(user, "connect") << (ircd->nickvhost && !vhost2.empty() ? Anope::string("(") + vhost2 + ")" : "") << ") (" << user->realname << ") " << (user->ip() ? Anope::string("[") + user->ip.addr() + "] " : "") << "connected to the network (" << serv->GetName() << ")"; EventReturn MOD_RESULT; FOREACH_RESULT(I_OnPreUserConnect, OnPreUserConnect(user)); @@ -692,7 +693,7 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop return finduser(nick); if (Config->LimitSessions && !serv->IsULined()) - add_session(nick, host, ipbuf); + add_session(nick, host, user->ip() ? user->ip.addr() : ""); XLineManager::CheckAll(user); |