diff --git a/include/znc/User.h b/include/znc/User.h index 4351baef..8f7b1512 100644 --- a/include/znc/User.h +++ b/include/znc/User.h @@ -68,7 +68,11 @@ class CUser : private CCoreTranslationMixin { void ClearAllowedHosts(); bool IsHostAllowed(const CString& sHost) const; bool IsValid(CString& sErrMsg, bool bSkipPass = false) const; + static bool IsValidUsername(const CString& sUsername); + /** @deprecated Use IsValidUsername() instead. */ static bool IsValidUserName(const CString& sUsername); + static CString MakeCleanUsername(const CString& sUsername); + /** @deprecated Use MakeCleanUsername() instead. */ static CString MakeCleanUserName(const CString& sUsername); // Modules @@ -164,7 +168,9 @@ class CUser : private CCoreTranslationMixin { // Getters const std::vector& GetUserClients() const { return m_vClients; } std::vector GetAllClients() const; + /** @deprecated Use GetUsername() instead. */ const CString& GetUserName() const; + const CString& GetUsername() const; const CString& GetCleanUserName() const; const CString& GetNick(bool bAllowDefault = true) const; const CString& GetAltNick(bool bAllowDefault = true) const; diff --git a/modules/adminlog.cpp b/modules/adminlog.cpp index b4f5634e..10de3cf3 100644 --- a/modules/adminlog.cpp +++ b/modules/adminlog.cpp @@ -58,13 +58,13 @@ class CAdminLogMod : public CModule { } void OnIRCConnected() override { - Log("[" + GetUser()->GetUserName() + "/" + GetNetwork()->GetName() + + Log("[" + GetUser()->GetUsername() + "/" + GetNetwork()->GetName() + "] connected to IRC: " + GetNetwork()->GetCurrentServer()->GetName()); } void OnIRCDisconnected() override { - Log("[" + GetUser()->GetUserName() + "/" + GetNetwork()->GetName() + + Log("[" + GetUser()->GetUsername() + "/" + GetNetwork()->GetName() + "] disconnected from IRC"); } @@ -73,7 +73,7 @@ class CAdminLogMod : public CModule { // ERROR :Closing Link: nick[24.24.24.24] (Excess Flood) // ERROR :Closing Link: nick[24.24.24.24] Killer (Local kill by // Killer (reason)) - Log("[" + GetUser()->GetUserName() + "/" + GetNetwork()->GetName() + + Log("[" + GetUser()->GetUsername() + "/" + GetNetwork()->GetName() + "] disconnected from IRC: " + GetNetwork()->GetCurrentServer()->GetName() + " [" + Message.GetParamsColon(0) + "]", @@ -83,12 +83,12 @@ class CAdminLogMod : public CModule { } void OnClientLogin() override { - Log("[" + GetUser()->GetUserName() + "] connected to ZNC from " + + Log("[" + GetUser()->GetUsername() + "] connected to ZNC from " + GetClient()->GetRemoteIP()); } void OnClientDisconnect() override { - Log("[" + GetUser()->GetUserName() + "] disconnected from ZNC from " + + Log("[" + GetUser()->GetUsername() + "] disconnected from ZNC from " + GetClient()->GetRemoteIP()); } diff --git a/modules/awaystore.cpp b/modules/awaystore.cpp index 081bb470..ac56b0cc 100644 --- a/modules/awaystore.cpp +++ b/modules/awaystore.cpp @@ -351,7 +351,7 @@ class CAway : public CModule { void OnClientDisconnect() override { Away(); } CString GetPath() { - CString sBuffer = GetUser()->GetUserName(); + CString sBuffer = GetUser()->GetUsername(); CString sRet = GetSavePath(); sRet += "/.znc-away-" + CBlowfish::MD5(sBuffer, true); return (sRet); diff --git a/modules/blockuser.cpp b/modules/blockuser.cpp index 2c9ccd35..985a0dab 100644 --- a/modules/blockuser.cpp +++ b/modules/blockuser.cpp @@ -101,7 +101,7 @@ class CBlockUser : public CModule { return; } - if (GetUser()->GetUserName().Equals(sUser)) { + if (GetUser()->GetUsername().Equals(sUser)) { PutModule(t_s("You can't block yourself")); return; } @@ -135,13 +135,13 @@ class CBlockUser : public CModule { if (sAction == "display") { Tmpl["Blocked"] = CString(IsBlocked(Tmpl["Username"])); Tmpl["Self"] = CString(Tmpl["Username"].Equals( - WebSock.GetSession()->GetUser()->GetUserName())); + WebSock.GetSession()->GetUser()->GetUsername())); return true; } if (sAction == "change" && WebSock.GetParam("embed_blockuser_presented").ToBool()) { if (Tmpl["Username"].Equals( - WebSock.GetSession()->GetUser()->GetUserName()) && + WebSock.GetSession()->GetUser()->GetUsername()) && WebSock.GetParam("embed_blockuser_block").ToBool()) { WebSock.GetSession()->AddError( t_s("You can't block yourself")); @@ -203,7 +203,7 @@ class CBlockUser : public CModule { (*it2)->SetIRCConnectEnabled(false); } - SetNV(pUser->GetUserName(), ""); + SetNV(pUser->GetUsername(), ""); return true; } }; diff --git a/modules/certauth.cpp b/modules/certauth.cpp index a92f5dfc..08c9e851 100644 --- a/modules/certauth.cpp +++ b/modules/certauth.cpp @@ -92,7 +92,7 @@ class CSSLClientCertMod : public CModule { bool AddKey(CUser* pUser, const CString& sKey) { const pair pair = - m_PubKeys[pUser->GetUserName()].insert(sKey.AsLower()); + m_PubKeys[pUser->GetUsername()].insert(sKey.AsLower()); if (pair.second) { Save(); @@ -170,7 +170,7 @@ class CSSLClientCertMod : public CModule { Table.AddColumn(t_s("Id", "list")); Table.AddColumn(t_s("Key", "list")); - MSCString::const_iterator it = m_PubKeys.find(GetUser()->GetUserName()); + MSCString::const_iterator it = m_PubKeys.find(GetUser()->GetUsername()); if (it == m_PubKeys.end()) { PutModule(t_s("No keys set for your user")); return; @@ -192,7 +192,7 @@ class CSSLClientCertMod : public CModule { void HandleDelCommand(const CString& sLine) { unsigned int id = sLine.Token(1, true).ToUInt(); - MSCString::iterator it = m_PubKeys.find(GetUser()->GetUserName()); + MSCString::iterator it = m_PubKeys.find(GetUser()->GetUsername()); if (it == m_PubKeys.end()) { PutModule(t_s("No keys set for your user")); @@ -242,7 +242,7 @@ class CSSLClientCertMod : public CModule { CUser* pUser = WebSock.GetSession()->GetUser(); if (sPageName == "index") { - MSCString::const_iterator it = m_PubKeys.find(pUser->GetUserName()); + MSCString::const_iterator it = m_PubKeys.find(pUser->GetUsername()); if (it != m_PubKeys.end()) { for (const CString& sKey : it->second) { CTemplate& row = Tmpl.AddRow("KeyLoop"); @@ -256,7 +256,7 @@ class CSSLClientCertMod : public CModule { WebSock.Redirect(GetWebPath()); return true; } else if (sPageName == "delete") { - MSCString::iterator it = m_PubKeys.find(pUser->GetUserName()); + MSCString::iterator it = m_PubKeys.find(pUser->GetUsername()); if (it != m_PubKeys.end()) { if (it->second.erase(WebSock.GetParam("key", false))) { if (it->second.size() == 0) { diff --git a/modules/controlpanel.cpp b/modules/controlpanel.cpp index 55ec739f..2e3f6d6f 100644 --- a/modules/controlpanel.cpp +++ b/modules/controlpanel.cpp @@ -195,7 +195,7 @@ class CAdminMod : public CModule { if (!pNetwork) { PutModule( t_f("Error: User {1} does not have a network named [{2}].")( - pUser->GetUserName(), sNetwork)); + pUser->GetUsername(), sNetwork)); } return pNetwork; } @@ -967,7 +967,7 @@ class CAdminMod : public CModule { return; } - if (!CZNC::Get().DeleteUser(pUser->GetUserName())) { + if (!CZNC::Get().DeleteUser(pUser->GetUsername())) { // This can't happen, because we got the user from FindUser() PutModule(t_s("Error: Internal error!")); return; @@ -1047,18 +1047,18 @@ class CAdminMod : public CModule { if (pUser->FindNetwork(sNetwork)) { PutModule( t_f("Error: User {1} already has a network with the name {2}")( - pUser->GetUserName(), sNetwork)); + pUser->GetUsername(), sNetwork)); return; } CString sNetworkAddError; if (pUser->AddNetwork(sNetwork, sNetworkAddError)) { PutModule(t_f("Network {1} added to user {2}.")( - sNetwork, pUser->GetUserName())); + sNetwork, pUser->GetUsername())); } else { PutModule(t_f( "Error: Network [{1}] could not be added for user {2}: {3}")( - sNetwork, pUser->GetUserName(), sNetworkAddError)); + sNetwork, pUser->GetUsername(), sNetworkAddError)); } } @@ -1095,11 +1095,11 @@ class CAdminMod : public CModule { if (pUser->DeleteNetwork(sNetwork)) { PutModule(t_f("Network {1} deleted for user {2}.")( - sNetwork, pUser->GetUserName())); + sNetwork, pUser->GetUsername())); } else { PutModule( t_f("Error: Network {1} could not be deleted for user {2}.")( - sNetwork, pUser->GetUserName())); + sNetwork, pUser->GetUsername())); } } @@ -1166,11 +1166,11 @@ class CAdminMod : public CModule { if (pNetwork->AddServer(sServer)) PutModule(t_f("Added IRC Server {1} to network {2} for user {3}.")( - sServer, pNetwork->GetName(), pUser->GetUserName())); + sServer, pNetwork->GetName(), pUser->GetUsername())); else PutModule(t_f( "Error: Could not add IRC server {1} to network {2} for user " - "{3}.")(sServer, pNetwork->GetName(), pUser->GetUserName())); + "{3}.")(sServer, pNetwork->GetName(), pUser->GetUsername())); } void DelServer(const CString& sLine) { @@ -1198,12 +1198,12 @@ class CAdminMod : public CModule { if (pNetwork->DelServer(sServer, uPort, sPass)) PutModule( t_f("Deleted IRC Server {1} from network {2} for user {3}.")( - sServer, pNetwork->GetName(), pUser->GetUserName())); + sServer, pNetwork->GetName(), pUser->GetUsername())); else PutModule( t_f("Error: Could not delete IRC server {1} from network {2} " "for user {3}.")(sServer, pNetwork->GetName(), - pUser->GetUserName())); + pUser->GetUsername())); } void ReconnectUser(const CString& sLine) { @@ -1239,7 +1239,7 @@ class CAdminMod : public CModule { pNetwork->SetIRCConnectEnabled(true); PutModule(t_f("Queued network {1} of user {2} for a reconnect.")( - pNetwork->GetName(), pUser->GetUserName())); + pNetwork->GetName(), pUser->GetUsername())); } void DisconnectUser(const CString& sLine) { @@ -1263,14 +1263,14 @@ class CAdminMod : public CModule { pNetwork->SetIRCConnectEnabled(false); PutModule(t_f("Closed IRC connection for network {1} of user {2}.")( - pNetwork->GetName(), pUser->GetUserName())); + pNetwork->GetName(), pUser->GetUsername())); } void ListCTCP(const CString& sLine) { CString sUsername = sLine.Token(1, true); if (sUsername.empty()) { - sUsername = GetUser()->GetUserName(); + sUsername = GetUser()->GetUsername(); } CUser* pUser = FindUser(sUsername); if (!pUser) return; @@ -1287,9 +1287,9 @@ class CAdminMod : public CModule { if (Table.empty()) { PutModule(t_f("No CTCP replies for user {1} are configured")( - pUser->GetUserName())); + pUser->GetUsername())); } else { - PutModule(t_f("CTCP replies for user {1}:")(pUser->GetUserName())); + PutModule(t_f("CTCP replies for user {1}:")(pUser->GetUsername())); PutModule(Table); } } @@ -1302,7 +1302,7 @@ class CAdminMod : public CModule { if (sCTCPRequest.empty()) { sCTCPRequest = sUsername; sCTCPReply = sLine.Token(2, true); - sUsername = GetUser()->GetUserName(); + sUsername = GetUser()->GetUsername(); } if (sCTCPRequest.empty()) { PutModule(t_s("Usage: AddCTCP [user] [request] [reply]")); @@ -1320,11 +1320,11 @@ class CAdminMod : public CModule { pUser->AddCTCPReply(sCTCPRequest, sCTCPReply); if (sCTCPReply.empty()) { PutModule(t_f("CTCP requests {1} to user {2} will now be blocked.")( - sCTCPRequest.AsUpper(), pUser->GetUserName())); + sCTCPRequest.AsUpper(), pUser->GetUsername())); } else { PutModule( t_f("CTCP requests {1} to user {2} will now get reply: {3}")( - sCTCPRequest.AsUpper(), pUser->GetUserName(), sCTCPReply)); + sCTCPRequest.AsUpper(), pUser->GetUsername(), sCTCPReply)); } } @@ -1334,7 +1334,7 @@ class CAdminMod : public CModule { if (sCTCPRequest.empty()) { sCTCPRequest = sUsername; - sUsername = GetUser()->GetUserName(); + sUsername = GetUser()->GetUsername(); } CUser* pUser = FindUser(sUsername); if (!pUser) return; @@ -1347,12 +1347,12 @@ class CAdminMod : public CModule { if (pUser->DelCTCPReply(sCTCPRequest)) { PutModule(t_f( "CTCP requests {1} to user {2} will now be sent to IRC clients")( - sCTCPRequest.AsUpper(), pUser->GetUserName())); + sCTCPRequest.AsUpper(), pUser->GetUsername())); } else { PutModule( t_f("CTCP requests {1} to user {2} will be sent to IRC clients " "(nothing has changed)")(sCTCPRequest.AsUpper(), - pUser->GetUserName())); + pUser->GetUsername())); } } @@ -1516,11 +1516,11 @@ class CAdminMod : public CModule { if (pUser->GetModules().empty()) { PutModule( - t_f("User {1} has no modules loaded.")(pUser->GetUserName())); + t_f("User {1} has no modules loaded.")(pUser->GetUsername())); return; } - PutModule(t_f("Modules loaded for user {1}:")(pUser->GetUserName())); + PutModule(t_f("Modules loaded for user {1}:")(pUser->GetUsername())); ListModulesFor(pUser->GetModules()); } @@ -1541,12 +1541,12 @@ class CAdminMod : public CModule { if (pNetwork->GetModules().empty()) { PutModule(t_f("Network {1} of user {2} has no modules loaded.")( - pNetwork->GetName(), pUser->GetUserName())); + pNetwork->GetName(), pUser->GetUsername())); return; } PutModule(t_f("Modules loaded for network {1} of user {2}:")( - pNetwork->GetName(), pUser->GetUserName())); + pNetwork->GetName(), pUser->GetUsername())); ListModulesFor(pNetwork->GetModules()); } diff --git a/modules/identfile.cpp b/modules/identfile.cpp index 2067ce27..3f9c8f5a 100644 --- a/modules/identfile.cpp +++ b/modules/identfile.cpp @@ -72,7 +72,7 @@ class CIdentFileModule : public CModule { PutModule("m_pIRCSock = " + CString((long long)m_pIRCSock)); if (m_pIRCSock) { PutModule("user/network - " + - m_pIRCSock->GetNetwork()->GetUser()->GetUserName() + "/" + + m_pIRCSock->GetNetwork()->GetUser()->GetUsername() + "/" + m_pIRCSock->GetNetwork()->GetName()); } else { PutModule(t_s("identfile is free")); @@ -132,7 +132,7 @@ class CIdentFileModule : public CModule { DEBUG("Writing [" + sData + "] to ident spoof file [" + m_pISpoofLockFile->GetLongName() + "] for user/network [" + - GetUser()->GetUserName() + "/" + GetNetwork()->GetName() + "]"); + GetUser()->GetUsername() + "/" + GetNetwork()->GetName() + "]"); m_pISpoofLockFile->Write(sData + "\n"); @@ -142,7 +142,7 @@ class CIdentFileModule : public CModule { void ReleaseISpoof() { DEBUG("Releasing ident spoof for user/network [" + (m_pIRCSock - ? m_pIRCSock->GetNetwork()->GetUser()->GetUserName() + "/" + + ? m_pIRCSock->GetNetwork()->GetUser()->GetUsername() + "/" + m_pIRCSock->GetNetwork()->GetName() : "") + "]"); diff --git a/modules/lastseen.cpp b/modules/lastseen.cpp index ed82cbee..927faad2 100644 --- a/modules/lastseen.cpp +++ b/modules/lastseen.cpp @@ -25,11 +25,11 @@ using std::multimap; class CLastSeenMod : public CModule { private: time_t GetTime(const CUser* pUser) { - return GetNV(pUser->GetUserName()).ToULong(); + return GetNV(pUser->GetUsername()).ToULong(); } void SetTime(const CUser* pUser) { - SetNV(pUser->GetUserName(), CString(time(nullptr))); + SetNV(pUser->GetUsername(), CString(time(nullptr))); } const CString FormatLastSeen(const CUser* pUser, @@ -88,7 +88,7 @@ class CLastSeenMod : public CModule { void OnClientDisconnect() override { SetTime(GetUser()); } EModRet OnDeleteUser(CUser& User) override { - DelNV(User.GetUserName()); + DelNV(User.GetUsername()); return CONTINUE; } @@ -118,7 +118,7 @@ class CLastSeenMod : public CModule { CUser* pUser = it->second; CTemplate& Row = Tmpl.AddRow("UserLoop"); - Row["Username"] = pUser->GetUserName(); + Row["Username"] = pUser->GetUsername(); Row["IsSelf"] = CString(pUser == WebSock.GetSession()->GetUser()); Row["LastSeen"] = FormatLastSeen(pUser, t_s("never")); diff --git a/modules/log.cpp b/modules/log.cpp index 941c3bcc..0af47626 100644 --- a/modules/log.cpp +++ b/modules/log.cpp @@ -284,7 +284,7 @@ void CLogMod::PutLog(const CString& sLine, // TODO: Properly handle IRC case mapping // $WINDOW has to be handled last, since it can contain % sPath.Replace("$USER", - CString((GetUser() ? GetUser()->GetUserName() : "UNKNOWN"))); + CString((GetUser() ? GetUser()->GetUsername() : "UNKNOWN"))); sPath.Replace("$NETWORK", CString((GetNetwork() ? GetNetwork()->GetName() : "znc"))); sPath.Replace("$WINDOW", CString(sWindow.Replace_n("/", "-") diff --git a/modules/modpython/codegen.pl b/modules/modpython/codegen.pl index 0d74c392..1dfc89d2 100755 --- a/modules/modpython/codegen.pl +++ b/modules/modpython/codegen.pl @@ -326,7 +326,7 @@ while (<$in>) { } say $out "\tif (!$a->{pyvar}) {"; say $out "\t\tCString sPyErr = m_pModPython->GetPyExceptionStr();"; - say $out "\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUserName() : CString("")) << "/" << GetModName() << '."\"/$name: $a->{error}: \" << sPyErr);"; + say $out "\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUsername() : CString("")) << "/" << GetModName() << '."\"/$name: $a->{error}: \" << sPyErr);"; print $out $cleanup; say $out "\t\treturn $default;"; say $out "\t}"; @@ -342,14 +342,14 @@ while (<$in>) { say $out "\t\tPyObject* pyVecEl = SWIG_NewInstanceObj(*i, SWIG_TypeQuery(\"$sub*\"), 0);"; say $out "\t\tif (!pyVecEl) {"; say $out "\t\t\tCString sPyErr = m_pModPython->GetPyExceptionStr();"; - say $out "\t\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUserName() : CString("")) << "/" << GetModName() << '. + say $out "\t\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUsername() : CString("")) << "/" << GetModName() << '. "\"/$name: can't convert element of vector '$a->{var}' to PyObject: \" << sPyErr);"; print $out $cleanup1; say $out "\t\t\treturn $default;"; say $out "\t\t}"; say $out "\t\tif (PyList_Append($a->{pyvar}, pyVecEl)) {"; say $out "\t\t\tCString sPyErr = m_pModPython->GetPyExceptionStr();"; - say $out "\t\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUserName() : CString("")) << "/" << GetModName() << '. + say $out "\t\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUsername() : CString("")) << "/" << GetModName() << '. "\"/$name: can't add element of vector '$a->{var}' to PyObject: \" << sPyErr);"; say $out "\t\t\tPy_CLEAR(pyVecEl);"; print $out $cleanup1; @@ -365,7 +365,7 @@ while (<$in>) { say $out ", nullptr);"; say $out "\tif (!pyRes) {"; say $out "\t\tCString sPyErr = m_pModPython->GetPyExceptionStr();"; - say $out "\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUserName() : CString("")) << "/" << GetModName() << '."\"/$name failed: \" << sPyErr);"; + say $out "\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUsername() : CString("")) << "/" << GetModName() << '."\"/$name failed: \" << sPyErr);"; print $out $cleanup; say $out "\t\treturn $default;"; say $out "\t}"; @@ -383,7 +383,7 @@ while (<$in>) { when (/^(.*)\*$/) { say $out "\t\tint res = SWIG_ConvertPtr(pyRes, (void**)&result, SWIG_TypeQuery(\"$type\"), 0);"; say $out "\t\tif (!SWIG_IsOK(res)) {"; - say $out "\t\t\tDEBUG(\"modpython: \" << (GetUser() ? GetUser()->GetUserName() : CString(\"\")) << \"/\" << GetModName() << \"/$name was expected to return '$type' but error=\" << res);"; + say $out "\t\t\tDEBUG(\"modpython: \" << (GetUser() ? GetUser()->GetUsername() : CString(\"\")) << \"/\" << GetModName() << \"/$name was expected to return '$type' but error=\" << res);"; say $out "\t\t\tresult = $default;"; say $out "\t\t}"; } @@ -391,10 +391,10 @@ while (<$in>) { say $out "\t\tCString* p = nullptr;"; say $out "\t\tint res = SWIG_AsPtr_CString(pyRes, &p);"; say $out "\t\tif (!SWIG_IsOK(res)) {"; - say $out "\t\t\tDEBUG(\"modpython: \" << (GetUser() ? GetUser()->GetUserName() : CString(\"\")) << \"/\" << GetModName() << \"/$name was expected to return '$type' but error=\" << res);"; + say $out "\t\t\tDEBUG(\"modpython: \" << (GetUser() ? GetUser()->GetUsername() : CString(\"\")) << \"/\" << GetModName() << \"/$name was expected to return '$type' but error=\" << res);"; say $out "\t\t\tresult = $default;"; say $out "\t\t} else if (!p) {"; - say $out "\t\t\tDEBUG(\"modpython: \" << (GetUser() ? GetUser()->GetUserName() : CString(\"\")) << \"/\" << GetModName() << \"/$name was expected to return '$type' but returned nullptr\");"; + say $out "\t\t\tDEBUG(\"modpython: \" << (GetUser() ? GetUser()->GetUsername() : CString(\"\")) << \"/\" << GetModName() << \"/$name was expected to return '$type' but returned nullptr\");"; say $out "\t\t\tresult = $default;"; say $out "\t\t} else result = *p;"; say $out "\t\tif (SWIG_IsNewObj(res)) delete p;"; @@ -403,7 +403,7 @@ while (<$in>) { say $out "\t\tlong int x = PyLong_AsLong(pyRes);"; say $out "\t\tif (PyErr_Occurred()) {"; say $out "\t\t\tCString sPyErr = m_pModPython->GetPyExceptionStr();"; - say $out "\t\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUserName() : CString("")) << "/" << GetModName() << '."\"/$name was expected to return EModRet but: \" << sPyErr);"; + say $out "\t\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUsername() : CString("")) << "/" << GetModName() << '."\"/$name was expected to return EModRet but: \" << sPyErr);"; say $out "\t\t\tresult = $default;"; say $out "\t\t} else { result = (CModule::EModRet)x; }"; } @@ -411,7 +411,7 @@ while (<$in>) { say $out "\t\tint x = PyObject_IsTrue(pyRes);"; say $out "\t\tif (-1 == x) {"; say $out "\t\t\tCString sPyErr = m_pModPython->GetPyExceptionStr();"; - say $out "\t\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUserName() : CString("")) << "/" << GetModName() << '."\"/$name was expected to return EModRet but: \" << sPyErr);"; + say $out "\t\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUsername() : CString("")) << "/" << GetModName() << '."\"/$name was expected to return EModRet but: \" << sPyErr);"; say $out "\t\t\tresult = $default;"; say $out "\t\t} else result = x ? true : false;"; } diff --git a/modules/modpython/modpython.i b/modules/modpython/modpython.i index 90db7793..a8e3a05e 100644 --- a/modules/modpython/modpython.i +++ b/modules/modpython/modpython.i @@ -257,10 +257,10 @@ class CPyRetBool { %extend CUser { CString __str__() { - return $self->GetUserName(); + return $self->GetUsername(); } CString __repr__() { - return "GetUserName() + ">"; + return "GetUsername() + ">"; } std::vector GetNetworks_() { return $self->GetNetworks(); diff --git a/modules/modtcl.cpp b/modules/modtcl.cpp index 21231f7d..325e8db4 100644 --- a/modules/modtcl.cpp +++ b/modules/modtcl.cpp @@ -300,7 +300,7 @@ class CModTcl : public CModule { static int tcl_GetUsername STDVAR { CModTcl* mod = static_cast(cd); - Tcl_SetResult(irp, (char*)mod->GetUser()->GetUserName().c_str(), + Tcl_SetResult(irp, (char*)mod->GetUser()->GetUsername().c_str(), TCL_VOLATILE); return TCL_OK; } diff --git a/modules/notify_connect.cpp b/modules/notify_connect.cpp index 1e221444..9d05afd4 100644 --- a/modules/notify_connect.cpp +++ b/modules/notify_connect.cpp @@ -31,7 +31,7 @@ class CNotifyConnectMod : public CModule { } void NotifyAdmins(const CString& event) { - CString client = GetUser()->GetUserName(); + CString client = GetUser()->GetUsername(); if (GetClient()->GetIdentifier() != "") { client += "@"; client += GetClient()->GetIdentifier(); diff --git a/modules/partyline.cpp b/modules/partyline.cpp index 05cb6f24..04675cfa 100644 --- a/modules/partyline.cpp +++ b/modules/partyline.cpp @@ -236,7 +236,7 @@ class CPartylineMod : public CModule { for (set::iterator a = m_ssDefaultChans.begin(); a != m_ssDefaultChans.end(); ++a) { CPartylineChannel* pChannel = GetChannel(*a); - const CString& sNick = pUser->GetUserName(); + const CString& sNick = pUser->GetUsername(); if (pChannel->IsInChannel(sNick)) continue; @@ -259,7 +259,7 @@ class CPartylineMod : public CModule { it != m_ssChannels.end(); ++it) { const set& ssNicks = (*it)->GetNicks(); - if ((*it)->IsInChannel(pUser->GetUserName())) { + if ((*it)->IsInChannel(pUser->GetUsername())) { pClient->PutClient(":" + sNickMask + " JOIN " + (*it)->GetName()); @@ -274,7 +274,7 @@ class CPartylineMod : public CModule { PutChan(ssNicks, ":*" + GetModName() + "!znc@znc.in MODE " + (*it)->GetName() + " +" + CString(pUser->IsAdmin() ? "o" : "v") + - " " + NICK_PREFIX + pUser->GetUserName(), + " " + NICK_PREFIX + pUser->GetUsername(), false); } } @@ -287,12 +287,12 @@ class CPartylineMod : public CModule { it != m_ssChannels.end(); ++it) { const set& ssNicks = (*it)->GetNicks(); - if (ssNicks.find(pUser->GetUserName()) != ssNicks.end()) { + if (ssNicks.find(pUser->GetUsername()) != ssNicks.end()) { PutChan(ssNicks, ":*" + GetModName() + "!znc@znc.in MODE " + (*it)->GetName() + " -ov " + NICK_PREFIX + - pUser->GetUserName() + " " + NICK_PREFIX + - pUser->GetUserName(), + pUser->GetUsername() + " " + NICK_PREFIX + + pUser->GetUsername(), false); } } @@ -315,7 +315,7 @@ class CPartylineMod : public CModule { CClient* pClient = GetClient(); CPartylineChannel* pChannel = FindChannel(sChannel); - if (pChannel && pChannel->IsInChannel(pUser->GetUserName())) { + if (pChannel && pChannel->IsInChannel(pUser->GetUsername())) { const set& ssNicks = pChannel->GetNicks(); if (!sTopic.empty()) { if (pUser->IsAdmin()) { @@ -377,7 +377,7 @@ class CPartylineMod : public CModule { void RemoveUser(CUser* pUser, CPartylineChannel* pChannel, const CString& sCommand, const CString& sMessage = "", bool bNickAsTarget = false) { - if (!pChannel || !pChannel->IsInChannel(pUser->GetUserName())) { + if (!pChannel || !pChannel->IsInChannel(pUser->GetUsername())) { return; } @@ -387,7 +387,7 @@ class CPartylineMod : public CModule { CString sMsg = sMessage; if (!sMsg.empty()) sMsg = " :" + sMsg; - pChannel->DelNick(pUser->GetUserName()); + pChannel->DelNick(pUser->GetUsername()); const set& ssNicks = pChannel->GetNicks(); CString sHost = pUser->GetBindHost(); @@ -406,10 +406,10 @@ class CPartylineMod : public CModule { pClient->GetNick() + sMsg); } - PutChan(ssNicks, ":" + NICK_PREFIX + pUser->GetUserName() + "!" + + PutChan(ssNicks, ":" + NICK_PREFIX + pUser->GetUsername() + "!" + pUser->GetIdent() + "@" + sHost + sCmd + pChannel->GetName() + " " + NICK_PREFIX + - pUser->GetUserName() + sMsg, + pUser->GetUsername() + sMsg, false, true, pUser); } else { for (vector::const_iterator it = vClients.begin(); @@ -420,7 +420,7 @@ class CPartylineMod : public CModule { pChannel->GetName() + sMsg); } - PutChan(ssNicks, ":" + NICK_PREFIX + pUser->GetUserName() + "!" + + PutChan(ssNicks, ":" + NICK_PREFIX + pUser->GetUsername() + "!" + pUser->GetIdent() + "@" + sHost + sCmd + pChannel->GetName() + sMsg, false, true, pUser); @@ -459,11 +459,11 @@ class CPartylineMod : public CModule { } void JoinUser(CUser* pUser, CPartylineChannel* pChannel) { - if (pChannel && !pChannel->IsInChannel(pUser->GetUserName())) { + if (pChannel && !pChannel->IsInChannel(pUser->GetUsername())) { vector vClients = pUser->GetAllClients(); const set& ssNicks = pChannel->GetNicks(); - const CString& sNick = pUser->GetUserName(); + const CString& sNick = pUser->GetUsername(); pChannel->AddNick(sNick); CString sHost = pUser->GetBindHost(); @@ -503,13 +503,13 @@ class CPartylineMod : public CModule { if (pUser->IsAdmin()) { PutChan(ssNicks, ":*" + GetModName() + "!znc@znc.in MODE " + pChannel->GetName() + " +o " + - NICK_PREFIX + pUser->GetUserName(), + NICK_PREFIX + pUser->GetUsername(), false, false, pUser); } PutChan(ssNicks, ":*" + GetModName() + "!znc@znc.in MODE " + pChannel->GetName() + " +v " + NICK_PREFIX + - pUser->GetUserName(), + pUser->GetUsername(), false, false, pUser); } } @@ -543,7 +543,7 @@ class CPartylineMod : public CModule { return HALT; } - PutChan(sTarget, ":" + NICK_PREFIX + pUser->GetUserName() + "!" + + PutChan(sTarget, ":" + NICK_PREFIX + pUser->GetUsername() + "!" + pUser->GetIdent() + "@" + sHost + " " + sCmd + " " + sTarget + " :" + sMessage, true, false); @@ -566,7 +566,7 @@ class CPartylineMod : public CModule { CClient* pTarget = *it; pTarget->PutClient( - ":" + NICK_PREFIX + pUser->GetUserName() + "!" + + ":" + NICK_PREFIX + pUser->GetUsername() + "!" + pUser->GetIdent() + "@" + sHost + " " + sCmd + " " + pTarget->GetNick() + " :" + sMessage); } diff --git a/modules/savebuff.cpp b/modules/savebuff.cpp index 395db447..2591ff41 100644 --- a/modules/savebuff.cpp +++ b/modules/savebuff.cpp @@ -283,7 +283,7 @@ class CSaveBuff : public CModule { } CString GetPath(const CString& sTarget) const { - CString sBuffer = GetUser()->GetUserName() + sTarget.AsLower(); + CString sBuffer = GetUser()->GetUsername() + sTarget.AsLower(); CString sRet = GetSavePath(); sRet += "/" + CBlowfish::MD5(sBuffer, true); return (sRet); diff --git a/modules/send_raw.cpp b/modules/send_raw.cpp index 555a7ab6..6336ac39 100644 --- a/modules/send_raw.cpp +++ b/modules/send_raw.cpp @@ -30,7 +30,7 @@ class CSendRaw_Mod : public CModule { if (pNetwork) { pNetwork->PutUser(sLine.Token(3, true)); PutModule(t_f("Sent [{1}] to {2}/{3}")(sLine.Token(3, true), - pUser->GetUserName(), + pUser->GetUsername(), pNetwork->GetName())); } else { PutModule(t_f("Network {1} not found for user {2}")( @@ -50,7 +50,7 @@ class CSendRaw_Mod : public CModule { if (pNetwork) { pNetwork->PutIRC(sLine.Token(3, true)); PutModule(t_f("Sent [{1}] to IRC server of {2}/{3}")( - sLine.Token(3, true), pUser->GetUserName(), + sLine.Token(3, true), pUser->GetUsername(), pNetwork->GetName())); } else { PutModule(t_f("Network {1} not found for user {2}")( @@ -103,7 +103,7 @@ class CSendRaw_Mod : public CModule { bool bToServer = WebSock.GetParam("send_to") == "server"; const CString sLine = WebSock.GetParam("line"); - Tmpl["user"] = pUser->GetUserName(); + Tmpl["user"] = pUser->GetUsername(); Tmpl[bToServer ? "to_server" : "to_client"] = "true"; Tmpl["line"] = sLine; @@ -119,12 +119,12 @@ class CSendRaw_Mod : public CModule { const map& msUsers = CZNC::Get().GetUserMap(); for (const auto& it : msUsers) { CTemplate& l = Tmpl.AddRow("UserLoop"); - l["Username"] = it.second->GetUserName(); + l["Username"] = it.second->GetUsername(); vector vNetworks = it.second->GetNetworks(); for (const CIRCNetwork* pNetwork : vNetworks) { CTemplate& NetworkLoop = l.AddRow("NetworkLoop"); - NetworkLoop["Username"] = it.second->GetUserName(); + NetworkLoop["Username"] = it.second->GetUsername(); NetworkLoop["Network"] = pNetwork->GetName(); } } diff --git a/modules/webadmin.cpp b/modules/webadmin.cpp index 365626db..068f9625 100644 --- a/modules/webadmin.cpp +++ b/modules/webadmin.cpp @@ -191,7 +191,7 @@ class CWebAdminMod : public CModule { if (pUser) { /* If we are editing a user we must not change the user name */ - sUsername = pUser->GetUserName(); + sUsername = pUser->GetUsername(); } CString sArg = WebSock.GetParam("password"); @@ -451,7 +451,7 @@ class CWebAdminMod : public CModule { return pNewUser; } - CString SafeGetUserNameParam(CWebSock& WebSock) { + CString SafeGetUsernameParam(CWebSock& WebSock) { CString sUsername = WebSock.GetParam("user"); // check for POST param if (sUsername.empty() && !WebSock.IsPost()) { // if no POST param named user has been given and we are not @@ -472,11 +472,11 @@ class CWebAdminMod : public CModule { } CUser* SafeGetUserFromParam(CWebSock& WebSock) { - return CZNC::Get().FindUser(SafeGetUserNameParam(WebSock)); + return CZNC::Get().FindUser(SafeGetUsernameParam(WebSock)); } CIRCNetwork* SafeGetNetworkFromParam(CWebSock& WebSock) { - CUser* pUser = CZNC::Get().FindUser(SafeGetUserNameParam(WebSock)); + CUser* pUser = CZNC::Get().FindUser(SafeGetUsernameParam(WebSock)); CIRCNetwork* pNetwork = nullptr; if (pUser) { @@ -650,7 +650,7 @@ class CWebAdminMod : public CModule { WebSock.PrintErrorPage(t_s("No such user")); return true; } else if (sPageName == "edituser") { - CString sUsername = SafeGetUserNameParam(WebSock); + CString sUsername = SafeGetUsernameParam(WebSock); CUser* pUser = CZNC::Get().FindUser(sUsername); if (!pUser) { @@ -708,17 +708,17 @@ class CWebAdminMod : public CModule { } if (!WebSock.GetParam("submitted").ToUInt()) { - Tmpl["User"] = pUser->GetUserName(); + Tmpl["User"] = pUser->GetUsername(); Tmpl["Network"] = pNetwork->GetName(); CTemplate& breadUser = Tmpl.AddRow("BreadCrumbs"); - breadUser["Text"] = t_f("Edit User [{1}]")(pUser->GetUserName()); + breadUser["Text"] = t_f("Edit User [{1}]")(pUser->GetUsername()); breadUser["URL"] = - GetWebPath() + "edituser?user=" + pUser->GetUserName(); + GetWebPath() + "edituser?user=" + pUser->GetUsername(); CTemplate& breadNet = Tmpl.AddRow("BreadCrumbs"); breadNet["Text"] = t_f("Edit Network [{1}]")(pNetwork->GetName()); breadNet["URL"] = GetWebPath() + "editnetwork?user=" + - pUser->GetUserName() + "&network=" + + pUser->GetUsername() + "&network=" + pNetwork->GetName(); CTemplate& breadChan = Tmpl.AddRow("BreadCrumbs"); @@ -728,7 +728,7 @@ class CWebAdminMod : public CModule { Tmpl["Title"] = t_f("Edit Channel [{1}] of Network [{2}] of User [{3}]")( pChan->GetName(), pNetwork->GetName(), - pUser->GetUserName()); + pUser->GetUsername()); Tmpl["ChanName"] = pChan->GetName(); Tmpl["BufferSize"] = CString(pChan->GetBufferCount()); Tmpl["DefModes"] = pChan->GetDefaultModes(); @@ -742,7 +742,7 @@ class CWebAdminMod : public CModule { Tmpl["Action"] = "addchan"; Tmpl["Title"] = t_f("Add Channel to Network [{1}] of User [{2}]")( - pNetwork->GetName(), pUser->GetUserName()); + pNetwork->GetName(), pUser->GetUsername()); Tmpl["BufferSize"] = CString(pUser->GetBufferCount()); Tmpl["DefModes"] = CString(pUser->GetDefaultChanModes()); Tmpl["InConfig"] = "true"; @@ -849,7 +849,7 @@ class CWebAdminMod : public CModule { pChan->Disable(); CTemplate TmplMod; - TmplMod["User"] = pUser->GetUserName(); + TmplMod["User"] = pUser->GetUsername(); TmplMod["ChanName"] = pChan->GetName(); TmplMod["WebadminAction"] = "change"; FOR_EACH_MODULE(it, pNetwork) { @@ -864,13 +864,13 @@ class CWebAdminMod : public CModule { if (WebSock.HasParam("submit_return")) { WebSock.Redirect(GetWebPath() + "editnetwork?user=" + - pUser->GetUserName().Escape_n(CString::EURL) + + pUser->GetUsername().Escape_n(CString::EURL) + "&network=" + pNetwork->GetName().Escape_n(CString::EURL)); } else { WebSock.Redirect( GetWebPath() + "editchan?user=" + - pUser->GetUserName().Escape_n(CString::EURL) + "&network=" + + pUser->GetUsername().Escape_n(CString::EURL) + "&network=" + pNetwork->GetName().Escape_n(CString::EURL) + "&name=" + pChan->GetName().Escape_n(CString::EURL)); } @@ -892,7 +892,7 @@ class CWebAdminMod : public CModule { } if (!WebSock.GetParam("submitted").ToUInt()) { - Tmpl["Username"] = pUser->GetUserName(); + Tmpl["Username"] = pUser->GetUsername(); CTemplate& breadNet = Tmpl.AddRow("BreadCrumbs"); CIRCNetwork EmptyNetwork(pUser, ""); @@ -901,13 +901,13 @@ class CWebAdminMod : public CModule { Tmpl["Action"] = "editnetwork"; Tmpl["Edit"] = "true"; Tmpl["Title"] = t_f("Edit Network [{1}] of User [{2}]")( - pNetwork->GetName(), pUser->GetUserName()); + pNetwork->GetName(), pUser->GetUsername()); breadNet["Text"] = t_f("Edit Network [{1}]")(pNetwork->GetName()); } else { Tmpl["Action"] = "addnetwork"; Tmpl["Title"] = - t_f("Add Network for User [{1}]")(pUser->GetUserName()); + t_f("Add Network for User [{1}]")(pUser->GetUsername()); breadNet["Text"] = t_s("Add Network"); pNetwork = &EmptyNetwork; @@ -969,9 +969,9 @@ class CWebAdminMod : public CModule { } CTemplate& breadUser = Tmpl.AddRow("BreadCrumbs"); - breadUser["Text"] = t_f("Edit User [{1}]")(pUser->GetUserName()); + breadUser["Text"] = t_f("Edit User [{1}]")(pUser->GetUsername()); breadUser["URL"] = - GetWebPath() + "edituser?user=" + pUser->GetUserName(); + GetWebPath() + "edituser?user=" + pUser->GetUsername(); Tmpl["Name"] = pNetwork->GetName(); @@ -1005,7 +1005,7 @@ class CWebAdminMod : public CModule { CTemplate& l = Tmpl.AddRow("ChannelLoop"); l["Network"] = pNetwork->GetName(); - l["Username"] = pUser->GetUserName(); + l["Username"] = pUser->GetUsername(); l["Name"] = pChan->GetName(); l["Perms"] = pChan->GetPermStr(); l["CurModes"] = pChan->GetModeString(); @@ -1214,7 +1214,7 @@ class CWebAdminMod : public CModule { } CTemplate TmplMod; - TmplMod["Username"] = pUser->GetUserName(); + TmplMod["Username"] = pUser->GetUsername(); TmplMod["Name"] = pNetwork->GetName(); TmplMod["WebadminAction"] = "change"; FOR_EACH_MODULE(it, make_pair(pUser, pNetwork)) { @@ -1229,10 +1229,10 @@ class CWebAdminMod : public CModule { if (WebSock.HasParam("submit_return")) { WebSock.Redirect(GetWebPath() + "edituser?user=" + - pUser->GetUserName().Escape_n(CString::EURL)); + pUser->GetUsername().Escape_n(CString::EURL)); } else { WebSock.Redirect(GetWebPath() + "editnetwork?user=" + - pUser->GetUserName().Escape_n(CString::EURL) + + pUser->GetUsername().Escape_n(CString::EURL) + "&network=" + pNetwork->GetName().Escape_n(CString::EURL)); } @@ -1260,7 +1260,7 @@ class CWebAdminMod : public CModule { // Show the "Are you sure?" page: Tmpl.SetFile("del_network.tmpl"); - Tmpl["Username"] = pUser->GetUserName(); + Tmpl["Username"] = pUser->GetUsername(); Tmpl["Network"] = sNetwork; return true; } @@ -1274,7 +1274,7 @@ class CWebAdminMod : public CModule { } WebSock.Redirect(GetWebPath() + "edituser?user=" + - pUser->GetUserName().Escape_n(CString::EURL)); + pUser->GetUsername().Escape_n(CString::EURL)); return false; } @@ -1298,7 +1298,7 @@ class CWebAdminMod : public CModule { WebSock.Redirect( GetWebPath() + "editnetwork?user=" + - pNetwork->GetUser()->GetUserName().Escape_n(CString::EURL) + + pNetwork->GetUser()->GetUsername().Escape_n(CString::EURL) + "&network=" + pNetwork->GetName().Escape_n(CString::EURL)); return false; } @@ -1311,7 +1311,7 @@ class CWebAdminMod : public CModule { CUser EmptyUser(""); CUser* pRealUser = pUser; if (pUser) { - Tmpl["Title"] = t_f("Edit User [{1}]")(pUser->GetUserName()); + Tmpl["Title"] = t_f("Edit User [{1}]")(pUser->GetUsername()); Tmpl["Edit"] = "true"; } else { CString sUsername = WebSock.GetParam("clone", false); @@ -1320,9 +1320,9 @@ class CWebAdminMod : public CModule { if (pUser) { Tmpl["Title"] = - t_f("Clone User [{1}]")(pUser->GetUserName()); + t_f("Clone User [{1}]")(pUser->GetUsername()); Tmpl["Clone"] = "true"; - Tmpl["CloneUsername"] = pUser->GetUserName(); + Tmpl["CloneUsername"] = pUser->GetUsername(); } else { pUser = &EmptyUser; Tmpl["Title"] = "Add User"; @@ -1331,7 +1331,7 @@ class CWebAdminMod : public CModule { Tmpl["ImAdmin"] = CString(spSession->IsAdmin()); - Tmpl["Username"] = pUser->GetUserName(); + Tmpl["Username"] = pUser->GetUsername(); Tmpl["AuthOnlyViaModule"] = CString(pUser->AuthOnlyViaModule()); Tmpl["Nick"] = pUser->GetNick(); Tmpl["AltNick"] = pUser->GetAltNick(); @@ -1361,7 +1361,7 @@ class CWebAdminMod : public CModule { for (const CIRCNetwork* pNetwork : vNetworks) { CTemplate& l = Tmpl.AddRow("NetworkLoop"); l["Name"] = pNetwork->GetName(); - l["Username"] = pUser->GetUserName(); + l["Username"] = pUser->GetUsername(); l["Clients"] = CString(pNetwork->GetClients().size()); l["IRCNick"] = pNetwork->GetIRCNick().GetNick(); CServer* pServer = pNetwork->GetCurrentServer(); @@ -1650,7 +1650,7 @@ class CWebAdminMod : public CModule { WebSock.Redirect(GetWebPath() + "listusers"); } else { WebSock.Redirect(GetWebPath() + "edituser?user=" + - pUser->GetUserName()); + pUser->GetUsername()); } /* we don't want the template to be printed while we redirect */ @@ -1667,7 +1667,7 @@ class CWebAdminMod : public CModule { CTemplate& l = Tmpl.AddRow("UserLoop"); CUser* pUser = it.second; - l["Username"] = pUser->GetUserName(); + l["Username"] = pUser->GetUsername(); l["Clients"] = CString(pUser->GetAllClients().size()); l["Networks"] = CString(pUser->GetNetworks().size()); @@ -1726,7 +1726,7 @@ class CWebAdminMod : public CModule { for (const auto& it : traffic) { if (!spSession->IsAdmin() && - !spSession->GetUser()->GetUserName().Equals(it.first)) { + !spSession->GetUser()->GetUsername().Equals(it.first)) { continue; } diff --git a/src/Client.cpp b/src/Client.cpp index c0efd628..33a0d174 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -385,7 +385,7 @@ void CClient::AcceptLogin(CUser& User) { // (constructor set a different timeout and mode) SetTimeout(User.GetNoTrafficTimeout(), TMO_READ); - SetSockName("USR::" + m_pUser->GetUserName()); + SetSockName("USR::" + m_pUser->GetUsername()); SetEncoding(m_pUser->GetClientEncoding()); if (!m_sNetwork.empty()) { @@ -413,7 +413,7 @@ void CClient::AcceptLogin(CUser& User) { PutStatusNotice(t_f( "If you want to choose another network, use /znc JumpNetwork " ", or connect to ZNC with username {1}/ " - "(instead of just {1})")(m_pUser->GetUserName())); + "(instead of just {1})")(m_pUser->GetUsername())); } } else { PutStatusNotice( @@ -470,7 +470,7 @@ void CClient::PutIRC(const CString& sLine) { CString CClient::GetFullName() const { if (!m_pUser) return GetRemoteIP(); - CString sFullName = m_pUser->GetUserName(); + CString sFullName = m_pUser->GetUsername(); if (!m_sIdentifier.empty()) sFullName += "@" + m_sIdentifier; if (m_pNetwork) sFullName += "/" + m_pNetwork->GetName(); return sFullName; diff --git a/src/ClientCommand.cpp b/src/ClientCommand.cpp index 44bcc324..cf559295 100644 --- a/src/ClientCommand.cpp +++ b/src/ClientCommand.cpp @@ -560,8 +560,8 @@ void CClient::UserCommand(CString& sLine) { PutStatus( t_f("Network added. Use /znc JumpNetwork {1}, or connect to " "ZNC with username {2} (instead of just {3}) to connect to " - "it.")(sNetwork, m_pUser->GetUserName() + "/" + sNetwork, - m_pUser->GetUserName())); + "it.")(sNetwork, m_pUser->GetUsername() + "/" + sNetwork, + m_pUser->GetUsername())); } else { PutStatus(t_s("Unable to add that network")); PutStatus(sNetworkAddError); diff --git a/src/IRCNetwork.cpp b/src/IRCNetwork.cpp index 433b7070..0edad1a3 100644 --- a/src/IRCNetwork.cpp +++ b/src/IRCNetwork.cpp @@ -34,7 +34,7 @@ class CIRCNetworkPingTimer : public CCron { CIRCNetworkPingTimer(CIRCNetwork* pNetwork) : CCron(), m_pNetwork(pNetwork) { SetName("CIRCNetworkPingTimer::" + - m_pNetwork->GetUser()->GetUserName() + "::" + + m_pNetwork->GetUser()->GetUsername() + "::" + m_pNetwork->GetName()); Start(m_pNetwork->GetUser()->GetPingSlack()); } @@ -77,7 +77,7 @@ class CIRCNetworkJoinTimer : public CCron { CIRCNetworkJoinTimer(CIRCNetwork* pNetwork) : CCron(), m_bDelayed(false), m_pNetwork(pNetwork) { SetName("CIRCNetworkJoinTimer::" + - m_pNetwork->GetUser()->GetUserName() + "::" + + m_pNetwork->GetUser()->GetUsername() + "::" + m_pNetwork->GetName()); Start(JOIN_FREQUENCY); } @@ -510,7 +510,7 @@ bool CIRCNetwork::ParseConfig(CConfig* pConfig, CString& sError, if (!pSubConf->empty()) { sError = "Unhandled lines in config for User [" + - m_pUser->GetUserName() + "], Network [" + GetName() + + m_pUser->GetUsername() + "], Network [" + GetName() + "], Channel [" + sChanName + "]!"; CUtils::PrintError(sError); @@ -1289,7 +1289,7 @@ bool CIRCNetwork::Connect() { pIRCSock->SetTrustAllCerts(GetTrustAllCerts()); pIRCSock->SetTrustPKI(GetTrustPKI()); - DEBUG("Connecting user/network [" << m_pUser->GetUserName() << "/" + DEBUG("Connecting user/network [" << m_pUser->GetUsername() << "/" << m_sName << "]"); bool bAbort = false; @@ -1303,7 +1303,7 @@ bool CIRCNetwork::Connect() { return false; } - CString sSockName = "IRC::" + m_pUser->GetUserName() + "::" + m_sName; + CString sSockName = "IRC::" + m_pUser->GetUsername() + "::" + m_sName; CZNC::Get().GetManager().Connect(pServer->GetName(), pServer->GetPort(), sSockName, 120, bSSL, GetBindHost(), pIRCSock); diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index 259881dc..a090d2a4 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -159,7 +159,7 @@ void CIRCSock::ReadLine(const CString& sData) { sLine.Replace("\n", ""); sLine.Replace("\r", ""); - DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" + DEBUG("(" << m_pNetwork->GetUser()->GetUsername() << "/" << m_pNetwork->GetName() << ") IRC -> ZNC [" << sLine << "]"); bool bReturn = false; @@ -1139,7 +1139,7 @@ void CIRCSock::PutIRC(const CMessage& Message) { // Only print if the line won't get sent immediately (same condition as in // TrySend()!) if (m_bFloodProtection && m_iSendsAllowed <= 0) { - DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" + DEBUG("(" << m_pNetwork->GetUser()->GetUsername() << "/" << m_pNetwork->GetName() << ") ZNC -> IRC [" << CDebug::Filter(Message.ToString()) << "] (queued)"); } @@ -1151,7 +1151,7 @@ void CIRCSock::PutIRCQuick(const CString& sLine) { // Only print if the line won't get sent immediately (same condition as in // TrySend()!) if (m_bFloodProtection && m_iSendsAllowed <= 0) { - DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" + DEBUG("(" << m_pNetwork->GetUser()->GetUsername() << "/" << m_pNetwork->GetName() << ") ZNC -> IRC [" << CDebug::Filter(sLine) << "] (queued to front)"); } @@ -1190,7 +1190,7 @@ void CIRCSock::PutIRCRaw(const CString& sLine) { bool bSkip = false; IRCSOCKMODULECALL(OnSendToIRC(sCopy), &bSkip); if (!bSkip) { - DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" + DEBUG("(" << m_pNetwork->GetUser()->GetUsername() << "/" << m_pNetwork->GetName() << ") ZNC -> IRC [" << CDebug::Filter(sCopy) << "]"); Write(sCopy + "\r\n"); diff --git a/src/Modules.cpp b/src/Modules.cpp index 5aec7805..e1089c1e 100644 --- a/src/Modules.cpp +++ b/src/Modules.cpp @@ -234,13 +234,13 @@ CString CModule::GetWebFilesPath() { } bool CModule::LoadRegistry() { - // CString sPrefix = (m_pUser) ? m_pUser->GetUserName() : ".global"; + // CString sPrefix = (m_pUser) ? m_pUser->GetUsername() : ".global"; return (m_mssRegistry.ReadFromDisk(GetSavePath() + "/.registry") == MCString::MCS_SUCCESS); } bool CModule::SaveRegistry() const { - // CString sPrefix = (m_pUser) ? m_pUser->GetUserName() : ".global"; + // CString sPrefix = (m_pUser) ? m_pUser->GetUsername() : ".global"; return (m_mssRegistry.WriteToDisk(GetSavePath() + "/.registry", 0600) == MCString::MCS_SUCCESS); } diff --git a/src/Socket.cpp b/src/Socket.cpp index 4ce05ee4..a6be1953 100644 --- a/src/Socket.cpp +++ b/src/Socket.cpp @@ -543,7 +543,7 @@ bool CSocket::Connect(const CString& sHostname, unsigned short uPort, bool bSSL, CString sBindHost; if (pUser) { - sSockName += "::" + pUser->GetUserName(); + sSockName += "::" + pUser->GetUsername(); sBindHost = pUser->GetBindHost(); CIRCNetwork* pNetwork = m_pModule->GetNetwork(); if (pNetwork) { @@ -574,7 +574,7 @@ bool CSocket::Listen(unsigned short uPort, bool bSSL, unsigned int uTimeout) { CString sSockName = "MOD::L::" + m_pModule->GetModName(); if (pUser) { - sSockName += "::" + pUser->GetUserName(); + sSockName += "::" + pUser->GetUsername(); } // Don't overwrite the socket name if one is already set if (!GetSockName().empty()) { diff --git a/src/User.cpp b/src/User.cpp index f8e0d31f..47bfdf0d 100644 --- a/src/User.cpp +++ b/src/User.cpp @@ -31,7 +31,7 @@ using std::set; class CUserTimer : public CCron { public: CUserTimer(CUser* pUser) : CCron(), m_pUser(pUser) { - SetName("CUserTimer::" + m_pUser->GetUserName()); + SetName("CUserTimer::" + m_pUser->GetUsername()); Start(m_pUser->GetPingSlack()); } ~CUserTimer() override {} @@ -61,7 +61,7 @@ class CUserTimer : public CCron { CUser::CUser(const CString& sUsername) : m_sUsername(sUsername), - m_sCleanUsername(MakeCleanUserName(sUsername)), + m_sCleanUsername(MakeCleanUsername(sUsername)), m_sNick(m_sCleanUsername), m_sAltNick(""), m_sIdent(m_sCleanUsername), @@ -588,7 +588,7 @@ CString& CUser::ExpandString(const CString& sStr, CString& sRet) const { sRet.Replace("%realname%", GetRealName()); sRet.Replace("%time%", sTime); sRet.Replace("%uptime%", CZNC::Get().GetUptime()); - sRet.Replace("%user%", GetUserName()); + sRet.Replace("%user%", GetUsername()); sRet.Replace("%version%", CZNC::GetVersion()); sRet.Replace("%vhost%", GetBindHost()); sRet.Replace("%znc%", CZNC::GetTag(false)); @@ -734,9 +734,9 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneNetworks) { // user names can only specified for the constructor, changing it later // on breaks too much stuff (e.g. lots of paths depend on the user name) - if (GetUserName() != User.GetUserName()) { + if (GetUsername() != User.GetUsername()) { DEBUG("Ignoring username in CUser::Clone(), old username [" - << GetUserName() << "]; New username [" << User.GetUserName() + << GetUsername() << "]; New username [" << User.GetUsername() << "]"); } @@ -877,6 +877,11 @@ const CString& CUser::GetTimestampFormat() const { return m_sTimestampFormat; } bool CUser::GetTimestampAppend() const { return m_bAppendTimestamp; } bool CUser::GetTimestampPrepend() const { return m_bPrependTimestamp; } +bool CUser::IsValidUsername(const CString& sUsername) { + return CUser::IsValidUserName(sUsername); +} + +/// @deprecated bool CUser::IsValidUserName(const CString& sUsername) { // /^[a-zA-Z][a-zA-Z@._\-]*$/ const char* p = sUsername.c_str(); @@ -913,7 +918,7 @@ bool CUser::IsValid(CString& sErrMsg, bool bSkipPass) const { return false; } - if (!CUser::IsValidUserName(m_sUsername)) { + if (!CUser::IsValidUsername(m_sUsername)) { sErrMsg = t_s("Username is invalid"); return false; } @@ -1160,6 +1165,12 @@ bool CUser::PutModNotice(const CString& sModule, const CString& sLine, return (pClient == nullptr); } + +CString CUser::MakeCleanUsername(const CString& sUsername) { + return CUser::MakeCleanUserName(sUsername); +} + +/// @deprecated CString CUser::MakeCleanUserName(const CString& sUsername) { return sUsername.Token(0, false, "@").Replace_n(".", ""); } @@ -1356,7 +1367,9 @@ vector CUser::GetAllClients() const { return vClients; } +/// @deprecated const CString& CUser::GetUserName() const { return m_sUsername; } +const CString& CUser::GetUsername() const { return m_sUsername; } const CString& CUser::GetCleanUserName() const { return m_sCleanUsername; } const CString& CUser::GetNick(bool bAllowDefault) const { return (bAllowDefault && m_sNick.empty()) ? GetCleanUserName() : m_sNick; diff --git a/src/WebModules.cpp b/src/WebModules.cpp index a5841987..74b42d6b 100644 --- a/src/WebModules.cpp +++ b/src/WebModules.cpp @@ -177,7 +177,7 @@ void CWebAuth::AcceptedLogin(CUser& User) { m_pWebSock->Redirect("/?cookie_check=true"); } - DEBUG("Successful login attempt ==> USER [" + User.GetUserName() + + DEBUG("Successful login attempt ==> USER [" + User.GetUsername() + "] ==> SESSION [" + spSession->GetId() + "]"); } } @@ -446,7 +446,7 @@ bool CWebSock::AddModLoop(const CString& sLoopName, CModule& Module, } if (Module.GetUser()) { - Row["Username"] = Module.GetUser()->GetUserName(); + Row["Username"] = Module.GetUser()->GetUsername(); } VWebSubPages& vSubPages = Module.GetSubPages(); @@ -672,7 +672,7 @@ CWebSock::EPageReqResult CWebSock::OnPageRequestInternal(const CString& sURI, SendCookie("SessionId", GetSession()->GetId()); if (GetSession()->IsLoggedIn()) { - m_sUser = GetSession()->GetUser()->GetUserName(); + m_sUser = GetSession()->GetUser()->GetUsername(); m_bLoggedIn = true; } CLanguageScope user_language( @@ -832,7 +832,7 @@ CWebSock::EPageReqResult CWebSock::OnPageRequestInternal(const CString& sURI, pModule->GetUser() != GetSession()->GetUser()) { PrintErrorPage(403, "Forbidden", "You must login as " + - pModule->GetUser()->GetUserName() + + pModule->GetUser()->GetUsername() + " in order to view this page"); return PAGE_DONE; } else if (pModule->OnWebPreRequest(*this, m_sPage)) { @@ -944,7 +944,7 @@ std::shared_ptr CWebSock::GetSession() { DEBUG("Found existing session from cookie: [" + sCookieSessionId + "] IsLoggedIn(" + CString((*pSession)->IsLoggedIn() - ? "true, " + ((*pSession)->GetUser()->GetUserName()) + ? "true, " + ((*pSession)->GetUser()->GetUsername()) : "false") + ")"); return *pSession; diff --git a/src/znc.cpp b/src/znc.cpp index a1d9ef7f..964d8c6a 100644 --- a/src/znc.cpp +++ b/src/znc.cpp @@ -169,7 +169,7 @@ bool CZNC::HandleUserDeletion() { pUser->SetBeingDeleted(false); continue; } - m_msUsers.erase(pUser->GetUserName()); + m_msUsers.erase(pUser->GetUsername()); CWebSock::FinishUserSessions(*pUser); delete pUser; } @@ -573,7 +573,7 @@ bool CZNC::WriteConfig() { continue; } - config.AddSubConfig("User", it.second->GetUserName(), + config.AddSubConfig("User", it.second->GetUsername(), it.second->ToConfig()); } @@ -739,7 +739,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) { CString sNick; do { CUtils::GetInput("Username", sUser, "", "alphanumeric"); - } while (!CUser::IsValidUserName(sUser)); + } while (!CUser::IsValidUsername(sUser)); vsLines.push_back(""); CString sSalt; @@ -749,7 +749,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) { vsLines.push_back("\tAdmin = true"); - CUtils::GetInput("Nick", sNick, CUser::MakeCleanUserName(sUser)); + CUtils::GetInput("Nick", sNick, CUser::MakeCleanUsername(sUser)); vsLines.push_back("\tNick = " + sNick); CUtils::GetInput("Alternate nick", sAnswer, sNick + "_"); if (!sAnswer.empty()) { @@ -1512,7 +1512,7 @@ bool CZNC::UpdateModule(const CString& sModule) { if (!pUser->GetModules().LoadModule( sModule, sArgs, CModInfo::UserModule, pUser, nullptr, sErr)) { DEBUG("Failed to reload [" << sModule << "] for [" - << pUser->GetUserName() << "] [" << sErr + << pUser->GetUsername() << "] [" << sErr << "]"); bError = true; } @@ -1527,7 +1527,7 @@ bool CZNC::UpdateModule(const CString& sModule) { sModule, sArgs, CModInfo::NetworkModule, pNetwork->GetUser(), pNetwork, sErr)) { DEBUG("Failed to reload [" - << sModule << "] for [" << pNetwork->GetUser()->GetUserName() + << sModule << "] for [" << pNetwork->GetUser()->GetUsername() << "/" << pNetwork->GetName() << "] [" << sErr << "]"); bError = true; } @@ -1553,18 +1553,18 @@ bool CZNC::DeleteUser(const CString& sUsername) { return false; } - m_msDelUsers[pUser->GetUserName()] = pUser; + m_msDelUsers[pUser->GetUsername()] = pUser; return true; } bool CZNC::AddUser(CUser* pUser, CString& sErrorRet, bool bStartup) { - if (FindUser(pUser->GetUserName()) != nullptr) { + if (FindUser(pUser->GetUsername()) != nullptr) { sErrorRet = t_s("User already exists"); - DEBUG("User [" << pUser->GetUserName() << "] - already exists"); + DEBUG("User [" << pUser->GetUsername() << "] - already exists"); return false; } if (!pUser->IsValid(sErrorRet)) { - DEBUG("Invalid user [" << pUser->GetUserName() << "] - [" << sErrorRet + DEBUG("Invalid user [" << pUser->GetUsername() << "] - [" << sErrorRet << "]"); return false; } @@ -1576,11 +1576,11 @@ bool CZNC::AddUser(CUser* pUser, CString& sErrorRet, bool bStartup) { } if (bFailed) { - DEBUG("AddUser [" << pUser->GetUserName() << "] aborted by a module [" + DEBUG("AddUser [" << pUser->GetUsername() << "] aborted by a module [" << sErrorRet << "]"); return false; } - m_msUsers[pUser->GetUserName()] = pUser; + m_msUsers[pUser->GetUsername()] = pUser; return true; } @@ -1863,8 +1863,8 @@ CZNC::TrafficStatsMap CZNC::GetTrafficStats(TrafficStatsPair& Users, } if (pUser) { - ret[pUser->GetUserName()].first += pSock->GetBytesRead(); - ret[pUser->GetUserName()].second += pSock->GetBytesWritten(); + ret[pUser->GetUsername()].first += pSock->GetBytesRead(); + ret[pUser->GetUsername()].second += pSock->GetBytesWritten(); uiUsers_in += pSock->GetBytesRead(); uiUsers_out += pSock->GetBytesWritten(); } else { diff --git a/test/integration/tests/scripting.cpp b/test/integration/tests/scripting.cpp index 9dd68d8f..8c9fa6ca 100644 --- a/test/integration/tests/scripting.cpp +++ b/test/integration/tests/scripting.cpp @@ -32,7 +32,7 @@ TEST_F(ZNCTest, Modperl) { client.Write("znc loadmod perleval"); client.Write("PRIVMSG *perleval :2+2"); client.ReadUntil(":*perleval!znc@znc.in PRIVMSG nick :Result: 4"); - client.Write("PRIVMSG *perleval :$self->GetUser->GetUserName"); + client.Write("PRIVMSG *perleval :$self->GetUser->GetUsername"); client.ReadUntil("Result: user"); } @@ -49,7 +49,7 @@ TEST_F(ZNCTest, Modpython) { client.Write("znc loadmod pyeval"); client.Write("PRIVMSG *pyeval :2+2"); client.ReadUntil(":*pyeval!znc@znc.in PRIVMSG nick :4"); - client.Write("PRIVMSG *pyeval :module.GetUser().GetUserName()"); + client.Write("PRIVMSG *pyeval :module.GetUser().GetUsername()"); client.ReadUntil("nick :'user'"); ircd.Write(":server 001 nick :Hello"); ircd.Write(":n!u@h PRIVMSG nick :Hi\xF0, github issue #1229");