diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index d7d973a10..b69218478 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -1281,7 +1281,7 @@ bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, cons { std::cerr << " Peer " << from << " reports a connexion address (" << sockaddr_storage_iptostring(addr_filtered) <<") that is not your current external address (" << sockaddr_storage_iptostring(own_addr) << "). This is weird." << std::endl; - RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_WRONG_EXTERNAL_IP_REPORTED, from.toStdString(), sockaddr_storage_iptostring(own_addr), sockaddr_storage_iptostring(addr)); + RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, from.toStdString(), sockaddr_storage_iptostring(own_addr), sockaddr_storage_iptostring(addr)); } return true ; diff --git a/libretroshare/src/retroshare/rsnotify.h b/libretroshare/src/retroshare/rsnotify.h index 65c16fdc1..23b311437 100644 --- a/libretroshare/src/retroshare/rsnotify.h +++ b/libretroshare/src/retroshare/rsnotify.h @@ -76,6 +76,7 @@ const uint32_t RS_FEED_TYPE_MSG = 0x0200; const uint32_t RS_FEED_TYPE_FILES = 0x0400; const uint32_t RS_FEED_TYPE_SECURITY = 0x0800; const uint32_t RS_FEED_TYPE_POSTED = 0x1000; +const uint32_t RS_FEED_TYPE_SECURITY_IP = 0x2000; const uint32_t RS_FEED_ITEM_PEER_CONNECT = RS_FEED_TYPE_PEER | 0x0001; const uint32_t RS_FEED_ITEM_PEER_DISCONNECT = RS_FEED_TYPE_PEER | 0x0002; @@ -90,8 +91,9 @@ const uint32_t RS_FEED_ITEM_SEC_WRONG_SIGNATURE = RS_FEED_TYPE_SECURITY | 0 const uint32_t RS_FEED_ITEM_SEC_BAD_CERTIFICATE = RS_FEED_TYPE_SECURITY | 0x0006; const uint32_t RS_FEED_ITEM_SEC_INTERNAL_ERROR = RS_FEED_TYPE_SECURITY | 0x0007; const uint32_t RS_FEED_ITEM_SEC_MISSING_CERTIFICATE = RS_FEED_TYPE_SECURITY | 0x0008; -const uint32_t RS_FEED_ITEM_SEC_IP_BLACKLISTED = RS_FEED_TYPE_SECURITY | 0x0010; -const uint32_t RS_FEED_ITEM_SEC_WRONG_EXTERNAL_IP_REPORTED = RS_FEED_TYPE_SECURITY | 0x0020; + +const uint32_t RS_FEED_ITEM_SEC_IP_BLACKLISTED = RS_FEED_TYPE_SECURITY_IP | 0x0001; +const uint32_t RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED = RS_FEED_TYPE_SECURITY_IP | 0x0002; const uint32_t RS_FEED_ITEM_CHANNEL_NEW = RS_FEED_TYPE_CHANNEL | 0x0001; //const uint32_t RS_FEED_ITEM_CHANNEL_UPDATE = RS_FEED_TYPE_CHANNEL | 0x0002; diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index ae654c7d2..6931173a3 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -249,12 +249,12 @@ void NewsFeed::updateDisplay() break; case RS_FEED_ITEM_SEC_IP_BLACKLISTED: - if (flags & RS_FEED_TYPE_SECURITY) + if (flags & RS_FEED_TYPE_SECURITY_IP) addFeedItemSecurityIpBlacklisted(fi, false); break; - case RS_FEED_ITEM_SEC_WRONG_EXTERNAL_IP_REPORTED: - if (flags & RS_FEED_TYPE_SECURITY) + case RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED: + if (flags & RS_FEED_TYPE_SECURITY_IP) addFeedItemSecurityWrongExternalIpReported(fi, false); break; @@ -423,6 +423,9 @@ void NewsFeed::testFeeds(uint notifyFlags) instance->addFeedItemSecurityUnknownIn(fi); instance->addFeedItemSecurityUnknownOut(fi); + break; + + case RS_FEED_TYPE_SECURITY_IP: fi.mId1 = rsPeers->getOwnId().toStdString(); fi.mId2 = "0.0.0.0"; fi.mResult1 = RSBANLIST_CHECK_RESULT_BLACKLISTED; @@ -433,6 +436,7 @@ void NewsFeed::testFeeds(uint notifyFlags) fi.mId3 = "0.0.0.2"; fi.mResult1 = 0; instance->addFeedItemSecurityWrongExternalIpReported(fi, true); + break; case RS_FEED_TYPE_CHANNEL: @@ -895,7 +899,8 @@ void NewsFeed::addFeedItem(FeedItem *item) struct AddFeedItemIfUniqueData { - AddFeedItemIfUniqueData(FeedItem *feedItem, int type, const RsPeerId &sslId) : mType(type), mSslId(sslId) + AddFeedItemIfUniqueData(FeedItem *feedItem, int type, const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported) + : mType(type), mSslId(sslId), mIpAddr(ipAddr), mIpAddrReported(ipAddrReported) { mSecItem = dynamic_cast(feedItem); mSecurityIpItem = dynamic_cast(feedItem); @@ -903,6 +908,8 @@ struct AddFeedItemIfUniqueData int mType; const RsPeerId &mSslId; + const std::string& mIpAddr; + const std::string& mIpAddrReported; SecurityItem *mSecItem; SecurityIpItem *mSecurityIpItem; }; @@ -924,7 +931,7 @@ static bool addFeedItemIfUniqueCallback(FeedItem *feedItem, void *data) if (findData->mSecurityIpItem) { SecurityIpItem *securityIpItem = dynamic_cast(feedItem); - if (securityIpItem && securityIpItem->isSame(findData->mSslId, findData->mType)) { + if (securityIpItem && securityIpItem->isSame(findData->mIpAddr, findData->mIpAddrReported, findData->mType)) { return true; } return false; @@ -933,9 +940,9 @@ static bool addFeedItemIfUniqueCallback(FeedItem *feedItem, void *data) return false; } -void NewsFeed::addFeedItemIfUnique(FeedItem *item, int itemType, const RsPeerId &sslId, bool replace) +void NewsFeed::addFeedItemIfUnique(FeedItem *item, int itemType, const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, bool replace) { - AddFeedItemIfUniqueData data(item, itemType, sslId); + AddFeedItemIfUniqueData data(item, itemType, sslId, ipAddr, ipAddrReported); FeedItem *feedItem = ui->feedWidget->findFeedItem(addFeedItemIfUniqueCallback, &data); if (feedItem) { @@ -1012,7 +1019,7 @@ void NewsFeed::addFeedItemSecurityConnectAttempt(const RsFeedItem &fi) SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, fi.mType, false); /* add to layout */ - addFeedItemIfUnique(pi, fi.mType, RsPeerId(fi.mId2), false); + addFeedItemIfUnique(pi, fi.mType, RsPeerId(fi.mId2), "", "", false); #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemSecurityConnectAttempt()"; @@ -1026,7 +1033,7 @@ void NewsFeed::addFeedItemSecurityAuthDenied(const RsFeedItem &fi) SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, fi.mType, false); /* add to layout */ - addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_AUTH_DENIED, RsPeerId(fi.mId2), false); + addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_AUTH_DENIED, RsPeerId(fi.mId2), "", "", false); #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemSecurityAuthDenied()"; @@ -1040,7 +1047,7 @@ void NewsFeed::addFeedItemSecurityUnknownIn(const RsFeedItem &fi) SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, RS_FEED_ITEM_SEC_UNKNOWN_IN, false); /* add to layout */ - addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_UNKNOWN_IN, RsPeerId(fi.mId2), false); + addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_UNKNOWN_IN, RsPeerId(fi.mId2), "", "", false); #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemSecurityUnknownIn()"; @@ -1054,7 +1061,7 @@ void NewsFeed::addFeedItemSecurityUnknownOut(const RsFeedItem &fi) SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, RS_FEED_ITEM_SEC_UNKNOWN_OUT, false); /* add to layout */ - addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_UNKNOWN_OUT, RsPeerId(fi.mId2), false); + addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_UNKNOWN_OUT, RsPeerId(fi.mId2), "", "", false); #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemSecurityUnknownOut()"; @@ -1068,7 +1075,7 @@ void NewsFeed::addFeedItemSecurityIpBlacklisted(const RsFeedItem &fi, bool isTes SecurityIpItem *pi = new SecurityIpItem(this, RsPeerId(fi.mId1), fi.mId2, fi.mResult1, RS_FEED_ITEM_SEC_IP_BLACKLISTED, isTest); /* add to layout */ - addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_IP_BLACKLISTED, RsPeerId(fi.mId1), false); + addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_IP_BLACKLISTED, RsPeerId(fi.mId1), fi.mId2, "", false); #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemSecurityIpBlacklisted()"; @@ -1079,10 +1086,10 @@ void NewsFeed::addFeedItemSecurityIpBlacklisted(const RsFeedItem &fi, bool isTes void NewsFeed::addFeedItemSecurityWrongExternalIpReported(const RsFeedItem &fi, bool isTest) { /* make new widget */ - SecurityIpItem *pi = new SecurityIpItem(this, RsPeerId(fi.mId1), fi.mId2, fi.mId3, RS_FEED_ITEM_SEC_WRONG_EXTERNAL_IP_REPORTED, isTest); + SecurityIpItem *pi = new SecurityIpItem(this, RsPeerId(fi.mId1), fi.mId2, fi.mId3, RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, isTest); /* add to layout */ - addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_WRONG_EXTERNAL_IP_REPORTED, RsPeerId(fi.mId1), false); + addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, RsPeerId(fi.mId1), fi.mId2, fi.mId3, false); #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemSecurityWrongExternalIpReported()"; diff --git a/retroshare-gui/src/gui/NewsFeed.h b/retroshare-gui/src/gui/NewsFeed.h index eb5966909..8a2ca60aa 100644 --- a/retroshare-gui/src/gui/NewsFeed.h +++ b/retroshare-gui/src/gui/NewsFeed.h @@ -83,7 +83,7 @@ private slots: private: void addFeedItem(FeedItem *item); - void addFeedItemIfUnique(FeedItem *item, int itemType, const RsPeerId &sslId, bool replace); + void addFeedItemIfUnique(FeedItem *item, int itemType, const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, bool replace); void addFeedItemPeerConnect(const RsFeedItem &fi); void addFeedItemPeerDisconnect(const RsFeedItem &fi); diff --git a/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp b/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp index bc825286d..502bdb569 100644 --- a/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp @@ -79,9 +79,9 @@ void SecurityIpItem::setup() updateItem(); } -bool SecurityIpItem::isSame(const RsPeerId &sslId, uint32_t type) +bool SecurityIpItem::isSame(const std::string& ipAddr, const std::string& ipAddrReported, uint32_t type) { - if (mSslId == sslId && mType == type) { + if (mType == type && mIpAddr == ipAddr && mIpAddrReported == ipAddrReported) { return true; } @@ -106,7 +106,7 @@ void SecurityIpItem::updateItemStatic() ui->ipAddrReported->hide(); ui->ipAddrReportedLabel->hide(); break; - case RS_FEED_ITEM_SEC_WRONG_EXTERNAL_IP_REPORTED: + case RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED: ui->rsBanListButton->hide(); break; default: @@ -149,7 +149,7 @@ void SecurityIpItem::updateItem() } } break; - case RS_FEED_ITEM_SEC_WRONG_EXTERNAL_IP_REPORTED: + case RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED: ui->titleLabel->setText(tr("Wrong external ip address reported")); ui->ipAddr->setText(QString::fromStdString(mIpAddr)); ui->ipAddr->setToolTip(tr("

