mirror of
https://github.com/znc/znc.git
synced 2026-06-27 13:31:32 +02:00
Add a web interface to listsockets
Thanks to kylef for the patch and again sorry for svn. ;) git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2212 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -72,6 +72,41 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool WebRequiresAdmin() { return true; }
|
||||
virtual CString GetWebMenuTitle() { return "List sockets"; }
|
||||
|
||||
virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) {
|
||||
if (sPageName.empty() || sPageName == "index") {
|
||||
CSockManager& m = CZNC::Get().GetManager();
|
||||
if (!m.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::priority_queue<CSocketSorter> socks;
|
||||
|
||||
for (unsigned int a = 0; a < m.size(); a++) {
|
||||
socks.push(m[a]);
|
||||
}
|
||||
|
||||
while (!socks.empty()) {
|
||||
Csock* pSocket = socks.top().GetSock();
|
||||
socks.pop();
|
||||
|
||||
CTemplate& Row = Tmpl.AddRow("SocketsLoop");
|
||||
Row["Name"] = pSocket->GetSockName();
|
||||
Row["Created"] = GetCreatedTime(pSocket);
|
||||
Row["State"] = GetSocketState(pSocket);
|
||||
Row["SSL"] = pSocket->GetSSL() ? "Yes" : "No";
|
||||
Row["Local"] = GetLocalHost(pSocket, true);
|
||||
Row["Remote"] = GetRemoteHost(pSocket, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void OnModCommand(const CString& sLine) {
|
||||
CString sCommand = sLine.Token(0);
|
||||
CString sArg = sLine.Token(1, true);
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<? INC Header.tmpl ?>
|
||||
|
||||
<table class="data">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Created</td>
|
||||
<td>State</td>
|
||||
<td>SSL</td>
|
||||
<td>Local</td>
|
||||
<td>Remote</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? LOOP SocketsLoop ?>
|
||||
<tr class="<? IF __EVEN__ ?>evenrow<? ELSE ?>oddrow<? ENDIF ?>">
|
||||
<td><? VAR Name ?></td>
|
||||
<td><? VAR Created ?></td>
|
||||
<td><? VAR State ?></td>
|
||||
<td><? VAR SSL ?></td>
|
||||
<td><? VAR Local ?></td>
|
||||
<td><? VAR Remote ?></td>
|
||||
</tr>
|
||||
<? ENDLOOP ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<? INC Footer.tmpl ?>
|
||||
Reference in New Issue
Block a user