merged upstream/master

This commit is contained in:
csoler 2018-07-05 17:41:30 +02:00
commit 0c45217fc0
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
22 changed files with 710 additions and 205 deletions

View file

@ -904,6 +904,9 @@ bool p3Peers::setHiddenNode(const RsPeerId &id, const std::string &address, uin
return true;
}
bool p3Peers::addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator)
{ return mPeerMgr->addPeerLocator(ssl_id, locator); }
bool p3Peers::setLocalAddress(const RsPeerId &id,
const std::string &addr_str, uint16_t port)
{
@ -1045,9 +1048,11 @@ bool p3Peers::setProxyServer(const uint32_t type, const std::string &addr_str, c
//===========================================================================
/* Auth Stuff */
std::string p3Peers::GetRetroshareInvite(bool include_signatures)
std::string p3Peers::GetRetroshareInvite(
bool include_signatures, bool includeExtraLocators )
{
return GetRetroshareInvite(getOwnId(),include_signatures);
return GetRetroshareInvite(
getOwnId(), include_signatures, includeExtraLocators );
}
std::string p3Peers::getPGPKey(const RsPgpId& pgp_id,bool include_signatures)
{
@ -1098,37 +1103,42 @@ bool p3Peers::GetPGPBase64StringAndCheckSum( const RsPgpId& gpg_id,
return true ;
}
std::string p3Peers::GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures)
std::string p3Peers::GetRetroshareInvite(
const RsPeerId& ssl_id, bool include_signatures,
bool includeExtraLocators )
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::GetRetroshareInvite()" << std::endl;
std::cerr << __PRETTY_FUNCTION__ << std::endl;
#endif
//add the sslid, location, ip local and external address after the signature
RsPeerDetails Detail;
std::string invite ;
RsPeerDetails detail;
std::string invite;
if (getPeerDetails(ssl_id, Detail))
if (getPeerDetails(ssl_id, detail))
{
unsigned char *mem_block = NULL;
if(!includeExtraLocators) detail.ipAddressList.clear();
unsigned char *mem_block = nullptr;
size_t mem_block_size = 0;
if(!AuthGPG::getAuthGPG()->exportPublicKey(RsPgpId(Detail.gpg_id),mem_block,mem_block_size,false,include_signatures))
if(!AuthGPG::getAuthGPG()->exportPublicKey(
RsPgpId(detail.gpg_id), mem_block, mem_block_size, false,
include_signatures ))
{
std::cerr << "Cannot output certificate for id \"" << Detail.gpg_id << "\". Sorry." << std::endl;
return "" ;
std::cerr << "Cannot output certificate for id \"" << detail.gpg_id
<< "\". Sorry." << std::endl;
return "";
}
RsCertificate cert( Detail,mem_block,mem_block_size ) ;
delete[] mem_block ;
return cert.toStdString() ;
RsCertificate cert(detail, mem_block, mem_block_size);
delete[] mem_block;
return cert.toStdString();
}
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::GetRetroshareInvite() returns : \n" << invite << std::endl;
std::cerr << __PRETTY_FUNCTION__ << " returns : \n" << invite << std::endl;
#endif
return invite;
}
@ -1148,11 +1158,12 @@ bool p3Peers::loadCertificateFromString(const std::string& cert, RsPeerId& ssl_
return res ;
}
bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetails &pd,uint32_t& error_code)
bool p3Peers::loadDetailsFromStringCert( const std::string &certstr,
RsPeerDetails &pd,
uint32_t& error_code )
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::LoadCertificateFromString() ";
std::cerr << std::endl;
std::cerr << "p3Peers::LoadCertificateFromString() " << std::endl;
#endif
//parse the text to get ip address
try
@ -1192,9 +1203,11 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
pd.localPort = cert.loc_port_us();
pd.extAddr = cert.ext_ip_string();
pd.extPort = cert.ext_port_us();
pd.dyndns = cert.dns_string() ;
pd.dyndns = cert.dns_string();
for(const RsUrl& locator : cert.locators())
pd.ipAddressList.push_back(locator.toString());
}
}
}
catch(uint32_t e)
{
std::cerr << "ConnectFriendWizard : Parse ip address error :" << e << std::endl;

View file

@ -36,6 +36,7 @@
#endif
#include "retroshare/rspeers.h"
#include "util/rsurl.h"
class p3LinkMgr;
class p3PeerMgr;
@ -96,7 +97,8 @@ public:
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port);
virtual bool isHiddenNode(const RsPeerId &id);
virtual bool setLocalAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
virtual bool addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator);
virtual bool setLocalAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
virtual bool setExtAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode);
@ -113,11 +115,15 @@ public:
/* Auth Stuff */
// Get the invitation (GPG cert + local/ext address + SSL id for the given peer)
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures);
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) ;
virtual std::string GetRetroshareInvite(
const RsPeerId& ssl_id, bool include_signatures = false,
bool includeExtraLocators = true );
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures);
// same but for own id
virtual std::string GetRetroshareInvite(bool include_signatures);
virtual std::string GetRetroshareInvite(
bool include_signatures = false,
bool includeExtraLocators = true );
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum);
virtual bool hasExportMinimal();