From 4b6a5042ada91af32eec400e78957805e2a1c147 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 3 Nov 2014 23:38:42 +0100 Subject: [PATCH] listsockets: use CModCommand --- modules/listsockets.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/modules/listsockets.cpp b/modules/listsockets.cpp index 6b883eaa..10575cd9 100644 --- a/modules/listsockets.cpp +++ b/modules/listsockets.cpp @@ -64,7 +64,10 @@ private: class CListSockets : public CModule { public: - MODCONSTRUCTOR(CListSockets) {} + MODCONSTRUCTOR(CListSockets) { + AddHelpCommand(); + AddCommand("List", static_cast(&CListSockets::OnListCommand), "[-n]", "Show the list of active sockets. Pass -n to show IP addresses"); + } virtual bool OnLoad(const CString& sArgs, CString& sMessage) { @@ -128,20 +131,14 @@ public: return false; } - virtual void OnModCommand(const CString& sLine) { - CString sCommand = sLine.Token(0); + void OnListCommand(const CString& sLine) { CString sArg = sLine.Token(1, true); - if (sCommand.Equals("LIST")) { - bool bShowHosts = true; - if (sArg.Equals("-n")) { - bShowHosts = false; - } - ShowSocks(bShowHosts); - } else { - PutModule("Use 'list' to view a list of active sockets"); - PutModule("Use 'list -n' if you want IP addresses to be displayed"); + bool bShowHosts = true; + if (sArg.Equals("-n")) { + bShowHosts = false; } + ShowSocks(bShowHosts); } CString GetSocketState(Csock* pSocket) {