Added new feed item when a wrong external ip address is reported.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8350 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2015-06-03 12:38:23 +00:00
parent e8c60816cf
commit 22a7d2eeeb
8 changed files with 150 additions and 55 deletions

View File

@ -1239,6 +1239,7 @@ bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, cons
{ {
std::cerr << "(WW) peer reports an address that is not our current external address. This is weird." << std::endl; std::cerr << "(WW) peer reports an address that is not our current external address. 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));
//mLinkMgr->disconnectFriend(from) ; //mLinkMgr->disconnectFriend(from) ;
} }
return true ; return true ;

View File

@ -91,6 +91,7 @@ const uint32_t RS_FEED_ITEM_SEC_BAD_CERTIFICATE = RS_FEED_TYPE_SECURITY | 0
const uint32_t RS_FEED_ITEM_SEC_INTERNAL_ERROR = RS_FEED_TYPE_SECURITY | 0x0007; 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_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_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_CHANNEL_NEW = RS_FEED_TYPE_CHANNEL | 0x0001; 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; //const uint32_t RS_FEED_ITEM_CHANNEL_UPDATE = RS_FEED_TYPE_CHANNEL | 0x0002;

View File

@ -253,6 +253,11 @@ void NewsFeed::updateDisplay()
addFeedItemSecurityIpBlacklisted(fi, false); addFeedItemSecurityIpBlacklisted(fi, false);
break; break;
case RS_FEED_ITEM_SEC_WRONG_EXTERNAL_IP_REPORTED:
if (flags & RS_FEED_TYPE_SECURITY)
addFeedItemSecurityWrongExternalIpReported(fi, false);
break;
case RS_FEED_ITEM_CHANNEL_NEW: case RS_FEED_ITEM_CHANNEL_NEW:
if (flags & RS_FEED_TYPE_CHANNEL) if (flags & RS_FEED_TYPE_CHANNEL)
addFeedItemChannelNew(fi); addFeedItemChannelNew(fi);
@ -422,6 +427,12 @@ void NewsFeed::testFeeds(uint notifyFlags)
fi.mId2 = "0.0.0.0"; fi.mId2 = "0.0.0.0";
fi.mResult1 = RSBANLIST_CHECK_RESULT_BLACKLISTED; fi.mResult1 = RSBANLIST_CHECK_RESULT_BLACKLISTED;
instance->addFeedItemSecurityIpBlacklisted(fi, true); instance->addFeedItemSecurityIpBlacklisted(fi, true);
//fi.mId1 = rsPeers->getOwnId().toStdString();
fi.mId2 = "0.0.0.1";
fi.mId3 = "0.0.0.2";
fi.mResult1 = 0;
instance->addFeedItemSecurityWrongExternalIpReported(fi, true);
break; break;
case RS_FEED_TYPE_CHANNEL: case RS_FEED_TYPE_CHANNEL:
@ -913,7 +924,7 @@ static bool addFeedItemIfUniqueCallback(FeedItem *feedItem, void *data)
if (findData->mSecurityIpItem) { if (findData->mSecurityIpItem) {
SecurityIpItem *securityIpItem = dynamic_cast<SecurityIpItem*>(feedItem); SecurityIpItem *securityIpItem = dynamic_cast<SecurityIpItem*>(feedItem);
if (securityIpItem && securityIpItem->isSame(findData->mSslId)) { if (securityIpItem && securityIpItem->isSame(findData->mSslId, findData->mType)) {
return true; return true;
} }
return false; return false;
@ -1054,10 +1065,10 @@ void NewsFeed::addFeedItemSecurityUnknownOut(const RsFeedItem &fi)
void NewsFeed::addFeedItemSecurityIpBlacklisted(const RsFeedItem &fi, bool isTest) void NewsFeed::addFeedItemSecurityIpBlacklisted(const RsFeedItem &fi, bool isTest)
{ {
/* make new widget */ /* make new widget */
SecurityIpItem *pi = new SecurityIpItem(this, RsPeerId(fi.mId1), fi.mId2, fi.mResult1, isTest); SecurityIpItem *pi = new SecurityIpItem(this, RsPeerId(fi.mId1), fi.mId2, fi.mResult1, RS_FEED_ITEM_SEC_IP_BLACKLISTED, isTest);
/* add to layout */ /* add to layout */
addFeedItemIfUnique(pi, 0, RsPeerId(fi.mId1), false); addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_IP_BLACKLISTED, RsPeerId(fi.mId1), false);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemSecurityIpBlacklisted()"; std::cerr << "NewsFeed::addFeedItemSecurityIpBlacklisted()";
@ -1065,6 +1076,20 @@ void NewsFeed::addFeedItemSecurityIpBlacklisted(const RsFeedItem &fi, bool isTes
#endif #endif
} }
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);
/* add to layout */
addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_WRONG_EXTERNAL_IP_REPORTED, RsPeerId(fi.mId1), false);
#ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemSecurityWrongExternalIpReported()";
std::cerr << std::endl;
#endif
}
void NewsFeed::addFeedItemChannelNew(const RsFeedItem &fi) void NewsFeed::addFeedItemChannelNew(const RsFeedItem &fi)
{ {
RsGxsGroupId grpId(fi.mId1); RsGxsGroupId grpId(fi.mId1);

View File

@ -95,6 +95,7 @@ private:
void addFeedItemSecurityUnknownIn(const RsFeedItem &fi); void addFeedItemSecurityUnknownIn(const RsFeedItem &fi);
void addFeedItemSecurityUnknownOut(const RsFeedItem &fi); void addFeedItemSecurityUnknownOut(const RsFeedItem &fi);
void addFeedItemSecurityIpBlacklisted(const RsFeedItem &fi, bool isTest); void addFeedItemSecurityIpBlacklisted(const RsFeedItem &fi, bool isTest);
void addFeedItemSecurityWrongExternalIpReported(const RsFeedItem &fi, bool isTest);
void addFeedItemChannelNew(const RsFeedItem &fi); void addFeedItemChannelNew(const RsFeedItem &fi);
// void addFeedItemChannelUpdate(const RsFeedItem &fi); // void addFeedItemChannelUpdate(const RsFeedItem &fi);

View File

@ -33,15 +33,28 @@
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
#include <retroshare/rsbanlist.h> #include <retroshare/rsbanlist.h>
#include <retroshare/rsnotify.h>
/***** /*****
* #define DEBUG_ITEM 1 * #define DEBUG_ITEM 1
****/ ****/
/** Constructor */ /** Constructor */
SecurityIpItem::SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string &ipAddr, uint32_t result, bool isTest) : SecurityIpItem::SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string &ipAddr, uint32_t result, uint32_t type, bool isTest) :
FeedItem(NULL), mParent(parent), mSslId(sslId), mIPAddr(ipAddr), mResult(result), mIsTest(isTest), FeedItem(NULL), mParent(parent), mType(type), mSslId(sslId), mIpAddr(ipAddr), mResult(result), mIsTest(isTest),
ui(new(Ui::SecurityIpItem)) ui(new(Ui::SecurityIpItem))
{
setup();
}
SecurityIpItem::SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, uint32_t type, bool isTest) :
FeedItem(NULL), mParent(parent), mType(type), mSslId(sslId), mIpAddr(ipAddr), mIpAddrReported(ipAddrReported), mResult(0), mIsTest(isTest),
ui(new(Ui::SecurityIpItem))
{
setup();
}
void SecurityIpItem::setup()
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui->setupUi(this); ui->setupUi(this);
@ -64,9 +77,9 @@ SecurityIpItem::SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const
updateItem(); updateItem();
} }
bool SecurityIpItem::isSame(const RsPeerId &sslId) bool SecurityIpItem::isSame(const RsPeerId &sslId, uint32_t type)
{ {
if ((mSslId == sslId)) { if (mSslId == sslId && mType == type) {
return true; return true;
} }
@ -84,6 +97,20 @@ void SecurityIpItem::updateItemStatic()
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
/* Specific type */
switch (mType) {
case RS_FEED_ITEM_SEC_IP_BLACKLISTED:
ui->rsBanListButton->setDisabled(mIsTest);
ui->ipAddrReported->hide();
ui->ipAddrReportedLabel->hide();
break;
case RS_FEED_ITEM_SEC_WRONG_EXTERNAL_IP_REPORTED:
ui->rsBanListButton->hide();
break;
default:
std::cerr << "SecurityIpItem::updateItem() Wrong type" << std::endl;
}
QDateTime currentTime = QDateTime::currentDateTime(); QDateTime currentTime = QDateTime::currentDateTime();
ui->timeLabel->setText(DateTime::formatLongDateTime(currentTime.toTime_t())); ui->timeLabel->setText(DateTime::formatLongDateTime(currentTime.toTime_t()));
} }
@ -100,24 +127,33 @@ void SecurityIpItem::updateItem()
#endif #endif
if(!RsAutoUpdatePage::eventsLocked()) { if(!RsAutoUpdatePage::eventsLocked()) {
ui->titleLabel->setText(RsBanListDefs::resultString(mResult)); switch (mType) {
ui->ipAddr->setText(QString::fromStdString(mIPAddr)); case RS_FEED_ITEM_SEC_IP_BLACKLISTED:
ui->titleLabel->setText(RsBanListDefs::resultString(mResult));
ui->ipAddr->setText(QString::fromStdString(mIpAddr));
if (mIsTest) { if (!mIsTest) {
ui->rsBanListButton->setEnabled(false); switch (mResult) {
} else { case RSBANLIST_CHECK_RESULT_NOCHECK:
switch (mResult) { case RSBANLIST_CHECK_RESULT_NOT_WHITELISTED:
case RSBANLIST_CHECK_RESULT_NOCHECK: case RSBANLIST_CHECK_RESULT_ACCEPTED:
case RSBANLIST_CHECK_RESULT_NOT_WHITELISTED: ui->rsBanListButton->hide();
case RSBANLIST_CHECK_RESULT_ACCEPTED: break;
ui->rsBanListButton->hide(); case RSBANLIST_CHECK_RESULT_BLACKLISTED:
break; ui->rsBanListButton->setVisible(ui->rsBanListButton->setIpAddress(QString::fromStdString(mIpAddr)));
case RSBANLIST_CHECK_RESULT_BLACKLISTED: break;
ui->rsBanListButton->setVisible(ui->rsBanListButton->setIpAddress(QString::fromStdString(mIPAddr))); default:
break; ui->rsBanListButton->hide();
default: }
ui->rsBanListButton->hide();
} }
break;
case RS_FEED_ITEM_SEC_WRONG_EXTERNAL_IP_REPORTED:
ui->titleLabel->setText(tr("Wrong external ip address reported"));
ui->ipAddr->setText(QString::fromStdString(mIpAddr));
ui->ipAddrReported->setText(QString::fromStdString(mIpAddrReported));
break;
default:
std::cerr << "SecurityIpItem::updateItem() Wrong type" << std::endl;
} }
RsPeerDetails details; RsPeerDetails details;

View File

@ -39,15 +39,19 @@ class SecurityIpItem : public FeedItem
public: public:
/** Default Constructor */ /** Default Constructor */
SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string& ipAddr, uint32_t result, bool isTest); SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string& ipAddr, uint32_t result, uint32_t type, bool isTest);
SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, uint32_t type, bool isTest);
void updateItemStatic(); void updateItemStatic();
bool isSame(const RsPeerId &sslId); bool isSame(const RsPeerId &sslId, uint32_t type);
/* FeedItem */ /* FeedItem */
virtual void expand(bool open); virtual void expand(bool open);
private:
void setup();
private slots: private slots:
/* default stuff */ /* default stuff */
void removeItem(); void removeItem();
@ -59,8 +63,10 @@ private:
FeedHolder *mParent; FeedHolder *mParent;
uint32_t mFeedId; uint32_t mFeedId;
uint32_t mType;
RsPeerId mSslId; RsPeerId mSslId;
std::string mIPAddr; std::string mIpAddr;
std::string mIpAddrReported;
uint32_t mResult; uint32_t mResult;
bool mIsTest; bool mIsTest;

