version 0.3.15
authorSomeDude <SomeDude@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw>
Sat, 2 Aug 2008 11:16:00 +0000 (13:16 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Sat, 2 Aug 2008 11:16:00 +0000 (13:16 +0200)
CMakeLists.txt
include/bitmapvalidator.h
include/documenttypevalidator.h
include/global.h
src/bitmapvalidator.cpp
src/freenet/captcha/alternatecaptcha1.cpp
src/freenet/introductionpuzzlerequester.cpp
src/http/httpthread.cpp
src/http/pages/announceidentitypage.cpp

index 27de288..a97f5dc 100644 (file)
@@ -122,6 +122,8 @@ IF(ALTERNATE_CAPTCHA)
        src/freenet/captcha/alternatecaptcha1.cpp\r
        src/freenet/captcha/freeimage/bitmap.cpp\r
        src/freenet/captcha/freeimage/font.cpp)\r
        src/freenet/captcha/alternatecaptcha1.cpp\r
        src/freenet/captcha/freeimage/bitmap.cpp\r
        src/freenet/captcha/freeimage/font.cpp)\r
+ELSE(ALTERNATE_CAPTCHA)\r
+       MESSAGE(STATUS "You are using the old captcha generator.  Add a -D ALTERNATE_CAPTCHA=ON to the command line to use the alternate captcha generator.")\r
 ENDIF(ALTERNATE_CAPTCHA)\r
 \r
 IF(NOT I_HAVE_READ_THE_README)\r
 ENDIF(ALTERNATE_CAPTCHA)\r
 \r
 IF(NOT I_HAVE_READ_THE_README)\r
@@ -169,7 +171,7 @@ FIND_LIBRARY(ICONV_LIBRARY NAMES iconv iconv_s libiconv libiconv_s)
 IF(ALTERNATE_CAPTCHA)\r
        FIND_FILE(FREEIMAGE_LIBRARY NAMES libfreeimage.a PATHS /usr/lib/)\r
        IF(NOT FREEIMAGE_LIBRARY)\r
 IF(ALTERNATE_CAPTCHA)\r
        FIND_FILE(FREEIMAGE_LIBRARY NAMES libfreeimage.a PATHS /usr/lib/)\r
        IF(NOT FREEIMAGE_LIBRARY)\r
-               FIND_LIBRARY(FREEIMAGE_LIBRARY NAMES FreeImage libFreeImage libfreeimage)\r
+               FIND_LIBRARY(FREEIMAGE_LIBRARY NAMES FreeImage libFreeImage libfreeimage freeimage)\r
        ENDIF(NOT FREEIMAGE_LIBRARY)\r
 ENDIF(ALTERNATE_CAPTCHA)\r
 \r
        ENDIF(NOT FREEIMAGE_LIBRARY)\r
 ENDIF(ALTERNATE_CAPTCHA)\r
 \r
index 0a1ee65..20c452c 100644 (file)
@@ -6,7 +6,15 @@
 class BitmapValidator:public DocumentTypeValidator\r
 {\r
 public:\r
 class BitmapValidator:public DocumentTypeValidator\r
 {\r
 public:\r
+       BitmapValidator();\r
+       ~BitmapValidator();\r
+\r
        const bool Validate(const std::vector<unsigned char> &data);\r
        const bool Validate(const std::vector<unsigned char> &data);\r
+       void SetMax(const int maxw, const int maxh)     { m_maxwidth=maxw; m_maxheight=maxh; }\r
+\r
+private:\r
+       int m_maxwidth;\r
+       int m_maxheight;\r
 };\r
 \r
 #endif // _bitmapvalidator_\r
 };\r
 \r
 #endif // _bitmapvalidator_\r
index 8c99dd5..6cc7200 100644 (file)
@@ -6,6 +6,8 @@
 class DocumentTypeValidator\r
 {\r
 public:\r
 class DocumentTypeValidator\r
 {\r
 public:\r
+       DocumentTypeValidator()                         {}\r
+       virtual ~DocumentTypeValidator()        {}\r
        virtual const bool Validate(const std::vector<unsigned char> &data)=0;  \r
 };\r
 \r
        virtual const bool Validate(const std::vector<unsigned char> &data)=0;  \r
 };\r
 \r
index 7104808..05d90fc 100644 (file)
@@ -7,7 +7,7 @@
 \r
 #define VERSION_MAJOR          "0"\r
 #define VERSION_MINOR          "3"\r
 \r
 #define VERSION_MAJOR          "0"\r
 #define VERSION_MINOR          "3"\r
