![]() |
MHandler Class Reference#include <MHandler.h>
Detailed Description
Definition at line 11 of file MHandler.h. Member Typedef Documentation
Definition at line 21 of file MHandler.h.
Constructor & Destructor Documentation
Definition at line 14 of file MHandler.cpp. 00015 :SocketHandler(p) 00016 ,m_listen_port(23) 00017 //,m_proxy_port(8005) 00018 ,m_valid_ip("193.15.240.60") 00019 ,m_admin_port(16667) 00020 { 00021 }
Member Function Documentation
Definition at line 29 of file MHandler.cpp. 00030 { 00031 for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++) 00032 { 00033 Socket *p0 = (*it).second; 00034 MasterSocket *p = dynamic_cast<MasterSocket *>(p0); 00035 if (p) 00036 { 00037 return p; 00038 } 00039 } 00040 return NULL; 00041 }
Definition at line 44 of file MHandler.cpp. 00045 { 00046 for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++) 00047 { 00048 Socket *p0 = (*it).second; 00049 ExtSocket *p = dynamic_cast<ExtSocket *>(p0); 00050 if (p && p -> GetID() == id) 00051 { 00052 p -> SendBuf(buf, len); 00053 } 00054 } 00055 }
Definition at line 58 of file MHandler.cpp. 00059 { 00060 for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++) 00061 { 00062 Socket *p0 = (*it).second; 00063 ExtSocket *p = dynamic_cast<ExtSocket *>(p0); 00064 if (p && p -> GetID() == id) 00065 { 00066 p -> SetCloseAndDelete(); 00067 } 00068 } 00069 }
Definition at line 89 of file MHandler.cpp. References m_services, SetAdminPort(), SetListenPort(), and SetValidIP(). Referenced by main(). 00090 { 00091 FILE *fil = fopen("services.txt", "rt"); 00092 if (fil) 00093 { 00094 port_t local_port = 0; 00095 std::string remote_host; 00096 port_t remote_port; 00097 char slask[1000]; 00098 fgets(slask, 1000, fil); 00099 while (!feof(fil)) 00100 { 00101 slask[strlen(slask) - 1] = 0; 00102 if (*slask && *slask != '#') 00103 { 00104 Parse pa(slask); 00105 std::string key = pa.getword(); 00106 std::string value = pa.getword(); 00107 if (key == "local_port") 00108 local_port = atoi(value.c_str()); 00109 else 00110 if (key == "remote_host" || key == "remote_ip") 00111 remote_host = value; 00112 else 00113 if (key == "remote_port" && local_port) 00114 { 00115 remote_port = atoi(value.c_str()); 00116 m_services.push_back(new SERVICE(local_port, remote_host, remote_port)); 00117 local_port = 0; 00118 } 00119 else 00120 if (key == "listen_port") 00121 SetListenPort(atoi(value.c_str())); 00122 else 00123 /* 00124 if (key == "proxy_port") 00125 SetProxyPort(atoi(value.c_str())); 00126 else 00127 */ 00128 if (key == "valid_ip") 00129 SetValidIP(value); 00130 else 00131 if (key == "admin_port") 00132 SetAdminPort(atoi(value.c_str())); 00133 } 00134 // 00135 fgets(slask, 1000, fil); 00136 } 00137 fclose(fil); 00138 } 00139 }
Definition at line 142 of file MHandler.cpp. References GetAdminPort(), GetListenPort(), GetValidIP(), and m_services. Referenced by main(). 00143 { 00144 FILE *fil = fopen("services.txt", "wt"); 00145 if (fil) 00146 { 00147 fprintf(fil, "# master listen port & valid IP that can connect\n"); 00148 fprintf(fil, "listen_port %u\n", GetListenPort()); 00149 fprintf(fil, "valid_ip %s\n", GetValidIP().c_str()); 00150 fprintf(fil, "\n"); 00151 /* 00152 fprintf(fil, "# proxy listen port\n"); 00153 fprintf(fil, "proxy_port %u\n", GetProxyPort()); 00154 fprintf(fil, "\n"); 00155 */ 00156 fprintf(fil, "# admin listen port\n"); 00157 fprintf(fil, "admin_port %u\n", GetAdminPort()); 00158 fprintf(fil, "\n"); 00159 00160 fprintf(fil, "# defined remote services (always end with remote_port because I'm lazy)\n"); 00161 for (service_v::iterator it = m_services.begin(); it != m_services.end(); it++) 00162 { 00163 SERVICE *p = *it; 00164 fprintf(fil, "local_port %u\n", p -> port); 00165 fprintf(fil, "remote_host %s\n", p -> remote_host.c_str()); 00166 fprintf(fil, "remote_port %u\n", p -> remote_port); 00167 fprintf(fil, "\n"); 00168 } 00169 fclose(fil); 00170 } 00171 }
Definition at line 36 of file MHandler.h. References m_listen_port. Referenced by LoadConfig(). 00036 { m_listen_port = x; }
Definition at line 37 of file MHandler.h. References m_listen_port. Referenced by main(), and SaveConfig(). 00037 { return m_listen_port; }
Definition at line 190 of file MHandler.cpp. References m_services, and StartService(). Referenced by main(). 00191 { 00192 for (service_v::iterator it = m_services.begin(); it != m_services.end(); it++) 00193 { 00194 SERVICE *p = *it; 00195 StartService(p); 00196 } 00197 }
Definition at line 43 of file MHandler.h. References m_services. Referenced by AdminSocket::Exec(). 00043 { return m_services; }
Definition at line 200 of file MHandler.cpp. References m_services, and StartService(). Referenced by AdminSocket::Exec(). 00201 { 00202 SERVICE *p = new SERVICE(port, remote_host, remote_port); 00203 m_services.push_back(p); 00204 StartService(p); 00205 }
Definition at line 174 of file MHandler.cpp. Referenced by AddService(), and StartServices(). 00175 { 00176 ListenSocket<ExtSocket> *l = new ListenSocket<ExtSocket>(*this); 00177 l -> SetDeleteByHandler(); 00178 if (!l -> Bind(p -> port)) 00179 { 00180 printf("%s:%u on port %u started\n", p -> remote_host.c_str(), p -> remote_port, p -> port); 00181 Add(l); 00182 } 00183 else 00184 { 00185 delete l; 00186 } 00187 }
Definition at line 47 of file MHandler.h. References m_valid_ip. Referenced by LoadConfig(). 00047 { m_valid_ip = x; }
Definition at line 48 of file MHandler.h. References m_valid_ip. Referenced by SaveConfig(). 00048 { return m_valid_ip; }
Definition at line 208 of file MHandler.cpp. References m_unique_id. 00209 { 00210 return ++m_unique_id; 00211 }
Definition at line 52 of file MHandler.h. References m_admin_port. Referenced by LoadConfig(). 00052 { m_admin_port = x; }
Definition at line 53 of file MHandler.h. References m_admin_port. Referenced by main(), and SaveConfig(). 00053 { return m_admin_port; }
Member Data Documentation
Definition at line 58 of file MHandler.h. Referenced by AddService(), GetServices(), LoadConfig(), SaveConfig(), and StartServices().
The documentation for this class was generated from the following files: |