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);
|
return sockaddr_storage_ipv6_isValidNet(addr);
|
||||||
break;
|
break;
|
||||||
default:
|
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;
|
std::cerr << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -552,8 +552,8 @@ bool sockaddr_storage_isLoopbackNet(const struct sockaddr_storage &addr)
|
|||||||
return sockaddr_storage_ipv6_isLoopbackNet(addr);
|
return sockaddr_storage_ipv6_isLoopbackNet(addr);
|
||||||
break;
|
break;
|
||||||
default:
|
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;
|
std::cerr << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -576,8 +576,8 @@ bool sockaddr_storage_isPrivateNet(const struct sockaddr_storage &addr)
|
|||||||
return sockaddr_storage_ipv6_isPrivateNet(addr);
|
return sockaddr_storage_ipv6_isPrivateNet(addr);
|
||||||
break;
|
break;
|
||||||
default:
|
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;
|
std::cerr << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "gui/msgs/MessageComposer.h"
|
#include "gui/msgs/MessageComposer.h"
|
||||||
|
|
||||||
#include <retroshare/rsiface.h>
|
#include <retroshare/rsiface.h>
|
||||||
|
#include <retroshare/rsbanlist.h>
|
||||||
|
|
||||||
#include "ConnectProgressDialog.h"
|
#include "ConnectProgressDialog.h"
|
||||||
|
|
||||||
@ -103,7 +104,7 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent) :
|
|||||||
ui->foffRadioButton->hide();
|
ui->foffRadioButton->hide();
|
||||||
ui->rsidRadioButton->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))) ;
|
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
|
#ifdef FRIEND_WIZARD_DEBUG
|
||||||
std::cerr << "ConnectFriendWizard got id : " << peerDetails.id << "; gpg_id : " << peerDetails.gpg_id << std::endl;
|
std::cerr << "ConnectFriendWizard got id : " << peerDetails.id << "; gpg_id : " << peerDetails.gpg_id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
mCertificate = certificate.toUtf8().constData();
|
mCertificate = certificate.toUtf8().constData();
|
||||||
setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion);
|
|
||||||
} else {
|
// Cyril: I disabled this because it seems to be not used anymore.
|
||||||
|
//setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion);
|
||||||
|
setStartId(Page_Conclusion);
|
||||||
|
} else {
|
||||||
// error message
|
// error message
|
||||||
setField("errorMessage", tr("Certificate Load Failed") + ": \n\n" + getErrorString(cert_load_error_code)) ;
|
setField("errorMessage", tr("Certificate Load Failed") + ": \n\n" + getErrorString(cert_load_error_code)) ;
|
||||||
setStartId(Page_ErrorMessage);
|
setStartId(Page_ErrorMessage);
|
||||||
@ -160,7 +164,8 @@ void ConnectFriendWizard::setGpgId(const RsPgpId &gpgId, const RsPeerId &sslId,
|
|||||||
/* Set ssl id when available */
|
/* Set ssl id when available */
|
||||||
peerDetails.id = sslId;
|
peerDetails.id = sslId;
|
||||||
|
|
||||||
setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion);
|
//setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion);
|
||||||
|
setStartId(Page_Conclusion);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectFriendWizard::~ConnectFriendWizard()
|
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->_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) ;
|
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 ;
|
RsPeerDetails tmp_det ;
|
||||||
bool already_in_keyring = rsPeers->getGPGDetails(peerDetails.gpg_id, 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->addFriend(peerDetails.id, peerDetails.gpg_id,serviceFlags()) ;
|
||||||
rsPeers->setServicePermissionFlags(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)
|
if(sign)
|
||||||
{
|
{
|
||||||
std::cerr << "ConclusionPage::validatePage() signing GPG key." << std::endl;
|
std::cerr << "ConclusionPage::validatePage() signing GPG key." << std::endl;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>662</width>
|
<width>691</width>
|
||||||
<height>650</height>
|
<height>650</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -774,7 +774,7 @@
|
|||||||
<attribute name="pageId">
|
<attribute name="pageId">
|
||||||
<string notr="true">ConnectFriendWizard::Page_Conclusion</string>
|
<string notr="true">ConnectFriendWizard::Page_Conclusion</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_18">
|
<layout class="QVBoxLayout" name="verticalLayout_17">
|
||||||
<item>
|
<item>
|
||||||
<widget class="StyledLabel" name="makefriend_infolabel">
|
<widget class="StyledLabel" name="makefriend_infolabel">
|
||||||
<property name="palette">
|
<property name="palette">
|
||||||
@ -948,99 +948,108 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="addKeyToKeyring_CB">
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Add key to keyring</string>
|
<layout class="QVBoxLayout" name="verticalLayout_18">
|
||||||
</property>
|
<item>
|
||||||
</widget>
|
<widget class="QCheckBox" name="addKeyToKeyring_CB">
|
||||||
</item>
|
<property name="text">
|
||||||
<item>
|
<string>Add key to keyring</string>
|
||||||
<widget class="QCheckBox" name="acceptNoSignGPGCheckBox">
|
</property>
|
||||||
<property name="text">
|
</widget>
|
||||||
<string>Add as friend to connect with</string>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
</widget>
|
<widget class="QCheckBox" name="signGPGCheckBox">
|
||||||
</item>
|
<property name="text">
|
||||||
<item>
|
<string>Authenticate friend (Sign PGP Key)</string>
|
||||||
<widget class="QGroupBox" name="optionsFrame">
|
</property>
|
||||||
<property name="title">
|
</widget>
|
||||||
<string/>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
<widget class="QCheckBox" name="acceptNoSignGPGCheckBox">
|
||||||
<item>
|
<property name="text">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
<string>Add as friend to connect with</string>
|
||||||
<item>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_17">
|
</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>
|
<item>
|
||||||
<widget class="QCheckBox" name="signGPGCheckBox">
|
<widget class="QCheckBox" name="_direct_transfer_CB_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Authenticate friend (Sign PGP Key)</string>
|
<string>Can be used as direct source</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
<widget class="QCheckBox" name="_allow_push_CB_2">
|
||||||
<item>
|
<property name="text">
|
||||||
<widget class="QLabel" name="groupLabel">
|
<string>Auto-download recommended files</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Add friend to group:</string>
|
</widget>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="groupComboBox"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_4">
|
<widget class="QCheckBox" name="_require_WL_CB_2">
|
||||||
<property name="orientation">
|
<property name="text">
|
||||||
<enum>Qt::Vertical</enum>
|
<string>Require whitelist clearance to connect</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
</widget>
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</widget>
|
||||||
<item>
|
</item>
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
<item>
|
||||||
<property name="title">
|
<spacer name="verticalSpacer_4">
|
||||||
<string>Options</string>
|
<property name="orientation">
|
||||||
</property>
|
<enum>Qt::Vertical</enum>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
</property>
|
||||||
<item>
|
<property name="sizeHint" stdset="0">
|
||||||
<widget class="QCheckBox" name="_direct_transfer_CB_2">
|
<size>
|
||||||
<property name="text">
|
<width>38</width>
|
||||||
<string>Can be used as direct source</string>
|
<height>38</height>
|
||||||
</property>
|
</size>
|
||||||
</widget>
|
</property>
|
||||||
</item>
|
</spacer>
|
||||||
<item>
|
</item>
|
||||||
<widget class="QCheckBox" name="_allow_push_CB_2">
|
</layout>
|
||||||
<property name="text">
|
</item>
|
||||||
<string>Auto-download recommended files</string>
|
</layout>
|
||||||
</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>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -723,9 +723,10 @@ void MessageWidget::anchorClicked(const QUrl &url)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (link.type() == RetroShareLink::TYPE_CERTIFICATE && currMsgFlags & RS_MSG_USER_REQUEST) {
|
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;
|
QList<RetroShareLink> links;
|
||||||
links.append(link);
|
links.append(link);
|
||||||
|
Loading…
Reference in New Issue
Block a user