View File

@ -287,23 +287,7 @@
<property name="verticalSpacing"> <property name="verticalSpacing">
<number>0</number> <number>0</number>
</property> </property>
<item row="1" column="1"> <item row="2" column="0">
<widget class="QLabel" name="ipAddr">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">IP Address</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="StyledLabel" name="ipAddrLabel"> <widget class="StyledLabel" name="ipAddrLabel">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum"> <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
@ -322,14 +306,57 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0" colspan="2"> <item row="2" column="1">
<widget class="QLabel" name="ipAddr">
<property name="text">
<string notr="true">IP Address</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="ipAddrReportedLabel">
<property name="text">
<string>but reported:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="ipAddrReported">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">IP address reported</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="StyledLabel" name="peerLabel">
<property name="text">
<string notr="true">Peer:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="StyledLabel" name="titleLabel"> <widget class="StyledLabel" name="titleLabel">
<property name="text"> <property name="text">
<string notr="true">Title</string> <string notr="true">Title</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="3" column="1" colspan="3">
<widget class="QLabel" name="peer"> <widget class="QLabel" name="peer">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
@ -345,16 +372,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<widget class="StyledLabel" name="peerLabel">
<property name="text">
<string notr="true">Peer:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View File

@ -11992,6 +11992,14 @@ Reducing image to %1x%2 pixels?</source>
<source>Hide</source> <source>Hide</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>but reported:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wrong external ip address reported</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>SecurityItem</name> <name>SecurityItem</name>