Merge pull request #1627 from pierlon/refactor/normalize-username

Normalize variable "sUserName" to "sUsername"
This commit is contained in:
Alexey Sokolov
2019-01-08 22:50:45 +00:00
committed by GitHub
27 changed files with 230 additions and 211 deletions
+11 -5
View File
@@ -37,7 +37,7 @@ class CServer;
class CUser : private CCoreTranslationMixin {
public:
CUser(const CString& sUserName);
CUser(const CString& sUsername);
~CUser();
CUser(const CUser&) = delete;
@@ -68,8 +68,12 @@ 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);
static CString MakeCleanUserName(const CString& sUserName);
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
CModules& GetModules() { return *m_pModules; }
@@ -164,7 +168,9 @@ class CUser : private CCoreTranslationMixin {
// Getters
const std::vector<CClient*>& GetUserClients() const { return m_vClients; }
std::vector<CClient*> 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;
@@ -220,8 +226,8 @@ class CUser : private CCoreTranslationMixin {
// !Getters
protected:
const CString m_sUserName;
const CString m_sCleanUserName;
const CString m_sUsername;
const CString m_sCleanUsername;
CString m_sNick;
CString m_sAltNick;
CString m_sIdent;
+5 -5
View File
@@ -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());
}
+1 -1
View File
@@ -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);
+4 -4
View File
@@ -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;
}
};
+5 -5
View File
@@ -92,7 +92,7 @@ class CSSLClientCertMod : public CModule {
bool AddKey(CUser* pUser, const CString& sKey) {
const pair<SCString::const_iterator, bool> 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) {
+41 -41
View File
@@ -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;
}
@@ -301,7 +301,7 @@ class CAdminMod : public CModule {
void Set(const CString& sLine) {
const CString sVar = sLine.Token(1).AsLower();
CString sUserName = sLine.Token(2);
CString sUsername = sLine.Token(2);
CString sValue = sLine.Token(3, true);
if (sValue.empty()) {
@@ -309,7 +309,7 @@ class CAdminMod : public CModule {
return;
}
CUser* pUser = FindUser(sUserName);
CUser* pUser = FindUser(sUsername);
if (!pUser) return;
if (sVar == "nick") {
@@ -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,16 +1198,16 @@ 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) {
CString sUserName = sLine.Token(1);
CString sUsername = sLine.Token(1);
CString sNetwork = sLine.Token(2);
if (sNetwork.empty()) {
@@ -1215,7 +1215,7 @@ class CAdminMod : public CModule {
return;
}
CUser* pUser = FindUser(sUserName);
CUser* pUser = FindUser(sUsername);
if (!pUser) {
return;
}
@@ -1239,11 +1239,11 @@ 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) {
CString sUserName = sLine.Token(1);
CString sUsername = sLine.Token(1);
CString sNetwork = sLine.Token(2);
if (sNetwork.empty()) {
@@ -1251,7 +1251,7 @@ class CAdminMod : public CModule {
return;
}
CUser* pUser = FindUser(sUserName);
CUser* pUser = FindUser(sUsername);
if (!pUser) {
return;
}
@@ -1263,16 +1263,16 @@ 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);
CString sUsername = sLine.Token(1, true);
if (sUserName.empty()) {
sUserName = GetUser()->GetUserName();
if (sUsername.empty()) {
sUsername = GetUser()->GetUsername();
}
CUser* pUser = FindUser(sUserName);
CUser* pUser = FindUser(sUsername);
if (!pUser) return;
const MCString& msCTCPReplies = pUser->GetCTCPReplies();
@@ -1287,22 +1287,22 @@ 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);
}
}
void AddCTCP(const CString& sLine) {
CString sUserName = sLine.Token(1);
CString sUsername = sLine.Token(1);
CString sCTCPRequest = sLine.Token(2);
CString sCTCPReply = sLine.Token(3, true);
if (sCTCPRequest.empty()) {
sCTCPRequest = sUserName;
sCTCPRequest = sUsername;
sCTCPReply = sLine.Token(2, true);
sUserName = GetUser()->GetUserName();
sUsername = GetUser()->GetUsername();
}
if (sCTCPRequest.empty()) {
PutModule(t_s("Usage: AddCTCP [user] [request] [reply]"));
@@ -1314,29 +1314,29 @@ class CAdminMod : public CModule {
return;
}
CUser* pUser = FindUser(sUserName);
CUser* pUser = FindUser(sUsername);
if (!pUser) return;
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));
}
}
void DelCTCP(const CString& sLine) {
CString sUserName = sLine.Token(1);
CString sUsername = sLine.Token(1);
CString sCTCPRequest = sLine.Token(2, true);
if (sCTCPRequest.empty()) {
sCTCPRequest = sUserName;
sUserName = GetUser()->GetUserName();
sCTCPRequest = sUsername;
sUsername = GetUser()->GetUsername();
}
CUser* pUser = FindUser(sUserName);
CUser* pUser = FindUser(sUsername);
if (!pUser) return;
if (sCTCPRequest.empty()) {
@@ -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());
}
+3 -3
View File
@@ -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()
: "<no user/network>") +
"]");
+4 -4
View File
@@ -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"));
+1 -1
View File
@@ -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("/", "-")
+9 -9
View File
@@ -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("<no user>")) << "/" << GetModName() << '."\"/$name: $a->{error}: \" << sPyErr);";
say $out "\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUsername() : CString("<no user>")) << "/" << 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("<no user>")) << "/" << GetModName() << '.
say $out "\t\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUsername() : CString("<no user>")) << "/" << 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("<no user>")) << "/" << GetModName() << '.
say $out "\t\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUsername() : CString("<no user>")) << "/" << 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("<no user>")) << "/" << GetModName() << '."\"/$name failed: \" << sPyErr);";
say $out "\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUsername() : CString("<no user>")) << "/" << 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(\"<no user>\")) << \"/\" << GetModName() << \"/$name was expected to return '$type' but error=\" << res);";
say $out "\t\t\tDEBUG(\"modpython: \" << (GetUser() ? GetUser()->GetUsername() : CString(\"<no user>\")) << \"/\" << 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(\"<no user>\")) << \"/\" << GetModName() << \"/$name was expected to return '$type' but error=\" << res);";
say $out "\t\t\tDEBUG(\"modpython: \" << (GetUser() ? GetUser()->GetUsername() : CString(\"<no user>\")) << \"/\" << 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(\"<no user>\")) << \"/\" << GetModName() << \"/$name was expected to return '$type' but returned nullptr\");";
say $out "\t\t\tDEBUG(\"modpython: \" << (GetUser() ? GetUser()->GetUsername() : CString(\"<no user>\")) << \"/\" << 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("<no user>")) << "/" << GetModName() << '."\"/$name was expected to return EModRet but: \" << sPyErr);";
say $out "\t\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUsername() : CString("<no user>")) << "/" << 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("<no user>")) << "/" << GetModName() << '."\"/$name was expected to return EModRet but: \" << sPyErr);";
say $out "\t\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUsername() : CString("<no user>")) << "/" << GetModName() << '."\"/$name was expected to return EModRet but: \" << sPyErr);";
say $out "\t\t\tresult = $default;";
say $out "\t\t} else result = x ? true : false;";
}
+2 -2
View File
@@ -257,10 +257,10 @@ class CPyRetBool {
%extend CUser {
CString __str__() {
return $self->GetUserName();
return $self->GetUsername();
}
CString __repr__() {
return "<CUser " + $self->GetUserName() + ">";
return "<CUser " + $self->GetUsername() + ">";
}
std::vector<CIRCNetwork*> GetNetworks_() {
return $self->GetNetworks();
+1 -1
View File
@@ -300,7 +300,7 @@ class CModTcl : public CModule {
static int tcl_GetUsername STDVAR {
CModTcl* mod = static_cast<CModTcl*>(cd);
Tcl_SetResult(irp, (char*)mod->GetUser()->GetUserName().c_str(),
Tcl_SetResult(irp, (char*)mod->GetUser()->GetUsername().c_str(),
TCL_VOLATILE);
return TCL_OK;
}
+1 -1
View File
@@ -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();
+18 -18
View File
@@ -236,7 +236,7 @@ class CPartylineMod : public CModule {
for (set<CString>::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<CString>& 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<CString>& 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<CString>& 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<CString>& 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<CClient*>::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<CClient*> vClients = pUser->GetAllClients();
const set<CString>& 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);
}
+1 -1
View File
@@ -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);
+5 -5
View File
@@ -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<CString, CUser*>& 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<CIRCNetwork*> 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();
}
}
+40 -40
View File
@@ -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,14 +451,14 @@ class CWebAdminMod : public CModule {
return pNewUser;
}
CString SafeGetUserNameParam(CWebSock& WebSock) {
CString sUserName = WebSock.GetParam("user"); // check for POST param
if (sUserName.empty() && !WebSock.IsPost()) {
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
// saving this form, fall back to using the GET parameter.
sUserName = WebSock.GetParam("user", false);
sUsername = WebSock.GetParam("user", false);
}
return sUserName;
return sUsername;
}
CString SafeGetNetworkParam(CWebSock& WebSock) {
@@ -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,11 +650,11 @@ class CWebAdminMod : public CModule {
WebSock.PrintErrorPage(t_s("No such user"));
return true;
} else if (sPageName == "edituser") {
CString sUserName = SafeGetUserNameParam(WebSock);
CUser* pUser = CZNC::Get().FindUser(sUserName);
CString sUsername = SafeGetUsernameParam(WebSock);
CUser* pUser = CZNC::Get().FindUser(sUsername);
if (!pUser) {
if (sUserName.empty()) {
if (sUsername.empty()) {
pUser = spSession->GetUser();
} // else: the "no such user" message will be printed.
}
@@ -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;
}
+3 -3
View File
@@ -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 "
"<network>, or connect to ZNC with username {1}/<network> "
"(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;
+2 -2
View File
@@ -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);
+5 -5
View File
@@ -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);
+4 -4
View File
@@ -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");
+2 -2
View File
@@ -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);
}
+2 -2
View File
@@ -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()) {
+34 -21
View File
@@ -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 {}
@@ -59,12 +59,12 @@ class CUserTimer : public CCron {
CUser* m_pUser;
};
CUser::CUser(const CString& sUserName)
: m_sUserName(sUserName),
m_sCleanUserName(MakeCleanUserName(sUserName)),
m_sNick(m_sCleanUserName),
CUser::CUser(const CString& sUsername)
: m_sUsername(sUsername),
m_sCleanUsername(MakeCleanUsername(sUsername)),
m_sNick(m_sCleanUsername),
m_sAltNick(""),
m_sIdent(m_sCleanUserName),
m_sIdent(m_sCleanUsername),
m_sRealName(""),
m_sBindHost(""),
m_sDCCBindHost(""),
@@ -78,7 +78,7 @@ CUser::CUser(const CString& sUserName)
m_sTimestampFormat("[%H:%M:%S]"),
m_sTimezone(""),
m_eHashType(HASH_NONE),
m_sUserPath(CZNC::Get().GetUserPath() + "/" + sUserName),
m_sUserPath(CZNC::Get().GetUserPath() + "/" + sUsername),
m_bMultiClients(true),
m_bDenyLoadMod(false),
m_bAdmin(false),
@@ -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,11 +877,16 @@ 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) {
// /^[a-zA-Z][a-zA-Z@._\-]*$/
const char* p = sUserName.c_str();
bool CUser::IsValidUsername(const CString& sUsername) {
return CUser::IsValidUserName(sUsername);
}
if (sUserName.empty()) {
/// @deprecated
bool CUser::IsValidUserName(const CString& sUsername) {
// /^[a-zA-Z][a-zA-Z@._\-]*$/
const char* p = sUsername.c_str();
if (sUsername.empty()) {
return false;
}
@@ -908,12 +913,12 @@ bool CUser::IsValid(CString& sErrMsg, bool bSkipPass) const {
return false;
}
if (m_sUserName.empty()) {
if (m_sUsername.empty()) {
sErrMsg = t_s("Username is empty");
return false;
}
if (!CUser::IsValidUserName(m_sUserName)) {
if (!CUser::IsValidUsername(m_sUsername)) {
sErrMsg = t_s("Username is invalid");
return false;
}
@@ -1034,7 +1039,7 @@ bool CUser::CheckPass(const CString& sPass) const {
/*CClient* CUser::GetClient() {
// Todo: optimize this by saving a pointer to the sock
CSockManager& Manager = CZNC::Get().GetManager();
CString sSockName = "USR::" + m_sUserName;
CString sSockName = "USR::" + m_sUsername;
for (unsigned int a = 0; a < Manager.size(); a++) {
Csock* pSock = Manager[a];
@@ -1160,8 +1165,14 @@ bool CUser::PutModNotice(const CString& sModule, const CString& sLine,
return (pClient == nullptr);
}
CString CUser::MakeCleanUserName(const CString& sUserName) {
return sUserName.Token(0, false, "@").Replace_n(".", "");
CString CUser::MakeCleanUsername(const CString& sUsername) {
return CUser::MakeCleanUserName(sUsername);
}
/// @deprecated
CString CUser::MakeCleanUserName(const CString& sUsername) {
return sUsername.Token(0, false, "@").Replace_n(".", "");
}
bool CUser::IsUserAttached() const {
@@ -1356,8 +1367,10 @@ vector<CClient*> CUser::GetAllClients() const {
return vClients;
}
const CString& CUser::GetUserName() const { return m_sUserName; }
const CString& CUser::GetCleanUserName() const { return m_sCleanUserName; }
/// @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;
}
+5 -5
View File
@@ -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<CWebSession> CWebSock::GetSession() {
DEBUG("Found existing session from cookie: [" + sCookieSessionId +
"] IsLoggedIn(" +
CString((*pSession)->IsLoggedIn()
? "true, " + ((*pSession)->GetUser()->GetUserName())
? "true, " + ((*pSession)->GetUser()->GetUsername())
: "false") +
")");
return *pSession;
+19 -19
View File
@@ -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("<User " + sUser + ">");
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()) {
@@ -1246,12 +1246,12 @@ bool CZNC::LoadUsers(CConfig& config, CString& sError) {
config.FindSubConfig("user", subConf);
for (const auto& subIt : subConf) {
const CString& sUserName = subIt.first;
const CString& sUsername = subIt.first;
CConfig* pSubConf = subIt.second.m_pSubConfig;
CUtils::PrintMessage("Loading user [" + sUserName + "]");
CUtils::PrintMessage("Loading user [" + sUsername + "]");
std::unique_ptr<CUser> pUser(new CUser(sUserName));
std::unique_ptr<CUser> pUser(new CUser(sUsername));
if (!m_sStatusPrefix.empty()) {
if (!pUser->SetStatusPrefix(m_sStatusPrefix)) {
@@ -1268,7 +1268,7 @@ bool CZNC::LoadUsers(CConfig& config, CString& sError) {
}
if (!pSubConf->empty()) {
sError = "Unhandled lines in config for User [" + sUserName + "]!";
sError = "Unhandled lines in config for User [" + sUsername + "]!";
CUtils::PrintError(sError);
DumpConfig(pSubConf);
return false;
@@ -1277,7 +1277,7 @@ bool CZNC::LoadUsers(CConfig& config, CString& sError) {
CString sErr;
CUser* pRawUser = pUser.release();
if (!AddUser(pRawUser, sErr, true)) {
sError = "Invalid user [" + sUserName + "] " + sErr;
sError = "Invalid user [" + sUsername + "] " + sErr;
CUtils::PrintError(sError);
pRawUser->SetBeingDeleted(true);
delete pRawUser;
@@ -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 {
+2 -2
View File
@@ -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");