mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 13:24:15 -05: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
@ -529,7 +529,7 @@ bool sockaddr_storage_isValidNet(const struct sockaddr_storage &addr)
|
||||
return sockaddr_storage_ipv6_isValidNet(addr);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "sockaddr_storage_isValidNet() INVALID Family - error";
|
||||
std::cerr << "sockaddr_storage_isValidNet() INVALID Family - error: " << sockaddr_storage_iptostring(addr);
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
@ -552,7 +552,7 @@ bool sockaddr_storage_isLoopbackNet(const struct sockaddr_storage &addr)
|
||||
return sockaddr_storage_ipv6_isLoopbackNet(addr);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "sockaddr_storage_isLoopbackNet() INVALID Family - error";
|
||||
std::cerr << "sockaddr_storage_isLoopbackNet() INVALID Family - error: " << sockaddr_storage_iptostring(addr);
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
@ -576,7 +576,7 @@ bool sockaddr_storage_isPrivateNet(const struct sockaddr_storage &addr)
|
||||
return sockaddr_storage_ipv6_isPrivateNet(addr);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "sockaddr_storage_isPrivateNet() INVALID Family - error";
|
||||
std::cerr << "sockaddr_storage_isPrivateNet() INVALID Family - error: " << sockaddr_storage_iptostring(addr);
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
|
@ -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))) ;
|
||||
}
|
||||
|
||||
@ -141,7 +142,10 @@ void ConnectFriendWizard::setCertificate(const QString &certificate, bool friend
|
||||
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);
|
||||
|
||||
// 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)) ;
|
||||
@ -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;
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>662</width>
|
||||
<width>691</width>
|
||||
<height>650</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -774,7 +774,7 @@
|
||||
<attribute name="pageId">
|
||||
<string notr="true">ConnectFriendWizard::Page_Conclusion</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_18">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_17">
|
||||
<item>
|
||||
<widget class="StyledLabel" name="makefriend_infolabel">
|
||||
<property name="palette">
|
||||
@ -947,6 +947,10 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_18">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="addKeyToKeyring_CB">
|
||||
<property name="text">
|
||||
@ -954,6 +958,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="signGPGCheckBox">
|
||||
<property name="text">
|
||||
<string>Authenticate friend (Sign PGP Key)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="acceptNoSignGPGCheckBox">
|
||||
<property name="text">
|
||||
@ -962,22 +973,19 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="optionsFrame">
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_17">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="signGPGCheckBox">
|
||||
<widget class="QCheckBox" name="_addIPToWhiteList_CB_2">
|
||||
<property name="text">
|
||||
<string>Authenticate friend (Sign PGP Key)</string>
|
||||
<string>Add IP to whitelist</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="_addIPToWhiteList_ComboBox_2"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<item>
|
||||
@ -992,23 +1000,12 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_19">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="_options_GB">
|
||||
<property name="title">
|
||||
<string>Options</string>
|
||||
</property>
|
||||
@ -1037,10 +1034,22 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>38</width>
|
||||
<height>38</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -724,7 +724,8 @@ void MessageWidget::anchorClicked(const QUrl &url)
|
||||
}
|
||||
|
||||
if (link.type() == RetroShareLink::TYPE_CERTIFICATE && currMsgFlags & RS_MSG_USER_REQUEST) {
|
||||
link.setSubType(RSLINK_SUBTYPE_CERTIFICATE_USER_REQUEST);
|
||||
std::cerr << "(WW) Calling some disabled code in MessageWidget::anchorClicked(). Please contact the developpers." << std::endl;
|
||||
// link.setSubType(RSLINK_SUBTYPE_CERTIFICATE_USER_REQUEST);
|
||||
}
|
||||
|
||||
QList<RetroShareLink> links;
|
||||
|
Loading…
x
Reference in New Issue
Block a user