diff --git a/libretroshare/src/chat/distantchat.cc b/libretroshare/src/chat/distantchat.cc index 113dd21c5..03acb6ff8 100644 --- a/libretroshare/src/chat/distantchat.cc +++ b/libretroshare/src/chat/distantchat.cc @@ -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) ; diff --git a/libretroshare/src/chat/distantchat.h b/libretroshare/src/chat/distantchat.h index 8b159c56a..5dc21e1d6 100644 --- a/libretroshare/src/chat/distantchat.h +++ b/libretroshare/src/chat/distantchat.h @@ -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) ; diff --git a/libretroshare/src/gxstunnel/p3gxstunnel.cc b/libretroshare/src/gxstunnel/p3gxstunnel.cc index 4539c0847..eb0c32812 100644 --- a/libretroshare/src/gxstunnel/p3gxstunnel.cc +++ b/libretroshare/src/gxstunnel/p3gxstunnel.cc @@ -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 diff --git a/libretroshare/src/retroshare/rsgxstunnel.h b/libretroshare/src/retroshare/rsgxstunnel.h index 94f4c79fe..4d3588c9f 100644 --- a/libretroshare/src/retroshare/rsgxstunnel.h +++ b/libretroshare/src/retroshare/rsgxstunnel.h @@ -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