X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fintroductionpuzzleinserter.cpp;h=cac38792d6c68701048bef1bcc96a0373be5f59f;hb=05ef25de71be91442b4cbd22dc7cc45629c5d5bb;hp=ba0ffabef15ef4eec3335163239a5907fbe0e58f;hpb=822f84f5dac64183c556bd86fea8cd7b0527f528;p=fms.git diff --git a/src/freenet/introductionpuzzleinserter.cpp b/src/freenet/introductionpuzzleinserter.cpp index ba0ffab..cac3879 100644 --- a/src/freenet/introductionpuzzleinserter.cpp +++ b/src/freenet/introductionpuzzleinserter.cpp @@ -5,6 +5,7 @@ #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" @@ -74,18 +75,26 @@ void IntroductionPuzzleInserter::CheckForNeededInsert() void IntroductionPuzzleInserter::GenerateCaptcha(std::string &encodeddata, std::string &solution) { + ICaptcha *cap=0; #ifdef ALTERNATE_CAPTCHA - AlternateCaptcha1 captcha; + if(rand()%2==0) + { + cap=new AlternateCaptcha1(); + } + else + { + cap=new AlternateCaptcha2(); + } m_log->trace("IntroductionPuzzleInserter::GenerateCaptcha using alternate captcha generator"); #else - SimpleCaptcha captcha; + 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(); @@ -93,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)