X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fintroductionpuzzleinserter.cpp;h=cac38792d6c68701048bef1bcc96a0373be5f59f;hb=05ef25de71be91442b4cbd22dc7cc45629c5d5bb;hp=b185b9d4a90f6b48a7126ebf574c7e347a698f02;hpb=b88f50bfec6dbcd169bb8285e7c42b93baf52b6b;p=fms.git diff --git a/src/freenet/introductionpuzzleinserter.cpp b/src/freenet/introductionpuzzleinserter.cpp index b185b9d..cac3879 100644 --- a/src/freenet/introductionpuzzleinserter.cpp +++ b/src/freenet/introductionpuzzleinserter.cpp @@ -3,6 +3,10 @@ #include "../../include/stringfunctions.h" #include "../../include/option.h" #include "../../include/freenet/captcha/simplecaptcha.h" +#ifdef ALTERNATE_CAPTCHA +#include "../../include/freenet/captcha/alternatecaptcha1.h" +#include "../../include/freenet/captcha/alternatecaptcha2.h" +#endif #include "../../include/base64.h" #include @@ -52,7 +56,8 @@ void IntroductionPuzzleInserter::CheckForNeededInsert() // identity doesn't have any non-solved puzzles for today - start a new insert if(rs2.Empty()==true) { - if(m_lastinserted.find(rs.GetInt(0))==m_lastinserted.end() || m_lastinserted[rs.GetInt(0)]<=lastinsert) + // make sure we are on the next day or the appropriate amount of time has elapsed since the last insert + if(m_lastinserted.find(rs.GetInt(0))==m_lastinserted.end() || m_lastinserted[rs.GetInt(0)]<=lastinsert || m_lastinserted[rs.GetInt(0)].day()!=now.day()) { StartInsert(rs.GetInt(0)); m_lastinserted[rs.GetInt(0)]=now; @@ -70,13 +75,26 @@ void IntroductionPuzzleInserter::CheckForNeededInsert() void IntroductionPuzzleInserter::GenerateCaptcha(std::string &encodeddata, std::string &solution) { - SimpleCaptcha captcha; + ICaptcha *cap=0; +#ifdef ALTERNATE_CAPTCHA + if(rand()%2==0) + { + cap=new AlternateCaptcha1(); + } + else + { + cap=new AlternateCaptcha2(); + } + m_log->trace("IntroductionPuzzleInserter::GenerateCaptcha using alternate captcha generator"); +#else + cap=new SimpleCaptcha(); +#endif std::vector puzzle; std::vector puzzlesolution; - captcha.Generate(); - captcha.GetPuzzle(puzzle); - captcha.GetSolution(puzzlesolution); + cap->Generate(); + cap->GetPuzzle(puzzle); + cap->GetSolution(puzzlesolution); encodeddata.clear(); solution.clear(); @@ -84,6 +102,8 @@ void IntroductionPuzzleInserter::GenerateCaptcha(std::string &encodeddata, std:: Base64::Encode(puzzle,encodeddata); solution.insert(solution.begin(),puzzlesolution.begin(),puzzlesolution.end()); + delete cap; + } const bool IntroductionPuzzleInserter::HandlePutFailed(FCPMessage &message)