From 07abdeeceb2ce27d7c1dda5d46541df1820b5d5b Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 20 Mar 2019 22:34:48 +0100 Subject: [PATCH] fixed bug causing distant chat preference contacts/nobody/everybody to be ignored --- libretroshare/src/chat/distantchat.cc | 8 ++++---- libretroshare/src/chat/distantchat.h | 2 +- libretroshare/src/gxstunnel/p3gxstunnel.cc | 10 +++++----- libretroshare/src/retroshare/rsgxstunnel.h | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libretroshare/src/chat/distantchat.cc b/libretroshare/src/chat/distantchat.cc index 60b11b0b3..2fbe0d4e8 100644 --- a/libretroshare/src/chat/distantchat.cc +++ b/libretroshare/src/chat/distantchat.cc @@ -135,13 +135,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 is_client_side) +bool DistantChatService::acceptDataFromPeer(const RsGxsId& gxs_id,const RsGxsTunnelId& tunnel_id,bool am_I_client_side) { - bool res = true ; - - if(is_client_side) // always accept distant chat when we're the client side. + if(am_I_client_side) // always accept distant chat when we're the client side. return true ; + bool res = 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 196c1079f..e978b7d72 100644 --- a/libretroshare/src/chat/distantchat.h +++ b/libretroshare/src/chat/distantchat.h @@ -91,7 +91,7 @@ public: virtual void connectToGxsTunnelService(RsGxsTunnelService *tunnel_service) ; private: - virtual bool acceptDataFromPeer(const RsGxsId& gxs_id, const RsGxsTunnelService::RsGxsTunnelId& tunnel_id, bool is_client_side) ; + virtual bool acceptDataFromPeer(const RsGxsId& gxs_id, const RsGxsTunnelService::RsGxsTunnelId& tunnel_id, bool am_I_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 264ddbc96..3c92bb312 100644 --- a/libretroshare/src/gxstunnel/p3gxstunnel.cc +++ b/libretroshare/src/gxstunnel/p3gxstunnel.cc @@ -370,11 +370,11 @@ void p3GxsTunnelService::handleRecvTunnelDataItem(const RsGxsTunnelId& tunnel_id std::map::iterator it2 = _gxs_tunnel_contacts.find(tunnel_id) ; if(it2 != _gxs_tunnel_contacts.end()) - { - it2->second.client_services.insert(item->service_id) ; - peer_from = it2->second.to_gxs_id ; - is_client_side = (it2->second.direction == RsTurtleGenericDataItem::DIRECTION_CLIENT); - } + { + it2->second.client_services.insert(item->service_id) ; + peer_from = it2->second.to_gxs_id ; + is_client_side = (it2->second.direction == RsTurtleGenericDataItem::DIRECTION_SERVER); + } // 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 // item may be received twice. This is conservative and ensure that no item is lost nor received twice. diff --git a/libretroshare/src/retroshare/rsgxstunnel.h b/libretroshare/src/retroshare/rsgxstunnel.h index ce7798300..239816f38 100644 --- a/libretroshare/src/retroshare/rsgxstunnel.h +++ b/libretroshare/src/retroshare/rsgxstunnel.h @@ -62,7 +62,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,bool is_client_side) = 0 ; + virtual bool acceptDataFromPeer(const RsGxsId& gxs_id,const RsGxsTunnelId& tunnel_id,bool am_I_client_side) = 0 ; }; class GxsTunnelInfo