From ba500284c7f2b980599641f7369d5a0fea7128ea Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 30 Jun 2016 14:16:45 -0400 Subject: [PATCH] added GXS distribution flag to defavor posts signed by key form unknown RS nodes, and updated UI in forums to use it --- libretroshare/src/gxs/rsgenexchange.cc | 11 ++- libretroshare/src/retroshare/rsgxsflags.h | 2 + retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp | 74 ++++++++------ retroshare-gui/src/gui/gxs/GxsGroupDialog.h | 5 +- retroshare-gui/src/gui/gxs/GxsGroupDialog.ui | 98 +++++++------------ .../src/gui/gxsforums/CreateGxsForumMsg.cpp | 2 +- .../gui/gxsforums/GxsForumThreadWidget.cpp | 3 +- 7 files changed, 96 insertions(+), 99 deletions(-) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 615c96e3e..e4c83d5db 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -881,8 +881,15 @@ int RsGenExchange::validateMsg(RsNxsMsg *msg, const uint32_t& grpFlag, const uin { // now check reputation of the message author - float reputation_threshold = ( (signFlag & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) && !(details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED)) ? (RsReputations::REPUTATION_THRESHOLD_ANTI_SPAM): (RsReputations::REPUTATION_THRESHOLD_DEFAULT) ; - + float reputation_threshold = RsReputations::REPUTATION_THRESHOLD_DEFAULT; + + if( (signFlag & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN) && !(details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN)) + reputation_threshold = RsReputations::REPUTATION_THRESHOLD_ANTI_SPAM; + else if( (signFlag & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) && !(details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED)) + reputation_threshold = RsReputations::REPUTATION_THRESHOLD_ANTI_SPAM; + else + reputation_threshold = RsReputations::REPUTATION_THRESHOLD_DEFAULT; + if(details.mReputation.mOverallReputationScore < reputation_threshold) { #ifdef GEN_EXCH_DEBUG diff --git a/libretroshare/src/retroshare/rsgxsflags.h b/libretroshare/src/retroshare/rsgxsflags.h index c9b92c6f1..6233fc1fd 100644 --- a/libretroshare/src/retroshare/rsgxsflags.h +++ b/libretroshare/src/retroshare/rsgxsflags.h @@ -34,6 +34,7 @@ namespace GXS_SERV { static const uint32_t FLAG_AUTHOR_AUTHENTICATION_REQUIRED = 0x00000200; static const uint32_t FLAG_AUTHOR_AUTHENTICATION_IFNOPUBSIGN = 0x00000400; static const uint32_t FLAG_AUTHOR_AUTHENTICATION_TRACK_MESSAGES = 0x00000800; + static const uint32_t FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN = 0x00001000; static const uint32_t FLAG_GROUP_SIGN_PUBLISH_MASK = 0x000000ff; static const uint32_t FLAG_GROUP_SIGN_PUBLISH_ENCRYPTED = 0x00000001; @@ -105,6 +106,7 @@ namespace GXS_SERV { #define IS_MSG_UNPROCESSED(status) (status & GXS_SERV::GXS_MSG_STATUS_UNPROCESSED) #define IS_GROUP_PGP_AUTHED(signFlags) (signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) +#define IS_GROUP_PGP_KNOWN_AUTHED(signFlags) (signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN) #define IS_GROUP_MESSAGE_TRACKING(signFlags) (signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_TRACK_MESSAGES) #define IS_GROUP_ADMIN(subscribeFlags) (subscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp index f519cb4bf..8c451e3da 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp @@ -302,7 +302,13 @@ void GxsGroupDialog::setupDefaults() } } ui.antiSpam_trackMessages->setChecked((bool)(mDefaultsFlags & GXS_GROUP_DEFAULTS_ANTISPAM_TRACK)); - ui.antiSpam_signedIds->setChecked((bool)(mDefaultsFlags & GXS_GROUP_DEFAULTS_ANTISPAM_FAVOR_PGP)); + + if( (mDefaultsFlags & GXS_GROUP_DEFAULTS_ANTISPAM_FAVOR_PGP) && (mDefaultsFlags & GXS_GROUP_DEFAULTS_ANTISPAM_FAVOR_PGP_KNOWN)) + ui.antiSpam_perms_CB->setCurrentIndex(2) ; + else if(mDefaultsFlags & GXS_GROUP_DEFAULTS_ANTISPAM_FAVOR_PGP) + ui.antiSpam_perms_CB->setCurrentIndex(1) ; + else + ui.antiSpam_perms_CB->setCurrentIndex(0) ; QString antispam_string ; if(mDefaultsFlags & GXS_GROUP_DEFAULTS_ANTISPAM_TRACK) antispam_string += tr("Message tracking") ; @@ -613,32 +619,37 @@ void GxsGroupDialog::createGroup() uint32_t GxsGroupDialog::getGroupSignFlags() { - /* grab from the ui options -> */ - uint32_t signFlags = 0; - if (ui.publish_encrypt->isChecked()) { - signFlags |= GXS_SERV::FLAG_GROUP_SIGN_PUBLISH_ENCRYPTED; - } else if (ui.publish_required->isChecked()) { - signFlags |= GXS_SERV::FLAG_GROUP_SIGN_PUBLISH_ALLSIGNED; - } else if (ui.publish_threads->isChecked()) { - signFlags |= GXS_SERV::FLAG_GROUP_SIGN_PUBLISH_THREADHEAD; - } else { // publish_open (default). - signFlags |= GXS_SERV::FLAG_GROUP_SIGN_PUBLISH_NONEREQ; - } + /* grab from the ui options -> */ + uint32_t signFlags = 0; + if (ui.publish_encrypt->isChecked()) { + signFlags |= GXS_SERV::FLAG_GROUP_SIGN_PUBLISH_ENCRYPTED; + } else if (ui.publish_required->isChecked()) { + signFlags |= GXS_SERV::FLAG_GROUP_SIGN_PUBLISH_ALLSIGNED; + } else if (ui.publish_threads->isChecked()) { + signFlags |= GXS_SERV::FLAG_GROUP_SIGN_PUBLISH_THREADHEAD; + } else { // publish_open (default). + signFlags |= GXS_SERV::FLAG_GROUP_SIGN_PUBLISH_NONEREQ; + } - if (ui.personal_required->isChecked()) - signFlags |= GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_REQUIRED; - - if (ui.personal_ifnopub->isChecked()) - signFlags |= GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_IFNOPUBSIGN; - - // Author Signature. - if (ui.antiSpam_signedIds->isChecked()) - signFlags |= GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG; - - if (ui.antiSpam_trackMessages->isChecked()) - signFlags |= GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_TRACK_MESSAGES; - - return signFlags; + if (ui.personal_required->isChecked()) + signFlags |= GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_REQUIRED; + + if (ui.personal_ifnopub->isChecked()) + signFlags |= GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_IFNOPUBSIGN; + + // Author Signature. + switch(ui.antiSpam_perms_CB->currentIndex()) + { + case 0: break ; + case 2: signFlags |= GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN; // no break below, since we want *both* flags in this case. + case 1: signFlags |= GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG; + break ; + } + + if (ui.antiSpam_trackMessages->isChecked()) + signFlags |= GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_TRACK_MESSAGES; + + return signFlags; } void GxsGroupDialog::setGroupSignFlags(uint32_t signFlags) @@ -660,11 +671,18 @@ void GxsGroupDialog::setGroupSignFlags(uint32_t signFlags) ui.personal_ifnopub->setChecked(true); ui.antiSpam_trackMessages ->setChecked((bool)(signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_TRACK_MESSAGES) ); - ui.antiSpam_signedIds ->setChecked((bool)(signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) ); + if( (signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN) && (signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG)) + ui.antiSpam_perms_CB->setCurrentIndex(2) ; + else if(signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) + ui.antiSpam_perms_CB->setCurrentIndex(1) ; + else + ui.antiSpam_perms_CB->setCurrentIndex(0) ; + QString antispam_string ; if(signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_TRACK_MESSAGES) antispam_string += tr("Message tracking") ; - if(signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) antispam_string += (antispam_string.isNull()?"":" and ")+tr("PGP signature required") ; + if(signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN) antispam_string += (antispam_string.isNull()?"":" and ")+tr("PGP signature from known ID required") ; + if(signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) antispam_string += (antispam_string.isNull()?"":" and ")+tr("PGP signature required") ; ui.antiSpamValueLabel->setText(antispam_string) ; //ui.antiSpam_trackMessages_2->setChecked((bool)(signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_TRACK_MESSAGES) ); diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.h b/retroshare-gui/src/gui/gxs/GxsGroupDialog.h index 7f94c32db..b71a39952 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.h @@ -90,8 +90,9 @@ public: #define GXS_GROUP_DEFAULTS_COMMENTS_YES 0x00001000 #define GXS_GROUP_DEFAULTS_COMMENTS_NO 0x00002000 -#define GXS_GROUP_DEFAULTS_ANTISPAM_FAVOR_PGP 0x00100000 -#define GXS_GROUP_DEFAULTS_ANTISPAM_TRACK 0x00200000 +#define GXS_GROUP_DEFAULTS_ANTISPAM_FAVOR_PGP 0x00100000 +#define GXS_GROUP_DEFAULTS_ANTISPAM_TRACK 0x00200000 +#define GXS_GROUP_DEFAULTS_ANTISPAM_FAVOR_PGP_KNOWN 0x00400000 /*! * The aim of this dialog is to be convenient to encapsulate group diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui b/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui index eb5228c81..790897d7c 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui @@ -6,32 +6,23 @@ 0 0 - 828 - 612 + 935 + 785 Create New - - 0 - - - 0 - - - 0 - - - 0 - 6 0 + + 0 + @@ -57,16 +48,7 @@ 0 - - 4 - - - 4 - - - 4 - - + 4 @@ -130,16 +112,7 @@ 9 - - 3 - - - 3 - - - 3 - - + 3 @@ -261,16 +234,7 @@ - - 0 - - - 0 - - - 0 - - + 0 @@ -580,35 +544,39 @@ Spam-protection - - 6 - - - 9 - - - 4 - - - 9 - - - 4 - - - - <html><head/><body><p>This makes the media increase the reputation threshold to 0.4 for anonymous ids, while keeping it to 0.0 for PGP-linked ids. Therefore, anonymous ids can still post, if their local reputation score is above that threshold.</p></body></html> - + - Favor PGP-signed ids + Posts permissions: + + + + <html><head/><body><p>This combo box allows you to choose how posts are handled depending on the node the poster belongs to.</p><p><span style=" font-weight:600;">All allowed</span>: all posts are treated equally.</p><p><span style=" font-weight:600;">Defavor posts from unsigned IDs</span>: anonymous IDs will require a reputation of 0.4 to be received/forwarded.</p><p><span style=" font-weight:600;">Defavor posts from unsigned IDs and IDs from unknown nodes</span>: anonymous IDs and IDs signed by unknown Retroshare nodes will require a reputation of 0.4 to be received/forwarded.</p></body></html> + + + + All allowed + + + + + Defavor unsigned IDs + + + + + Defavor unsigned IDs and IDs from unknown nodes + + + + - <html><head/><body><p align="justify">This feature allows Retroshare to locally keep a record of who forwarded each message to you, for the last 10 days. Although useless if alone (and already available whatsoever) this information can be used by a group of collaborative friends to easily locate the source of spams. To be used with care, since it significantly decreases the anonymity of message posts.</p></body></html> + <html><head/><body><p align="justify">This feature allows Retroshare to locally keep a record of who forwarded each message to you, for the last 10 days. Although useless if alone (and already available whatsoever) this information can be used by a group of teamed-up friends to easily locate a source of spams. To be used with care, since it significantly decreases the anonymity of message posts.</p></body></html> Keep track of posts diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp index 6898ce228..f73aeef91 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp @@ -212,7 +212,7 @@ void CreateGxsForumMsg::loadFormInformation() //std::cerr << "CreateGxsForumMsg::loadMsgInformation() using signFlags=" << std::hex << mForumMeta.mSignFlags << std::dec << std::endl; - if(mForumMeta.mSignFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) + if( (mForumMeta.mSignFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) || (mForumMeta.mSignFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN)) ui.idChooser->setFlags(IDCHOOSER_ID_REQUIRED | IDCHOOSER_NON_ANONYMOUS) ; else ui.idChooser->setFlags(IDCHOOSER_ID_REQUIRED) ; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 82ed1e6dd..84dda7516 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -791,7 +791,8 @@ void GxsForumThreadWidget::insertGroupData() tw->ui->forumName->setText(QString::fromUtf8(group.mMeta.mGroupName.c_str())); QString anti_spam_features1 ; - if(IS_GROUP_PGP_AUTHED(tw->mSignFlags)) anti_spam_features1 = tr("Anonymous IDs reputation threshold set to 0.4"); + if(IS_GROUP_PGP_KNOWN_AUTHED(tw->mSignFlags)) anti_spam_features1 = tr("Anonymous/unknown node IDs reputation threshold set to 0.4"); + else if(IS_GROUP_PGP_AUTHED(tw->mSignFlags)) anti_spam_features1 = tr("Anonymous IDs reputation threshold set to 0.4"); QString anti_spam_features2 ; if(IS_GROUP_MESSAGE_TRACKING(tw->mSignFlags)) anti_spam_features2 = tr("Message routing info kept for 10 days");