summaryrefslogtreecommitdiff
path: root/src/users.cpp
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2018-09-24 18:25:06 +0100
committerPeter Powell <petpow@saberuk.com>2018-09-24 18:25:06 +0100
commitc6e40d36b42a7ebf832c3a57d2816a47ee9c9a76 (patch)
treec78c143ff7e25fe6aa7c62bcef6e075102b3080c /src/users.cpp
parentcae87fa047bafedc665d07929b47eaa707ff5f42 (diff)
parent548def58600a5841792504bfdb117c1077482a0d (diff)
Merge branch 'insp20' into master.
Diffstat (limited to 'src/users.cpp')
-rw-r--r--src/users.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/users.cpp b/src/users.cpp
index 1ddd3ca0e..8f20b7523 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -722,21 +722,31 @@ irc::sockets::cidr_mask User::GetCIDRMask()
bool User::SetClientIP(const std::string& address, bool recheck_eline)
{
- this->InvalidateCache();
- return irc::sockets::aptosa(address, 0, client_sa);
+ irc::sockets::sockaddrs sa;
+ if (!irc::sockets::aptosa(address, client_sa.port(), sa))
+ return false;
+
+ User::SetClientIP(sa, recheck_eline);
+ return true;
}
void User::SetClientIP(const irc::sockets::sockaddrs& sa, bool recheck_eline)
{
- this->InvalidateCache();
+ const std::string oldip(GetIPString());
memcpy(&client_sa, &sa, sizeof(irc::sockets::sockaddrs));
+ this->InvalidateCache();
+
+ // If the users hostname was their IP then update it.
+ if (GetRealHost() == oldip)
+ ChangeRealHost(GetIPString(), false);
+ if (GetDisplayedHost() == oldip)
+ ChangeDisplayedHost(GetIPString());
}
bool LocalUser::SetClientIP(const std::string& address, bool recheck_eline)
{
irc::sockets::sockaddrs sa;
- if (!irc::sockets::aptosa(address, 0, sa))
- // Invalid
+ if (!irc::sockets::aptosa(address, client_sa.port(), sa))
return false;
LocalUser::SetClientIP(sa, recheck_eline);