当前位置: 首页>>代码示例>>C++>>正文


C++ IPAddressSQLHelper类代码示例

本文整理汇总了C++中IPAddressSQLHelper的典型用法代码示例。如果您正苦于以下问题:C++ IPAddressSQLHelper类的具体用法?C++ IPAddressSQLHelper怎么用?C++ IPAddressSQLHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IPAddressSQLHelper类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

   bool 
   PersistentGreyList::AddObject(shared_ptr<GreyListTriplet> pTriplet)
   //---------------------------------------------------------------------------()
   // DESCRIPTION:
   // Adds a new greylist triple into the database.
   //---------------------------------------------------------------------------()
   {
      String sSenderAddress = pTriplet->GetSenderAddress().Left(200);
      String sRecipientAddress = pTriplet->GetRecipientAddress().Left(200);
   
      // Update the triplet
      SQLStatement oStatement;

      IPAddressSQLHelper helper;

      oStatement.SetTable("hm_greylisting_triplets");
      oStatement.AddColumn("glcreatetime", pTriplet->GetCreateTime());
      oStatement.AddColumn("glblockendtime", pTriplet->GetBlockEndTime());
      oStatement.AddColumn("gldeletetime", pTriplet->GetDeleteTime());
      
      helper.AppendStatement(oStatement, pTriplet->GetIPAddress(), "glipaddress1", "glipaddress2");

      oStatement.AddColumn("glsenderaddress", sSenderAddress);
      oStatement.AddColumn("glrecipientaddress", sRecipientAddress);
      oStatement.AddColumn("glpassedcount", "0");
      oStatement.AddColumn("glblockedcount", "0");

      oStatement.SetStatementType(SQLStatement::STInsert);
      oStatement.SetIdentityColumn("glid");

      bool bResult = Application::Instance()->GetDBManager()->Execute(oStatement, 0, DALConnection::DALErrorInSQL);

      return bResult;
   }
开发者ID:jrallo,项目名称:hMailServer,代码行数:34,代码来源:PersistentGreyList.cpp

示例2: if

   bool 
   PersistentTCPIPPort::ReadObject(shared_ptr<TCPIPPort> pObject, shared_ptr<DALRecordset> pRS)
   {
      IPAddressSQLHelper helper;

      pObject->SetID (pRS->GetLongValue("portid"));
      pObject->SetProtocol((SessionType) pRS->GetLongValue("portprotocol"));
      pObject->SetPortNumber(pRS->GetLongValue("portnumber"));
      //JDR: added to load set use STARTTLS.
      long _portSSL = pRS->GetLongValue("portusessl");
      if (_portSSL == 1)
      {
         // use regular SSL
         pObject->SetUseSSL(true);
         pObject->SetUseSTARTTLS(false); 
      }
      else if (_portSSL == 2)
      {
         // use starttls
        pObject->SetUseSSL(false);
        pObject->SetUseSTARTTLS(true); 
      }
      else
      {
         // all other options are invalid, set all to false.
         pObject->SetUseSSL(false);
         pObject->SetUseSTARTTLS(false); 
      }
     //JDR: end mod
      pObject->SetAddress(helper.Construct(pRS, "portaddress1", "portaddress2"));
      pObject->SetSSLCertificateID(pRS->GetLongValue("portsslcertificateid"));
      
      return true;
   }
开发者ID:Bill48105,项目名称:hmailserver,代码行数:34,代码来源:PersistentTCPIPPort.cpp

示例3:

   bool
   PersistentSecurityRange::SaveObject(shared_ptr<SecurityRange> pSR, String &result)
   {
      if (!Validate(pSR, result))
         return false;

      DateTime rangeExpiresTime = pSR->GetExpiresTime();
      if (rangeExpiresTime.GetStatus() != DateTime::valid)
         rangeExpiresTime.SetDateTime(2001,01,01,0,0,0);

      String name = pSR->GetName();
      if (name.GetLength() > 100)
         name = name.Mid(0, 100);

      IPAddressSQLHelper helper;

      SQLStatement oStatement;
      oStatement.SetTable("hm_securityranges");

      oStatement.AddColumn("rangename", name);
      oStatement.AddColumn("rangepriorityid", pSR->GetPriority());

      helper.AppendStatement(oStatement, pSR->GetLowerIP(), "rangelowerip1", "rangelowerip2");
      helper.AppendStatement(oStatement, pSR->GetUpperIP(), "rangeupperip1", "rangeupperip2");

      oStatement.AddColumn("rangeoptions", pSR->GetOptions());
      oStatement.AddColumn("rangeexpires", pSR->GetExpires());
      oStatement.AddColumn("rangeexpirestime", Time::GetTimeStampFromDateTime(rangeExpiresTime));

      if (pSR->GetID() == 0)
      {
         oStatement.SetStatementType(SQLStatement::STInsert);
         oStatement.SetIdentityColumn("rangeid");
      }
      else
      {
         oStatement.SetStatementType(SQLStatement::STUpdate);

         String sWhere;
         sWhere.Format(_T("rangeid = %I64d"), pSR->GetID());
         oStatement.SetWhereClause(sWhere);
      }


      bool bNewObject = pSR->GetID() == 0;

      // Save and fetch ID
      __int64 iDBID = 0;
      bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0);
      if (bRetVal && bNewObject)
         pSR->SetID((int) iDBID);

      if (!bRetVal)
         result = "Failed to save. Please see the hMailServer error log for details.";

      return bRetVal;
   }
