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()) 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); mIncludeDNSact = new QAction(QIcon(), tr("Include my DNS"),this);
connect(mIncludeDNSact, SIGNAL(triggered()), this, SLOT(updateOwnCert())); connect(mIncludeDNSact, SIGNAL(triggered()), this, SLOT(updateOwnCert()));
mIncludeDNSact->setCheckable(true); mIncludeDNSact->setCheckable(true);
mIncludeDNSact->setChecked(true); mIncludeDNSact->setChecked(true);
menu->addAction(mIncludeDNSact); menu->addAction(mIncludeDNSact);
mIncludeIPsAct = new QAction(QIcon(), tr("Include all your known IPs"),this); mIncludeIPHistoryact = new QAction(QIcon(), tr("Include all IPs history"),this);
connect(mIncludeIPsAct, SIGNAL(triggered()), this, SLOT(updateOwnCert())); connect(mIncludeIPHistoryact, SIGNAL(triggered()), this, SLOT(updateOwnCert()));
mIncludeIPsAct->setCheckable(true); mIncludeIPHistoryact->setCheckable(true);
mIncludeIPsAct->setChecked(false); mIncludeIPHistoryact->setChecked(false);
menu->addAction(mIncludeIPsAct); menu->addAction(mIncludeIPHistoryact);
} }
mUseOldFormatAct = new QAction(QIcon(), tr("Use old certificate format"),this); 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")); 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())); connect(mUseOldFormatact, SIGNAL(triggered()), this, SLOT(updateOwnCert()));
mUseOldFormatAct->setCheckable(true); mUseOldFormatact->setCheckable(true);
mUseOldFormatAct->setChecked(false); mUseOldFormatact->setChecked(false);
menu->addAction(mUseOldFormatAct); menu->addAction(mUseOldFormatact);
ui->shareButton->setMenu(menu); ui->shareButton->setMenu(menu);
@ -193,9 +205,8 @@ HomePage::~HomePage()
delete ui; delete ui;
} }
void HomePage::updateOwnCert() void HomePage::getOwnCert(QString& invite,QString& description) const
{ {
bool include_extra_locators = mIncludeIPsAct->isChecked();
RsPeerDetails detail; RsPeerDetails detail;
@ -205,23 +216,47 @@ void HomePage::updateOwnCert()
return ; return ;
} }
QString invite ; RetroshareInviteFlags invite_flags = RetroshareInviteFlags::NOTHING;
RetroshareInviteFlags invite_flags = RsPeers::defaultCertificateFlags;
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; invite_flags |= RetroshareInviteFlags::FULL_IP_HISTORY;
if(!mUseOldFormatAct->isChecked()) if(!mUseOldFormatact->isChecked())
{ {
std::string short_invite; std::string short_invite;
rsPeers->getShortInvite(short_invite,rsPeers->getOwnId(),invite_flags | RetroshareInviteFlags::RADIX_FORMAT); 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 S;
QString txt; QString txt;
for(uint32_t i=0;i<short_invite.size();) for(int i=0;i<certificate.size();)
if(S.length() < 100) if(S.length() < 100)
S += short_invite[i++]; S += certificate[i++];
else else
{ {
txt += S + "\n"; txt += S + "\n";
@ -229,16 +264,10 @@ void HomePage::updateOwnCert()
} }
txt += S; txt += S;
certificate = txt; // the "\n" is here to make some space
invite = 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); ui->retroshareid->setToolTip(description);
} }

View File

@ -46,6 +46,10 @@ public:
virtual QString pageName() const { return tr("Home") ; } //MainPage virtual QString pageName() const { return tr("Home") ; } //MainPage
virtual QString helpText() const { return ""; } //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: private slots:
#ifdef DEAD_CODE #ifdef DEAD_CODE
void certContextMenu(QPoint); void certContextMenu(QPoint);
@ -64,8 +68,10 @@ private:
Ui::HomePage *ui; Ui::HomePage *ui;
QAction *mIncludeDNSact; QAction *mIncludeDNSact;
QAction *mIncludeIPsAct; QAction *mIncludeIPHistoryact;
QAction *mUseOldFormatAct; QAction *mIncludeExtIPact;
QAction *mIncludeLocIPact;
QAction *mUseOldFormatact;
RsEventsHandlerId_t mEventHandlerId; RsEventsHandlerId_t mEventHandlerId;

View File

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

View File

@ -100,9 +100,10 @@ public:
Channels = 6, /** Channels page. */ Channels = 6, /** Channels page. */
Forums = 7, /** Forums page. */ Forums = 7, /** Forums page. */
Search = 8, /** Search page. */ Search = 8, /** Search page. */
Posted = 11, /** Posted links */ Posted = 11, /** Posted links */
People = 12, /** People page. */ 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 "ChatLobbyWidget.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "HomePage.h"
#include "chat/ChatDialog.h" #include "chat/ChatDialog.h"
#include "common/PeerDefs.h" #include "common/PeerDefs.h"
#include "common/RsCollection.h" #include "common/RsCollection.h"
@ -551,32 +552,41 @@ RetroShareLink RetroShareLink::createMessage(const RsGxsId& peerId, const QStrin
RetroShareLink RetroShareLink::createCertificate(const RsPeerId& ssl_id) RetroShareLink RetroShareLink::createCertificate(const RsPeerId& ssl_id)
{ {
RetroShareLink link; RetroShareLink link;
link.clear(); link.clear();
#ifndef RS_NO_WARN_CPP #ifndef RS_NO_WARN_CPP
#pragma message("csoler 2012-08-14: This is baaaaaad code") #pragma message("csoler 2012-08-14: This is baaaaaad code")
#endif #endif
// - we should not need to parse and re-read a cert in old format. // - we should not need to parse and re-read a cert in old format.
// //
RsPeerDetails detail; 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; std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_id << std::endl;
} else { else
{
link._type = TYPE_CERTIFICATE;
link._type = TYPE_CERTIFICATE; if(rsPeers->getOwnId() == ssl_id) // in this case, use application-wide parameters set in HomePage
link._radix = QString::fromUtf8(rsPeers->GetRetroshareInvite(ssl_id).c_str()); {
link._name = QString::fromUtf8(detail.name.c_str()); QString invite,description;
link._location = QString::fromUtf8(detail.location.c_str()); static_cast<HomePage*>(MainWindow::getPage(MainWindow::Home))->getOwnCert(invite,description);
link._radix.replace("\n",""); link._radix = invite;
}
else
link._radix = QString::fromUtf8(rsPeers->GetRetroshareInvite(ssl_id).c_str());
std::cerr << "Found radix = " << link._radix.toStdString() << std::endl; link._name = QString::fromUtf8(detail.name.c_str());
} link._location = QString::fromUtf8(detail.location.c_str());
link._radix.replace("\n","");
link.check(); std::cerr << "Found radix = " << link._radix.toStdString() << std::endl;
}
return link; link.check();
return link;
} }
RetroShareLink RetroShareLink::createUnknownSslCertificate(const RsPeerId& sslId, const RsPgpId& gpgId) RetroShareLink RetroShareLink::createUnknownSslCertificate(const RsPeerId& sslId, const RsPgpId& gpgId)
{ {