]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Reorder local user initialization steps
authorattilamolnar <attilamolnar@hush.com>
Wed, 21 Nov 2012 01:20:23 +0000 (02:20 +0100)
committerattilamolnar <attilamolnar@hush.com>
Thu, 29 Nov 2012 19:26:00 +0000 (20:26 +0100)
OnSetUserIP hook now runs after the user has a connect class and the g/k/z lines were checked (ip only, no host at that point)
Fixes #360 reported by @JDowny
Allows #336

src/usermanager.cpp
src/users.cpp

index bb4d58d90062df6a151e8619f1bdb75e008bf33f..b6a33d2c48c0f3eae4a1b7cbd11450a1161932d0 100644 (file)
@@ -146,6 +146,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs
        if (ServerInstance->Config->RawLog)
                New->WriteServ("NOTICE Auth :*** Raw I/O logging is enabled on this server. All messages, passwords, and commands are being recorded.");
 
+       FOREACH_MOD(I_OnSetUserIP,OnSetUserIP(New));
        FOREACH_MOD(I_OnUserInit,OnUserInit(New));
 
        if (ServerInstance->Config->NoUserDns)
index 0c6204adb1f6fb103f2f639f8c0c115b5dc83026..92276d07c2d555372f8dd9684d810c6c688fe3ce 100644 (file)
@@ -225,25 +225,9 @@ LocalUser::LocalUser(int myfd, irc::sockets::sockaddrs* client, irc::sockets::so
        ident = "unknown";
        lastping = 0;
        eh.SetFd(myfd);
+       memcpy(&client_sa, client, sizeof(irc::sockets::sockaddrs));
        memcpy(&server_sa, servaddr, sizeof(irc::sockets::sockaddrs));
-
-       /*
-        * Initialize host and dhost here to the user's IP.
-        * It is important to do this before calling SetClientIP()
-        * as that passes execution to modules that expect these
-        * fields to be valid.
-        *
-        * We cannot call GetIPString() now as that will access
-        * client_sa, and that's only initialized after the first
-        * SetClientIP() call.
-        */
-
-       int port;
-       irc::sockets::satoap(*client, host, port);
-       if (host[0] == ':')
-               host.insert(0, 1, '0');
-       dhost = host;
-       SetClientIP(*client);
+       dhost = host = GetIPString();
 }
 
 User::~User()
@@ -1005,12 +989,14 @@ irc::sockets::cidr_mask User::GetCIDRMask()
 bool User::SetClientIP(const char* sip)
 {
        cachedip.clear();
+       cached_hostip.clear();
        return irc::sockets::aptosa(sip, 0, client_sa);
 }
 
 void User::SetClientIP(const irc::sockets::sockaddrs& sa)
 {
        cachedip.clear();
+       cached_hostip.clear();
        memcpy(&client_sa, &sa, sizeof(irc::sockets::sockaddrs));
 }