always pass data accept test in distant chat when we are on the client side of the tunnel

This commit is contained in:
csoler 2016-04-10 21:09:47 -04:00
parent c97f197b7e
commit b148239e4f
4 changed files with 11 additions and 4 deletions

View File

@ -124,10 +124,13 @@ void DistantChatService::handleRecvChatStatusItem(RsChatStatusItem *cs)
std::cerr << "DistantChatService::handleRecvChatStatusItem(): received keep alive packet for inactive chat! peerId=" << cs->PeerId() << std::endl;
}
bool DistantChatService::acceptDataFromPeer(const RsGxsId& gxs_id,const RsGxsTunnelId& tunnel_id)
bool DistantChatService::acceptDataFromPeer(const RsGxsId& gxs_id,const RsGxsTunnelId& tunnel_id,bool is_client_side)
{
bool res = true ;
if(is_client_side) // always accept distant chat when we're the client side.
return true ;
if(mDistantChatPermissions & RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_NON_CONTACTS)
res = (rsIdentity!=NULL) && rsIdentity->isARegularContact(gxs_id) ;

View File

@ -89,7 +89,7 @@ public:
virtual void connectToGxsTunnelService(RsGxsTunnelService *tunnel_service) ;
private:
virtual bool acceptDataFromPeer(const RsGxsId& gxs_id,const RsGxsTunnelService::RsGxsTunnelId& tunnel_id) ;
virtual bool acceptDataFromPeer(const RsGxsId& gxs_id, const RsGxsTunnelService::RsGxsTunnelId& tunnel_id, bool is_client_side) ;
virtual void notifyTunnelStatus(const RsGxsTunnelService::RsGxsTunnelId& tunnel_id,uint32_t tunnel_status) ;
virtual void receiveData(const RsGxsTunnelService::RsGxsTunnelId& id,unsigned char *data,uint32_t data_size) ;

View File

@ -349,6 +349,7 @@ void p3GxsTunnelService::handleRecvTunnelDataItem(const RsGxsTunnelId& tunnel_id
RsGxsTunnelClientService *service = NULL ;
RsGxsId peer_from ;
bool is_client_side = false ;
{
RS_STACK_MUTEX(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/
@ -367,6 +368,7 @@ void p3GxsTunnelService::handleRecvTunnelDataItem(const RsGxsTunnelId& tunnel_id
{
it2->second.client_services.insert(item->service_id) ;
peer_from = it2->second.to_gxs_id ;
is_client_side = (it2->second.direction == RsTurtleGenericDataItem::DIRECTION_CLIENT);
}
// Check if the item has already been received. This is necessary because we actually re-send items until an ACK is received. If the ACK gets lost (connection interrupted) the
@ -380,7 +382,7 @@ void p3GxsTunnelService::handleRecvTunnelDataItem(const RsGxsTunnelId& tunnel_id
it2->second.received_data_prints[item->unique_item_counter] = time(NULL) ;
}
if(service->acceptDataFromPeer(peer_from,tunnel_id))
if(service->acceptDataFromPeer(peer_from,tunnel_id,is_client_side))
service->receiveData(tunnel_id,item->data,item->data_size) ;
item->data = NULL ; // avoids deletion, since the client has the memory now
@ -1474,6 +1476,7 @@ bool p3GxsTunnelService::getTunnelInfo(const RsGxsTunnelId& tunnel_id,GxsTunnelI
info.tunnel_status = it->second.status;
info.total_size_sent = it->second.total_sent;
info.total_size_received= it->second.total_received;
info.is_client_side = (it->second.direction == RsTurtleGenericTunnelItem::DIRECTION_CLIENT);
// Data packets

View File

@ -66,7 +66,7 @@ public:
// Gives feedback about type of data that is allowed in. For security reasons, this always needs to be re-derived (Clients can return true on default)
virtual bool acceptDataFromPeer(const RsGxsId& gxs_id,const RsGxsTunnelId& tunnel_id) = 0 ;
virtual bool acceptDataFromPeer(const RsGxsId& gxs_id,const RsGxsTunnelId& tunnel_id,bool is_client_side) = 0 ;
};
class GxsTunnelInfo
@ -80,6 +80,7 @@ public:
uint32_t tunnel_status ; // active, requested, DH pending, etc.
uint32_t total_size_sent ; // total bytes sent through that tunnel since openned (including management).
uint32_t total_size_received ; // total bytes received through that tunnel since openned (including management).
bool is_client_side ; // specifiec wether we are client(managing the tunnel) or server.
// Data packets