mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-30 09:56:14 -05:00
fixed bug caused by RsNxsPullItem not deriving from RsNxsItem and uniformized the code
This commit is contained in:
parent
77dd76a108
commit
aa904a3528
@ -1730,15 +1730,6 @@ void RsGxsNetService::recvNxsItemQueue()
|
|||||||
#endif
|
#endif
|
||||||
/* Handle pull request and other new items here to not mess with all the
|
/* Handle pull request and other new items here to not mess with all the
|
||||||
* old nested code and items hell */
|
* old nested code and items hell */
|
||||||
switch(static_cast<RsNxsSubtype>(item->PacketSubType()))
|
|
||||||
{
|
|
||||||
case RsNxsSubtype::PULL_REQUEST:
|
|
||||||
std::unique_ptr<RsNxsPullRequestItem> pullItem(
|
|
||||||
static_cast<RsNxsPullRequestItem*>(item) );
|
|
||||||
handlePullRequest(std::move(pullItem));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// RsNxsItem needs dynamic_cast, since they have derived siblings.
|
// RsNxsItem needs dynamic_cast, since they have derived siblings.
|
||||||
//
|
//
|
||||||
RsNxsItem *ni = dynamic_cast<RsNxsItem*>(item) ;
|
RsNxsItem *ni = dynamic_cast<RsNxsItem*>(item) ;
|
||||||
@ -1781,10 +1772,11 @@ void RsGxsNetService::recvNxsItemQueue()
|
|||||||
|
|
||||||
switch(ni->PacketSubType())
|
switch(ni->PacketSubType())
|
||||||
{
|
{
|
||||||
case RS_PKT_SUBTYPE_NXS_SYNC_GRP_STATS_ITEM: handleRecvSyncGrpStatistics (dynamic_cast<RsNxsSyncGrpStatsItem*>(ni)) ; break ;
|
case RS_PKT_SUBTYPE_NXS_SYNC_GRP_STATS_ITEM: handleRecvSyncGrpStatistics (dynamic_cast<RsNxsSyncGrpStatsItem*>(ni)) ; break ;
|
||||||
case RS_PKT_SUBTYPE_NXS_SYNC_GRP_REQ_ITEM: handleRecvSyncGroup (dynamic_cast<RsNxsSyncGrpReqItem*>(ni)) ; break ;
|
case RS_PKT_SUBTYPE_NXS_SYNC_GRP_REQ_ITEM: handleRecvSyncGroup (dynamic_cast<RsNxsSyncGrpReqItem*>(ni)) ; break ;
|
||||||
case RS_PKT_SUBTYPE_NXS_SYNC_MSG_REQ_ITEM: handleRecvSyncMessage (dynamic_cast<RsNxsSyncMsgReqItem*>(ni),item_was_encrypted) ; break ;
|
case RS_PKT_SUBTYPE_NXS_SYNC_MSG_REQ_ITEM: handleRecvSyncMessage (dynamic_cast<RsNxsSyncMsgReqItem*>(ni),item_was_encrypted) ; break ;
|
||||||
case RS_PKT_SUBTYPE_NXS_GRP_PUBLISH_KEY_ITEM:handleRecvPublishKeys (dynamic_cast<RsNxsGroupPublishKeyItem*>(ni)) ; break ;
|
case RS_PKT_SUBTYPE_NXS_GRP_PUBLISH_KEY_ITEM: handleRecvPublishKeys (dynamic_cast<RsNxsGroupPublishKeyItem*>(ni)) ; break ;
|
||||||
|
case RS_PKT_SUBTYPE_NXS_SYNC_PULL_REQUEST_ITEM: handlePullRequest (dynamic_cast<RsNxsPullRequestItem*>(ni)) ; break ;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if(ni->PacketSubType() != RS_PKT_SUBTYPE_NXS_ENCRYPTED_DATA_ITEM)
|
if(ni->PacketSubType() != RS_PKT_SUBTYPE_NXS_ENCRYPTED_DATA_ITEM)
|
||||||
@ -5119,8 +5111,7 @@ std::error_condition RsGxsNetService::requestPull(std::set<RsPeerId> peers)
|
|||||||
|
|
||||||
for(auto& peerId: std::as_const(peers))
|
for(auto& peerId: std::as_const(peers))
|
||||||
{
|
{
|
||||||
auto item = new RsNxsPullRequestItem(
|
auto item = new RsNxsPullRequestItem(mServType);
|
||||||
static_cast<RsServiceType>(mServType) );
|
|
||||||
item->PeerId(peerId);
|
item->PeerId(peerId);
|
||||||
generic_sendItem(item);
|
generic_sendItem(item);
|
||||||
}
|
}
|
||||||
@ -5128,8 +5119,7 @@ std::error_condition RsGxsNetService::requestPull(std::set<RsPeerId> peers)
|
|||||||
return std::error_condition();
|
return std::error_condition();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsNetService::handlePullRequest(
|
void RsGxsNetService::handlePullRequest(RsNxsPullRequestItem *item)
|
||||||
std::unique_ptr<RsNxsPullRequestItem> item )
|
|
||||||
{
|
{
|
||||||
checkUpdatesFromPeers(std::set<RsPeerId>{item->PeerId()});
|
checkUpdatesFromPeers(std::set<RsPeerId>{item->PeerId()});
|
||||||
}
|
}
|
||||||
|
@ -432,7 +432,11 @@ private:
|
|||||||
*/
|
*/
|
||||||
void handleRecvPublishKeys(RsNxsGroupPublishKeyItem*) ;
|
void handleRecvPublishKeys(RsNxsGroupPublishKeyItem*) ;
|
||||||
|
|
||||||
void handlePullRequest(std::unique_ptr<RsNxsPullRequestItem> item);
|
/*!
|
||||||
|
* Handles a nxs pull request item from a given friend/tunnel
|
||||||
|
* @param item contaims keys/grp info
|
||||||
|
*/
|
||||||
|
void handlePullRequest(RsNxsPullRequestItem *item);
|
||||||
|
|
||||||
/** E: item handlers **/
|
/** E: item handlers **/
|
||||||
|
|
||||||
|
@ -586,9 +586,9 @@ bool pqisslproxy::connect_parameter(uint32_t type, const std::string &value)
|
|||||||
|
|
||||||
if (type == NET_PARAM_CONNECT_DOMAIN_ADDRESS)
|
if (type == NET_PARAM_CONNECT_DOMAIN_ADDRESS)
|
||||||
{
|
{
|
||||||
std::string out;
|
|
||||||
rs_sprintf(out, "pqisslproxy::connect_parameter() Peer: %s DOMAIN_ADDRESS: %s", PeerId().toStdString().c_str(), value.c_str());
|
|
||||||
#ifdef PROXY_DEBUG_LOG
|
#ifdef PROXY_DEBUG_LOG
|
||||||
|
std::string out;
|
||||||
|
rs_sprintf(out, "pqisslproxy::connect_parameter() Peer: %s DOMAIN_ADDRESS: %s", PeerId().toStdString().c_str(), value.c_str());
|
||||||
rslog(RSL_WARNING, pqisslproxyzone, out);
|
rslog(RSL_WARNING, pqisslproxyzone, out);
|
||||||
#endif
|
#endif
|
||||||
mDomainAddress = value;
|
mDomainAddress = value;
|
||||||
|
@ -64,12 +64,6 @@ RsItem *RsNxsSerialiser::create_item(uint16_t service_id,uint8_t item_subtype) c
|
|||||||
if(service_id != SERVICE_TYPE)
|
if(service_id != SERVICE_TYPE)
|
||||||
return NULL ;
|
return NULL ;
|
||||||
|
|
||||||
switch(static_cast<RsNxsSubtype>(item_subtype))
|
|
||||||
{
|
|
||||||
case RsNxsSubtype::PULL_REQUEST:
|
|
||||||
return new RsNxsPullRequestItem(static_cast<RsServiceType>(service_id));
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(item_subtype)
|
switch(item_subtype)
|
||||||
{
|
{
|
||||||
case RS_PKT_SUBTYPE_NXS_SYNC_GRP_REQ_ITEM: return new RsNxsSyncGrpReqItem(SERVICE_TYPE) ;
|
case RS_PKT_SUBTYPE_NXS_SYNC_GRP_REQ_ITEM: return new RsNxsSyncGrpReqItem(SERVICE_TYPE) ;
|
||||||
@ -82,6 +76,7 @@ RsItem *RsNxsSerialiser::create_item(uint16_t service_id,uint8_t item_subtype) c
|
|||||||
case RS_PKT_SUBTYPE_NXS_GRP_PUBLISH_KEY_ITEM:return new RsNxsGroupPublishKeyItem(SERVICE_TYPE) ;
|
case RS_PKT_SUBTYPE_NXS_GRP_PUBLISH_KEY_ITEM:return new RsNxsGroupPublishKeyItem(SERVICE_TYPE) ;
|
||||||
case RS_PKT_SUBTYPE_NXS_ENCRYPTED_DATA_ITEM: return new RsNxsEncryptedDataItem(SERVICE_TYPE) ;
|
case RS_PKT_SUBTYPE_NXS_ENCRYPTED_DATA_ITEM: return new RsNxsEncryptedDataItem(SERVICE_TYPE) ;
|
||||||
case RS_PKT_SUBTYPE_NXS_SYNC_GRP_STATS_ITEM: return new RsNxsSyncGrpStatsItem(SERVICE_TYPE) ;
|
case RS_PKT_SUBTYPE_NXS_SYNC_GRP_STATS_ITEM: return new RsNxsSyncGrpStatsItem(SERVICE_TYPE) ;
|
||||||
|
case RS_PKT_SUBTYPE_NXS_SYNC_PULL_REQUEST_ITEM: return new RsNxsPullRequestItem(SERVICE_TYPE) ;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -35,11 +35,6 @@
|
|||||||
#include "serialiser/rstlvkeys.h"
|
#include "serialiser/rstlvkeys.h"
|
||||||
#include "gxs/rsgxsdata.h"
|
#include "gxs/rsgxsdata.h"
|
||||||
|
|
||||||
enum class RsNxsSubtype : uint8_t
|
|
||||||
{
|
|
||||||
PULL_REQUEST = 0x90 /// @see RsNxsPullRequestItem
|
|
||||||
};
|
|
||||||
|
|
||||||
// These items have "flag type" numbers, but this is not used.
|
// These items have "flag type" numbers, but this is not used.
|
||||||
// TODO: refactor as C++11 enum class
|
// TODO: refactor as C++11 enum class
|
||||||
const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_GRP_REQ_ITEM = 0x01;
|
const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_GRP_REQ_ITEM = 0x01;
|
||||||
@ -53,6 +48,7 @@ const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_MSG_REQ_ITEM = 0x10;
|
|||||||
const uint8_t RS_PKT_SUBTYPE_NXS_MSG_ITEM = 0x20;
|
const uint8_t RS_PKT_SUBTYPE_NXS_MSG_ITEM = 0x20;
|
||||||
const uint8_t RS_PKT_SUBTYPE_NXS_TRANSAC_ITEM = 0x40;
|
const uint8_t RS_PKT_SUBTYPE_NXS_TRANSAC_ITEM = 0x40;
|
||||||
const uint8_t RS_PKT_SUBTYPE_NXS_GRP_PUBLISH_KEY_ITEM = 0x80;
|
const uint8_t RS_PKT_SUBTYPE_NXS_GRP_PUBLISH_KEY_ITEM = 0x80;
|
||||||
|
const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_PULL_REQUEST_ITEM = 0x90;
|
||||||
|
|
||||||
|
|
||||||
#ifdef RS_DEAD_CODE
|
#ifdef RS_DEAD_CODE
|
||||||
@ -370,13 +366,10 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
* Used to request to a peer pull updates from us ASAP without waiting GXS sync
|
* Used to request to a peer pull updates from us ASAP without waiting GXS sync
|
||||||
* timer */
|
* timer */
|
||||||
struct RsNxsPullRequestItem: RsItem
|
class RsNxsPullRequestItem: public RsNxsItem
|
||||||
{
|
{
|
||||||
explicit RsNxsPullRequestItem(RsServiceType servtype):
|
public:
|
||||||
RsItem( RS_PKT_VERSION_SERVICE,
|
explicit RsNxsPullRequestItem(uint16_t servtype): RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_SYNC_PULL_REQUEST_ITEM) {}
|
||||||
servtype,
|
|
||||||
static_cast<uint8_t>(RsNxsSubtype::PULL_REQUEST),
|
|
||||||
QOS_PRIORITY_RS_GXS_NET ) {}
|
|
||||||
|
|
||||||
/// @see RsSerializable
|
/// @see RsSerializable
|
||||||
void serial_process( RsGenericSerializer::SerializeJob,
|
void serial_process( RsGenericSerializer::SerializeJob,
|
||||||
@ -388,8 +381,9 @@ struct RsNxsPullRequestItem: RsItem
|
|||||||
* Used to respond to a RsGrpMsgsReq
|
* Used to respond to a RsGrpMsgsReq
|
||||||
* with message items satisfying request
|
* with message items satisfying request
|
||||||
*/
|
*/
|
||||||
struct RsNxsMsg : RsNxsItem
|
class RsNxsMsg : public RsNxsItem
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
explicit RsNxsMsg(uint16_t servtype)
|
explicit RsNxsMsg(uint16_t servtype)
|
||||||
: RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_MSG_ITEM)
|
: RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_MSG_ITEM)
|
||||||
, pos(0), count(0), meta(servtype), msg(servtype), metaData(NULL)
|
, pos(0), count(0), meta(servtype), msg(servtype), metaData(NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user