From 52581afffd81f5a71c129d87e3ac822d9522f12d Mon Sep 17 00:00:00 2001 From: SomeDude Date: Mon, 28 Apr 2008 16:42:00 +0200 Subject: [PATCH] version 0.2.12 --- include/global.h | 3 ++- include/message.h | 3 ++- src/freenet/fileinserter.cpp | 10 ++++++++-- src/global.cpp | 36 +++++++++++++++++++++++++++++++++--- src/http/pages/insertedfilespage.cpp | 4 +++- src/http/pages/peerdetailspage.cpp | 5 ++++- src/message.cpp | 18 +++++++++++++++--- 7 files changed, 67 insertions(+), 12 deletions(-) diff --git a/include/global.h b/include/global.h index 59d9dd2..6258372 100644 --- a/include/global.h +++ b/include/global.h @@ -5,7 +5,7 @@ #include #include "pthreadwrapper/thread.h" -#define FMS_VERSION "0.2.11" +#define FMS_VERSION "0.2.12" // opens database and creates tables and initial inserts if necessary void SetupDB(); @@ -17,6 +17,7 @@ void ConvertDB0105To0106(); void ConvertDB0106To0107(); void ConvertDB0107To0108(); void ConvertDB0108To0109(); +void ConvertDB0109To0110(); // inserts default options into the database void SetupDefaultOptions(); // opens logfile and sets it up diff --git a/include/message.h b/include/message.h index 625aa22..4b4cb6e 100644 --- a/include/message.h +++ b/include/message.h @@ -61,8 +61,9 @@ private: struct fileattachment { - fileattachment(const std::string &filename, const std::vector &data):m_filename(filename),m_data(data) {} + fileattachment(const std::string &filename, const std::string &mimetype, const std::vector &data):m_filename(filename),m_mimetype(mimetype),m_data(data) {} std::string m_filename; + std::string m_mimetype; std::vector m_data; }; diff --git a/src/freenet/fileinserter.cpp b/src/freenet/fileinserter.cpp index d8d2721..4a82bda 100644 --- a/src/freenet/fileinserter.cpp +++ b/src/freenet/fileinserter.cpp @@ -55,7 +55,7 @@ const bool FileInserter::HandlePutSuccessful(FCPMessage &message) StringFunctions::Convert(idparts[1],fileinsertid); SQLite3DB::Statement st=m_db->Prepare("UPDATE tblFileInserts SET Key=?, Data=NULL WHERE FileInsertID=?;"); - st.Bind(0,message["URI"]); + st.Bind(0,StringFunctions::UriDecode(message["URI"])); st.Bind(1,fileinsertid); st.Step(); @@ -75,13 +75,14 @@ void FileInserter::StartInsert(const long &fileinsertid) std::string fileinsertidstr=""; std::string sizestr=""; std::string filename=""; + std::string mimetype=""; int datalen=-1; std::vector data; StringFunctions::Convert(fileinsertid,fileinsertidstr); - SQLite3DB::Statement st=m_db->Prepare("SELECT FileName,Size,Data FROM tblFileInserts WHERE FileInsertID=?;"); + SQLite3DB::Statement st=m_db->Prepare("SELECT FileName,Size,Data,MimeType FROM tblFileInserts WHERE FileInsertID=?;"); st.Bind(0,fileinsertid); st.Step(); @@ -90,12 +91,17 @@ void FileInserter::StartInsert(const long &fileinsertid) data.resize(datalen,0); st.ResultBlob(2,&data[0],datalen); data.resize(datalen); + st.ResultText(3,mimetype); StringFunctions::Convert(data.size(),sizestr); message.SetName("ClientPut"); message["URI"]="CHK@"; message["TargetFilename"]=filename; + if(mimetype!="") + { + message["Metadata.ContentType"]=mimetype; + } message["Identifier"]=m_fcpuniquename+"|"+fileinsertidstr; message["UploadFrom"]="direct"; message["DataLength"]=sizestr; diff --git a/src/global.cpp b/src/global.cpp index 7e6d842..aed8c3e 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -107,13 +107,19 @@ void SetupDB() major=1; minor=9; } + if(major==1 && minor==9) + { + ConvertDB0109To0110(); + major=1; + minor=10; + } } else { - db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,9);"); + db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,10);"); } - db->Execute("UPDATE tblDBVersion SET Major=1, Minor=9;"); + db->Execute("UPDATE tblDBVersion SET Major=1, Minor=10;"); db->Execute("CREATE TABLE IF NOT EXISTS tblOption(\ Option TEXT UNIQUE,\ @@ -340,6 +346,7 @@ void SetupDB() FileName TEXT,\ Key TEXT,\ Size INTEGER,\ + MimeType TEXT,\ Data BLOB\ );"); @@ -491,6 +498,16 @@ void SetupDB() db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@~mimyB1kmH4f7Cgsd2wM2Qv2NxrZHRMM6IY8~7EWRVQ,fxTKkR0TYhgMYb-vEGAv55sMOxCGD2xhE4ZxWHxdPz4,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');"); // insert garfield's public key db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@T8l1IEGU4-PoASFzgc2GYhIgRzUvZsKdoQWeuLHuTmM,QLxAPfkGis8l5NafNpSCdbxzXhBlu9WL8svcqJw9Mpo,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');"); + // insert alek's public key + db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@lTjeI6V0lQsktXqaqJ6Iwk4TdsHduQI54rdUpHfhGbg,0oTYfrxxx8OmdU1~60gqpf3781qzEicM4Sz97mJsBM4,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');"); + // insert Luke771's public key + db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@mdXK~ZVlfTZhF1SLBrvZ--i0vOsOpa~w9wv~~psQ-04,gXonsXKc7aexKSO8Gt8Fwre4Qgmmbt2WueO7VzxNKkk,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');"); + // insert falafel's public key + db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@IxVqeqM0LyYdTmYAf5z49SJZUxr7NtQkOqVYG0hvITw,RM2wnMn5zAufCMt5upkkgq25B1elfBAxc7htapIWg1c,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');"); + // insert cptn_insano's public key + db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@bloE1LJ~qzSYUkU2nt7sB9kq060D4HTQC66pk5Q8NpA,DOOASUnp0kj6tOdhZJ-h5Tk7Ka50FSrUgsH7tCG1usU,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');"); + // insert Flink's public key + db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@q2TtkNBOuuniyJ56~8NSopCs3ttwe5KlB31ugZtWmXA,6~PzIupS8YK7L6oFNpXGKJmHT2kBMDfwTg73nHdNur8,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');"); // TODO remove sometime after 0.1.17 FixCapitalBoardNames(); @@ -627,6 +644,13 @@ void ConvertDB0108To0109() db->Execute("UPDATE tblDBVersion SET Major=1, Minor=9;"); } +void ConvertDB0109To0110() +{ + SQLite3DB::DB *db=SQLite3DB::DB::Instance(); + db->Execute("ALTER TABLE tblFileInserts ADD COLUMN MimeType TEXT;"); + db->Execute("UPDATE tblDBVersion SET Major=1, Minor=10;"); +} + void SetupDefaultOptions() { // OptionValue should always be inserted as a string, even if the option really isn't a string - just to keep the field data type consistent @@ -685,7 +709,7 @@ void SetupDefaultOptions() st.Bind(0,"HTTPAccessControl"); st.Bind(1,"-0.0.0.0/0,+127.0.0.1"); - st.Bind(2,"Comma separated list of addresses and/or subnet masks that are allowed access to the administration pages. Default is localhost only. + allows a host, - denies as host."); + st.Bind(2,"Comma separated list of addresses and/or subnet masks that are allowed access to the administration pages. Default is localhost only. + allows a host, - denies a host."); st.Step(); st.Reset(); @@ -710,6 +734,12 @@ void SetupDefaultOptions() st.Step(); st.Reset(); + st.Bind(0,"FProxyPort"); + st.Bind(1,"8888"); + st.Bind(2,"The port that Freenet is listening for http connections on."); + st.Step(); + st.Reset(); + st.Bind(0,"MessageBase"); st.Bind(1,"fms"); st.Bind(2,"A unique string shared by all clients who want to communicate with each other. This should not be changed unless you want to create your own separate communications network."); diff --git a/src/http/pages/insertedfilespage.cpp b/src/http/pages/insertedfilespage.cpp index 13abc3d..c9d4684 100644 --- a/src/http/pages/insertedfilespage.cpp +++ b/src/http/pages/insertedfilespage.cpp @@ -15,6 +15,8 @@ const std::string InsertedFilesPage::GeneratePage(const std::string &method, con std::string node="localhost"; Option::Instance()->Get("FCPHost",node); + std::string fproxyport="8888"; + Option::Instance()->Get("FProxyPort",fproxyport); while(st.RowReturned()) { @@ -26,7 +28,7 @@ const std::string InsertedFilesPage::GeneratePage(const std::string &method, con st.ResultText(1,filename); st.ResultText(2,sizestr); - content+=""+SanitizeOutput(filename)+" - "+sizestr+" bytes"; + content+=""+SanitizeOutput(filename)+" - "+sizestr+" bytes"; content+="
"; st.Step(); diff --git a/src/http/pages/peerdetailspage.cpp b/src/http/pages/peerdetailspage.cpp index 842df31..afb1c42 100644 --- a/src/http/pages/peerdetailspage.cpp +++ b/src/http/pages/peerdetailspage.cpp @@ -24,6 +24,9 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const std::string hidden=""; int freesiteedition=-1; + std::string fproxyport="8888"; + Option::Instance()->Get("FProxyPort",fproxyport); + if(queryvars.find("identityid")!=queryvars.end() && (*queryvars.find("identityid")).second!="") { identityidstr=(*queryvars.find("identityid")).second; @@ -90,7 +93,7 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const content+="Public Key"+SanitizeOutput(publickey)+""; if(usk!="") { - content+="Freesite"+SanitizeOutput(usk)+""; + content+="Freesite"+SanitizeOutput(usk)+""; } content+="Date Added"+dateadded+""; content+="Last Seen"+lastseen+""; diff --git a/src/message.cpp b/src/message.cpp index 5905021..c0bed87 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -698,8 +698,19 @@ const bool Message::ParseNNTPMessage(const std::string &nntpmessage) // add a binary file attachment else if((*i)->GetName()!="" && (*i)->GetLength()>0 && (*i)->GetContent()) { + std::string contenttype=""; std::vector data((*i)->GetContent(),(*i)->GetContent()+(*i)->GetContentLength()); - m_fileattachments.push_back(fileattachment((*i)->GetName(),data)); + if((*i)->GetContentType()) + { + contenttype=(*i)->GetContentType(); + // find first ; tab cr or lf and erase it and everything after it + std::string::size_type endpos=contenttype.find_first_of(";\t\r\n "); + if(endpos!=std::string::npos) + { + contenttype.erase(endpos); + } + } + m_fileattachments.push_back(fileattachment((*i)->GetName(),contenttype,data)); } } @@ -743,13 +754,14 @@ const bool Message::StartFreenetInsert() st.Step(); // insert file attachments into database - st=m_db->Prepare("INSERT INTO tblFileInserts(MessageUUID,FileName,Size,Data) VALUES(?,?,?,?);"); + st=m_db->Prepare("INSERT INTO tblFileInserts(MessageUUID,FileName,Size,MimeType,Data) VALUES(?,?,?,?,?);"); for(std::vector::iterator i=m_fileattachments.begin(); i!=m_fileattachments.end(); i++) { st.Bind(0,m_messageuuid); st.Bind(1,(*i).m_filename); st.Bind(2,(long)(*i).m_data.size()); - st.Bind(3,&((*i).m_data[0]),(*i).m_data.size()); + st.Bind(3,(*i).m_mimetype); + st.Bind(4,&((*i).m_data[0]),(*i).m_data.size()); st.Step(); st.Reset(); } -- 2.7.4