X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Ffreenet%2Fintroductionpuzzleinserter.cpp;fp=src%2Ffreenet%2Fintroductionpuzzleinserter.cpp;h=60f7bb66c8f9ca9c97f1b99a1a0b9ff4cf2651d2;hp=ba0ffabef15ef4eec3335163239a5907fbe0e58f;hb=b7f3b3e6ae9dc527f02b5c06e2eeae0e9cac3ad8;hpb=f8c0410b12183ecb40aafbb44086fa146b25b528 diff --git a/src/freenet/introductionpuzzleinserter.cpp b/src/freenet/introductionpuzzleinserter.cpp index ba0ffab..60f7bb6 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,27 @@ 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=&captcha; #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 +103,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)