-#define VERSION_RELEASE                "14"\r
+#define VERSION_RELEASE                "15"\r
 #define FMS_VERSION                    VERSION_MAJOR"."VERSION_MINOR"."VERSION_RELEASE\r
 \r
 typedef Poco::ScopedLock<Poco::FastMutex> Guard;\r
 #define FMS_VERSION                    VERSION_MAJOR"."VERSION_MINOR"."VERSION_RELEASE\r
 \r
 typedef Poco::ScopedLock<Poco::FastMutex> Guard;\r
index 771b707..c2a4a3c 100644 (file)
@@ -6,6 +6,16 @@
 #include <sstream>\r
 #include <cstdlib>\r
 \r
 #include <sstream>\r
 #include <cstdlib>\r
 \r
+BitmapValidator::BitmapValidator():m_maxwidth(-1),m_maxheight(-1)\r
+{\r
+       \r
+}\r
+\r
+BitmapValidator::~BitmapValidator()\r
+{\r
+       \r
+}\r
+\r
 const bool BitmapValidator::Validate(const std::vector<unsigned char> &data)\r
 {\r
        bool validated=false;\r
 const bool BitmapValidator::Validate(const std::vector<unsigned char> &data)\r
 {\r
        bool validated=false;\r
@@ -20,7 +30,15 @@ const bool BitmapValidator::Validate(const std::vector<unsigned char> &data)
                BMP temp;\r
                if(temp.ReadFromFile(tempname.c_str()))\r
                {\r
                BMP temp;\r
                if(temp.ReadFromFile(tempname.c_str()))\r
                {\r
-                       validated=true; \r
+                       validated=true;\r
+                       if(m_maxwidth!=-1 && temp.TellWidth()>m_maxwidth)\r
+                       {\r
+                               validated=false;\r
+                       }\r
+                       if(m_maxheight!=-1 && temp.TellHeight()>m_maxheight)\r
+                       {\r
+                               validated=false;\r
+                       }\r
                }\r
 \r
                unlink(tempname.c_str());\r
                }\r
 \r
                unlink(tempname.c_str());\r
index 07f4dde..e76a57c 100644 (file)
@@ -88,6 +88,7 @@ void AlternateCaptcha1::Generate()
                }\r
        }\r
 \r
                }\r
        }\r
 \r
