added parsing of short invites in connect friend wizard (not working yet)

This commit is contained in:
csoler 2019-06-09 15:03:48 +02:00
parent 3a799bae37
commit 4bd5aaa9b2
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
6 changed files with 69 additions and 24 deletions

View file

@ -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 ;

View file

@ -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 );