fixed accepting connection attempts from unknown peers using short invite system

This commit is contained in:
csoler 2019-12-14 18:24:46 +01:00
parent 536c0852d4
commit 8d121a1038
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
6 changed files with 102 additions and 1250 deletions

File diff suppressed because it is too large Load Diff

View File

@ -56,7 +56,7 @@ class RsFeedItem;
class FeedNotify; class FeedNotify;
class FeedItem; class FeedItem;
class NewsFeed : public RsAutoUpdatePage, public FeedHolder class NewsFeed : public MainPage,public FeedHolder
{ {
Q_OBJECT Q_OBJECT
@ -81,8 +81,6 @@ public:
static void testFeeds(uint notifyFlags); static void testFeeds(uint notifyFlags);
static void testFeed(FeedNotify *feedNotify); static void testFeed(FeedNotify *feedNotify);
virtual void updateDisplay();
void handleEvent(std::shared_ptr<const RsEvent> event); // get events from libretroshare void handleEvent(std::shared_ptr<const RsEvent> event); // get events from libretroshare
signals: signals:
@ -91,9 +89,6 @@ signals:
protected: protected:
void processSettings(bool load); void processSettings(bool load);
/* TokenResponse */
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
private slots: private slots:
void feedoptions(); void feedoptions();
void sortChanged(int index); void sortChanged(int index);
@ -119,10 +114,6 @@ private:
void addFeedItemBlogMsg(const RsFeedItem &fi); void addFeedItemBlogMsg(const RsFeedItem &fi);
#endif #endif
// void addFeedItemChatNew(const RsFeedItem &fi, bool addWithoutCheck);
// void addFeedItemMessage(const RsFeedItem &fi);
// void addFeedItemFilesNew(const RsFeedItem &fi);
private: private:
/* UI - from Designer */ /* UI - from Designer */
Ui::NewsFeed *ui; Ui::NewsFeed *ui;

View File

@ -337,24 +337,49 @@ void ConnectFriendWizard::setCertificate(const QString &certificate, bool friend
void ConnectFriendWizard::setGpgId(const RsPgpId &gpgId, const RsPeerId &sslId, bool friendRequest) void ConnectFriendWizard::setGpgId(const RsPgpId &gpgId, const RsPeerId &sslId, bool friendRequest)
{ {
if (!rsPeers->getGPGDetails(gpgId, peerDetails)) { if(sslId == rsPeers->getOwnId())
setField("errorMessage", tr("Cannot get peer details of PGP key %1").arg(QString::fromStdString(gpgId.toStdString()))); {
setField("errorMessage", tr("This is your own certificate! You would not want to make friend with yourself. Wouldn't you?") ) ;
setStartId(Page_ErrorMessage); setStartId(Page_ErrorMessage);
return; error = false;
} }
/* Set ssl id when available */ if (!rsPeers->getGPGDetails(gpgId, peerDetails))
peerDetails.id = sslId; {
mIsShortInvite = true;
//setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion); peerDetails.id = sslId;
setStartId(Page_Conclusion); peerDetails.gpg_id = gpgId;
if (friendRequest){ peerDetails.skip_pgp_signature_validation = true;
ui->cp_Label->show();
ui->requestinfolabel->show(); mCertificate.clear();
setTitleText(ui->ConclusionPage,tr("Friend request"));
ui->ConclusionPage->setSubTitle(tr("Details about the request")); setStartId(Page_Conclusion);
setButtonText(QWizard::FinishButton , tr("Accept"));
} if (friendRequest){
ui->cp_Label->show();
ui->requestinfolabel->show();
setTitleText(ui->ConclusionPage, tr("Friend request"));
ui->ConclusionPage->setSubTitle(tr("Details about the request"));
setButtonText(QWizard::FinishButton , tr("Accept"));
}
}
else
{
/* Set ssl id when available */
peerDetails.id = sslId;
mIsShortInvite = false;
//setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion);
setStartId(Page_Conclusion);
if (friendRequest){
ui->cp_Label->show();
ui->requestinfolabel->show();
setTitleText(ui->ConclusionPage,tr("Friend request"));
ui->ConclusionPage->setSubTitle(tr("Details about the request"));
setButtonText(QWizard::FinishButton , tr("Accept"));
}
}
} }
ConnectFriendWizard::~ConnectFriendWizard() ConnectFriendWizard::~ConnectFriendWizard()
@ -507,7 +532,7 @@ void ConnectFriendWizard::initializePage(int id)
ui->cp_Label->setText(tr("You have a friend request from") + " " + QString::fromUtf8(peerDetails.name.c_str())); ui->cp_Label->setText(tr("You have a friend request from") + " " + QString::fromUtf8(peerDetails.name.c_str()));
ui->nameEdit->setText(QString::fromUtf8(peerDetails.name.c_str())); ui->nameEdit->setText(QString::fromUtf8(peerDetails.name.c_str()));
ui->trustEdit->setText(trustString); ui->trustEdit->setText(trustString);
ui->emailEdit->setText(QString::fromUtf8(peerDetails.email.c_str())); ui->profileIdEdit->setText(QString::fromStdString(peerDetails.gpg_id.toStdString()));
QString loc = QString::fromUtf8(peerDetails.location.c_str()); QString loc = QString::fromUtf8(peerDetails.location.c_str());
if (!loc.isEmpty()) if (!loc.isEmpty())
{ {
@ -540,12 +565,19 @@ void ConnectFriendWizard::initializePage(int id)
ui->ipLabel->setPixmap(QPixmap(":/images/anonymous_128_blue.png").scaledToHeight(S*2,Qt::SmoothTransformation)); ui->ipLabel->setPixmap(QPixmap(":/images/anonymous_128_blue.png").scaledToHeight(S*2,Qt::SmoothTransformation));
ui->ipLabel->setToolTip("This is a Hidden node - you need tor/i2p proxy to connect"); ui->ipLabel->setToolTip("This is a Hidden node - you need tor/i2p proxy to connect");
} }
if(mIsShortInvite)
if(peerDetails.email.empty())
{ {
ui->emailLabel->hide(); // is it ever used? ui->nameEdit->setText(tr("[Unknown]"));
ui->emailEdit->hide(); ui->addKeyToKeyring_CB->setChecked(false);
ui->addKeyToKeyring_CB->setEnabled(false);
ui->signersEdit->hide();
ui->signersLabel->hide();
ui->signGPGCheckBox->setChecked(false);
ui->signGPGCheckBox->setEnabled(false);
ui->acceptNoSignGPGCheckBox->setChecked(true);
ui->acceptNoSignGPGCheckBox->setEnabled(false);
} }
ui->ipEdit->setTextInteractionFlags(Qt::TextSelectableByMouse); ui->ipEdit->setTextInteractionFlags(Qt::TextSelectableByMouse);
} }

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>600</width> <width>1139</width>
<height>437</height> <height>1171</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -480,14 +480,14 @@
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="emailLabel"> <widget class="QLabel" name="profileIdLabel">
<property name="text"> <property name="text">
<string>Email:</string> <string>Profile ID:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QLabel" name="emailEdit"> <widget class="QLabel" name="profileIdEdit">
<property name="text"> <property name="text">
<string notr="true">Email</string> <string notr="true">Email</string>
</property> </property>
@ -794,8 +794,8 @@
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../images.qrc"/>
<include location="../icons.qrc"/> <include location="../icons.qrc"/>
<include location="../images.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -174,40 +174,47 @@ void SecurityItem::updateItem()
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
if(!RsAutoUpdatePage::eventsLocked()) { if(!RsAutoUpdatePage::eventsLocked())
{
RsPeerDetails details; RsPeerDetails details;
/* first try sslid */ /* first try sslid */;
if (!rsPeers->getPeerDetails(mSslId, details)) if (!rsPeers->getPeerDetails(mSslId, details) && !rsPeers->getGPGDetails(mGpgId, details))
{ {
/* then gpgid */ /* it is very likely that we will end up here for some of the
if(!rsPeers->getGPGDetails(mGpgId, details))
{
/* it is very likely that we will end up here for some of the
* Unknown peer cases.... so allow them here * Unknown peer cases.... so allow them here
*/ */
/* set peer name */ /* set peer name */
peerNameLabel->setText(QString("%1 (%2)").arg(tr("Unknown Peer"), QString::fromUtf8(mSslCn.c_str()))); peerNameLabel->setText(tr("A unknown peer"));
nameLabel->setText(QString::fromUtf8(mSslCn.c_str()) + " (" + QString::fromStdString(mGpgId.toStdString()) + ")"); nameLabel->setText(tr("Unknown") + " (" + tr("Profile ID: ") + QString::fromStdString(mGpgId.toStdString()) + ")");
idLabel->setText(QString::fromStdString(mSslId.toStdString())); idLabel->setText(QString::fromStdString(mSslId.toStdString()));
statusLabel->setText(tr("Unknown Peer")); statusLabel->hide();
trustLabel->setText(tr("Unknown Peer")); typeLabel->hide();
locLabel->setText(tr("Unknown Peer"));
ipLabel->setText(QString::fromStdString(mIP)) ; //tr("Unknown Peer"));
connLabel->setText(tr("Unknown Peer"));
chatButton->hide(); trustLabel->hide();
//quickmsgButton->hide(); trustLeftLabel->hide();
requestLabel->hide();
removeFriendButton->setEnabled(false); locLabel->hide();
removeFriendButton->hide(); locLeftLabel->hide();
peerDetailsButton->setEnabled(false);
return; ipLabel->setText(QString::fromStdString(mIP)) ;
} connLabel->hide();
connLeftLabel->hide();
chatButton->hide();
//quickmsgButton->hide();
requestLabel->hide();
removeFriendButton->setEnabled(false);
removeFriendButton->hide();
peerDetailsButton->setEnabled(false);
friendRequesttoolButton->show();
requestLabel->show();
return;
} }
/* set peer name */ /* set peer name */
@ -344,6 +351,7 @@ void SecurityItem::friendRequest()
#endif #endif
ConnectFriendWizard *connectFriendWizard = new ConnectFriendWizard; ConnectFriendWizard *connectFriendWizard = new ConnectFriendWizard;
connectFriendWizard->setAttribute(Qt::WA_DeleteOnClose, true); connectFriendWizard->setAttribute(Qt::WA_DeleteOnClose, true);
connectFriendWizard->setGpgId(mGpgId, mSslId, true); connectFriendWizard->setGpgId(mGpgId, mSslId, true);
connectFriendWizard->show(); connectFriendWizard->show();

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>763</width> <width>1196</width>
<height>246</height> <height>491</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout"> <layout class="QGridLayout">
@ -354,7 +354,7 @@
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="nameLeftLabel">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight> <weight>75</weight>
@ -367,7 +367,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="idLeftLabel">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight> <weight>75</weight>
@ -380,7 +380,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="trustLeftLabel">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -399,7 +399,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="locLeftLabel">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight> <weight>75</weight>
@ -412,7 +412,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="ipLeftLabel">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight> <weight>75</weight>
@ -425,7 +425,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_9"> <widget class="QLabel" name="connLeftLabel">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight> <weight>75</weight>
@ -578,8 +578,8 @@
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../images.qrc"/>
<include location="../icons.qrc"/> <include location="../icons.qrc"/>
<include location="../images.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>