mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
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:
parent
e8c60816cf
commit
22a7d2eeeb
@ -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;
|
||||
|
||||
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) ;
|
||||
}
|
||||
return true ;
|
||||
|
@ -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_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_CHANNEL_NEW = RS_FEED_TYPE_CHANNEL | 0x0001;
|
||||
//const uint32_t RS_FEED_ITEM_CHANNEL_UPDATE = RS_FEED_TYPE_CHANNEL | 0x0002;
|
||||
|
@ -253,6 +253,11 @@ void NewsFeed::updateDisplay()
|
||||
addFeedItemSecurityIpBlacklisted(fi, false);
|
||||
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:
|
||||
if (flags & RS_FEED_TYPE_CHANNEL)
|
||||
addFeedItemChannelNew(fi);
|
||||
@ -422,6 +427,12 @@ void NewsFeed::testFeeds(uint notifyFlags)
|
||||
fi.mId2 = "0.0.0.0";
|
||||
fi.mResult1 = RSBANLIST_CHECK_RESULT_BLACKLISTED;
|
||||
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;
|
||||
|
||||
case RS_FEED_TYPE_CHANNEL:
|
||||
@ -913,7 +924,7 @@ static bool addFeedItemIfUniqueCallback(FeedItem *feedItem, void *data)
|
||||
|
||||
if (findData->mSecurityIpItem) {
|
||||
SecurityIpItem *securityIpItem = dynamic_cast<SecurityIpItem*>(feedItem);
|
||||
if (securityIpItem && securityIpItem->isSame(findData->mSslId)) {
|
||||
if (securityIpItem && securityIpItem->isSame(findData->mSslId, findData->mType)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -1054,10 +1065,10 @@ void NewsFeed::addFeedItemSecurityUnknownOut(const RsFeedItem &fi)
|
||||
void NewsFeed::addFeedItemSecurityIpBlacklisted(const RsFeedItem &fi, bool isTest)
|
||||
{
|
||||
/* 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 */
|
||||
addFeedItemIfUnique(pi, 0, RsPeerId(fi.mId1), false);
|
||||
addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_IP_BLACKLISTED, RsPeerId(fi.mId1), false);
|
||||
|
||||
#ifdef NEWS_DEBUG
|
||||
std::cerr << "NewsFeed::addFeedItemSecurityIpBlacklisted()";
|
||||
@ -1065,6 +1076,20 @@ void NewsFeed::addFeedItemSecurityIpBlacklisted(const RsFeedItem &fi, bool isTes
|
||||
#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)
|
||||
{
|
||||
RsGxsGroupId grpId(fi.mId1);
|
||||
|
@ -95,6 +95,7 @@ private:
|
||||
void addFeedItemSecurityUnknownIn(const RsFeedItem &fi);
|
||||
void addFeedItemSecurityUnknownOut(const RsFeedItem &fi);
|
||||
void addFeedItemSecurityIpBlacklisted(const RsFeedItem &fi, bool isTest);
|
||||
void addFeedItemSecurityWrongExternalIpReported(const RsFeedItem &fi, bool isTest);
|
||||
|
||||
void addFeedItemChannelNew(const RsFeedItem &fi);
|
||||
// void addFeedItemChannelUpdate(const RsFeedItem &fi);
|
||||
|
@ -33,15 +33,28 @@
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsbanlist.h>
|
||||
#include <retroshare/rsnotify.h>
|
||||
|
||||
/*****
|
||||
* #define DEBUG_ITEM 1
|
||||
****/
|
||||
|
||||
/** Constructor */
|
||||
SecurityIpItem::SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string &ipAddr, uint32_t result, bool isTest) :
|
||||
FeedItem(NULL), mParent(parent), mSslId(sslId), mIPAddr(ipAddr), mResult(result), mIsTest(isTest),
|
||||
SecurityIpItem::SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string &ipAddr, uint32_t result, uint32_t type, bool isTest) :
|
||||
FeedItem(NULL), mParent(parent), mType(type), mSslId(sslId), mIpAddr(ipAddr), mResult(result), mIsTest(isTest),
|
||||
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 */
|
||||
ui->setupUi(this);
|
||||
@ -64,9 +77,9 @@ SecurityIpItem::SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const
|
||||
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;
|
||||
}
|
||||
|
||||
@ -84,6 +97,20 @@ void SecurityIpItem::updateItemStatic()
|
||||
std::cerr << std::endl;
|
||||
#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();
|
||||
ui->timeLabel->setText(DateTime::formatLongDateTime(currentTime.toTime_t()));
|
||||
}
|
||||
@ -100,24 +127,33 @@ void SecurityIpItem::updateItem()
|
||||
#endif
|
||||
|
||||
if(!RsAutoUpdatePage::eventsLocked()) {
|
||||
ui->titleLabel->setText(RsBanListDefs::resultString(mResult));
|
||||
ui->ipAddr->setText(QString::fromStdString(mIPAddr));
|
||||
switch (mType) {
|
||||
case RS_FEED_ITEM_SEC_IP_BLACKLISTED:
|
||||
ui->titleLabel->setText(RsBanListDefs::resultString(mResult));
|
||||
ui->ipAddr->setText(QString::fromStdString(mIpAddr));
|
||||
|
||||
if (mIsTest) {
|
||||
ui->rsBanListButton->setEnabled(false);
|
||||
} else {
|
||||
switch (mResult) {
|
||||
case RSBANLIST_CHECK_RESULT_NOCHECK:
|
||||
case RSBANLIST_CHECK_RESULT_NOT_WHITELISTED:
|
||||
case RSBANLIST_CHECK_RESULT_ACCEPTED:
|
||||
ui->rsBanListButton->hide();
|
||||
break;
|
||||
case RSBANLIST_CHECK_RESULT_BLACKLISTED:
|
||||
ui->rsBanListButton->setVisible(ui->rsBanListButton->setIpAddress(QString::fromStdString(mIPAddr)));
|
||||
break;
|
||||
default:
|
||||
ui->rsBanListButton->hide();
|
||||
if (!mIsTest) {
|
||||
switch (mResult) {
|
||||
case RSBANLIST_CHECK_RESULT_NOCHECK:
|
||||
case RSBANLIST_CHECK_RESULT_NOT_WHITELISTED:
|
||||
case RSBANLIST_CHECK_RESULT_ACCEPTED:
|
||||
ui->rsBanListButton->hide();
|
||||
break;
|
||||
case RSBANLIST_CHECK_RESULT_BLACKLISTED:
|
||||
ui->rsBanListButton->setVisible(ui->rsBanListButton->setIpAddress(QString::fromStdString(mIpAddr)));
|
||||
break;
|
||||
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;
|
||||
|
@ -39,15 +39,19 @@ class SecurityIpItem : public FeedItem
|
||||
|
||||
public:
|
||||
/** 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();
|
||||
|
||||
bool isSame(const RsPeerId &sslId);
|
||||
bool isSame(const RsPeerId &sslId, uint32_t type);
|
||||
|
||||
/* FeedItem */
|
||||
virtual void expand(bool open);
|
||||
|
||||
private:
|
||||
void setup();
|
||||
|
||||
private slots:
|
||||
/* default stuff */
|
||||
void removeItem();
|
||||
@ -59,8 +63,10 @@ private:
|
||||
FeedHolder *mParent;
|
||||
uint32_t mFeedId;
|
||||
|
||||
uint32_t mType;
|
||||
RsPeerId mSslId;
|
||||
std::string mIPAddr;
|
||||
std::string mIpAddr;
|
||||
std::string mIpAddrReported;
|
||||
uint32_t mResult;
|
||||
bool mIsTest;
|
||||
|
||||
|
@ -287,23 +287,7 @@
|
||||
<property name="verticalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="1">
|
||||
<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">
|
||||
<item row="2" column="0">
|
||||
<widget class="StyledLabel" name="ipAddrLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
|
||||
@ -322,14 +306,57 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<property name="text">
|
||||
<string notr="true">Title</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="1" colspan="3">
|
||||
<widget class="QLabel" name="peer">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
@ -345,16 +372,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -11992,6 +11992,14 @@ Reducing image to %1x%2 pixels?</source>
|
||||
<source>Hide</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</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>
|
||||
<name>SecurityItem</name>
|
||||
|
Loading…
Reference in New Issue
Block a user