Skip to content

Commit de1db9b

Browse files
committed
added new feed item for TLS connection attempts
1 parent 713d0fe commit de1db9b

4 files changed

Lines changed: 34 additions & 2 deletions

File tree

retroshare-gui/src/gui/NewsFeed.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include "feeds/SecurityIpItem.h"
5353
#include "feeds/WireNotifyGroupItem.h"
5454
#include "feeds/WireNotifyPostItem.h"
55+
#include "feeds/TLSItem.h"
5556

5657
#include "settings/rsettingswin.h"
5758
#include "settings/rsharesettings.h"
@@ -203,7 +204,7 @@ void NewsFeed::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
203204
{
204205
RsFeedTypeFlags flags = (RsFeedTypeFlags)Settings->getNewsFeedFlags();
205206

206-
if(event->mType == RsEventType::AUTHSSL_CONNECTION_AUTENTICATION && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_SECURITY)))
207+
if(event->mType == RsEventType::AUTHSSL_CONNECTION_AUTENTICATION && (!!(flags & (RsFeedTypeFlags::RS_FEED_TYPE_SECURITY | RsFeedTypeFlags::RS_FEED_TYPE_TLS_ATTEMPT))))
207208
handleSecurityEvent(event);
208209

209210
if(event->mType == RsEventType::FRIEND_LIST && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_PEER)))
@@ -479,6 +480,32 @@ void NewsFeed::handleSecurityEvent(std::shared_ptr<const RsEvent> event)
479480
auto& e(*pe);
480481
RsFeedTypeFlags flags = (RsFeedTypeFlags)Settings->getNewsFeedFlags();
481482

483+
// 1 - treat the case of unknown PeerID
484+
485+
if(e.mSslId.isNull())
486+
{
487+
// if(!(flags & RsFeedTypeFlags::RS_FEED_TYPE_TLS_ATTEMPT))
488+
// return;
489+
490+
auto item = new TLSItem(this,NEWSFEED_TLSLIST);
491+
FeedItem *feedItem = ui->feedWidget->findFeedItem(item->uniqueIdentifier());
492+
493+
if(feedItem)
494+
{
495+
dynamic_cast<TLSItem*>(feedItem)->addIPEntry(e.mLocator.host()+":"+std::to_string(e.mLocator.port()));
496+
delete item;
497+
}
498+
else
499+
{
500+
item->addIPEntry(e.mLocator.host()+":"+std::to_string(e.mLocator.port()));
501+
addFeedItem(item);
502+
}
503+
504+
return;
505+
}
506+
507+
// 2 - if the peer Id is known, use the dedicated item.
508+
482509
if(e.mErrorCode == RsAuthSslError::PEER_REFUSED_CONNECTION && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_SECURITY_IP)))
483510
{
484511
addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_HELLO, false), true );

retroshare-gui/src/gui/NewsFeed.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const uint32_t NEWSFEED_PEERLIST = 0x0001;
3333

3434
const uint32_t NEWSFEED_NEW_FORUM = 0x0002;
3535
const uint32_t NEWSFEED_NEW_FORUM_MSG = 0x0003;
36-
const uint32_t NEWSFEED_UPDATED_FORUM = 0x000f;
3736

3837
const uint32_t NEWSFEED_CHANNELNEWLIST = 0x0004;
3938
//const uint32_t NEWSFEED_CHANNELMSGLIST = 0x0005;
@@ -49,7 +48,9 @@ const uint32_t NEWSFEED_POSTEDNEWLIST = 0x000b;
4948
const uint32_t NEWSFEED_POSTEDMSGLIST = 0x000c;
5049
const uint32_t NEWSFEED_CIRCLELIST = 0x000d;
5150
const uint32_t NEWSFEED_CHANNELPUBKEYLIST= 0x000e;
51+
const uint32_t NEWSFEED_UPDATED_FORUM = 0x000f;
5252
const uint32_t NEWSFEED_WIRELIST = 0x0010;
53+
const uint32_t NEWSFEED_TLSLIST = 0x0011;
5354

5455
namespace Ui {
5556
class NewsFeed;

retroshare-gui/src/gui/feeds/FeedItem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ enum class RsFeedTypeFlags: uint32_t {
3131
RS_FEED_TYPE_PEER = 0x0010,
3232
RS_FEED_TYPE_CHANNEL = 0x0020,
3333
RS_FEED_TYPE_FORUM = 0x0040,
34+
RS_FEED_TYPE_TLS_ATTEMPT = 0x0080,
3435
RS_FEED_TYPE_CHAT = 0x0100,
3536
RS_FEED_TYPE_MSG = 0x0200,
3637
RS_FEED_TYPE_FILES = 0x0400,

retroshare-gui/src/retroshare-gui.pro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ HEADERS += rshare.h \
609609
gui/feeds/ChatMsgItem.h \
610610
gui/feeds/SubFileItem.h \
611611
gui/feeds/AttachFileItem.h \
612+
gui/feeds/TLSItem.h \
612613
gui/feeds/SecurityItem.h \
613614
gui/feeds/SecurityIpItem.h \
614615
gui/feeds/NewsFeedUserNotify.h \
@@ -703,6 +704,7 @@ FORMS += gui/StartDialog.ui \
703704
gui/feeds/ChatMsgItem.ui \
704705
gui/feeds/SubFileItem.ui \
705706
gui/feeds/AttachFileItem.ui \
707+
gui/feeds/TLSItem.ui \
706708
gui/feeds/SecurityItem.ui \
707709
gui/feeds/SecurityIpItem.ui \
708710
gui/im_history/ImHistoryBrowser.ui \
@@ -961,6 +963,7 @@ SOURCES += main.cpp \
961963
gui/feeds/ChatMsgItem.cpp \
962964
gui/feeds/SubFileItem.cpp \
963965
gui/feeds/AttachFileItem.cpp \
966+
gui/feeds/TLSItem.cpp \
964967
gui/feeds/SecurityItem.cpp \
965968
gui/feeds/SecurityIpItem.cpp \
966969
gui/feeds/NewsFeedUserNotify.cpp \

0 commit comments

Comments
 (0)