policy.cpp
来自「特别好玩有启发的东西」· C++ 代码 · 共 1,712 行 · 第 1/3 页
CPP
1,712 行
//a-timeOut
//b-bRecord
//c-isWithAttachment
//d-bAuth
//e-bTime(time segment)
//f-IsSubjectFilter
//g-bAddress
//h-bAttachName;
//i-bContent;
//-bUse
//policy talbe-------total 10.
//1-CPop3PubPolicy table
if(! dbop->exec_sql("select * from HTTPProxy"))
return -1;
if(dbop->IsEmpty())
return -1;
if(1 != dbop->get_line_value())//how many records?
return -1;
//HTTPProxy policy initializing:9 bools
int col[10] = {2,3,4,5,6,7,8,9,10,11};
std::string strTmp;
std::vector<int> vecColNo(col,col+10);
std::vector<std::string> vecHttpProValue;
dbop->GetMultiFieldValue(vecColNo,vecHttpProValue);
//TimeOut
strTmp = vecHttpProValue.operator[](2);
if(NULL ==strTmp.c_str())
return -1;
else TimeOut = (short)atoi(strTmp.c_str());//should judge the validity of the string?
//brecord:whether to record the content
strTmp = vecHttpProValue.operator[](3);
if(NULL == strTmp.c_str())
return -1;
else bRecord = atoi(strTmp.c_str());
//bWithAttach:whether to record the content
strTmp = vecHttpProValue.operator[](4);
if(NULL == strTmp.c_str())
return -1;
else bWithAttach = atoi(strTmp.c_str());
//bAuth:should verify the user's identity?
strTmp = vecHttpProValue.operator[](5);
if(NULL == strTmp.c_str())
return -1;
else bAuth = atoi(strTmp.c_str());
//bTime
strTmp = vecHttpProValue.operator[](6);
if(NULL == strTmp.c_str())
return -1;
else bTime = atoi(strTmp.c_str());
//bKeyWordFlt
strTmp = vecHttpProValue.operator[](7);
if(NULL == strTmp.c_str())
return -1;
else bSubject = atoi(strTmp.c_str());
//bEmailAddress:
strTmp = vecHttpProValue.operator[](8);
if(NULL == strTmp.c_str())
return -1;
else bEmailAddress = atoi(strTmp.c_str());
//bAttachName
strTmp = vecHttpProValue.operator[](9);
if(NULL == strTmp.c_str())
return -1;
else bAttachName = atoi(strTmp.c_str());
//bContent
strTmp = vecHttpProValue.operator[](10);
if(NULL == strTmp.c_str())
return -1;
else bContent = atoi(strTmp.c_str());
//bUse
strTmp = vecHttpProValue.operator[](11);
if(NULL == strTmp.c_str())
return -1;
else bUse = atoi(strTmp.c_str());
//2-time segment
if(bTime)
if(0 != fltTime(dbop,tTimeSegt,POP3,PUB))
return -1;
//3-Subject key words filter
if(bSubject)
if(0 != fltKeyWord(dbop,tSubjectVec,SUBJECT,POP3,PUB))
return -1;
//4-email address filter:
if(bEmailAddress){
if(0 != fltAddress(dbop,tSenderAddrVec,SENDER, POP3,PUB))
return -1;
if(0 != fltAddress(dbop,tRcptAddrVec,RECEIPIENT, POP3,PUB))
return -1;
if(0 != fltAddress(dbop,tCcAddrVec,CCRECEIPIENT, POP3,PUB))
return -1;
if(0 != fltAddress(dbop,tBccAddrVec,BCCRECEIPIENT, POP3,PUB))
return -1;
}
//5-bAttachName
if(bAttachName)
if(0 != fltKeyWord(dbop,tAtthNameVec,ATTACHNAME,POP3,PUB))
return -1;
//6-bContent
if(bContent)
if(0 != fltKeyWord(dbop,tContentVec,CONTENT,POP3,PUB))
return -1;
return 0;
}
void CPop3PubPolicy::Clear()
{
;
}
/*****************************************************************************
name :CFtpProxyPolicy::Load
usage :initialize the smtp proxy policy.
calls :none
be called :netstrobe main frame;
table visited: :none
table repaired :none
input :CDB_Operator
output :none
return value :0-runing succeed; 1-runing failed.
others :none.
*****************************************************************************/
int CFtpProxyPolicy::Load(CDB_Operator* dbop, char * * pResult)
{
//initialize the CFtpProxyPolicy alone. param pResult is not used now.
//a-timeOut
//b-bRecord
//c-bAuth
//d-bTime(time segment)
//e-furl
//f-service ip
//g-port
//h-bUse
//policy talbe-------total 8.
//1-CFtpProxyPolicy table
if(! dbop->exec_sql("select * from FTPProxy"))
return -1;
if(dbop->IsEmpty())
return -1;
if(1 != dbop->get_line_value())//how many records?
return -1;
//HTTPProxy policy initializing:9 bools
int col[10] = {2,3,4,5,6,7,8,9};
std::string strTmp;
std::vector<int> vecColNo(col,col+10);
std::vector<std::string> vecHttpProValue;
dbop->GetMultiFieldValue(vecColNo,vecHttpProValue);
//TimeOut
strTmp = vecHttpProValue.operator[](2);
if(NULL ==strTmp.c_str())
return -1;
else TimeOut = (short)atoi(strTmp.c_str());//should judge the validity of the string?
//brecord:whether to record the content
strTmp = vecHttpProValue.operator[](3);
if(NULL == strTmp.c_str())
return -1;
else bRecord = atoi(strTmp.c_str());
//bAuth:should verify the user's identity?
strTmp = vecHttpProValue.operator[](4);
if(NULL == strTmp.c_str())
return -1;
else bAuth = atoi(strTmp.c_str());
//bTime
strTmp = vecHttpProValue.operator[](5);
if(NULL == strTmp.c_str())
return -1;
else bTime= atoi(strTmp.c_str());
//bUrl
strTmp = vecHttpProValue.operator[](6);
if(NULL == strTmp.c_str())
return -1;
else bUrl= atoi(strTmp.c_str());
//bIP:
strTmp = vecHttpProValue.operator[](7);
if(NULL == strTmp.c_str())
return -1;
else bIP= atoi(strTmp.c_str());
//bPort
strTmp = vecHttpProValue.operator[](8);
if(NULL == strTmp.c_str())
return -1;
else bPort= atoi(strTmp.c_str());
//bUse
strTmp = vecHttpProValue.operator[](9);
if(NULL == strTmp.c_str())
return -1;
else bUse= atoi(strTmp.c_str());
//2-time segment
if(bTime)
if(0 != fltTime(dbop,tTimeSegt,FTP,PROXY))
return -1;
//3-url filter
if(bUrl)
if(0 != fltUrl(dbop, tUrlVec, FTP,PROXY))
return -1;
//4-serveice ip filter:
if(bIP)
if(0 != fltIP(dbop, tIPVec,FTP,PROXY))
return -1;
//5-bPort
if(bPort)
if(0 != fltPort(dbop,tPortVec,FTP,PROXY))
return -1;
return 0;
}
void CFtpProxyPolicy::Clear()
{
;
}
/*****************************************************************************
name :CFtpPubPolicy::Load
usage :initialize the smtp proxy policy.
calls :none
be called :netstrobe main frame;
table visited: :none
table repaired :none
input :CDB_Operator
output :none
return value :0-runing succeed; 1-runing failed.
others :none.
*****************************************************************************/
int CFtpPubPolicy::Load(CDB_Operator* dbop, char * * pResult)
{
//initialize the CFtpProxyPolicy alone. param pResult is not used now.
//a-timeOut
//b-bRecord
//c-bAuth
//d-bTime(time segment)
//e-furl
//f-service ip
//g-port
//h-bUse
//policy talbe-------total 8.
//1-CFtpProxyPolicy table
if(! dbop->exec_sql("select * from FTPPup"))
return -1;
if(dbop->IsEmpty())
return -1;
if(1 != dbop->get_line_value())//how many records?
return -1;
//HTTPProxy policy initializing:9 bools
int col[10] = {2,3,4,5,6,7,8,9};
std::string strTmp;
std::vector<int> vecColNo(col,col+10);
std::vector<std::string> vecHttpProValue;
dbop->GetMultiFieldValue(vecColNo,vecHttpProValue);
//TimeOut
strTmp = vecHttpProValue.operator[](2);
if(NULL ==strTmp.c_str())
return -1;
else TimeOut = (short)atoi(strTmp.c_str());//should judge the validity of the string?
//brecord:whether to record the content
strTmp = vecHttpProValue.operator[](3);
if(NULL == strTmp.c_str())
return -1;
else bRecord = atoi(strTmp.c_str());
//bAuth:should verify the user's identity?
strTmp = vecHttpProValue.operator[](4);
if(NULL == strTmp.c_str())
return -1;
else bAuth = atoi(strTmp.c_str());
//bTime
strTmp = vecHttpProValue.operator[](5);
if(NULL == strTmp.c_str())
return -1;
else bTime= atoi(strTmp.c_str());
//2-time segment
if(bTime)
if(0 != fltTime(dbop,tTimeSegt,FTP,PUB))
return -1;
return 0;
}
void CFtpPubPolicy::Clear()
{
;
}
/*****************************************************************************
name :CSockProxyPolicy::Load
usage :initialize the smtp proxy policy.
calls :none
be called :netstrobe main frame;
table visited: :none
table repaired :none
input :CDB_Operator
output :none
return value :0-runing succeed; 1-runing failed.
others :none.
*****************************************************************************/
int CSockProxyPolicy::Load(CDB_Operator* dbop, char * * pResult)
{
//initialize the CSockProxyPolicy alone. param pResult is not used now.
//a-timeOut
//b-bAuth
//c-bTime(time segment)
//d-bUse
//policy talbe-------total 4.
//1-CSockProxyPolicy table
if(! dbop->exec_sql("select * from SOCKProxy"))
return -1;
if(dbop->IsEmpty())
return -1;
if(1 != dbop->get_line_value())//how many records?
return -1;
//HTTPProxy policy initializing:9 bools
int col[10] = {2,3,4,5};
std::string strTmp;
std::vector<int> vecColNo(col,col+4);
std::vector<std::string> vecHttpProValue;
dbop->GetMultiFieldValue(vecColNo,vecHttpProValue);
//TimeOut
strTmp = vecHttpProValue.operator[](2);
if(NULL ==strTmp.c_str())
return -1;
else TimeOut = (short)atoi(strTmp.c_str());//should judge the validity of the string?
//bAuth:should verify the user's identity?
strTmp = vecHttpProValue.operator[](3);
if(NULL == strTmp.c_str())
return -1;
else bAuth = atoi(strTmp.c_str());
//bTime:whether to record the content
strTmp = vecHttpProValue.operator[](4);
if(NULL == strTmp.c_str())
return -1;
else bTime = atoi(strTmp.c_str());
//bUse:whether to use this service
strTmp = vecHttpProValue.operator[](5);
if(NULL == strTmp.c_str())
return -1;
else bUse = atoi(strTmp.c_str());
//2-time segment
if(bTime)
if(0 != fltTime(dbop,tTimeSegt,FTP,PROXY))
return -1;
return 0;
}
void CSockProxyPolicy::Clear()
{
;
}
/*****************************************************************************
name :CDBPubPolicy::Load
usage :initialize the smtp proxy policy.
calls :none
be called :netstrobe main frame;
table visited: :none
table repaired :none
input :CDB_Operator
output :none
return value :0-runing succeed; 1-runing failed.
others :none.
*****************************************************************************/
int CDBPubPolicy::Load(CDB_Operator* dbop, char * * pResult)
{
//initialize the CDBPubPolicy ,and param pResult is not used now.
//a-timeOut
//b-bAuth
//c-bTime(time segment)
//d-bUse
//policy talbe-------total 4.
//1-CSockProxyPolicy table
if(! dbop->exec_sql("select * from DBPub"))
return -1;
if(dbop->IsEmpty())
return -1;
if(1 != dbop->get_line_value())//how many records?
return -1;
//HTTPProxy policy initializing:9 bools
int col[10] = {2,3,4,5};
std::string strTmp;
std::vector<int> vecColNo(col,col+4);
std::vector<std::string> vecHttpProValue;
dbop->GetMultiFieldValue(vecColNo,vecHttpProValue);
//TimeOut
strTmp = vecHttpProValue.operator[](2);
if(NULL ==strTmp.c_str())
return -1;
else TimeOut = (short)atoi(strTmp.c_str());//should judge the validity of the string?
//bAuth:should verify the user's identity?
strTmp = vecHttpProValue.operator[](3);
if(NULL == strTmp.c_str())
return -1;
else bAuth = atoi(strTmp.c_str());
//bTime:whether to record the content
strTmp = vecHttpProValue.operator[](4);
if(NULL == strTmp.c_str())
return -1;
else bTime = atoi(strTmp.c_str());
//bUse:whether to use this service
strTmp = vecHttpProValue.operator[](5);
if(NULL == strTmp.c_str())
return -1;
else bUse = atoi(strTmp.c_str());
//2-time segment
if(bTime)
if(0 != fltTime(dbop,tTimeSegt,DB,PUB))
return -1;
return 0;
}
void CDBPubPolicy::Clear()
{
;
}
/*****************************************************************************
name :InitPolicy
usage :setting the policy struct;
calls :getModAndFuncType()
be called :init() of CNetStrobe class.
table visited: :none
table repaired :none
input :none
output :none
return value :NS_SUCCEEDED-runing succeed; NS_FAILED-runing failed.
others :none.
*****************************************************************************/
int InitPolicy(CPolicy& stPolicy)
{
//{{{to read all the policy from the database
int iRet;
//CPolicy stPolicy;
CDB_Operator* objDbOpPtr = CDB_Operator::Instance();
stPolicy.bVirusCheck = false; //which table to read this value from????????
iRet = stPolicy.tDBPubPolicy.Load(objDbOpPtr,NULL);
if(0 != iRet)
return -1;
iRet = stPolicy.tFtpProxyPolicy.Load(objDbOpPtr,0);
if(0 != iRet)
return -1;
iRet = stPolicy.tFtpPubPolicy.Load(objDbOpPtr, 0);
if(0 != iRet)
return -1;
iRet = stPolicy.tHttpProxyPolicy.Load(objDbOpPtr,0);
if(0 != iRet)
return -1;
iRet = stPolicy.tHttpPubPolicy.Load(objDbOpPtr, 0);
if(0 != iRet)
return -1;
iRet = stPolicy.tPop3PubPolicy.Load(objDbOpPtr, 0);
if(0 != iRet)
return -1;
iRet = stPolicy.tPop3PubPolicy.Load(objDbOpPtr, 0);
if(0 != iRet)
return -1;
iRet = stPolicy.tSmtpProxyPolicy.Load(objDbOpPtr,0);
if(0 != iRet)
return -1;
iRet = stPolicy.tSmtpPubPolicy.Load(objDbOpPtr,0);
if(0 != iRet)
return -1;
iRet = stPolicy.tSockProxyPolicy.Load(objDbOpPtr,0);
if(0 != iRet)
return -1;
//}}} readed all the policy from the database
//close the databse ,doing it here ????
if(objDbOpPtr->closeDB()){
WriteLog(LOG_NORMAL, "Database closed succeed.");
return 0;
}
else {
WriteLog(LOG_ERROR, "Database closing failed!");
return -1;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?