Merge pull request #1863 from sehraf/pr_handle_deprecated_packets

Fix log spam by handling deprecated packet gracefully
This commit is contained in:
csoler 2020-04-19 18:57:11 +02:00 committed by GitHub
commit 096cdd6dd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 0 deletions

View File

@ -37,6 +37,7 @@ RsItem *RsDiscSerialiser::create_item(
{
case RsGossipDiscoveryItemType::PGP_LIST: return new RsDiscPgpListItem();
case RsGossipDiscoveryItemType::PGP_CERT_BINARY: return new RsDiscPgpKeyItem();
case RsGossipDiscoveryItemType::PGP_CERT: return new RsDiscPgpCertItem(); // deprecated, hanlde to suppress "unkown item" warning
case RsGossipDiscoveryItemType::CONTACT: return new RsDiscContactItem();
case RsGossipDiscoveryItemType::IDENTITY_LIST: return new RsDiscIdentityListItem();
default:

View File

@ -97,6 +97,27 @@ public:
uint32_t bin_len;
};
class RS_DEPRECATED_FOR(RsDiscPgpKeyItem) RsDiscPgpCertItem: public RsDiscItem
{
public:
RsDiscPgpCertItem() : RsDiscItem(RsGossipDiscoveryItemType::PGP_CERT)
{ setPriorityLevel(QOS_PRIORITY_RS_DISC_PGP_CERT); }
void clear() override
{
pgpId.clear();
pgpCert.clear();
}
void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext& ctx) override
{
RsTypeSerializer::serial_process(j,ctx,pgpId,"pgpId") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_PGPCERT,pgpCert,"pgpCert") ;
}
RsPgpId pgpId;
std::string pgpCert;
};
class RsDiscContactItem: public RsDiscItem
{
public:

View File

@ -260,6 +260,7 @@ int p3discovery2::handleIncoming()
{
RsDiscPgpListItem* pgplist = nullptr;
RsDiscPgpKeyItem* pgpkey = nullptr;
RsDiscPgpCertItem* pgpcert = nullptr; // deprecated, hanlde for retro compability
RsDiscContactItem* contact = nullptr;
RsDiscIdentityListItem* gxsidlst = nullptr;
@ -282,6 +283,9 @@ int p3discovery2::handleIncoming()
}
else if((pgpkey = dynamic_cast<RsDiscPgpKeyItem *>(item)) != nullptr)
recvPGPCertificate(item->PeerId(), pgpkey);
else if((pgpcert = dynamic_cast<RsDiscPgpCertItem *>(item)) != nullptr)
// sink
delete pgpcert;
else if((pgplist = dynamic_cast<RsDiscPgpListItem *>(item)) != nullptr)
{
if (pgplist->mode == RsGossipDiscoveryPgpListMode::FRIENDS)