mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 22:25:04 -04:00
Merge remote-tracking branch 'upstream/master' into v0.6-CacheTests
This commit is contained in:
commit
a6010beab3
51 changed files with 1382 additions and 785 deletions
|
@ -258,8 +258,7 @@ int p3discovery2::handleIncoming()
|
|||
|
||||
++nhandled;
|
||||
|
||||
Dbg4() << __PRETTY_FUNCTION__ << " Received item: " << std::endl
|
||||
<< *item << std::endl;
|
||||
Dbg4() << __PRETTY_FUNCTION__ << " Received item: " << *item << std::endl;
|
||||
|
||||
if((contact = dynamic_cast<RsDiscContactItem *>(item)) != nullptr)
|
||||
{
|
||||
|
@ -269,30 +268,26 @@ int p3discovery2::handleIncoming()
|
|||
processContactInfo(item->PeerId(), contact);
|
||||
}
|
||||
else if( (gxsidlst = dynamic_cast<RsDiscIdentityListItem *>(item)) != nullptr )
|
||||
{
|
||||
recvIdentityList(item->PeerId(),gxsidlst->ownIdentityList);
|
||||
delete item;
|
||||
}
|
||||
else if((pgpkey = dynamic_cast<RsDiscPgpKeyItem *>(item)) != nullptr)
|
||||
recvPGPCertificate(item->PeerId(), pgpkey);
|
||||
else if((pgpcert = dynamic_cast<RsDiscPgpCertItem *>(item)) != nullptr)
|
||||
// sink
|
||||
delete pgpcert;
|
||||
RsWarn() << "Received a deprecated RsDiscPgpCertItem. Will not be handled." << std::endl; // nothing to do.
|
||||
else if((pgplist = dynamic_cast<RsDiscPgpListItem *>(item)) != nullptr)
|
||||
{
|
||||
if (pgplist->mode == RsGossipDiscoveryPgpListMode::FRIENDS)
|
||||
processPGPList(pgplist->PeerId(), pgplist);
|
||||
else if (pgplist->mode == RsGossipDiscoveryPgpListMode::GETCERT)
|
||||
recvPGPCertificateRequest(pgplist->PeerId(), pgplist);
|
||||
else delete item;
|
||||
}
|
||||
else
|
||||
{
|
||||
RsWarn() << __PRETTY_FUNCTION__ << " Received unknown item type " << (int)item->PacketSubType() << "! " << std::endl ;
|
||||
RsWarn() << item << std::endl;
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
delete item;
|
||||
}
|
||||
|
||||
return nhandled;
|
||||
}
|
||||
|
@ -350,8 +345,6 @@ void p3discovery2::sendOwnContactInfo(const RsPeerId &sslid)
|
|||
|
||||
void p3discovery2::recvOwnContactInfo(const RsPeerId &fromId, const RsDiscContactItem *item)
|
||||
{
|
||||
std::unique_ptr<const RsDiscContactItem> pitem(item); // ensures that item will be destroyed whichever door we leave through
|
||||
|
||||
#ifdef P3DISC_DEBUG
|
||||
std::cerr << "p3discovery2::recvOwnContactInfo()";
|
||||
std::cerr << std::endl;
|
||||
|
@ -678,7 +671,6 @@ void p3discovery2::processPGPList(const RsPeerId &fromId, const RsDiscPgpListIte
|
|||
#endif
|
||||
|
||||
// cleanup.
|
||||
delete item;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -716,9 +708,6 @@ void p3discovery2::processPGPList(const RsPeerId &fromId, const RsDiscPgpListIte
|
|||
|
||||
it->second.mergeFriendList(item->pgpIdSet.ids);
|
||||
updatePeers_locked(fromId);
|
||||
|
||||
// cleanup.
|
||||
delete item;
|
||||
}
|
||||
|
||||
|
||||
|
@ -913,7 +902,6 @@ void p3discovery2::processContactInfo(const RsPeerId &fromId, const RsDiscContac
|
|||
if(sockaddr_storage_isExternalNet(item->currentConnectAddress.addr))
|
||||
mPeerMgr->addCandidateForOwnExternalAddress(item->PeerId(), item->currentConnectAddress.addr);
|
||||
|
||||
delete item;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -942,7 +930,6 @@ void p3discovery2::processContactInfo(const RsPeerId &fromId, const RsDiscContac
|
|||
/* inform NetMgr that we know this peer */
|
||||
mNetMgr->netAssistKnownPeer(item->sslId, item->extAddrV4.addr, NETASSIST_KNOWN_PEER_FOF | NETASSIST_KNOWN_PEER_OFFLINE);
|
||||
}
|
||||
delete item;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -991,8 +978,6 @@ void p3discovery2::processContactInfo(const RsPeerId &fromId, const RsDiscContac
|
|||
|
||||
if(should_notify_discovery)
|
||||
RsServer::notify()->notifyDiscInfoChanged();
|
||||
|
||||
delete item;
|
||||
}
|
||||
|
||||
/* we explictly request certificates, instead of getting them all the time
|
||||
|
@ -1041,8 +1026,6 @@ void p3discovery2::recvPGPCertificateRequest( const RsPeerId& fromId, const RsDi
|
|||
sendPGPCertificate(pgpId, fromId);
|
||||
else
|
||||
std::cerr << "(WW) not sending certificate " << pgpId << " asked by friend " << fromId << " because this either this cert is not a friend, or discovery is off" << std::endl;
|
||||
|
||||
delete item;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1119,7 +1102,6 @@ void p3discovery2::recvPGPCertificate(const RsPeerId& fromId, RsDiscPgpKeyItem*
|
|||
#endif
|
||||
// now that will add the key *and* set the skip_signature_validation flag at once
|
||||
rsPeers->loadPgpKeyFromBinaryData((unsigned char*)item->bin_data,item->bin_len, tmp_pgp_id,error_string); // no error should occur at this point because we called loadDetailsFromStringCert() already
|
||||
delete item;
|
||||
|
||||
// Make sure we allow connections after the key is added. This is not the case otherwise. We only do that if the peer is non validated peer, since
|
||||
// otherwise the connection should already be accepted. This only happens when the short invite peer sends its own PGP key.
|
||||
|
|
|
@ -121,9 +121,9 @@ class p3GxsTunnelService: public RsGxsTunnelService, public RsTurtleClientServic
|
|||
{
|
||||
public:
|
||||
explicit p3GxsTunnelService(RsGixs *pids) ;
|
||||
virtual void connectToTurtleRouter(p3turtle *) ;
|
||||
virtual void connectToTurtleRouter(p3turtle *) override;
|
||||
|
||||
uint16_t serviceId() const { return RS_SERVICE_TYPE_GXS_TUNNEL ; }
|
||||
uint16_t serviceId() const override { return RS_SERVICE_TYPE_GXS_TUNNEL ; }
|
||||
|
||||
// Creates the invite if the public key of the distant peer is available.
|
||||
// Om success, stores the invite in the map above, so that we can respond to tunnel requests.
|
||||
|
@ -137,8 +137,8 @@ public:
|
|||
|
||||
// derived from p3service
|
||||
|
||||
virtual int tick();
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
virtual int tick() override;
|
||||
virtual RsServiceInfo getServiceInfo() override;
|
||||
|
||||
private:
|
||||
void flush() ;
|
||||
|
@ -147,19 +147,19 @@ private:
|
|||
class GxsTunnelPeerInfo
|
||||
{
|
||||
public:
|
||||
GxsTunnelPeerInfo() : last_contact(0), last_keep_alive_sent(0), status(0), direction(0)
|
||||
#ifndef V07_NON_BACKWARD_COMPATIBLE_CHANGE_004
|
||||
,accepts_fast_turtle_items(false)
|
||||
#endif
|
||||
GxsTunnelPeerInfo()
|
||||
: last_contact(0), last_keep_alive_sent(0), status(0), direction(0)
|
||||
, total_sent(0), total_received(0)
|
||||
#ifndef V07_NON_BACKWARD_COMPATIBLE_CHANGE_004
|
||||
, accepts_fast_turtle_items(false)
|
||||
, already_probed_for_fast_items(false)
|
||||
#endif
|
||||
{
|
||||
memset(aes_key, 0, GXS_TUNNEL_AES_KEY_SIZE);
|
||||
|
||||
total_sent = 0 ;
|
||||
total_received = 0 ;
|
||||
}
|
||||
|
||||
rstime_t last_contact ; // used to keep track of working connexion
|
||||
rstime_t last_keep_alive_sent ; // last time we sent a keep alive packet.
|
||||
rstime_t last_keep_alive_sent ; // last time we sent a keep alive packet.
|
||||
|
||||
unsigned char aes_key[GXS_TUNNEL_AES_KEY_SIZE] ;
|
||||
|
||||
|
@ -213,10 +213,10 @@ private:
|
|||
|
||||
// Overloaded from RsTurtleClientService
|
||||
|
||||
virtual bool handleTunnelRequest(const RsFileHash &hash,const RsPeerId& peer_id) ;
|
||||
virtual void receiveTurtleData(const RsTurtleGenericTunnelItem *item,const RsFileHash& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ;
|
||||
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) ;
|
||||
void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) ;
|
||||
virtual bool handleTunnelRequest(const RsFileHash &hash,const RsPeerId& peer_id) override;
|
||||
virtual void receiveTurtleData(const RsTurtleGenericTunnelItem *item,const RsFileHash& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) override;
|
||||
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) override;
|
||||
void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) override;
|
||||
|
||||
// session handling handles
|
||||
|
||||
|
|
|
@ -1864,6 +1864,8 @@ bool PGPHandler::locked_writePrivateTrustDatabase()
|
|||
return false;
|
||||
}
|
||||
PrivateTrustPacket trustpacket ;
|
||||
/* Clear PrivateTrustPacket struct to suppress valgrind warnings due to the compiler extra padding*/
|
||||
memset(&trustpacket, 0, sizeof(PrivateTrustPacket));
|
||||
|
||||
for( std::map<RsPgpId,PGPCertificateInfo>::iterator it =
|
||||
_public_keyring_map.begin(); it!=_public_keyring_map.end(); ++it )
|
||||
|
|
|
@ -1238,14 +1238,6 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
|
|||
|
||||
RsErr() << __PRETTY_FUNCTION__ << " " << errMsg << std::endl;
|
||||
|
||||
// if(rsEvents)
|
||||
// {
|
||||
// ev->mErrorMsg = errMsg;
|
||||
// ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::NO_CERTIFICATE_SUPPLIED;
|
||||
//
|
||||
// rsEvents->postEvent(std::move(ev));
|
||||
// }
|
||||
|
||||
return verificationFailed;
|
||||
}
|
||||
|
||||
|
@ -1400,8 +1392,7 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
|
|||
return verificationFailed;
|
||||
}
|
||||
|
||||
//setCurrentConnectionAttemptInfo(pgpId, sslId, sslCn);
|
||||
LocalStoreCert(x509Cert);
|
||||
LocalStoreCert(x509Cert);
|
||||
|
||||
RsInfo() << __PRETTY_FUNCTION__ << " authentication successfull for "
|
||||
<< "sslId: " << sslId << " isSslOnlyFriend: " << isSslOnlyFriend
|
||||
|
@ -1410,9 +1401,7 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
|
|||
return verificationSuccess;
|
||||
}
|
||||
|
||||
bool AuthSSLimpl::parseX509DetailsFromFile(
|
||||
const std::string& certFilePath, RsPeerId& certId,
|
||||
RsPgpId& issuer, std::string& location )
|
||||
bool AuthSSLimpl::parseX509DetailsFromFile( const std::string& certFilePath, RsPeerId& certId, RsPgpId& issuer, std::string& location )
|
||||
{
|
||||
FILE* tmpfp = RsDirUtil::rs_fopen(certFilePath.c_str(), "r");
|
||||
if(!tmpfp)
|
||||
|
@ -1433,11 +1422,14 @@ bool AuthSSLimpl::parseX509DetailsFromFile(
|
|||
}
|
||||
|
||||
uint32_t diagnostic = 0;
|
||||
|
||||
if(!AuthX509WithGPG(x509,false, diagnostic))
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__ << " AuthX509WithGPG failed with "
|
||||
<< "diagnostic: " << diagnostic << std::endl;
|
||||
return false;
|
||||
|
||||
X509_free(x509);
|
||||
return false;
|
||||
}
|
||||
|
||||
certId = RsX509Cert::getCertSslId(*x509);
|
||||
|
@ -1805,26 +1797,28 @@ bool AuthSSLimpl::loadList(std::list<RsItem*>& load)
|
|||
for(it = load.begin(); it != load.end(); ++it) {
|
||||
RsConfigKeyValueSet *vitem = dynamic_cast<RsConfigKeyValueSet *>(*it);
|
||||
|
||||
if(vitem) {
|
||||
#ifdef AUTHSSL_DEBUG
|
||||
if(vitem)
|
||||
{
|
||||
#ifdef AUTHSSL_DEBUG
|
||||
std::cerr << "AuthSSLimpl::loadList() General Variable Config Item:" << std::endl;
|
||||
vitem->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
std::list<RsTlvKeyValue>::iterator kit;
|
||||
for(kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); ++kit) {
|
||||
if (RsPeerId(kit->key) == mOwnId) {
|
||||
continue;
|
||||
}
|
||||
for(kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); ++kit)
|
||||
{
|
||||
if (RsPeerId(kit->key) == mOwnId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
X509 *peer = loadX509FromPEM(kit->value);
|
||||
/* authenticate it */
|
||||
uint32_t diagnos ;
|
||||
if (AuthX509WithGPG(peer,false,diagnos))
|
||||
{
|
||||
LocalStoreCert(peer);
|
||||
}
|
||||
X509 *peer = loadX509FromPEM(kit->value);
|
||||
/* authenticate it */
|
||||
uint32_t diagnos ;
|
||||
if (peer && AuthX509WithGPG(peer,false,diagnos))
|
||||
LocalStoreCert(peer);
|
||||
|
||||
X509_free(peer);
|
||||
}
|
||||
}
|
||||
delete (*it);
|
||||
|
|
|
@ -2206,7 +2206,7 @@ bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
|
|||
|
||||
if( status == GxsTransSendStatus::RECEIPT_RECEIVED )
|
||||
{
|
||||
pEvent->mMailStatusEventCode = RsMailStatusEventCode::NEW_MESSAGE;
|
||||
pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_RECEIVED_ACK;
|
||||
uint32_t msg_id;
|
||||
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue