mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added own flag and new checkbox in settings for security ip feed items.
Changed NewsFeed::addUnique for SecurityIpItem to compare the ip addresses. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8424 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f360e9d0ba
commit
ad4f57d756
@ -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 ;
|
||||
|
@ -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;
|
||||
|
@ -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<SecurityItem*>(feedItem);
|
||||
mSecurityIpItem = dynamic_cast<SecurityIpItem*>(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<SecurityIpItem*>(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()";
|
||||
|
@ -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);
|
||||
|
@ -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("<p>This is the external IP your Retroshare node thinks it is using.</p>")) ;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tabFeed">
|
||||
<attribute name="title">
|
||||
@ -91,6 +91,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="notify_SecurityIp">
|
||||
<property name="text">
|
||||
<string>Security Ip</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="feedLayout"/>
|
||||
</item>
|
||||
@ -468,6 +475,38 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
<tabstop>notify_Peers</tabstop>
|
||||
<tabstop>notify_Channels</tabstop>
|
||||
<tabstop>notify_Forums</tabstop>
|
||||
<tabstop>notify_Posted</tabstop>
|
||||
<tabstop>notify_Blogs</tabstop>
|
||||
<tabstop>notify_Messages</tabstop>
|
||||
<tabstop>notify_Chat</tabstop>
|
||||
<tabstop>notify_Security</tabstop>
|
||||
<tabstop>notify_SecurityIp</tabstop>
|
||||
<tabstop>message_ConnectAttempt</tabstop>
|
||||
<tabstop>testFeedButton</tabstop>
|
||||
<tabstop>popup_Connect</tabstop>
|
||||
<tabstop>popup_NewMsg</tabstop>
|
||||
<tabstop>popup_DownloadFinished</tabstop>
|
||||
<tabstop>popup_PrivateChat</tabstop>
|
||||
<tabstop>popup_GroupChat</tabstop>
|
||||
<tabstop>popup_ChatLobby</tabstop>
|
||||
<tabstop>popup_ConnectAttempt</tabstop>
|
||||
<tabstop>testToasterButton</tabstop>
|
||||
<tabstop>comboBoxToasterPosition</tabstop>
|
||||
<tabstop>spinBoxToasterXMargin</tabstop>
|
||||
<tabstop>spinBoxToasterYMargin</tabstop>
|
||||
<tabstop>systray_GroupChat</tabstop>
|
||||
<tabstop>systray_ChatLobby</tabstop>
|
||||
<tabstop>chatLobbies_CountUnRead</tabstop>
|
||||
<tabstop>chatLobbies_CheckNickName</tabstop>
|
||||
<tabstop>chatLobbies_CountFollowingText</tabstop>
|
||||
<tabstop>chatLobbies_TextToNotify</tabstop>
|
||||
<tabstop>pushButtonDisableAll</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
Reference in New Issue
Block a user