mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 23:36:59 -05:00
fixed up addign friend from short invite
This commit is contained in:
parent
4bd5aaa9b2
commit
fb52f6717c
@ -1571,6 +1571,11 @@ void PGPHandler::locked_updateOwnSignatureFlag(PGPCertificateInfo& cert,const Rs
|
||||
cert._flags &= ~PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_SIGNED_ME ;
|
||||
}
|
||||
|
||||
RsPgpId PGPHandler::pgpIdFromFingerprint(const PGPFingerprintType& f)
|
||||
{
|
||||
return RsPgpId(f.toByteArray() + _RsIdSize::PGP_FINGERPRINT - _RsIdSize::PGP_ID);
|
||||
}
|
||||
|
||||
bool PGPHandler::getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const
|
||||
{
|
||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||
|
@ -153,6 +153,7 @@ class PGPHandler
|
||||
|
||||
static void setPassphraseCallback(PassphraseCallback cb) ;
|
||||
static PassphraseCallback passphraseCallback() { return _passphrase_callback ; }
|
||||
static RsPgpId pgpIdFromFingerprint(const PGPFingerprintType& f) ;
|
||||
|
||||
// Gets info about the key. Who are the signers, what's the owner's name, etc.
|
||||
//
|
||||
|
@ -1065,7 +1065,7 @@ bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg
|
||||
}
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::addSslOnlyFriend( const RsPeerId& sslId, const RsPeerDetails& dt )
|
||||
bool p3PeerMgrIMPL::addSslOnlyFriend( const RsPeerId& sslId, const RsPgpId& pgp_id,const RsPeerDetails& dt )
|
||||
{
|
||||
if(sslId.isNull() || sslId == getOwnId())
|
||||
{
|
||||
@ -1095,7 +1095,13 @@ bool p3PeerMgrIMPL::addSslOnlyFriend( const RsPeerId& sslId, const RsPeerDetails
|
||||
return false;
|
||||
}
|
||||
|
||||
pstate.gpg_id.clear();
|
||||
if(pgp_id.isNull())
|
||||
{
|
||||
RsErr() << "Null pgp id for friend added with skip_pgp_signature_validaiton flag. This is not allowed." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
pstate.gpg_id = pgp_id;
|
||||
pstate.id = sslId;
|
||||
|
||||
if(!dt.name.empty()) pstate.name = dt.name;
|
||||
@ -2460,14 +2466,19 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
||||
#endif
|
||||
/* ************* */
|
||||
// permission flags is used as a mask for the existing perms, so we set it to 0xffff
|
||||
if(!addFriend( peer_id, peer_pgp_id, pitem->netMode,
|
||||
pitem->vs_disc, pitem->vs_dht,
|
||||
pitem->lastContact, RS_NODE_PERM_ALL ))
|
||||
|
||||
RsPeerDetails det ;
|
||||
if(!rsPeers->getGPGDetails(peer_pgp_id,det))
|
||||
{
|
||||
// would be better to add flags into RsPeerNetItem so that we already have this information. However, it's possible that the PGP key
|
||||
// has been added in the meantime, so the peer would be loaded with the right pGP key attached.
|
||||
|
||||
RsInfo() << __PRETTY_FUNCTION__ << " loading SSL-only " << "friend: " << peer_id << " " << pitem->location << std::endl;
|
||||
addSslOnlyFriend(peer_id,peer_pgp_id);
|
||||
}
|
||||
else if(!addFriend( peer_id, peer_pgp_id, pitem->netMode, pitem->vs_disc, pitem->vs_dht, pitem->lastContact, RS_NODE_PERM_ALL ))
|
||||
{
|
||||
RsInfo() << __PRETTY_FUNCTION__ << " loading SSL-only "
|
||||
<< "friend: " << peer_id << " " << pitem->location
|
||||
<< std::endl;
|
||||
addSslOnlyFriend(peer_id);
|
||||
RsInfo() << __PRETTY_FUNCTION__ << " cannot add friend friend: " << peer_id << " " << pitem->location << ". Somthing's wrong." << std::endl;
|
||||
}
|
||||
setLocation(pitem->nodePeerId, pitem->location);
|
||||
}
|
||||
|
@ -137,6 +137,7 @@ public:
|
||||
|
||||
virtual bool addSslOnlyFriend(
|
||||
const RsPeerId& sslId,
|
||||
const RsPgpId& pgpId,
|
||||
const RsPeerDetails& details = RsPeerDetails() ) = 0;
|
||||
|
||||
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId) = 0;
|
||||
@ -256,9 +257,7 @@ public:
|
||||
uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL,
|
||||
rstime_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT));
|
||||
|
||||
bool addSslOnlyFriend(
|
||||
const RsPeerId& sslId,
|
||||
const RsPeerDetails& details = RsPeerDetails() ) override;
|
||||
bool addSslOnlyFriend(const RsPeerId& sslId, const RsPgpId &pgp_id, const RsPeerDetails& details = RsPeerDetails() ) override;
|
||||
|
||||
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId);
|
||||
virtual bool removeFriend(const RsPgpId &pgp_id);
|
||||
|
@ -205,6 +205,14 @@ std::string RsPeerNetModeString(uint32_t netModel);
|
||||
std::string RsPeerLastConnectString(uint32_t lastConnect);
|
||||
|
||||
|
||||
/* We should definitely split this into 2 sub-structures:
|
||||
* PGP info (or profile info) with all info related to PGP keys
|
||||
* peer info: all network related information
|
||||
*
|
||||
* Plus top level information:
|
||||
* isOnlyPgpDetail (this could be obsolete if the methods to query about PGP info is a different function)
|
||||
* peer Id
|
||||
*/
|
||||
struct RsPeerDetails : RsSerializable
|
||||
{
|
||||
RsPeerDetails();
|
||||
@ -228,6 +236,7 @@ struct RsPeerDetails : RsSerializable
|
||||
uint32_t trustLvl;
|
||||
uint32_t validLvl;
|
||||
|
||||
bool skip_signature_validation;
|
||||
bool ownsign; /* we have signed the remote peer GPG key */
|
||||
bool hasSignedMe; /* the remote peer has signed my GPG key */
|
||||
|
||||
@ -519,6 +528,7 @@ public:
|
||||
*/
|
||||
virtual bool addSslOnlyFriend(
|
||||
const RsPeerId& sslId,
|
||||
const RsPgpId& pgp_id,
|
||||
const RsPeerDetails& details = RsPeerDetails() ) = 0;
|
||||
|
||||
/**
|
||||
|
@ -765,9 +765,10 @@ bool p3Peers::addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePe
|
||||
return mPeerMgr->addFriend(ssl_id, gpg_id, RS_NET_MODE_UDP, RS_VS_DISC_FULL, RS_VS_DHT_FULL, now, perm_flags);
|
||||
}
|
||||
|
||||
bool p3Peers::addSslOnlyFriend(
|
||||
const RsPeerId& sslId, const RsPeerDetails& details )
|
||||
{ return mPeerMgr->addSslOnlyFriend(sslId, details); }
|
||||
bool p3Peers::addSslOnlyFriend( const RsPeerId& sslId, const RsPgpId& pgp_id,const RsPeerDetails& details )
|
||||
{
|
||||
return mPeerMgr->addSslOnlyFriend(sslId, pgp_id,details);
|
||||
}
|
||||
|
||||
bool p3Peers::removeKeysFromPGPKeyring(const std::set<RsPgpId>& pgp_ids,std::string& backup_file,uint32_t& error_code)
|
||||
{
|
||||
@ -1241,8 +1242,7 @@ bool p3Peers::parseShortInvite(const std::string& inviteStrUrl, RsPeerDetails& d
|
||||
rsInvite = inviteUrl.getQueryV("rsInvite");
|
||||
|
||||
std::vector<uint8_t> inviteBuf = Radix64::decode(*rsInvite);
|
||||
RsGenericSerializer::SerializeContext ctx(
|
||||
inviteBuf.data(), static_cast<uint32_t>(inviteBuf.size()));
|
||||
RsGenericSerializer::SerializeContext ctx( inviteBuf.data(), static_cast<uint32_t>(inviteBuf.size()));
|
||||
RsGenericSerializer::SerializeJob j = RsGenericSerializer::DESERIALIZE;
|
||||
|
||||
while(ctx.mOk && ctx.mOffset < ctx.mSize)
|
||||
@ -1346,6 +1346,20 @@ bool p3Peers::parseShortInvite(const std::string& inviteStrUrl, RsPeerDetails& d
|
||||
}
|
||||
}
|
||||
|
||||
// now check if the PGP key is available. If so, add it in the PeerDetails:
|
||||
|
||||
RsPeerDetails pgp_det ;
|
||||
if(getGPGDetails(PGPHandler::pgpIdFromFingerprint(details.fpr),pgp_det) && pgp_det.fpr == details.fpr)
|
||||
{
|
||||
details.issuer = pgp_det.issuer;
|
||||
details.gpg_id = pgp_det.gpg_id;
|
||||
details.gpgSigners = pgp_det.gpgSigners;
|
||||
details.trustLvl = pgp_det.trustLvl;
|
||||
details.validLvl = pgp_det.validLvl;
|
||||
details.ownsign = pgp_det.ownsign;
|
||||
details.hasSignedMe = pgp_det.hasSignedMe;
|
||||
details.accept_connection = pgp_det.accept_connection;
|
||||
}
|
||||
|
||||
return ctx.mOk;
|
||||
}
|
||||
@ -1730,7 +1744,7 @@ RsPeerDetails::RsPeerDetails()
|
||||
:isOnlyGPGdetail(false),
|
||||
name(""),email(""),location(""),
|
||||
org(""),authcode(""),
|
||||
trustLvl(0), validLvl(0),ownsign(false),
|
||||
trustLvl(0), validLvl(0),skip_signature_validation(false),ownsign(false),
|
||||
hasSignedMe(false),accept_connection(false),
|
||||
state(0),actAsServer(false),
|
||||
connectPort(0),
|
||||
|
@ -97,6 +97,7 @@ public:
|
||||
/// @see RsPeers
|
||||
bool addSslOnlyFriend(
|
||||
const RsPeerId& sslId,
|
||||
const RsPgpId& pgp_id,
|
||||
const RsPeerDetails& details = RsPeerDetails() ) override;
|
||||
|
||||
virtual bool removeFriend(const RsPgpId& gpgid);
|
||||
|
@ -922,7 +922,7 @@ void ConnectFriendWizard::accept()
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mCertificate.empty() && add_key_to_keyring)
|
||||
if(!peerDetails.skip_signature_validation && !mCertificate.empty() && add_key_to_keyring)
|
||||
{
|
||||
RsPgpId pgp_id ;
|
||||
RsPeerId ssl_id ;
|
||||
@ -940,28 +940,33 @@ void ConnectFriendWizard::accept()
|
||||
if(accept_connection && !peerDetails.gpg_id.isNull())
|
||||
{
|
||||
std::cerr << "ConclusionPage::validatePage() accepting GPG key for connection." << std::endl;
|
||||
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(peerDetails.skip_signature_validation)
|
||||
rsPeers->addSslOnlyFriend(peerDetails.id, peerDetails.gpg_id,peerDetails);
|
||||
else
|
||||
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;
|
||||
rsPeers->signGPGCertificate(peerDetails.gpg_id); //bye default sign set accept_connection to true;
|
||||
rsPeers->setServicePermissionFlags(peerDetails.gpg_id,serviceFlags()) ;
|
||||
}
|
||||
}
|
||||
|
||||
if (!groupId.isEmpty())
|
||||
rsPeers->assignPeerToGroup(RsNodeGroupId(groupId.toStdString()), peerDetails.gpg_id, true);
|
||||
if (!groupId.isEmpty())
|
||||
rsPeers->assignPeerToGroup(RsNodeGroupId(groupId.toStdString()), peerDetails.gpg_id, true);
|
||||
}
|
||||
|
||||
if ((accept_connection) && (!peerDetails.id.isNull()))
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
<width>1100</width>
|
||||
<height>604</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -45,7 +45,7 @@
|
||||
<item>
|
||||
<widget class="QRadioButton" name="foffRadioButton">
|
||||
<property name="text">
|
||||
<string>&Make friend with selected friends of my friends</string>
|
||||
<string>Ma&ke friend with selected friends of my friends</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -59,7 +59,7 @@
|
||||
<item>
|
||||
<widget class="QRadioButton" name="webmailRadioButton">
|
||||
<property name="text">
|
||||
<string>&Send an Invitation by Web Mail Providers</string>
|
||||
<string>Send an In&vitation by Web Mail Providers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -1502,6 +1502,12 @@
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AvatarWidget</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>gui/common/AvatarWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>StyledLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
@ -1513,12 +1519,6 @@
|
||||
<header>gui/common/FriendSelectionWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AvatarWidget</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>gui/common/AvatarWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>DropLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
@ -1537,8 +1537,8 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../icons.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../icons.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
x
Reference in New Issue
Block a user