![]() |
AdminSocket Class Reference#include <AdminSocket.h>
Detailed Description
Definition at line 7 of file AdminSocket.h. Constructor & Destructor Documentation
Member Function Documentation
Definition at line 19 of file AdminSocket.cpp. References MHandler::AddService(), and MHandler::GetServices(). 00020 { 00021 MHandler& h = static_cast<MHandler&>(Handler()); 00022 00023 // POST /add 00024 if (GetMethod() == "POST" && GetUri() == "/add") 00025 { 00026 std::string local_port = GetForm() -> getvalue("port"); 00027 std::string remote_host = GetForm() -> getvalue("remote_host"); 00028 std::string remote_port = GetForm() -> getvalue("remote_port"); 00029 port_t port = atoi(local_port.c_str()); 00030 port_t rport = atoi(remote_port.c_str()); 00031 if (port && remote_host.size() && rport) 00032 { 00033 h.AddService(port, remote_host, rport); 00034 } 00035 } 00036 00037 // create page 00038 Send("<html><head><title>Services</title>"); 00039 Send("<style>" 00040 "td { background: #e0e0e0; padding-left: 5px; padding-right: 5px; }" 00041 "th { background: #c0c0c0; padding-left: 5px; padding-right: 5px; }" 00042 "</style>"); 00043 Send("</head>"); 00044 Send("<body>"); 00045 Send("<h3>Service administration</h3>"); 00046 00047 Send("<table cellspacing='1'>"); 00048 Send("<tr><th>Local port</th><th>Remote host</th><th>Remote port</th></tr>"); 00049 MHandler::service_v& ref = h.GetServices(); 00050 for (MHandler::service_v::iterator it = ref.begin(); it != ref.end(); it++) 00051 { 00052 MHandler::SERVICE *p = *it; 00053 Send("<tr>"); 00054 Send("<td align='right'>" + Utility::l2string(p -> port) + "</td>"); 00055 Send("<td align='center'>" + p -> remote_host + "</td>"); 00056 Send("<td align='right'>" + Utility::l2string(p -> remote_port) + "</td>"); 00057 Send("</tr>"); 00058 } 00059 Send("</table>"); 00060 // add service 00061 Send("<h3>Add service</h3>"); 00062 Send("<form action='/add' method='POST'>"); 00063 Send("Local port<br><input type='text' name='port'><br>"); 00064 Send("Remote hostname<br><input type='text' name='remote_host'><br>"); 00065 Send("Remote port<br><input type='text' name='remote_port'><br>"); 00066 Send("<input type='submit' name='submit' value=' Add Service '>"); 00067 Send("</form>"); 00068 // end of document 00069 Send("</body></html>"); 00070 00071 // 00072 SetCloseAndDelete(); 00073 }
The documentation for this class was generated from the following files: |