00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifdef _WIN32
00021 #pragma warning(disable:4786)
00022 #endif
00023
00024
00025 #include "SMTPSocket.h"
00026 #include "FwdSocket.h"
00027 #include "NukeHandler.h"
00028 #ifdef _WIN32
00029
00030 #endif
00031
00032 #define DEB(x)
00033
00034
00035 NukeHandler::NukeHandler()
00036 :SocketHandler()
00037 ,m_db(NULL)
00038 {
00039 InitDB();
00040 }
00041
00042
00043 NukeHandler::~NukeHandler()
00044 {
00045 }
00046
00047
00048 void NukeHandler::ViewSockets()
00049 {
00050 for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++)
00051 {
00052 SOCKET s = (*it).first;
00053 Socket *p = (*it).second;
00054 if (dynamic_cast<SMTPSocket *>(p))
00055 {
00056 printf("%4d: SMTPSocket\n",s);
00057 }
00058 else
00059 if (dynamic_cast<FwdSocket *>(p))
00060 {
00061 printf("%4d: FwdSocket\n",s);
00062 }
00063 }
00064 }
00065
00066
00067 void NukeHandler::InitDB()
00068 {
00069 FILE *fil = fopen("nuke.db","rb");
00070 bool exists = false;
00071 if (fil)
00072 {
00073 exists = true;
00074 fclose(fil);
00075 }
00076 m_db = new Database("nuke.db");
00077 if (!exists)
00078 {
00079 Query q(m_db);
00080 q.execute("create table sender ("
00081 "num integer primary key,"
00082 "email string,"
00083 "status string,"
00084 "forward string"
00085 ")");
00086 q.execute("create table recipient ("
00087 "num integer primary key,"
00088 "email string,"
00089 "status string,"
00090 "forward string"
00091 ")");
00092 q.execute("create table mailinst ("
00093 "id integer primary key,"
00094 "host string,"
00095 "mail string,"
00096 "rcpt string,"
00097 "h_from string,"
00098 "h_to string,"
00099 "h_subject string,"
00100 "host_spam string,"
00101 "mail_spam string,"
00102 "from_spam string,"
00103 "subject_spam string"
00104 ")");
00105 }
00106 }
00107
00108