Merge pull request #1644 from G10h4ck/broadcast_discovery_fingerprint

Send PGP fingerprint in broadcast discovery
This commit is contained in:
G10h4ck 2019-09-27 23:48:37 +02:00 committed by GitHub
commit 1480e6d0b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 10 deletions

View File

@ -41,11 +41,12 @@ class RsBroadcastDiscovery;
* TODO: this should become std::weak_ptr once we have a reasonable services * TODO: this should become std::weak_ptr once we have a reasonable services
* management. * management.
*/ */
extern std::shared_ptr<RsBroadcastDiscovery> rsBroadcastDiscovery; extern RsBroadcastDiscovery* rsBroadcastDiscovery;
struct RsBroadcastDiscoveryResult : RsSerializable struct RsBroadcastDiscoveryResult : RsSerializable
{ {
RsPgpFingerprint mPgpFingerprint;
RsPeerId mSslId; RsPeerId mSslId;
std::string mProfileName; std::string mProfileName;
RsUrl mLocator; RsUrl mLocator;
@ -54,6 +55,7 @@ struct RsBroadcastDiscoveryResult : RsSerializable
void serial_process( RsGenericSerializer::SerializeJob j, void serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx) override RsGenericSerializer::SerializeContext& ctx) override
{ {
RS_SERIAL_PROCESS(mPgpFingerprint);
RS_SERIAL_PROCESS(mSslId); RS_SERIAL_PROCESS(mSslId);
RS_SERIAL_PROCESS(mProfileName); RS_SERIAL_PROCESS(mProfileName);
RS_SERIAL_PROCESS(mLocator); RS_SERIAL_PROCESS(mLocator);

View File

@ -1429,9 +1429,9 @@ int RsServer::StartupRetroShare()
mStatusSrv = new p3StatusService(serviceCtrl); mStatusSrv = new p3StatusService(serviceCtrl);
#ifdef RS_BROADCAST_DISCOVERY #ifdef RS_BROADCAST_DISCOVERY
rsBroadcastDiscovery.reset(new BroadcastDiscoveryService(*rsPeers)); BroadcastDiscoveryService* broadcastDiscoveryService =
BroadcastDiscoveryService& tBroadcastDiscoveryService = new BroadcastDiscoveryService(*rsPeers);
static_cast<BroadcastDiscoveryService&>(*rsBroadcastDiscovery); rsBroadcastDiscovery = broadcastDiscoveryService;
#endif // def RS_BROADCAST_DISCOVERY #endif // def RS_BROADCAST_DISCOVERY
#ifdef ENABLE_GROUTER #ifdef ENABLE_GROUTER
@ -1828,7 +1828,7 @@ int RsServer::StartupRetroShare()
#endif // RS_ENABLE_GXS #endif // RS_ENABLE_GXS
#ifdef RS_BROADCAST_DISCOVERY #ifdef RS_BROADCAST_DISCOVERY
startServiceThread(&tBroadcastDiscoveryService, "Broadcast Discovery"); startServiceThread(broadcastDiscoveryService, "Broadcast Discovery");
#endif // def RS_BROADCAST_DISCOVERY #endif // def RS_BROADCAST_DISCOVERY
ftserver->StartupThreads(); ftserver->StartupThreads();

View File

@ -31,15 +31,13 @@
#include "serialiser/rsserializer.h" #include "serialiser/rsserializer.h"
#include "retroshare/rsevents.h" #include "retroshare/rsevents.h"
/*extern*/ std::shared_ptr<RsBroadcastDiscovery> rsBroadcastDiscovery(nullptr); /*extern*/ RsBroadcastDiscovery* rsBroadcastDiscovery = nullptr;
RsBroadcastDiscovery::~RsBroadcastDiscovery() { /* Beware of Rs prefix! */ }
RsBroadcastDiscoveryResult::~RsBroadcastDiscoveryResult() {}
RsBroadcastDiscoveryPeerFoundEvent::~RsBroadcastDiscoveryPeerFoundEvent() {}
struct BroadcastDiscoveryPack : RsSerializable struct BroadcastDiscoveryPack : RsSerializable
{ {
BroadcastDiscoveryPack() : mLocalPort(0) {} BroadcastDiscoveryPack() : mLocalPort(0) {}
RsPgpFingerprint mPgpFingerprint;
RsPeerId mSslId; RsPeerId mSslId;
uint16_t mLocalPort; uint16_t mLocalPort;
std::string mProfileName; std::string mProfileName;
@ -47,6 +45,7 @@ struct BroadcastDiscoveryPack : RsSerializable
void serial_process( RsGenericSerializer::SerializeJob j, void serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx ) override RsGenericSerializer::SerializeContext& ctx ) override
{ {
RS_SERIAL_PROCESS(mPgpFingerprint);
RS_SERIAL_PROCESS(mSslId); RS_SERIAL_PROCESS(mSslId);
RS_SERIAL_PROCESS(mLocalPort); RS_SERIAL_PROCESS(mLocalPort);
RS_SERIAL_PROCESS(mProfileName); RS_SERIAL_PROCESS(mProfileName);
@ -55,6 +54,7 @@ struct BroadcastDiscoveryPack : RsSerializable
static BroadcastDiscoveryPack fromPeerDetails(const RsPeerDetails& pd) static BroadcastDiscoveryPack fromPeerDetails(const RsPeerDetails& pd)
{ {
BroadcastDiscoveryPack bdp; BroadcastDiscoveryPack bdp;
bdp.mPgpFingerprint = pd.fpr;
bdp.mSslId = pd.id; bdp.mSslId = pd.id;
bdp.mLocalPort = pd.localPort; bdp.mLocalPort = pd.localPort;
bdp.mProfileName = pd.name; bdp.mProfileName = pd.name;
@ -86,7 +86,6 @@ struct BroadcastDiscoveryPack : RsSerializable
~BroadcastDiscoveryPack() override; ~BroadcastDiscoveryPack() override;
}; };
BroadcastDiscoveryPack::~BroadcastDiscoveryPack() {};
BroadcastDiscoveryService::BroadcastDiscoveryService( BroadcastDiscoveryService::BroadcastDiscoveryService(
RsPeers& pRsPeers ) : RsPeers& pRsPeers ) :
@ -202,3 +201,8 @@ RsBroadcastDiscoveryResult BroadcastDiscoveryService::createResult(
return rbdr; return rbdr;
} }
RsBroadcastDiscovery::~RsBroadcastDiscovery() = default;
RsBroadcastDiscoveryResult::~RsBroadcastDiscoveryResult() = default;
RsBroadcastDiscoveryPeerFoundEvent::~RsBroadcastDiscoveryPeerFoundEvent() = default;
BroadcastDiscoveryPack::~BroadcastDiscoveryPack() = default;