This is the external IP your Retroshare node thinks it is using.

")) ; diff --git a/retroshare-gui/src/gui/feeds/SecurityIpItem.h b/retroshare-gui/src/gui/feeds/SecurityIpItem.h index 9c834ca55..11ef5152f 100644 --- a/retroshare-gui/src/gui/feeds/SecurityIpItem.h +++ b/retroshare-gui/src/gui/feeds/SecurityIpItem.h @@ -44,7 +44,7 @@ public: void updateItemStatic(); - bool isSame(const RsPeerId &sslId, uint32_t type); + bool isSame(const std::string& ipAddr, const std::string& ipAddrReported, uint32_t type); /* FeedItem */ virtual void expand(bool open); diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp index 404f25db4..502cbef5c 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.cpp +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -165,6 +165,8 @@ uint NotifyPage::getNewsFlags() newsFlags |= RS_FEED_TYPE_CHAT; if (ui.notify_Security->isChecked()) newsFlags |= RS_FEED_TYPE_SECURITY; + if (ui.notify_SecurityIp->isChecked()) + newsFlags |= RS_FEED_TYPE_SECURITY_IP; return newsFlags; } @@ -287,6 +289,7 @@ void NotifyPage::load() ui.notify_Messages->setChecked(newsflags & RS_FEED_TYPE_MSG); ui.notify_Chat->setChecked(newsflags & RS_FEED_TYPE_CHAT); ui.notify_Security->setChecked(newsflags & RS_FEED_TYPE_SECURITY); + ui.notify_SecurityIp->setChecked(newsflags & RS_FEED_TYPE_SECURITY_IP); ui.message_ConnectAttempt->setChecked(messageflags & RS_MESSAGE_CONNECT_ATTEMPT); diff --git a/retroshare-gui/src/gui/settings/NotifyPage.ui b/retroshare-gui/src/gui/settings/NotifyPage.ui index 9c42131d0..da63ce6d2 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.ui +++ b/retroshare-gui/src/gui/settings/NotifyPage.ui @@ -14,7 +14,7 @@ - 1 + 0 @@ -91,6 +91,13 @@ + + + + Security Ip + + + @@ -468,6 +475,38 @@ + + tabWidget + notify_Peers + notify_Channels + notify_Forums + notify_Posted + notify_Blogs + notify_Messages + notify_Chat + notify_Security + notify_SecurityIp + message_ConnectAttempt + testFeedButton + popup_Connect + popup_NewMsg + popup_DownloadFinished + popup_PrivateChat + popup_GroupChat + popup_ChatLobby + popup_ConnectAttempt + testToasterButton + comboBoxToasterPosition + spinBoxToasterXMargin + spinBoxToasterYMargin + systray_GroupChat + systray_ChatLobby + chatLobbies_CountUnRead + chatLobbies_CheckNickName + chatLobbies_CountFollowingText + chatLobbies_TextToNotify + pushButtonDisableAll +