+       // make output a little wavy\r
        int offset=rand()%10000;\r
        for(int y=0; y<bmp.Height(); y++)\r
        {\r
        int offset=rand()%10000;\r
        for(int y=0; y<bmp.Height(); y++)\r
        {\r
@@ -128,6 +129,7 @@ const bool AlternateCaptcha1::GetSolution(std::vector<unsigned char> &solution)
 \r
 void AlternateCaptcha1::LoadFonts()\r
 {\r
 \r
 void AlternateCaptcha1::LoadFonts()\r
 {\r
+\r
        FreeImage::Bitmap bmp;\r
        Poco::Path path("fonts");\r
        Poco::DirectoryIterator di(path);\r
        FreeImage::Bitmap bmp;\r
        Poco::Path path("fonts");\r
        Poco::DirectoryIterator di(path);\r
index f7d5317..66669b3 100644 (file)
@@ -112,6 +112,7 @@ const bool IntroductionPuzzleRequester::HandleAllData(FCPMessage &message)
 \r
                // we can only validate bitmaps for now\r
                BitmapValidator val;\r
 \r
                // we can only validate bitmaps for now\r
                BitmapValidator val;\r
+               val.SetMax(200,200);\r
                std::vector<unsigned char> puzzledata;\r
                Base64::Decode(xml.GetPuzzleData(),puzzledata);\r
                if(xml.GetMimeType()!="image/bmp" || val.Validate(puzzledata)==false)\r
                std::vector<unsigned char> puzzledata;\r
                Base64::Decode(xml.GetPuzzleData(),puzzledata);\r
                if(xml.GetMimeType()!="image/bmp" || val.Validate(puzzledata)==false)\r
@@ -265,7 +266,7 @@ void IntroductionPuzzleRequester::PopulateIDList()
        st.Finalize();\r
 \r
        // select identities that aren't single use, are publishing a trust list, and have been seen today ( order by trust DESC and limit to limitnum )\r
        st.Finalize();\r
 \r
        // select identities that aren't single use, are publishing a trust list, and have been seen today ( order by trust DESC and limit to limitnum )\r
-       st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublishTrustList='true' AND PublicKey IS NOT NULL AND PublicKey <> '' AND SingleUse='false' AND LastSeen>='"+Poco::DateTimeFormatter::format(now,"%Y-%m-%d")+"' ORDER BY LocalMessageTrust DESC LIMIT 0,"+limitnum+";");\r
+       st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublishTrustList='true' AND PublicKey IS NOT NULL AND PublicKey <> '' AND SingleUse='false' AND (LocalTrustListTrust IS NULL OR LocalTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalTrustListTrust')) AND LastSeen>='"+Poco::DateTimeFormatter::format(now,"%Y-%m-%d")+"' ORDER BY LocalMessageTrust DESC LIMIT 0,"+limitnum+";");\r
        st.Step();\r
 \r
        m_ids.clear();\r
        st.Step();\r
 \r
        m_ids.clear();\r
index 89edc93..2ddfbcd 100644 (file)
@@ -25,28 +25,39 @@ void HTTPThread::run()
 {\r
        m_log->debug("HTTPThread::run thread started.");\r
 \r
 {\r
        m_log->debug("HTTPThread::run thread started.");\r
 \r
-       Poco::Net::ServerSocket sock(m_listenport);\r
-       Poco::Net::HTTPServerParams* pParams = new Poco::Net::HTTPServerParams;\r
-       pParams->setMaxQueued(30);\r
-       pParams->setMaxThreads(5);\r
-       Poco::Net::HTTPServer srv(new FMSHTTPRequestHandlerFactory,sock,pParams);\r
+       try\r
+       {\r
+               Poco::Net::ServerSocket sock(m_listenport);\r
+               Poco::Net::HTTPServerParams* pParams = new Poco::Net::HTTPServerParams;\r
+               pParams->setMaxQueued(30);\r
+               pParams->setMaxThreads(5);\r
+               Poco::Net::HTTPServer srv(new FMSHTTPRequestHandlerFactory,sock,pParams);\r
+\r
+               srv.start();\r
+               m_log->trace("Started HTTPServer");\r
 \r
 \r
-       srv.start();\r
-       m_log->trace("Started HTTPServer");\r
+               do\r
+               {\r
+                       Poco::Thread::sleep(1000);\r
+               }while(!IsCancelled());\r
 \r
 \r
-       do\r
+               m_log->trace("Trying to stop HTTPServer");\r
+               srv.stop();\r
+               m_log->trace("Stopped HTTPServer");\r
+               \r
+               m_log->trace("Waiting for current HTTP requests to finish");\r
+               while(srv.currentConnections()>0)\r
+               {\r
+                       Poco::Thread::sleep(500);\r
+               }\r
+       }\r
+       catch(Poco::Exception &e)\r
        {\r
        {\r
-               Poco::Thread::sleep(1000);\r
-       }while(!IsCancelled());\r
-\r
-       m_log->trace("Trying to stop HTTPServer");\r
-       srv.stop();\r
-       m_log->trace("Stopped HTTPServer");\r
-       \r
-       m_log->trace("Waiting for current HTTP requests to finish");\r
-       while(srv.currentConnections()>0)\r
+               m_log->fatal("HTTPThread::run caught "+e.displayText());\r
+       }\r
+       catch(...)\r
        {\r
        {\r
-               Poco::Thread::sleep(500);\r
+               m_log->fatal("HTTPThread::run caught unknown exception");\r
        }\r
 \r
        m_log->debug("HTTPThread::run thread exiting.");\r
        }\r
 \r
        m_log->debug("HTTPThread::run thread exiting.");\r
index 7858d88..f14b275 100644 (file)
@@ -43,6 +43,8 @@ const std::string AnnounceIdentityPage::GeneratePage(const std::string &method,
        std::string lastid="";\r
        std::string thisid="";\r
        std::string day="";\r
        std::string lastid="";\r
        std::string thisid="";\r
        std::string day="";\r
+       std::string name="";\r
+       std::string pubkey="";\r
        int requestindex=0;\r
        bool willshow=false;\r
 \r
        int requestindex=0;\r
        bool willshow=false;\r
 \r
@@ -87,11 +89,11 @@ const std::string AnnounceIdentityPage::GeneratePage(const std::string &method,
        content+="<tr><td colspan=\"4\"><center>Select Identity : ";\r
        content+=CreateLocalIdentityDropDown("localidentityid","");\r
        content+="</td></tr>";\r
        content+="<tr><td colspan=\"4\"><center>Select Identity : ";\r
        content+=CreateLocalIdentityDropDown("localidentityid","");\r
        content+="</td></tr>";\r
-       content+="<tr><td colspan=\"4\"><center>Type the answers of a few puzzles.  The puzzles are case sensitive.  Getting announced will take some time.  DO NOT continuously solve captchas.  Solve 30 at most, wait a day, and if your identity has not been announced, repeat until it is.</td></tr>";\r
+       content+="<tr><td colspan=\"4\"><center>Type the answers of a few of the following puzzles.  You don't need to get them all correct, but remember that they are case sensitive.  Getting announced will take some time.  DO NOT continuously solve captchas.  Solve 30 at most, wait a day, and if your identity has not been announced, repeat until it is.</td></tr>";\r
        content+="<tr>";\r
 \r
        date-=Poco::Timespan(1,0,0,0,0);\r
        content+="<tr>";\r
 \r
        date-=Poco::Timespan(1,0,0,0,0);\r
-       SQLite3DB::Statement st=m_db->Prepare("SELECT UUID,Day,IdentityID,RequestIndex FROM tblIntroductionPuzzleRequests WHERE UUID NOT IN (SELECT UUID FROM tblIdentityIntroductionInserts) AND UUID NOT IN (SELECT UUID FROM tblIntroductionPuzzleInserts) AND Day>='"+Poco::DateTimeFormatter::format(date,"%Y-%m-%d")+"' AND Found='true' ORDER BY IdentityID, Day DESC, RequestIndex DESC;");\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT UUID,Day,tblIdentity.IdentityID,RequestIndex,tblIdentity.Name,tblIdentity.PublicKey FROM tblIntroductionPuzzleRequests INNER JOIN tblIdentity ON tblIntroductionPuzzleRequests.IdentityID=tblIdentity.IdentityID WHERE UUID NOT IN (SELECT UUID FROM tblIdentityIntroductionInserts) AND UUID NOT IN (SELECT UUID FROM tblIntroductionPuzzleInserts) AND Day>='"+Poco::DateTimeFormatter::format(date,"%Y-%m-%d")+"' AND Found='true' ORDER BY tblIdentity.IdentityID, Day DESC, RequestIndex DESC;");\r
        st.Step();\r
 \r
        if(st.RowReturned()==false)\r
        st.Step();\r
 \r
        if(st.RowReturned()==false)\r
@@ -105,6 +107,8 @@ const std::string AnnounceIdentityPage::GeneratePage(const std::string &method,
                st.ResultText(1,day);\r
                st.ResultText(2,thisid);\r
                st.ResultInt(3,requestindex);\r
                st.ResultText(1,day);\r
                st.ResultText(2,thisid);\r
                st.ResultInt(3,requestindex);\r
+               st.ResultText(4,name);\r
+               st.ResultText(5,pubkey);\r
 \r
                // if we are already inserting a solution for an identity - we shouldn't show any puzzles that are older than the one we are inserting\r
                // get the last index # we are inserting this day from this identity\r
 \r
                // if we are already inserting a solution for an identity - we shouldn't show any puzzles that are older than the one we are inserting\r
                // get the last index # we are inserting this day from this identity\r
@@ -129,7 +133,7 @@ const std::string AnnounceIdentityPage::GeneratePage(const std::string &method,
                        {\r
                                content+="</tr>\r\n<tr>";\r
                        }\r
                        {\r
                                content+="</tr>\r\n<tr>";\r
                        }\r
-                       content+="<td>";\r
+                       content+="<td title=\"From "+SanitizeOutput(CreateShortIdentityName(name,pubkey))+"\">";\r
                        content+="<img src=\"showcaptcha.htm?UUID="+uuid+"\"><br>";\r
                        content+="<input type=\"hidden\" name=\"uuid["+countstr+"]\" value=\""+uuid+"\">";\r
                        content+="<input type=\"hidden\" name=\"day["+countstr+"]\" value=\""+day+"\">";\r
                        content+="<img src=\"showcaptcha.htm?UUID="+uuid+"\"><br>";\r
                        content+="<input type=\"hidden\" name=\"uuid["+countstr+"]\" value=\""+uuid+"\">";\r
                        content+="<input type=\"hidden\" name=\"day["+countstr+"]\" value=\""+day+"\">";\r