added entries to control what we add in the certificate

This commit is contained in:
csoler 2022-02-11 16:20:52 +01:00
parent 33800e9cb9
commit 6fcb3e8972
5 changed files with 98 additions and 50 deletions

View File

@ -80,25 +80,37 @@ HomePage::HomePage(QWidget *parent) :
if(!RsAccounts::isHiddenNode())
{
mIncludeLocIPact = new QAction(QIcon(), tr("Include current local IP"),this);
connect(mIncludeLocIPact, SIGNAL(triggered()), this, SLOT(updateOwnCert()));
mIncludeLocIPact->setCheckable(true);
mIncludeLocIPact->setChecked(true);
menu->addAction(mIncludeLocIPact);
mIncludeExtIPact = new QAction(QIcon(), tr("Include current external IP"),this);
connect(mIncludeExtIPact, SIGNAL(triggered()), this, SLOT(updateOwnCert()));
mIncludeExtIPact->setCheckable(true);
mIncludeExtIPact->setChecked(true);
menu->addAction(mIncludeExtIPact);
mIncludeDNSact = new QAction(QIcon(), tr("Include my DNS"),this);
connect(mIncludeDNSact, SIGNAL(triggered()), this, SLOT(updateOwnCert()));
mIncludeDNSact->setCheckable(true);
mIncludeDNSact->setChecked(true);
menu->addAction(mIncludeDNSact);
mIncludeIPsAct = new QAction(QIcon(), tr("Include all your known IPs"),this);
connect(mIncludeIPsAct, SIGNAL(triggered()), this, SLOT(updateOwnCert()));
mIncludeIPsAct->setCheckable(true);
mIncludeIPsAct->setChecked(false);
menu->addAction(mIncludeIPsAct);
mIncludeIPHistoryact = new QAction(QIcon(), tr("Include all IPs history"),this);
connect(mIncludeIPHistoryact, SIGNAL(triggered()), this, SLOT(updateOwnCert()));
mIncludeIPHistoryact->setCheckable(true);
mIncludeIPHistoryact->setChecked(false);
menu->addAction(mIncludeIPHistoryact);
}
mUseOldFormatAct = new QAction(QIcon(), tr("Use old certificate format"),this);
mUseOldFormatAct->setToolTip(tr("Displays the certificate format used up to version 0.6.5\nOld Retroshare nodes will not understand the\nnew short format"));
connect(mUseOldFormatAct, SIGNAL(triggered()), this, SLOT(updateOwnCert()));
mUseOldFormatAct->setCheckable(true);
mUseOldFormatAct->setChecked(false);
menu->addAction(mUseOldFormatAct);
mUseOldFormatact = new QAction(QIcon(), tr("Use old certificate format"),this);
mUseOldFormatact->setToolTip(tr("Displays the certificate format used up to version 0.6.5\nOld Retroshare nodes will not understand the\nnew short format"));
connect(mUseOldFormatact, SIGNAL(triggered()), this, SLOT(updateOwnCert()));
mUseOldFormatact->setCheckable(true);
mUseOldFormatact->setChecked(false);
menu->addAction(mUseOldFormatact);
ui->shareButton->setMenu(menu);
@ -193,9 +205,8 @@ HomePage::~HomePage()
delete ui;
}
void HomePage::updateOwnCert()
void HomePage::getOwnCert(QString& invite,QString& description) const
{
bool include_extra_locators = mIncludeIPsAct->isChecked();
RsPeerDetails detail;
@ -205,23 +216,47 @@ void HomePage::updateOwnCert()
return ;
}
QString invite ;
RetroshareInviteFlags invite_flags = RsPeers::defaultCertificateFlags;
RetroshareInviteFlags invite_flags = RetroshareInviteFlags::NOTHING;
if(mIncludeIPsAct->isChecked())
if(mIncludeLocIPact->isChecked())
invite_flags |= RetroshareInviteFlags::CURRENT_LOCAL_IP;
if(mIncludeExtIPact->isChecked())
invite_flags |= RetroshareInviteFlags::CURRENT_EXTERNAL_IP;
if(mIncludeDNSact->isChecked())
invite_flags |= RetroshareInviteFlags::DNS;
if(mIncludeIPHistoryact->isChecked())
invite_flags |= RetroshareInviteFlags::FULL_IP_HISTORY;
if(!mUseOldFormatAct->isChecked())
if(!mUseOldFormatact->isChecked())
{
std::string short_invite;
rsPeers->getShortInvite(short_invite,rsPeers->getOwnId(),invite_flags | RetroshareInviteFlags::RADIX_FORMAT);
invite = QString::fromStdString(short_invite);
}
else
invite = QString::fromStdString(rsPeers->GetRetroshareInvite(detail.id,invite_flags));
bool include_extra_locators = mIncludeIPHistoryact->isChecked();
description = ConfCertDialog::getCertificateDescription(detail,false,!mUseOldFormatact->isChecked(),include_extra_locators);
}
void HomePage::updateOwnCert()
{
QString certificate, description;
getOwnCert(certificate,description);
if(!mUseOldFormatact->isChecked()) // in this case we have to split the cert for a bettr display
{
QString S;
QString txt;
for(uint32_t i=0;i<short_invite.size();)
for(int i=0;i<certificate.size();)
if(S.length() < 100)
S += short_invite[i++];
S += certificate[i++];
else
{
txt += S + "\n";
@ -229,16 +264,10 @@ void HomePage::updateOwnCert()
}
txt += S;
invite = txt; // the "\n" is here to make some space
certificate = txt; // the "\n" is here to make some space
}
else
invite = QString::fromStdString(rsPeers->GetRetroshareInvite(detail.id,invite_flags));
ui->retroshareid->setText("\n"+invite+"\n");
QString description = ConfCertDialog::getCertificateDescription(detail,false,!mUseOldFormatAct->isChecked(),include_extra_locators);
ui->retroshareid->setText("\n"+certificate+"\n");
ui->retroshareid->setToolTip(description);
}

View File

@ -46,6 +46,10 @@ public:
virtual QString pageName() const { return tr("Home") ; } //MainPage
virtual QString helpText() const { return ""; } //MainPage
// Returns the certificate along with its description using current options.
void getOwnCert(QString& invite,QString& description) const;
private slots:
#ifdef DEAD_CODE
void certContextMenu(QPoint);
@ -64,8 +68,10 @@ private:
Ui::HomePage *ui;
QAction *mIncludeDNSact;
QAction *mIncludeIPsAct;
QAction *mUseOldFormatAct;
QAction *mIncludeIPHistoryact;
QAction *mIncludeExtIPact;
QAction *mIncludeLocIPact;
QAction *mUseOldFormatact;
RsEventsHandlerId_t mEventHandlerId;

View File

@ -1083,6 +1083,8 @@ void SetForegroundWindowInternal(HWND hWnd)
return _instance->gxsforumDialog;
case Posted:
return _instance->postedDialog;
case Home:
return _instance->homePage;
}
return NULL;

View File

@ -102,7 +102,8 @@ public:
Search = 8, /** Search page. */
Posted = 11, /** Posted links */
People = 12, /** People page. */
Options = 13 /** People page. */
Options = 13, /** People page. */
Home = 14 /** Home page. */
};

View File

@ -22,6 +22,7 @@
#include "ChatLobbyWidget.h"
#include "MainWindow.h"
#include "HomePage.h"
#include "chat/ChatDialog.h"
#include "common/PeerDefs.h"
#include "common/RsCollection.h"
@ -561,12 +562,21 @@ RetroShareLink RetroShareLink::createCertificate(const RsPeerId& ssl_id)
// - we should not need to parse and re-read a cert in old format.
//
RsPeerDetails detail;
if (rsPeers->getPeerDetails(ssl_id, detail) == false) {
if (rsPeers->getPeerDetails(ssl_id, detail) == false)
std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_id << std::endl;
} else {
else
{
link._type = TYPE_CERTIFICATE;
if(rsPeers->getOwnId() == ssl_id) // in this case, use application-wide parameters set in HomePage
{
QString invite,description;
static_cast<HomePage*>(MainWindow::getPage(MainWindow::Home))->getOwnCert(invite,description);
link._radix = invite;
}
else
link._radix = QString::fromUtf8(rsPeers->GetRetroshareInvite(ssl_id).c_str());
link._name = QString::fromUtf8(detail.name.c_str());
link._location = QString::fromUtf8(detail.location.c_str());
link._radix.replace("\n","");