diff --git a/libretroshare/src/retroshare/rsreputations.h b/libretroshare/src/retroshare/rsreputations.h index 8db42ee57..6445efd09 100644 --- a/libretroshare/src/retroshare/rsreputations.h +++ b/libretroshare/src/retroshare/rsreputations.h @@ -51,6 +51,8 @@ public: virtual bool setOwnOpinion(const RsGxsId& key_id, const Opinion& op) =0; virtual bool getReputationInfo(const RsGxsId& id,ReputationInfo& info) =0 ; + virtual void setNodeAutoBanThreshold(uint32_t n) =0; + virtual uint32_t nodeAutoBanThreshold() =0; // This one is a proxy designed to allow fast checking of a GXS id. // it basically returns true if assessment is not ASSESSMENT_OK diff --git a/libretroshare/src/services/p3gxsreputation.cc b/libretroshare/src/services/p3gxsreputation.cc index 2c2a77867..f4c334a02 100644 --- a/libretroshare/src/services/p3gxsreputation.cc +++ b/libretroshare/src/services/p3gxsreputation.cc @@ -39,7 +39,6 @@ /**** * #define DEBUG_REPUTATION 1 ****/ -#define DEBUG_REPUTATION 1 /************ IMPLEMENTATION NOTES ********************************* * @@ -187,7 +186,6 @@ int p3GxsReputation::tick() } static time_t last_identity_flags_update = 0 ; - static time_t last_banned_nodes_update = 0 ; // no more than once per 5 second chunk. @@ -201,6 +199,7 @@ int p3GxsReputation::tick() { mLastBannedNodesUpdate = now ; + updateIdentityFlags() ; // needed before updateBannedNodesList! updateBannedNodesList(); } @@ -248,9 +247,9 @@ class ZeroInitCnt void p3GxsReputation::updateBannedNodesList() { -#ifdef DEBUG_REPUTATION +//#ifdef DEBUG_REPUTATION std::cerr << "Updating PGP ban list based on signed GxsIds to ban" << std::endl; -#endif +//#endif std::map tmpreps ; RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/ @@ -267,9 +266,9 @@ void p3GxsReputation::updateBannedNodesList() if(mPgpAutoBanThreshold > 0) for(std::map::const_iterator it(pgp_ids_to_ban.begin());it!=pgp_ids_to_ban.end();++it) { -#ifdef DEBUG_REPUTATION +//#ifdef DEBUG_REPUTATION std::cerr << "PGP Id: " << it->first << ". Ban count=" << it->second << " - " << (( it->second >= mPgpAutoBanThreshold)?"Banned!":"OK" ) << std::endl; -#endif +//#endif if(it->second >= mPgpAutoBanThreshold) mBannedPgpIds.insert(it->first) ; } @@ -688,7 +687,9 @@ bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, RsReputations::Rep if( (rep.mIdentityFlags & REPUTATION_IDENTITY_FLAG_PGP_LINKED) && (mBannedPgpIds.find(rep.mOwnerNode) != mBannedPgpIds.end())) { info.mAssessment = RsReputations::ASSESSMENT_BAD ; +#ifdef DEBUG_REPUTATION std::cerr << "p3GxsReputations: identity " << gxsid << " is banned because owner node ID " << rep.mOwnerNode << " is banned." << std::endl; +#endif return true; } @@ -1019,9 +1020,9 @@ void p3GxsReputation::sendReputationRequests() int p3GxsReputation::sendReputationRequest(RsPeerId peerid) { #ifdef DEBUG_REPUTATION + time_t now = time(NULL) ; std::cerr << " p3GxsReputation::sendReputationRequest(" << peerid << ") " ; #endif - time_t now = time(NULL) ; /* */ RsGxsReputationRequestItem *requestItem = new RsGxsReputationRequestItem(); diff --git a/retroshare-gui/src/gui/settings/PeoplePage.cpp b/retroshare-gui/src/gui/settings/PeoplePage.cpp new file mode 100644 index 000000000..f2df90bf3 --- /dev/null +++ b/retroshare-gui/src/gui/settings/PeoplePage.cpp @@ -0,0 +1,55 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006, crypton + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#include "PeoplePage.h" +#include "rsharesettings.h" +#include "retroshare/rsreputations.h" + +PeoplePage::PeoplePage(QWidget * parent, Qt::WindowFlags flags) + : ConfigPage(parent, flags) +{ + ui.setupUi(this); + setAttribute(Qt::WA_QuitOnClose, false); +} + +PeoplePage::~PeoplePage() +{ +} + +/** Saves the changes on this page */ +bool PeoplePage::save(QString &/*errmsg*/) +{ + if(!ui.identityBan_CB->isChecked()) + rsReputations->setNodeAutoBanThreshold(0) ; + else + rsReputations->setNodeAutoBanThreshold(ui.identityBanThreshold_SB->value()) ; + + return true; +} + +/** Loads the settings for this page */ +void PeoplePage::load() +{ + uint32_t ban_limit = rsReputations->nodeAutoBanThreshold() ; + + ui.identityBan_CB->setChecked(ban_limit > 0) ; + ui.identityBanThreshold_SB->setValue(ban_limit) ; +} diff --git a/retroshare-gui/src/gui/settings/PeoplePage.h b/retroshare-gui/src/gui/settings/PeoplePage.h new file mode 100644 index 000000000..94a576198 --- /dev/null +++ b/retroshare-gui/src/gui/settings/PeoplePage.h @@ -0,0 +1,50 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006, crypton + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#ifndef PEOPLEPAGE_H +#define PEOPLEPAGE_H + +#include +#include "ui_PeoplePage.h" + +class PeoplePage : public ConfigPage +{ + Q_OBJECT + +public: + PeoplePage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + ~PeoplePage(); + + /** Saves the changes on this page */ + virtual bool save(QString &errmsg); + /** Loads the settings for this page */ + virtual void load(); + + virtual QPixmap iconPixmap() const { return QPixmap(":/icons/friends_128.png") ; } + virtual QString pageName() const { return tr("People") ; } + virtual QString helpText() const { return ""; } + +private: + Ui::PeoplePage ui; +}; + +#endif + diff --git a/retroshare-gui/src/gui/settings/PeoplePage.ui b/retroshare-gui/src/gui/settings/PeoplePage.ui new file mode 100644 index 000000000..60a4a4121 --- /dev/null +++ b/retroshare-gui/src/gui/settings/PeoplePage.ui @@ -0,0 +1,84 @@ + + + PeoplePage + + + + 0 + 0 + 1153 + 441 + + + + + + + Identities handling + + + + + + + + ban all identities of a node when more than + + + true + + + + + + + 10 + + + 2 + + + + + + + of them have a negative opinion + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index 741cd5ad7..8a57e148d 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -36,6 +36,7 @@ #include "RelayPage.h" #include "ChatPage.h" #include "ChannelPage.h" +#include "PeoplePage.h" #include "MessagePage.h" #include "ForumPage.h" #include "PostedPage.h" @@ -142,6 +143,7 @@ RSettingsWin::initStackedWidget() addPage(new PluginsPage() ); addPage(new NotifyPage()); addPage(new CryptoPage()); + addPage(new PeoplePage()); addPage(new ChatPage()); addPage(new MessagePage()); addPage(new ChannelPage()); diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 4386b9fd7..7d436eea4 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -419,6 +419,7 @@ HEADERS += rshare.h \ gui/settings/rsettings.h \ gui/settings/rsettingswin.h \ gui/settings/GeneralPage.h \ + gui/settings/PeoplePage.h \ gui/settings/DirectoriesPage.h \ gui/settings/ServerPage.h \ gui/settings/NetworkPage.h \ @@ -602,6 +603,7 @@ FORMS += gui/StartDialog.ui \ gui/settings/ServerPage.ui \ gui/settings/NetworkPage.ui \ gui/settings/NotifyPage.ui \ + gui/settings/PeoplePage.ui \ gui/settings/CryptoPage.ui \ gui/settings/MessagePage.ui \ gui/settings/NewTag.ui \ @@ -822,6 +824,7 @@ SOURCES += main.cpp \ gui/settings/NetworkPage.cpp \ gui/settings/NotifyPage.cpp \ gui/settings/CryptoPage.cpp \ + gui/settings/PeoplePage.cpp \ gui/settings/MessagePage.cpp \ gui/settings/NewTag.cpp \ gui/settings/ForumPage.cpp \