X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fglobal.cpp;h=251ea2abbb4e48a0887ad18f2245bcd99679d623;hb=a007770a843aa759763b98288c9432c3906ce5c6;hp=2dbfcdf9a3148f26a3e8a56e13c6fe4ef03e4160;hpb=3dc3ac3cfe10b7196a7977e9c041c29fa141c35e;p=fms.git diff --git a/src/global.cpp b/src/global.cpp index 2dbfcdf..251ea2a 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -28,9 +28,6 @@ void SetupDB() db->Open("fms.db3"); db->SetBusyTimeout(10000); // set timeout to 10 seconds db->Execute("VACUUM;"); - - // TODO remove this - temp fix for problem in 0.1.8 - db->Execute("DELETE FROM tblMessageBoard WHERE MessageID NOT IN (SELECT MessageID FROM tblMessage);"); db->Execute("CREATE TABLE IF NOT EXISTS tblDBVersion(\ Major INTEGER,\ @@ -64,10 +61,16 @@ void SetupDB() major=1; minor=4; } + if(major==1 && minor==4) + { + ConvertDB0104To0105(); + major=1; + minor=5; + } } else { - db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,4);"); + db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,5);"); } db->Execute("UPDATE tblDBVersion SET Major=1, Minor=4;"); @@ -131,18 +134,21 @@ void SetupDB() );"); db->Execute("CREATE TABLE IF NOT EXISTS tblIdentity(\ - IdentityID INTEGER PRIMARY KEY,\ - PublicKey TEXT UNIQUE,\ - Name TEXT,\ - SingleUse BOOL CHECK(SingleUse IN('true','false')) DEFAULT 'false',\ - PublishTrustList BOOL CHECK(PublishTrustList IN('true','false')) DEFAULT 'false',\ - PublishBoardList BOOL CHECK(PublishBoardList IN('true','false')) DEFAULT 'false',\ - DateAdded DATETIME,\ - LastSeen DATETIME,\ - LocalMessageTrust INTEGER CHECK(LocalMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\ - PeerMessageTrust INTEGER CHECK(PeerMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\ - LocalTrustListTrust INTEGER CHECK(LocalTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL,\ - PeerTrustListTrust INTEGER CHECK(PeerTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL\ + IdentityID INTEGER PRIMARY KEY,\ + PublicKey TEXT UNIQUE,\ + Name TEXT,\ + SingleUse BOOL CHECK(SingleUse IN('true','false')) DEFAULT 'false',\ + PublishTrustList BOOL CHECK(PublishTrustList IN('true','false')) DEFAULT 'false',\ + PublishBoardList BOOL CHECK(PublishBoardList IN('true','false')) DEFAULT 'false',\ + DateAdded DATETIME,\ + LastSeen DATETIME,\ + LocalMessageTrust INTEGER CHECK(LocalMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\ + PeerMessageTrust INTEGER CHECK(PeerMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\ + LocalTrustListTrust INTEGER CHECK(LocalTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL,\ + PeerTrustListTrust INTEGER CHECK(PeerTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL,\ + AddedMethod TEXT,\ + MessageTrustComment TEXT,\ + TrustListTrustComment TEXT\ );"); db->Execute("CREATE TABLE IF NOT EXISTS tblIdentityRequests(\ @@ -172,10 +178,12 @@ void SetupDB() );"); db->Execute("CREATE TABLE IF NOT EXISTS tblPeerTrust(\ - IdentityID INTEGER,\ - TargetIdentityID INTEGER,\ - MessageTrust INTEGER CHECK(MessageTrust BETWEEN 0 AND 100),\ - TrustListTrust INTEGER CHECK(TrustListTrust BETWEEN 0 AND 100)\ + IdentityID INTEGER,\ + TargetIdentityID INTEGER,\ + MessageTrust INTEGER CHECK(MessageTrust BETWEEN 0 AND 100),\ + TrustListTrust INTEGER CHECK(TrustListTrust BETWEEN 0 AND 100),\ + MessageTrustComment TEXT,\ + TrustListTrustComment TEXT\ );"); db->Execute("CREATE TABLE IF NOT EXISTS tblBoard(\ @@ -463,6 +471,19 @@ void ConvertDB0103To0104() db->Execute("UPDATE tblDBVersion SET Major=1, Minor=4;"); } +void ConvertDB0104To0105() +{ + // add AddedMethod, MessageTrustComment, TrustListTrustComment to tblIdentity + // add MessageTrustComment,TrustListTrustComment to tblPeerTrust + SQLite3DB::DB *db=SQLite3DB::DB::Instance(); + db->Execute("ALTER TABLE tblIdentity ADD COLUMN AddedMethod TEXT;"); + db->Execute("ALTER TABLE tblIdentity ADD COLUMN MessageTrustComment TEXT;"); + db->Execute("ALTER TABLE tblIdentity ADD COLUMN TrustListTrustComment TEXT;"); + db->Execute("ALTER TABLE tblPeerTrust ADD COLUMN MessageTrustComment TEXT;"); + db->Execute("ALTER TABLE tblPeerTrust ADD COLUMN TrustListTrustComment TEXT;"); + db->Execute("UPDATE tblDBVersion SET Major=1, Minor=5;"); +} + 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 @@ -519,6 +540,12 @@ void SetupDefaultOptions() st.Step(); st.Reset(); + 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.Step(); + st.Reset(); + // StartFreenetUpdater st.Bind(0,"StartFreenetUpdater"); st.Bind(1,"true"); @@ -714,72 +741,6 @@ void SigHandler(int signum) exit(0); } -/* -void ShutdownThreads(std::vector &threads) -{ - std::vector::iterator i; - for(i=threads.begin(); i!=threads.end(); i++) - { - (*i)->Cancel(); - } - - for(i=threads.begin(); i!=threads.end(); i++) - { - LogFile::Instance()->WriteLog(LogFile::LOGLEVEL_DEBUG,"ShutdownThreads waiting for thread to exit."); - //(*i)->wait(); - (*i)->Join(); - delete (*i); - } - - threads.clear(); - -} - -void StartThreads(std::vector &threads) -{ - std::string startfreenet; - std::string startnntp; - std::string starthttp; - - if(Option::Instance()->Get("StartFreenetUpdater",startfreenet)==false) - { - startfreenet="true"; - Option::Instance()->Set("StartFreenetUpdater","true"); - } - - if(Option::Instance()->Get("StartNNTP",startnntp)==false) - { - startnntp="true"; - Option::Instance()->Set("StartNNTP","true"); - } - - if(Option::Instance()->Get("StartHTTP",starthttp)==false) - { - starthttp="true"; - Option::Instance()->Set("StartHTTP","true"); - } - - if(startfreenet=="true") - { - PThread::Thread *t=new PThread::Thread(new FreenetMasterThread()); - threads.push_back(t); - } - - if(startnntp=="true") - { - PThread::Thread *t=new PThread::Thread(new NNTPListener()); - threads.push_back(t); - } - - if(starthttp=="true") - { - PThread::Thread *t=new PThread::Thread(new HTTPThread()); - threads.push_back(t); - } - -} -*/ - void FixCapitalBoardNames() { SQLite3DB::DB *db=SQLite3DB::DB::Instance();