void CModule::ListTimers() { if (m_sTimers.empty()) { PutModule("You have no timers running."); return; } CTable Table; Table.AddColumn("Name"); Table.AddColumn("Secs"); Table.AddColumn("Cycles"); Table.AddColumn("Description"); set<CTimer*>::iterator it; for (it = m_sTimers.begin(); it != m_sTimers.end(); ++it) { CTimer* pTimer = *it; unsigned int uCycles = pTimer->GetCyclesLeft(); Table.AddRow(); Table.SetCell("Name", pTimer->GetName()); Table.SetCell("Secs", CString(pTimer->GetInterval())); Table.SetCell("Cycles", ((uCycles) ? CString(uCycles) : "INF")); Table.SetCell("Description", pTimer->GetDescription()); } PutModule(Table); }
void ListUsers(const CString&) { if (!m_pUser->IsAdmin()) return; const map<CString, CUser*>& msUsers = CZNC::Get().GetUserMap(); CTable Table; Table.AddColumn("Username"); Table.AddColumn("Realname"); Table.AddColumn("IsAdmin"); Table.AddColumn("Nick"); Table.AddColumn("AltNick"); Table.AddColumn("Ident"); Table.AddColumn("VHost"); for (map<CString, CUser*>::const_iterator it = msUsers.begin(); it != msUsers.end(); it++) { Table.AddRow(); Table.SetCell("Username", it->first); Table.SetCell("Realname", it->second->GetRealName()); if (!it->second->IsAdmin()) Table.SetCell("IsAdmin", "No"); else Table.SetCell("IsAdmin", "Yes"); Table.SetCell("Nick", it->second->GetNick()); Table.SetCell("AltNick", it->second->GetAltNick()); Table.SetCell("Ident", it->second->GetIdent()); Table.SetCell("VHost", it->second->GetVHost()); } PutModule(Table); }
virtual void OnModCommand(const CString& sLine) { const CString sCommand = sLine.Token(0).AsLower(); if (!GetUser()->IsAdmin()) { PutModule("Access denied"); return; } if (sCommand == "show") { const MUsers& mUsers = CZNC::Get().GetUserMap(); MUsers::const_iterator it; CTable Table; Table.AddColumn("User"); Table.AddColumn("Last Seen"); for (it = mUsers.begin(); it != mUsers.end(); ++it) { Table.AddRow(); Table.SetCell("User", it->first); Table.SetCell("Last Seen", FormatLastSeen(it->second)); } PutModule(Table); } else { PutModule("This module only supports 'show'"); } }
void ListNotes(bool bNotice = false) { CClient* pClient = GetClient(); if (pClient) { CTable Table; Table.AddColumn("Key"); Table.AddColumn("Note"); for (MCString::iterator it = BeginNV(); it != EndNV(); ++it) { Table.AddRow(); Table.SetCell("Key", it->first); Table.SetCell("Note", it->second); } if (Table.size()) { unsigned int idx = 0; CString sLine; while (Table.GetLine(idx++, sLine)) { if (bNotice) { pClient->PutModNotice(GetModName(), sLine); } else { pClient->PutModule(GetModName(), sLine); } } } else { if (bNotice) { PutModNotice("You have no entries."); } else { PutModule("You have no entries."); } } } }
void CModule::ListTimers() { if (m_sTimers.empty()) { PutModule("You have no timers running."); return; } CTable Table; Table.AddColumn("Name"); Table.AddColumn("Secs"); Table.AddColumn("Cycles"); Table.AddColumn("Description"); for (auto pTimer : m_sTimers) { unsigned int uCycles = pTimer->GetCyclesLeft(); timeval Interval = pTimer->GetInterval(); Table.AddRow(); Table.SetCell("Name", pTimer->GetName()); Table.SetCell("Secs", CString(Interval.tv_sec) + "seconds" + (Interval.tv_usec ? " " + CString(Interval.tv_usec) + " microseconds" : "")); Table.SetCell("Cycles", ((uCycles) ? CString(uCycles) : "INF")); Table.SetCell("Description", pTimer->GetDescription()); } PutModule(Table); }
void List(const CString& sCommand) { CTable Table; unsigned int index = 1; CString sExpanded; Table.AddColumn("Id"); Table.AddColumn("Perform"); Table.AddColumn("Expanded"); for (VCString::const_iterator it = m_vPerform.begin(); it != m_vPerform.end(); it++, index++) { Table.AddRow(); Table.SetCell("Id", CString(index)); Table.SetCell("Perform", *it); if (m_pNetwork) { sExpanded = m_pNetwork->ExpandString(*it); } else { sExpanded = GetUser()->ExpandString(*it); } if (sExpanded != *it) { Table.SetCell("Expanded", sExpanded); } } if (PutModule(Table) == 0) { PutModule("No commands in your perform list."); } }
void HandleListCommand(const CString& sLine) { CTable Table; Table.AddColumn("Id"); Table.AddColumn("Key"); MSCString::iterator it = m_PubKeys.find(m_pUser->GetUserName()); if (it == m_PubKeys.end()) { PutModule("No keys set for your user"); return; } SCString::iterator it2; unsigned int id = 1; for (it2 = it->second.begin(); it2 != it->second.end(); ++it2) { Table.AddRow(); Table.SetCell("Id", CString(id++)); Table.SetCell("Key", *it2); } if (PutModule(Table) == 0) { // This double check is necessary, because the // set could be empty. PutModule("No keys set for your user"); } }
virtual void OnModCommand(const CString& sCommand) { CString sCmd = sCommand.Token(0); if (sCmd.Equals("DELKEY")) { CString sTarget = sCommand.Token(1); if (!sTarget.empty()) { if (DelNV(sTarget.AsLower())) { PutModule("Target [" + sTarget + "] deleted"); } else { PutModule("Target [" + sTarget + "] not found"); } } else { PutModule("Usage DelKey <#chan|Nick>"); } } else if (sCmd.Equals("SETKEY")) { CString sTarget = sCommand.Token(1); CString sKey = sCommand.Token(2, true); // Strip "cbc:" from beginning of string incase someone pastes directly from mircryption sKey.TrimPrefix("cbc:"); if (!sKey.empty()) { SetNV(sTarget.AsLower(), sKey); PutModule("Set encryption key for [" + sTarget + "] to [" + sKey + "]"); } else { PutModule("Usage: SetKey <#chan|Nick> <Key>"); } } else if (sCmd.Equals("LISTKEYS")) { if (BeginNV() == EndNV()) { PutModule("You have no encryption keys set."); } else { CTable Table; Table.AddColumn("Target"); Table.AddColumn("Key"); for (MCString::iterator it = BeginNV(); it != EndNV(); ++it) { Table.AddRow(); Table.SetCell("Target", it->first); Table.SetCell("Key", it->second); } MCString::iterator it = FindNV(NICK_PREFIX_KEY); if (it == EndNV()) { Table.AddRow(); Table.SetCell("Target", NICK_PREFIX_KEY); Table.SetCell("Key", NickPrefix()); } PutModule(Table); } } else if (sCmd.Equals("HELP")) { PutModule("Try: SetKey, DelKey, ListKeys"); } else { PutModule("Unknown command, try 'Help'"); } }
virtual void OnModCommand(const CString& sLine) { CString sCommand = sLine.Token(0); if (sCommand.Equals("help")) { CTable Table; Table.AddColumn("Command"); Table.AddColumn("Description"); Table.AddRow(); Table.SetCell("Command", "Reason [<text>]"); Table.SetCell("Description", "Prints and optionally sets the away reason."); Table.AddRow(); Table.SetCell("Command", "Timer"); Table.SetCell("Description", "Prints the current time to wait before setting you away."); Table.AddRow(); Table.SetCell("Command", "SetTimer <time>"); Table.SetCell("Description", "Sets the time to wait before setting you away (in seconds)."); Table.AddRow(); Table.SetCell("Command", "DisableTimer"); Table.SetCell("Description", "Disables the wait time before setting you away."); PutModule(Table); PutModule("In the away reason, %s will be replaced with the time you were set away."); } else if (sCommand.Equals("reason")) { CString sReason = sLine.Token(1, true); if (!sReason.empty()) { SetReason(sReason); PutModule("Away reason set"); } else { PutModule("Away reason: " + m_sReason); PutModule("Current away reason would be: " + ExpandReason()); } } else if (sCommand.Equals("timer")) { PutModule("Current timer setting: " + CString(m_iAwayWait) + " seconds"); } else if (sCommand.Equals("settimer")) { SetAwayWait(sLine.Token(1).ToUInt()); if (m_iAwayWait == 0) PutModule("Timer disabled"); else PutModule("Timer set to " + CString(m_iAwayWait) + " seconds"); } else if (sCommand.Equals("disabletimer")) { SetAwayWait(0); PutModule("Timer disabled"); } else { PutModule("Unknown command. Try 'help'."); } }
void CIdentServerMod::OnModCommand(const CString& sLine) { CString sCommand = sLine.Token(0); if(sCommand.Equals("HELP")) { CTable Table; Table.AddColumn("Command"); Table.AddColumn("Description"); Table.AddRow(); Table.SetCell("Command", "Status"); Table.SetCell("Description", "Displays status information about IdentServer"); PutModule(Table); return; } else if(sCommand.Equals("STATUS")) { if(m_identServer) { PutModule("IdentServer is listening on: " + m_identServer->GetLocalIP() + ":" + CString(m_serverPort)); if(m_pUser->IsAdmin()) { PutModule("List of active users/networks:"); for(CIRCNetwork* pNetwork : m_identServer->GetActiveUsers()) { PutModule("* " + pNetwork->GetUser()->GetCleanUserName() + "/" + pNetwork->GetName()); } } } else { if(m_listenFailed) { PutModule("WARNING: Opening the listening socket failed!"); } PutModule("IdentServer isn't listening."); } if(m_pUser->IsAdmin()) { PutModule("Last IDENT request: " + m_sLastRequest); PutModule("Last IDENT reply: " + m_sLastReply); } } else { PutModule("Unknown command [" + sCommand + "] try 'Help'"); } }
void PrintHelp(const CString& sLine) { HandleHelpCommand(sLine); CTable Mechanisms; Mechanisms.AddColumn("Mechanism"); Mechanisms.AddColumn("Description"); for (const auto& it : SupportedMechanisms) { Mechanisms.AddRow(); Mechanisms.SetCell("Mechanism", it.szName); Mechanisms.SetCell("Description", it.szDescription); } PutModule("The following mechanisms are available:"); PutModule(Mechanisms); }
void PrintHelp(const CString& sLine) { HandleHelpCommand(sLine); CTable Mechanisms; Mechanisms.AddColumn("Mechanism"); Mechanisms.AddColumn("Description"); for (size_t i = 0; SupportedMechanisms[i].szName != NULL; i++) { Mechanisms.AddRow(); Mechanisms.SetCell("Mechanism", SupportedMechanisms[i].szName); Mechanisms.SetCell("Description", SupportedMechanisms[i].szDescription); } PutModule("The following mechanisms are available:"); PutModule(Mechanisms); }
void CLogMod::ListRulesCmd(const CString& sLine) { CTable Table; Table.AddColumn("Rule"); Table.AddColumn("Logging enabled"); for (const CLogRule& Rule : m_vRules) { Table.AddRow(); Table.SetCell("Rule", Rule.GetRule()); Table.SetCell("Logging enabled", CString(Rule.IsEnabled())); } if (Table.empty()) { PutModule("No logging rules. Everything is logged."); } else { PutModule(Table); } }
void HandleListCommand(const CString& sLine) { CTable Table; Table.AddColumn("Hostmask"); Table.AddColumn("Type"); for (vector<CIgnore>::const_iterator it = m_vIgnores.begin(); it != m_vIgnores.end(); ++it) { const CIgnore& Ignore = *it; Table.AddRow(); Table.SetCell("Hostmask", Ignore.GetHostmask()); Table.SetCell("Type", Ignore.GetType()); } if (!PutModule(Table)) { PutModule("You are not ignoring anyone"); } }
void ParseEmails(const vector<EmailST> & vEmails) { if (!m_bInitialized) { m_bInitialized = true; for (u_int a = 0; a < vEmails.size(); a++) m_ssUidls.insert(vEmails[a].sUidl); stringstream s; s << "You have " << vEmails.size() << " emails."; PutModule(s.str()); } else { set<CString> ssUidls; CTable Table; Table.AddColumn("From"); Table.AddColumn("Size"); Table.AddColumn("Subject"); for (u_int a = 0; a < vEmails.size(); a++) { if (m_ssUidls.find(vEmails[a].sUidl) == m_ssUidls.end()) { //PutModule("------------------- New Email -------------------"); Table.AddRow(); Table.SetCell("From", vEmails[a].sFrom.Ellipsize(32)); Table.SetCell("Size", CString(vEmails[a].iSize)); Table.SetCell("Subject", vEmails[a].sSubject.Ellipsize(64)); } ssUidls.insert(vEmails[a].sUidl); } m_ssUidls = ssUidls; // keep the list in synch if (Table.size()) { PutModule(Table); stringstream s; s << "You have " << vEmails.size() << " emails."; PutModule(s.str()); } } }
void HandleList(const CString& sLine) { CTable Table; Table.AddColumn("Neg"); Table.AddColumn("Chan"); Table.AddColumn("Host"); VAttachIter it = m_vMatches.begin(); for (; it != m_vMatches.end(); ++it) { Table.AddRow(); Table.SetCell("Neg", it->IsNegated() ? "!" : ""); Table.SetCell("Chan", it->GetChans()); Table.SetCell("Host", it->GetHostMask()); } if (Table.size()) { PutModule(Table); } else { PutModule("You have no entries."); } }
void ListDCCsCommand(const CString& sLine) { CTable Table; Table.AddColumn("Type"); Table.AddColumn("State"); Table.AddColumn("Speed"); Table.AddColumn("Nick"); Table.AddColumn("IP"); Table.AddColumn("File"); set<CSocket*>::const_iterator it; for (it = BeginSockets(); it != EndSockets(); ++it) { CDCCBounce* pSock = (CDCCBounce*) *it; CString sSockName = pSock->GetSockName(); if (!(pSock->IsRemote())) { Table.AddRow(); Table.SetCell("Nick", pSock->GetRemoteNick()); Table.SetCell("IP", pSock->GetRemoteIP()); if (pSock->IsChat()) { Table.SetCell("Type", "Chat"); } else { Table.SetCell("Type", "Xfer"); Table.SetCell("File", pSock->GetFileName()); } CString sState = "Waiting"; if ((pSock->IsConnected()) || (pSock->IsPeerConnected())) { sState = "Halfway"; if ((pSock->IsPeerConnected()) && (pSock->IsPeerConnected())) { sState = "Connected"; } } Table.SetCell("State", sState); } } if (PutModule(Table) == 0) { PutModule("You have no active DCCs."); } }
void OnListUsersCommand(const CString& sLine) { if (m_msUsers.empty()) { PutModule("There are no users defined"); return; } CTable Table; Table.AddColumn("User"); Table.AddColumn("Hostmask"); Table.AddColumn("Channels"); for (const auto& it : m_msUsers) { Table.AddRow(); Table.SetCell("User", it.second->GetUsername()); Table.SetCell("Hostmask", it.second->GetHostmask()); Table.SetCell("Channels", it.second->GetChannels()); } PutModule(Table); }
void ListCommand(const CString &sLine) { CTable Table; Table.AddColumn("Host"); Table.AddColumn("Network"); Table.AddColumn("Away"); const vector<CClient*> vClients = m_pUser->GetAllClients(); for (vector<CClient*>::const_iterator it = vClients.begin(); it != vClients.end(); ++it) { CClient *pClient = *it; Table.AddRow(); Table.SetCell("Host", pClient->GetRemoteIP()); if (pClient->GetNetwork()) { Table.SetCell("Network", pClient->GetNetwork()->GetName()); } Table.SetCell("Away", CString(pClient->IsAway())); } PutModule(Table); }
void ShowCommand(const CString &sLine) { if (!GetUser()->IsAdmin()) { PutModule("Access denied"); return; } const MUsers& mUsers = CZNC::Get().GetUserMap(); MUsers::const_iterator it; CTable Table; Table.AddColumn("User"); Table.AddColumn("Last Seen"); for (it = mUsers.begin(); it != mUsers.end(); ++it) { Table.AddRow(); Table.SetCell("User", it->first); Table.SetCell("Last Seen", FormatLastSeen(it->second, "never")); } PutModule(Table); }
void OnListUsersCommand(const CString& sLine) { if (m_msUsers.empty()) { PutModule("There are no users defined"); return; } CTable Table; Table.AddColumn("User"); Table.AddColumn("Hostmask"); Table.AddColumn("Channels"); for (map<CString, CAutoVoiceUser*>::iterator it = m_msUsers.begin(); it != m_msUsers.end(); ++it) { Table.AddRow(); Table.SetCell("User", it->second->GetUsername()); Table.SetCell("Hostmask", it->second->GetHostmask()); Table.SetCell("Channels", it->second->GetChannels()); } PutModule(Table); }
void ListTransfersCommand(const CString& sLine) { CTable Table; Table.AddColumn(t_s("Type", "list")); Table.AddColumn(t_s("State", "list")); Table.AddColumn(t_s("Speed", "list")); Table.AddColumn(t_s("Nick", "list")); Table.AddColumn(t_s("IP", "list")); Table.AddColumn(t_s("File", "list")); set<CSocket*>::const_iterator it; for (it = BeginSockets(); it != EndSockets(); ++it) { CDCCSock* pSock = (CDCCSock*)*it; Table.AddRow(); Table.SetCell(t_s("Nick", "list"), pSock->GetRemoteNick()); Table.SetCell(t_s("IP", "list"), pSock->GetRemoteIP()); Table.SetCell(t_s("File", "list"), pSock->GetFileName()); if (pSock->IsSend()) { Table.SetCell(t_s("Type", "list"), t_s("Sending", "list-type")); } else { Table.SetCell(t_s("Type", "list"), t_s("Getting", "list-type")); } if (pSock->GetType() == Csock::LISTENER) { Table.SetCell(t_s("State", "list"), t_s("Waiting", "list-state")); } else { Table.SetCell(t_s("State", "list"), CString::ToPercent(pSock->GetProgress())); Table.SetCell(t_s("Speed", "list"), t_f("{1} KiB/s")(static_cast<int>( pSock->GetAvgRead() / 1024.0))); } } if (PutModule(Table) == 0) { PutModule(t_s("You have no active DCC transfers.")); } }
void CModule::ListSockets() { if (m_sSockets.empty()) { PutModule("You have no open sockets."); return; } CTable Table; Table.AddColumn("Name"); Table.AddColumn("State"); Table.AddColumn("LocalPort"); Table.AddColumn("SSL"); Table.AddColumn("RemoteIP"); Table.AddColumn("RemotePort"); set<CSocket*>::iterator it; for (it = m_sSockets.begin(); it != m_sSockets.end(); ++it) { CSocket* pSocket = *it; Table.AddRow(); Table.SetCell("Name", pSocket->GetSockName()); if (pSocket->GetType() == CSocket::LISTENER) { Table.SetCell("State", "Listening"); } else { Table.SetCell("State", (pSocket->IsConnected() ? "Connected" : "")); } Table.SetCell("LocalPort", CString(pSocket->GetLocalPort())); Table.SetCell("SSL", (pSocket->GetSSL() ? "yes" : "no")); Table.SetCell("RemoteIP", pSocket->GetRemoteIP()); Table.SetCell("RemotePort", (pSocket->GetRemotePort()) ? CString(pSocket->GetRemotePort()) : CString("")); } PutModule(Table); }
// Displays all blocked users as a list. void OnListCommand(const CString& sCommand) { CTable Table; MCString::iterator it; Table.AddColumn("Blocked user"); for (it = BeginNV(); it != EndNV(); ++it) { Table.AddRow(); Table.SetCell("Blocked user", it->first); } if (PutModule(Table) == 0) PutModule("No users blocked"); }
void OnListKeysCommand(const CString& sCommand) { if (BeginNV() == EndNV()) { PutModule("You have no encryption keys set."); } else { CTable Table; Table.AddColumn("Target"); Table.AddColumn("Key"); for (MCString::iterator it = BeginNV(); it != EndNV(); ++it) { Table.AddRow(); Table.SetCell("Target", it->first); Table.SetCell("Key", it->second); } MCString::iterator it = FindNV(NICK_PREFIX_KEY); if (it == EndNV()) { Table.AddRow(); Table.SetCell("Target", NICK_PREFIX_KEY); Table.SetCell("Key", NickPrefix()); } PutModule(Table); } }
void ListTokens(const CString& sLine) { SCString ssTokens = GetUserTokens(m_pUser); CTable table; table.AddColumn("Tolken"); for (SCString::const_iterator it = ssTokens.begin(); it != ssTokens.end(); ++it) { table.AddRow(); table.SetCell("Token", *it); } if (PutModule(table) == 0) { PutModule("No tokens set for your user"); } }
void List(const CString& sCommand) { CTable Table; unsigned int index = 1; Table.AddColumn(t_s("Id", "list")); Table.AddColumn(t_s("Perform", "list")); Table.AddColumn(t_s("Expanded", "list")); for (const CString& sPerf : m_vPerform) { Table.AddRow(); Table.SetCell(t_s("Id", "list"), CString(index++)); Table.SetCell(t_s("Perform", "list"), sPerf); CString sExpanded = ExpandString(sPerf); if (sExpanded != sPerf) { Table.SetCell(t_s("Expanded", "list"), sExpanded); } } if (PutModule(Table) == 0) { PutModule(t_s("No commands in your perform list.")); } }
void ListCmd(const CString& sCommand) { CTable Table; Table.AddColumn("Pattern"); vector<CPattern>::iterator it = m_vPatterns.begin(); for (; it != m_vPatterns.end(); ++it) { Table.AddRow(); Table.SetCell("Pattern", it->GetPattern()); } if (Table.size()) { PutModule(Table); } else { PutModule("No patterns known."); } }
void ShowSocks(bool bShowHosts) { if (CZNC::Get().GetManager().empty()) { PutStatus("You have no open sockets."); return; } std::priority_queue<CSocketSorter> socks = GetSockets(); CTable Table; Table.AddColumn("Name"); Table.AddColumn("Created"); Table.AddColumn("State"); #ifdef HAVE_LIBSSL Table.AddColumn("SSL"); #endif Table.AddColumn("Local"); Table.AddColumn("Remote"); Table.AddColumn("In"); Table.AddColumn("Out"); while (!socks.empty()) { Csock* pSocket = socks.top().GetSock(); socks.pop(); Table.AddRow(); Table.SetCell("Name", pSocket->GetSockName()); Table.SetCell("Created", GetCreatedTime(pSocket)); Table.SetCell("State", GetSocketState(pSocket)); #ifdef HAVE_LIBSSL Table.SetCell("SSL", pSocket->GetSSL() ? "Yes" : "No"); #endif Table.SetCell("Local", GetLocalHost(pSocket, bShowHosts)); Table.SetCell("Remote", GetRemoteHost(pSocket, bShowHosts)); Table.SetCell("In", CString::ToByteStr(pSocket->GetBytesRead())); Table.SetCell("Out", CString::ToByteStr(pSocket->GetBytesWritten())); } PutModule(Table); return; }
void OnModCommand(const CString& sCommand) { CString sCmd = sCommand.Token(0); if (!m_pUser->IsAdmin()) { PutModule("Access denied"); return; } if (sCmd.Equals("list")) { CTable Table; MCString::iterator it; Table.AddColumn("Blocked user"); for (it = BeginNV(); it != EndNV(); ++it) { Table.AddRow(); Table.SetCell("Blocked user", it->first); } if (PutModule(Table) == 0) PutModule("No users blocked"); } else if (sCmd.Equals("block")) { CString sUser = sCommand.Token(1, true); if (m_pUser->GetUserName().Equals(sUser)) { PutModule("You can't block yourself"); return; } if (Block(sUser)) PutModule("Blocked [" + sUser + "]"); else PutModule("Could not block [" + sUser + "] (misspelled?)"); } else if (sCmd.Equals("unblock")) { CString sUser = sCommand.Token(1, true); if (DelNV(sUser)) PutModule("Unblocked [" + sUser + "]"); else PutModule("This user is not blocked"); } else { PutModule("Commands: list, block [user], unblock [user]"); } }