p3Peers::getPeerDetails retrocompatible IPv4 format

This commit is contained in:
Gioacchino Mazzurco 2018-02-25 12:48:55 +01:00
parent 4a138e07b9
commit 9281a5966b
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
2 changed files with 29 additions and 29 deletions

View File

@ -174,24 +174,24 @@ RsCertificate::RsCertificate(const RsPeerDetails& Detail, const unsigned char *b
try try
{ {
scan_ip(Detail.localAddr,Detail.localPort,ipv4_internal_ip_and_port) ; scan_ip(Detail.localAddr,Detail.localPort,ipv4_internal_ip_and_port);
} }
catch(...) catch(...)
{ {
std::cerr << "RsCertificate::Invalid LocalAddress"; std::cerr << "RsCertificate::Invalid LocalAddress: "
std::cerr << std::endl; << Detail.localAddr << std::endl;
memset(ipv4_internal_ip_and_port,0,6) ; memset(ipv4_internal_ip_and_port,0,6);
} }
try try
{ {
scan_ip(Detail.extAddr,Detail.extPort,ipv4_external_ip_and_port) ; scan_ip(Detail.extAddr,Detail.extPort,ipv4_external_ip_and_port);
} }
catch(...) catch(...)
{ {
std::cerr << "RsCertificate::Invalid ExternalAddress"; std::cerr << "RsCertificate::Invalid ExternalAddress: "
std::cerr << std::endl; << Detail.extAddr << std::endl;
memset(ipv4_external_ip_and_port,0,6) ; memset(ipv4_external_ip_and_port,0,6) ;
} }

View File

@ -333,27 +333,27 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
d.hiddenNodePort = 0; d.hiddenNodePort = 0;
d.hiddenType = RS_HIDDEN_TYPE_NONE; d.hiddenType = RS_HIDDEN_TYPE_NONE;
if (sockaddr_storage_isnull(ps.localaddr)) if (sockaddr_storage_ipv6_to_ipv4(ps.localaddr))
{
d.localAddr = "INVALID_IP";
d.localPort = 0;
}
else
{ {
d.localAddr = sockaddr_storage_iptostring(ps.localaddr); d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
d.localPort = sockaddr_storage_port(ps.localaddr); d.localPort = sockaddr_storage_port(ps.localaddr);
} }
if (sockaddr_storage_isnull(ps.serveraddr))
{
d.extAddr = "INVALID_IP";
d.extPort = 0;
}
else else
{
d.localAddr = "INVALID_IP";
d.localPort = 0;
}
if (sockaddr_storage_ipv6_to_ipv4(ps.serveraddr))
{ {
d.extAddr = sockaddr_storage_iptostring(ps.serveraddr); d.extAddr = sockaddr_storage_iptostring(ps.serveraddr);
d.extPort = sockaddr_storage_port(ps.serveraddr); d.extPort = sockaddr_storage_port(ps.serveraddr);
} }
else
{
d.extAddr = "INVALID_IP";
d.extPort = 0;
}
d.dyndns = ps.dyndns; d.dyndns = ps.dyndns;
@ -1051,22 +1051,22 @@ std::string p3Peers::getPGPKey(const RsPgpId& pgp_id,bool include_signatures)
unsigned char *mem_block = NULL; unsigned char *mem_block = NULL;
size_t mem_block_size = 0; size_t mem_block_size = 0;
if(!AuthGPG::getAuthGPG()->exportPublicKey(RsPgpId(pgp_id),mem_block,mem_block_size,false,include_signatures)) if( !AuthGPG::getAuthGPG()->exportPublicKey(
RsPgpId(pgp_id), mem_block, mem_block_size,
false, include_signatures ) )
{ {
std::cerr << "Cannot output certificate for id \"" << pgp_id << "\". Sorry." << std::endl; std::cerr << "Cannot output certificate for id \"" << pgp_id
<< "\". Sorry." << std::endl;
return "" ; return "" ;
} }
RsPeerDetails Detail ; RsPeerDetails Detail;
if(!getGPGDetails(pgp_id,Detail)) return "";
if(!getGPGDetails(pgp_id,Detail) ) RsCertificate cert( Detail,mem_block,mem_block_size );
return "" ; delete[] mem_block ;
RsCertificate cert( Detail,mem_block,mem_block_size ) ; return cert.armouredPGPKey();
delete[] mem_block ;
return cert.armouredPGPKey() ;
} }