mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-22 14:10:54 -04:00
added IP whitelist to connect friend wizard. Disabled page for Friend Request, since the job can be handled by the Conclusion page just as well. If possible the duplicated code should be removed. Missing: add IP to conclusion page when coming from security item
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8342 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a8bc2d8d64
commit
25c0dfe69e
4 changed files with 145 additions and 97 deletions
|
@ -40,6 +40,7 @@
|
|||
#include "gui/msgs/MessageComposer.h"
|
||||
|
||||
#include <retroshare/rsiface.h>
|
||||
#include <retroshare/rsbanlist.h>
|
||||
|
||||
#include "ConnectProgressDialog.h"
|
||||
|
||||
|
@ -103,7 +104,7 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent) :
|
|||
ui->foffRadioButton->hide();
|
||||
ui->rsidRadioButton->hide();
|
||||
|
||||
connect(ui->acceptNoSignGPGCheckBox,SIGNAL(toggled(bool)), ui->optionsFrame,SLOT(setEnabled(bool))) ;
|
||||
connect(ui->acceptNoSignGPGCheckBox,SIGNAL(toggled(bool)), ui->_options_GB,SLOT(setEnabled(bool))) ;
|
||||
connect(ui->addKeyToKeyring_CB,SIGNAL(toggled(bool)), ui->acceptNoSignGPGCheckBox,SLOT(setChecked(bool))) ;
|
||||
}
|
||||
|
||||
|
@ -140,9 +141,12 @@ void ConnectFriendWizard::setCertificate(const QString &certificate, bool friend
|
|||
#ifdef FRIEND_WIZARD_DEBUG
|
||||
std::cerr << "ConnectFriendWizard got id : " << peerDetails.id << "; gpg_id : " << peerDetails.gpg_id << std::endl;
|
||||
#endif
|
||||
mCertificate = certificate.toUtf8().constData();
|
||||
setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion);
|
||||
} else {
|
||||
mCertificate = certificate.toUtf8().constData();
|
||||
|
||||
// Cyril: I disabled this because it seems to be not used anymore.
|
||||
//setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion);
|
||||
setStartId(Page_Conclusion);
|
||||
} else {
|
||||
// error message
|
||||
setField("errorMessage", tr("Certificate Load Failed") + ": \n\n" + getErrorString(cert_load_error_code)) ;
|
||||
setStartId(Page_ErrorMessage);
|
||||
|
@ -160,7 +164,8 @@ void ConnectFriendWizard::setGpgId(const RsPgpId &gpgId, const RsPeerId &sslId,
|
|||
/* Set ssl id when available */
|
||||
peerDetails.id = sslId;
|
||||
|
||||
setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion);
|
||||
//setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion);
|
||||
setStartId(Page_Conclusion);
|
||||
}
|
||||
|
||||
ConnectFriendWizard::~ConnectFriendWizard()
|
||||
|
@ -260,6 +265,29 @@ void ConnectFriendWizard::initializePage(int id)
|
|||
ui->_allow_push_CB_2 ->setChecked(peerDetails.service_perm_flags & RS_NODE_PERM_ALLOW_PUSH) ;
|
||||
ui->_require_WL_CB_2 ->setChecked(peerDetails.service_perm_flags & RS_NODE_PERM_REQUIRE_WL) ;
|
||||
|
||||
sockaddr_storage addr ;
|
||||
|
||||
std::cerr << "Cert IP = " << peerDetails.extAddr << std::endl;
|
||||
if(sockaddr_storage_ipv4_aton(addr,peerDetails.extAddr.c_str()) && sockaddr_storage_isValidNet(addr))
|
||||
{
|
||||
QString ipstring0 = QString::fromStdString(sockaddr_storage_iptostring(addr));
|
||||
|
||||
ui->_addIPToWhiteList_CB_2->setChecked(true) ;
|
||||
ui->_addIPToWhiteList_ComboBox_2->addItem(ipstring0) ;
|
||||
ui->_addIPToWhiteList_ComboBox_2->addItem(ipstring0+"/24") ;
|
||||
ui->_addIPToWhiteList_ComboBox_2->addItem(ipstring0+"/16") ;
|
||||
ui->_addIPToWhiteList_ComboBox_2->setEnabled(true) ;
|
||||
ui->_addIPToWhiteList_CB_2->setEnabled(true) ;
|
||||
}
|
||||
else if(ui->_require_WL_CB_2->isChecked())
|
||||
{
|
||||
ui->_addIPToWhiteList_ComboBox_2->addItem(tr("No IP in this certificate!")) ;
|
||||
ui->_addIPToWhiteList_ComboBox_2->setToolTip(tr("<p>This certificate has no IP. You will rely on discovery and DHT to find it. Because you require whitelist clearance, the peer will raise a security warning in the NewsFeed tab. From there, you can whitelist his IP.</p>")) ;
|
||||
ui->_addIPToWhiteList_ComboBox_2->setEnabled(false) ;
|
||||
ui->_addIPToWhiteList_CB_2->setChecked(false) ;
|
||||
ui->_addIPToWhiteList_CB_2->setEnabled(false) ;
|
||||
}
|
||||
|
||||
RsPeerDetails tmp_det ;
|
||||
bool already_in_keyring = rsPeers->getGPGDetails(peerDetails.gpg_id, tmp_det) ;
|
||||
|
||||
|
@ -675,6 +703,16 @@ void ConnectFriendWizard::accept()
|
|||
rsPeers->addFriend(peerDetails.id, peerDetails.gpg_id,serviceFlags()) ;
|
||||
rsPeers->setServicePermissionFlags(peerDetails.gpg_id,serviceFlags()) ;
|
||||
|
||||
if(ui->_addIPToWhiteList_CB_2->isChecked())
|
||||
{
|
||||
sockaddr_storage addr ;
|
||||
if(sockaddr_storage_ipv4_aton(addr,peerDetails.extAddr.c_str()) && sockaddr_storage_isValidNet(addr))
|
||||
{
|
||||
std::cerr << "ConclusionPage::adding IP " << sockaddr_storage_tostring(addr) << " to whitelist." << std::endl;
|
||||
rsBanList->addIpRange(addr,ui->_addIPToWhiteList_ComboBox_2->currentIndex(),RSBANLIST_TYPE_WHITELIST,std::string(tr("Added with certificate from %1").arg(ui->nameEdit->text()).toUtf8().constData()));
|
||||
}
|
||||
}
|
||||
|
||||
if(sign)
|
||||
{
|
||||
std::cerr << "ConclusionPage::validatePage() signing GPG key." << std::endl;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue