mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -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
@ -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,8 +552,8 @@ 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 << std::endl;
|
||||
std::cerr << "sockaddr_storage_isLoopbackNet() INVALID Family - error: " << sockaddr_storage_iptostring(addr);
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
@ -576,8 +576,8 @@ 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 << std::endl;
|
||||
std::cerr << "sockaddr_storage_isPrivateNet() INVALID Family - error: " << sockaddr_storage_iptostring(addr);
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
@ -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;
|
||||
|
@ -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">
|
||||
@ -948,99 +948,108 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="addKeyToKeyring_CB">
|
||||
<property name="text">
|
||||
<string>Add key to keyring</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="acceptNoSignGPGCheckBox">
|
||||
<property name="text">
|
||||
<string>Add as friend to connect with</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="optionsFrame">
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_17">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_18">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="addKeyToKeyring_CB">
|
||||
<property name="text">
|
||||
<string>Add key to keyring</string>
|
||||
</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">
|
||||
<string>Add as friend to connect with</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="_addIPToWhiteList_CB_2">
|
||||
<property name="text">
|
||||
<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>
|
||||
<widget class="QLabel" name="groupLabel">
|
||||
<property name="text">
|
||||
<string>Add friend to group:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="groupComboBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_19">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="_options_GB">
|
||||
<property name="title">
|
||||
<string>Options</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="signGPGCheckBox">
|
||||
<widget class="QCheckBox" name="_direct_transfer_CB_2">
|
||||
<property name="text">
|
||||
<string>Authenticate friend (Sign PGP Key)</string>
|
||||
<string>Can be used as direct source</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<item>
|
||||
<widget class="QLabel" name="groupLabel">
|
||||
<property name="text">
|
||||
<string>Add friend to group:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="groupComboBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QCheckBox" name="_allow_push_CB_2">
|
||||
<property name="text">
|
||||
<string>Auto-download recommended files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<widget class="QCheckBox" name="_require_WL_CB_2">
|
||||
<property name="text">
|
||||
<string>Require whitelist clearance to connect</string>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Options</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="_direct_transfer_CB_2">
|
||||
<property name="text">
|
||||
<string>Can be used as direct source</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="_allow_push_CB_2">
|
||||
<property name="text">
|
||||
<string>Auto-download recommended files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="_require_WL_CB_2">
|
||||
<property name="text">
|
||||
<string>Require whitelist clearance to connect</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</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>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -723,9 +723,10 @@ void MessageWidget::anchorClicked(const QUrl &url)
|
||||
return;
|
||||
}
|
||||
|
||||
if (link.type() == RetroShareLink::TYPE_CERTIFICATE && currMsgFlags & RS_MSG_USER_REQUEST) {
|
||||
link.setSubType(RSLINK_SUBTYPE_CERTIFICATE_USER_REQUEST);
|
||||
}
|
||||
if (link.type() == RetroShareLink::TYPE_CERTIFICATE && currMsgFlags & RS_MSG_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;
|
||||
links.append(link);
|
||||
|
Loading…
Reference in New Issue
Block a user