开发者ID:Bill48105,项目名称:hmailserver,代码行数:57,代码来源:PersistentSecurityRange.cpp

示例4: command

   shared_ptr<SecurityRange>
   PersistentSecurityRange::ReadMatchingIP(const IPAddress &ipaddress)
   {
      shared_ptr<SecurityRange> empty;

      IPAddressSQLHelper helper;
      String sSQL;

      if (ipaddress.GetType() == IPAddress::IPV4)
      {
         shared_ptr<SecurityRange> pSR = shared_ptr<SecurityRange>(new SecurityRange());

         sSQL.Format(_T("select * from hm_securityranges where %s >= rangelowerip1 and %s <= rangeupperip1 and rangelowerip2 IS NULL and rangeupperip2 IS NULL order by rangepriorityid desc"), 
            String(helper.GetAddress1String(ipaddress)), String(helper.GetAddress1String(ipaddress)));

         if (!ReadObject(pSR, SQLCommand(sSQL)))
            return empty;

         return pSR;
      }
      else
      {
         // Read all IPv6 items.
         shared_ptr<SecurityRange> bestMatch;

         SQLCommand command(_T("select * from hm_securityranges where rangelowerip2 is not null order by rangepriorityid desc"));
         
         shared_ptr<DALRecordset> recordset = Application::Instance()->GetDBManager()->OpenRecordset(command);
         if (!recordset)
            return empty;

         while (!recordset->IsEOF())
         {
            shared_ptr<SecurityRange> securityRange = shared_ptr<SecurityRange>(new SecurityRange());

            if (ReadObject(securityRange, recordset) == false)
               return empty;

            if (ipaddress.WithinRange(securityRange->GetLowerIP(), securityRange->GetUpperIP()))
            {
               // This IP range matches the client. Does it have higher prio than the currently
               // matching?

               if (!bestMatch || securityRange->GetPriority() > bestMatch->GetPriority())
                  bestMatch = securityRange;
            }

            recordset->MoveNext();
         }

         return bestMatch;
      }


      
   }
开发者ID:Bill48105,项目名称:hmailserver,代码行数:56,代码来源:PersistentSecurityRange.cpp

示例5:

   bool 
   PersistentTCPIPPort::SaveObject(std::shared_ptr<TCPIPPort> pObject, String &errorMessage, PersistenceMode mode)
   {
      if (mode == PersistenceModeNormal)
      {
         if (pObject->GetSSLCertificateID() == 0 &&
             (pObject->GetConnectionSecurity() == CSSSL || pObject->GetConnectionSecurity() == CSSTARTTLSOptional || pObject->GetConnectionSecurity() == CSSTARTTLSRequired))
         {
            errorMessage = "Certificate must be specified.";
            return false;
         }
      }

      SQLStatement oStatement;
      oStatement.SetTable("hm_tcpipports");

      if (pObject->GetID() == 0)
      {
         oStatement.SetStatementType(SQLStatement::STInsert);
         oStatement.SetIdentityColumn("portid");
      }
      else
      {
         oStatement.SetStatementType(SQLStatement::STUpdate);
         String sWhere;
         sWhere.Format(_T("portid = %I64d"), pObject->GetID());
         oStatement.SetWhereClause(sWhere);
         
      }

      __int64 iAddress = 0;

      IPAddressSQLHelper helper;
      

      oStatement.AddColumn("portprotocol", pObject->GetProtocol());
      oStatement.AddColumn("portnumber", pObject->GetPortNumber());
      oStatement.AddColumnInt64("portsslcertificateid", pObject->GetSSLCertificateID());
      helper.AppendStatement(oStatement, pObject->GetAddress(), "portaddress1", "portaddress2");
      oStatement.AddColumn("portconnectionsecurity", pObject->GetConnectionSecurity());
      
      bool bNewObject = pObject->GetID() == 0;

      // Save and fetch ID
      __int64 iDBID = 0;
      bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0);
      if (bRetVal && bNewObject)
         pObject->SetID((int) iDBID);


      return true;
   }
开发者ID:AimaTeam-hehai,项目名称:hmailserver,代码行数:52,代码来源:PersistentTCPIPPort.cpp

示例6: Instance

   bool 
   PersistentLogonFailure::AddFailure(const IPAddress &ipaddress)
   {
      SQLStatement statement;

      IPAddressSQLHelper helper;
      helper.AppendStatement(statement, ipaddress, "ipaddress1", "ipaddress2");

      statement.AddColumnCommand("failuretime", SQLStatement::GetCurrentTimestamp());
      statement.SetStatementType(SQLStatement::STInsert);
      statement.SetTable("hm_logon_failures");

      return Application::Instance()->GetDBManager()->Execute(statement);
   }
开发者ID:Bill48105,项目名称:hmailserver,代码行数:14,代码来源:PersistentLogonFailure.cpp

示例7:

   bool
   PersistentIncomingRelay::ReadObject(boost::shared_ptr<IncomingRelay> pSR, boost::shared_ptr<DALRecordset> pRS)
   {
      pSR->SetID(pRS->GetLongValue("relayid"));
      
      IPAddressSQLHelper helper;

      pSR->SetLowerIP(helper.Construct(pRS, "relaylowerip1", "relaylowerip2"));
      pSR->SetUpperIP(helper.Construct(pRS, "relayupperip1", "relayupperip2"));

      pSR->SetName(pRS->GetStringValue("relayname"));
  
      return true;
   }
开发者ID:bogri5520,项目名称:hMailServer,代码行数:14,代码来源:PersistentIncomingRelay.cpp

示例8:

   bool 
   PersistentTCPIPPort::ReadObject(boost::shared_ptr<TCPIPPort> pObject, boost::shared_ptr<DALRecordset> pRS)
   {
      IPAddressSQLHelper helper;

      pObject->SetID (pRS->GetLongValue("portid"));
      pObject->SetProtocol((SessionType) pRS->GetLongValue("portprotocol"));
      pObject->SetPortNumber(pRS->GetLongValue("portnumber"));
      pObject->SetUseSSL(pRS->GetLongValue("portusessl") ? true : false);
      pObject->SetAddress(helper.Construct(pRS, "portaddress1", "portaddress2"));
      pObject->SetSSLCertificateID(pRS->GetLongValue("portsslcertificateid"));
      
      return true;
   }
开发者ID:bogri5520,项目名称:hMailServer,代码行数:14,代码来源:PersistentTCPIPPort.cpp

示例9: command

   shared_ptr<GreyListTriplet> 
   PersistentGreyList::GetRecord(const String &sSenderAddress, const String &sRecipientAddress, const IPAddress & remoteIP)
   //---------------------------------------------------------------------------()
   // DESCRIPTION:
   // Returns a grey list triple based on sender, recipient and IP address.
   //---------------------------------------------------------------------------()
   {
      shared_ptr<GreyListTriplet> pTriplet;

      IPAddressSQLHelper helper;

      String sSQL;
      sSQL.Format(_T("select * from hm_greylisting_triplets where glipaddress1 %s and glipaddress2 %s and glsenderaddress = @SENDERADDRESS and glrecipientaddress = @RECIPIENTADDRESS"), 
            String(helper.GetAddress1Equals(remoteIP)),
            String(helper.GetAddress2Equals(remoteIP)));

      SQLCommand command(sSQL);
      command.AddParameter("@SENDERADDRESS", sSenderAddress);
      command.AddParameter("@RECIPIENTADDRESS", sRecipientAddress);

      shared_ptr<DALRecordset> pRS = Application::Instance()->GetDBManager()->OpenRecordset(command);
      if (!pRS || pRS->IsEOF())
      {
         // Not found
         return pTriplet;
      }

      // Read the record.
      pTriplet = shared_ptr<GreyListTriplet>(new GreyListTriplet);
      pTriplet->SetID(pRS->GetInt64Value("glid"));
      pTriplet->SetCreateTime(pRS->GetStringValue("glcreatetime"));
      pTriplet->SetBlockEndTime(pRS->GetStringValue("glblockendtime"));
      pTriplet->SetDeleteTime(pRS->GetStringValue("gldeletetime"));
      
      pTriplet->SetIPAddress(IPAddress(pRS->GetInt64Value("glipaddress1"), pRS->GetInt64Value("glipaddress2")));
      pTriplet->SetSenderAddress(pRS->GetStringValue("glsenderaddress"));
      pTriplet->SetRecipientAddress(pRS->GetStringValue("glrecipientaddress"));

      pTriplet->SetPassedCount(pRS->GetLongValue("glpassedcount"));
      pTriplet->SetBlockedCount(pRS->GetLongValue("glblockedcount"));

      return pTriplet;
   }
开发者ID:jrallo,项目名称:hMailServer,代码行数:43,代码来源:PersistentGreyList.cpp

示例10: command

   int 
   PersistentLogonFailure::GetCurrrentFailureCount(const IPAddress &ipaddress)
   {
      IPAddressSQLHelper helper;

      String sql;
      sql.Format(_T("select count(*) as c from hm_logon_failures where ipaddress1 %s and ipaddress2 %s"), 
         String(helper.GetAddress1Equals(ipaddress)),
         String(helper.GetAddress2Equals(ipaddress)));

      SQLCommand command(sql);

      shared_ptr<DALRecordset> pRS = Application::Instance()->GetDBManager()->OpenRecordset(command);
      if (!pRS)
         return 0;

      long count = pRS->GetLongValue("c");

      return count;
   }
开发者ID:Bill48105,项目名称:hmailserver,代码行数:20,代码来源:PersistentLogonFailure.cpp


注:本文中的IPAddressSQLHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。