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

View File

@ -337,14 +337,38 @@ void ConnectFriendWizard::setCertificate(const QString &certificate, bool friend
void ConnectFriendWizard::setGpgId(const RsPgpId &gpgId, const RsPeerId &sslId, bool friendRequest)
{
if (!rsPeers->getGPGDetails(gpgId, peerDetails)) {
setField("errorMessage", tr("Cannot get peer details of PGP key %1").arg(QString::fromStdString(gpgId.toStdString())));
if(sslId == rsPeers->getOwnId())
{
setField("errorMessage", tr("This is your own certificate! You would not want to make friend with yourself. Wouldn't you?") ) ;
setStartId(Page_ErrorMessage);
return;
error = false;
}
if (!rsPeers->getGPGDetails(gpgId, peerDetails))
{
mIsShortInvite = true;
peerDetails.id = sslId;
peerDetails.gpg_id = gpgId;
peerDetails.skip_pgp_signature_validation = true;
mCertificate.clear();
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"));
}
}
else
{
/* Set ssl id when available */
peerDetails.id = sslId;
mIsShortInvite = false;
//setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion);
setStartId(Page_Conclusion);
@ -355,6 +379,7 @@ void ConnectFriendWizard::setGpgId(const RsPgpId &gpgId, const RsPeerId &sslId,
ui->ConclusionPage->setSubTitle(tr("Details about the request"));
setButtonText(QWizard::FinishButton , tr("Accept"));
}
}
}
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->nameEdit->setText(QString::fromUtf8(peerDetails.name.c_str()));
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());
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->setToolTip("This is a Hidden node - you need tor/i2p proxy to connect");
}
if(peerDetails.email.empty())
if(mIsShortInvite)
{
ui->emailLabel->hide(); // is it ever used?
ui->emailEdit->hide();
ui->nameEdit->setText(tr("[Unknown]"));
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);
}

View File

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

View File

@ -174,29 +174,34 @@ void SecurityItem::updateItem()
std::cerr << std::endl;
#endif
if(!RsAutoUpdatePage::eventsLocked()) {
RsPeerDetails details;
/* first try sslid */
if (!rsPeers->getPeerDetails(mSslId, details))
if(!RsAutoUpdatePage::eventsLocked())
{
/* then gpgid */
if(!rsPeers->getGPGDetails(mGpgId, details))
RsPeerDetails details;
/* first try sslid */;
if (!rsPeers->getPeerDetails(mSslId, details) && !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
*/
/* 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()));
statusLabel->setText(tr("Unknown Peer"));
trustLabel->setText(tr("Unknown Peer"));
locLabel->setText(tr("Unknown Peer"));
ipLabel->setText(QString::fromStdString(mIP)) ; //tr("Unknown Peer"));
connLabel->setText(tr("Unknown Peer"));
statusLabel->hide();
typeLabel->hide();
trustLabel->hide();
trustLeftLabel->hide();
locLabel->hide();
locLeftLabel->hide();
ipLabel->setText(QString::fromStdString(mIP)) ;
connLabel->hide();
connLeftLabel->hide();
chatButton->hide();
//quickmsgButton->hide();
@ -206,9 +211,11 @@ void SecurityItem::updateItem()
removeFriendButton->hide();
peerDetailsButton->setEnabled(false);
friendRequesttoolButton->show();
requestLabel->show();
return;
}
}
/* set peer name */
peerNameLabel->setText(QString::fromUtf8(details.name.c_str()));
@ -344,6 +351,7 @@ void SecurityItem::friendRequest()
#endif
ConnectFriendWizard *connectFriendWizard = new ConnectFriendWizard;
connectFriendWizard->setAttribute(Qt::WA_DeleteOnClose, true);
connectFriendWizard->setGpgId(mGpgId, mSslId, true);
connectFriendWizard->show();

View File

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