mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-07 08:35:16 -04:00
added parsing of short invites in connect friend wizard (not working yet)
This commit is contained in:
parent
3a799bae37
commit
4bd5aaa9b2
6 changed files with 69 additions and 24 deletions
|
@ -552,14 +552,22 @@ unsigned short RsCertificate::loc_port_us() const
|
|||
return (int)ipv4_internal_ip_and_port[4]*256 + (int)ipv4_internal_ip_and_port[5] ;
|
||||
}
|
||||
|
||||
bool RsCertificate::cleanCertificate(
|
||||
const std::string& input, std::string& output, Format& format,
|
||||
int& error_code, bool check_content )
|
||||
bool RsCertificate::cleanCertificate( const std::string& input, std::string& output, Format& format, int& error_code, bool check_content )
|
||||
{
|
||||
if(cleanCertificate(input,output,error_code))
|
||||
if(cleanRadix64(input,output,error_code))
|
||||
{
|
||||
RsPeerDetails details;
|
||||
|
||||
if(rsPeers->parseShortInvite(output,details))
|
||||
{
|
||||
format = RS_CERTIFICATE_SHORT_RADIX;
|
||||
return true;
|
||||
}
|
||||
|
||||
format = RS_CERTIFICATE_RADIX;
|
||||
|
||||
if(!check_content) return true;
|
||||
|
||||
uint32_t errCode;
|
||||
auto crt = RsCertificate::fromString(input, errCode);
|
||||
error_code = static_cast<int>(errCode);
|
||||
|
@ -576,7 +584,7 @@ std::string RsCertificate::armouredPGPKey() const
|
|||
|
||||
// Yeah, this is simple, and that is what's good about the radix format. Can't be broken ;-)
|
||||
//
|
||||
bool RsCertificate::cleanCertificate(const std::string& instr,std::string& str,int& error_code)
|
||||
bool RsCertificate::cleanRadix64(const std::string& instr,std::string& str,int& error_code)
|
||||
{
|
||||
error_code = RS_PEER_CERT_CLEANING_CODE_NO_ERROR ;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ struct RsPeerDetails;
|
|||
class RsCertificate
|
||||
{
|
||||
public:
|
||||
typedef enum { RS_CERTIFICATE_OLD_FORMAT, RS_CERTIFICATE_RADIX } Format;
|
||||
typedef enum { RS_CERTIFICATE_OLD_FORMAT, RS_CERTIFICATE_RADIX, RS_CERTIFICATE_SHORT_RADIX } Format;
|
||||
|
||||
/**
|
||||
* @brief Create certificate object from certificate string
|
||||
|
@ -99,8 +99,7 @@ public:
|
|||
|
||||
private:
|
||||
// new radix format
|
||||
static bool cleanCertificate( const std::string& input,
|
||||
std::string& output, int&);
|
||||
static bool cleanRadix64( const std::string& input, std::string& output, int&);
|
||||
|
||||
static void scan_ip( const std::string& ip_string, unsigned short port,
|
||||
unsigned char *destination_memory );
|
||||
|
|
|
@ -717,7 +717,7 @@ public:
|
|||
uint32_t& errorCode ) = 0;
|
||||
|
||||
// Certificate utils
|
||||
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code) = 0;
|
||||
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,bool& is_short_format,int& error_code) = 0;
|
||||
virtual bool saveCertificateToFile(const RsPeerId& id, const std::string &fname) = 0;
|
||||
virtual std::string saveCertificateToString(const RsPeerId &id) = 0;
|
||||
|
||||
|
|
|
@ -1536,11 +1536,20 @@ bool p3Peers::loadDetailsFromStringCert( const std::string &certstr,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3Peers::cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code)
|
||||
bool p3Peers::cleanCertificate(const std::string &certstr, std::string &cleanCert,bool& is_short_format,int& error_code)
|
||||
{
|
||||
RsCertificate::Format format ;
|
||||
|
||||
return RsCertificate::cleanCertificate(certstr,cleanCert,format,error_code,true) ;
|
||||
bool res = RsCertificate::cleanCertificate(certstr,cleanCert,format,error_code,true) ;
|
||||
|
||||
if(format == RsCertificate::RS_CERTIFICATE_RADIX)
|
||||
is_short_format = false;
|
||||
else if(format == RsCertificate::RS_CERTIFICATE_SHORT_RADIX)
|
||||
is_short_format = true;
|
||||
else
|
||||
return false ;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool p3Peers::saveCertificateToFile(const RsPeerId &id, const std::string &/*fname*/)
|
||||
|
|
|
@ -157,7 +157,7 @@ public:
|
|||
virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,RsPgpId& pgp_id, std::string& error_string);
|
||||
virtual bool loadDetailsFromStringCert(const std::string &cert, RsPeerDetails &pd, uint32_t& error_code);
|
||||
|
||||
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code);
|
||||
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert, bool &is_short_format, int& error_code) override;
|
||||
virtual bool saveCertificateToFile(const RsPeerId &id, const std::string &fname);
|
||||
virtual std::string saveCertificateToString(const RsPeerId &id);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue