mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 08:29:32 -05:00
finished fast track turtle items for distant chat
This commit is contained in:
parent
3f75bff48b
commit
44d0cbe295
@ -770,7 +770,11 @@ void p3GxsTunnelService::receiveTurtleData(const RsTurtleGenericTunnelItem *gite
|
|||||||
|
|
||||||
// This function encrypts the given data and adds a MAC and an IV into a serialised memory chunk that is then sent through the tunnel.
|
// This function encrypts the given data and adds a MAC and an IV into a serialised memory chunk that is then sent through the tunnel.
|
||||||
|
|
||||||
|
#ifndef V07_NON_BACKWARD_COMPATIBLE_CHANGE_004
|
||||||
bool p3GxsTunnelService::handleEncryptedData(const uint8_t *data_bytes,uint32_t data_size,const TurtleFileHash& hash,const RsPeerId& virtual_peer_id,bool accepts_fast_items)
|
bool p3GxsTunnelService::handleEncryptedData(const uint8_t *data_bytes,uint32_t data_size,const TurtleFileHash& hash,const RsPeerId& virtual_peer_id,bool accepts_fast_items)
|
||||||
|
#else
|
||||||
|
bool p3GxsTunnelService::handleEncryptedData(const uint8_t *data_bytes,uint32_t data_size,const TurtleFileHash& hash,const RsPeerId& virtual_peer_id)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_GXS_TUNNEL
|
#ifdef DEBUG_GXS_TUNNEL
|
||||||
std::cerr << "p3GxsTunnelService::handleEncryptedDataItem()" << std::endl;
|
std::cerr << "p3GxsTunnelService::handleEncryptedDataItem()" << std::endl;
|
||||||
@ -813,9 +817,15 @@ bool p3GxsTunnelService::handleEncryptedData(const uint8_t *data_bytes,uint32_t
|
|||||||
std::cerr << "(EE) no tunnel data for tunnel ID=" << tunnel_id << ". This is a bug." << std::endl;
|
std::cerr << "(EE) no tunnel data for tunnel ID=" << tunnel_id << ". This is a bug." << std::endl;
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
#ifndef V07_NON_BACKWARD_COMPATIBLE_CHANGE_004
|
||||||
if(accepts_fast_items)
|
if(accepts_fast_items)
|
||||||
it2->second.accepts_fast_turtle_items = accepts_fast_items;
|
{
|
||||||
|
if(!it2->second.accepts_fast_turtle_items)
|
||||||
|
std::cerr << "(II) received probe for Fast track turtle items for tunnel VPID " << it2->second.virtual_peer_id << ": switching to Fast items mode." << std::endl;
|
||||||
|
|
||||||
|
it2->second.accepts_fast_turtle_items = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
memcpy(aes_key,it2->second.aes_key,GXS_TUNNEL_AES_KEY_SIZE) ;
|
memcpy(aes_key,it2->second.aes_key,GXS_TUNNEL_AES_KEY_SIZE) ;
|
||||||
|
|
||||||
@ -1342,27 +1352,48 @@ bool p3GxsTunnelService::locked_sendEncryptedTunnelData(RsGxsTunnelItem *item)
|
|||||||
// We send the item through the turtle tunnel. We do that using the new 'fast' item type if the tunnel accepts it, and using the old slow one otherwise.
|
// We send the item through the turtle tunnel. We do that using the new 'fast' item type if the tunnel accepts it, and using the old slow one otherwise.
|
||||||
// Still if the tunnel hasn't been probed, we duplicate the packet using the new fast item format. The packet being received twice on the other side will
|
// Still if the tunnel hasn't been probed, we duplicate the packet using the new fast item format. The packet being received twice on the other side will
|
||||||
// be discarded with a warning.
|
// be discarded with a warning.
|
||||||
|
// Note that because the data is deleted by sendTurtleData(), we need to send all packets at the end, and properly duplicate the data when needed.
|
||||||
|
|
||||||
|
#ifdef V07_NON_BACKWARD_COMPATIBLE_CHANGE_004
|
||||||
|
RsTurtleGenericFastDataItem *gitem = new RsTurtleGenericFastDataItem;
|
||||||
|
gitem->data_bytes = data_bytes;
|
||||||
|
gitem->data_size = data_size ;
|
||||||
|
#else
|
||||||
|
RsTurtleGenericDataItem *gitem = NULL;
|
||||||
|
RsTurtleGenericFastDataItem *gitem2 = NULL;
|
||||||
|
|
||||||
if(!it->second.accepts_fast_turtle_items)
|
if(!it->second.accepts_fast_turtle_items)
|
||||||
{
|
{
|
||||||
RsTurtleGenericDataItem *gitem = new RsTurtleGenericDataItem ;
|
std::cerr << "Sending old format (slow) item for packet IV=" << std::hex << IV << std::dec << " in tunnel VPID=" << it->second.virtual_peer_id << std::endl;
|
||||||
|
gitem = new RsTurtleGenericDataItem ;
|
||||||
|
|
||||||
gitem->data_bytes = data_bytes;
|
gitem->data_bytes = data_bytes;
|
||||||
gitem->data_size = data_size ;
|
gitem->data_size = data_size ;
|
||||||
|
|
||||||
mTurtle->sendTurtleData(virtual_peer_id,gitem) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(it->second.accepts_fast_turtle_items || !it->second.already_probed_for_fast_items)
|
if(it->second.accepts_fast_turtle_items || !it->second.already_probed_for_fast_items)
|
||||||
{
|
{
|
||||||
RsTurtleGenericFastDataItem *gitem = new RsTurtleGenericFastDataItem ;
|
std::cerr << "Sending new format (fast) item for packet IV=" << std::hex << IV << std::dec << " in tunnel VPID=" << it->second.virtual_peer_id << std::endl;
|
||||||
#warning we should duplicate the data here, otherwise it's gonna crash
|
gitem2 = new RsTurtleGenericFastDataItem ;
|
||||||
gitem->data_bytes = data_bytes;
|
|
||||||
gitem->data_size = data_size ;
|
if(gitem != NULL) // duplicate the data because it was already sent in gitem.
|
||||||
|
{
|
||||||
|
gitem2->data_bytes = rs_malloc(data_size);
|
||||||
|
gitem2->data_size = data_size ;
|
||||||
|
memcpy(gitem2->data_bytes,data_bytes,data_size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gitem2->data_bytes = data_bytes;
|
||||||
|
gitem2->data_size = data_size ;
|
||||||
|
}
|
||||||
|
|
||||||
it->second.already_probed_for_fast_items = true;
|
it->second.already_probed_for_fast_items = true;
|
||||||
mTurtle->sendTurtleData(virtual_peer_id,gitem) ;
|
|
||||||
}
|
}
|
||||||
|
if(gitem2) mTurtle->sendTurtleData(virtual_peer_id,gitem2) ;
|
||||||
|
#endif
|
||||||
|
if(gitem) mTurtle->sendTurtleData(virtual_peer_id,gitem) ;
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,10 @@ private:
|
|||||||
class GxsTunnelPeerInfo
|
class GxsTunnelPeerInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GxsTunnelPeerInfo() : last_contact(0), last_keep_alive_sent(0), status(0), direction(0),accepts_fast_turtle_items(false)
|
GxsTunnelPeerInfo() : last_contact(0), last_keep_alive_sent(0), status(0), direction(0)
|
||||||
|
#ifndef V07_NON_BACKWARD_COMPATIBLE_CHANGE_004
|
||||||
|
,accepts_fast_turtle_items(false)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
memset(aes_key, 0, GXS_TUNNEL_AES_KEY_SIZE);
|
memset(aes_key, 0, GXS_TUNNEL_AES_KEY_SIZE);
|
||||||
|
|
||||||
@ -170,8 +173,10 @@ private:
|
|||||||
std::map<uint64_t,rstime_t> received_data_prints ; // list of recently received messages, to avoid duplicates. Kept for 20 mins at most.
|
std::map<uint64_t,rstime_t> received_data_prints ; // list of recently received messages, to avoid duplicates. Kept for 20 mins at most.
|
||||||
uint32_t total_sent ; // total data sent to this peer
|
uint32_t total_sent ; // total data sent to this peer
|
||||||
uint32_t total_received ; // total data received by this peer
|
uint32_t total_received ; // total data received by this peer
|
||||||
|
#ifndef V07_NON_BACKWARD_COMPATIBLE_CHANGE_004
|
||||||
bool accepts_fast_turtle_items; // does the tunnel accept RsTurtleGenericFastDataItem type?
|
bool accepts_fast_turtle_items; // does the tunnel accept RsTurtleGenericFastDataItem type?
|
||||||
bool already_probed_for_fast_items; // has the tunnel been probed already? If not, a fast item will be sent
|
bool already_probed_for_fast_items; // has the tunnel been probed already? If not, a fast item will be sent
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class GxsTunnelDHInfo
|
class GxsTunnelDHInfo
|
||||||
@ -243,7 +248,11 @@ private:
|
|||||||
bool locked_sendEncryptedTunnelData(RsGxsTunnelItem *item) ;
|
bool locked_sendEncryptedTunnelData(RsGxsTunnelItem *item) ;
|
||||||
bool locked_sendClearTunnelData(RsGxsTunnelDHPublicKeyItem *item); // this limits the usage to DH items. Others should be encrypted!
|
bool locked_sendClearTunnelData(RsGxsTunnelDHPublicKeyItem *item); // this limits the usage to DH items. Others should be encrypted!
|
||||||
|
|
||||||
|
#ifndef V07_NON_BACKWARD_COMPATIBLE_CHANGE_004
|
||||||
bool handleEncryptedData(const uint8_t *data_bytes, uint32_t data_size, const TurtleFileHash& hash, const RsPeerId& virtual_peer_id, bool accepts_fast_items) ;
|
bool handleEncryptedData(const uint8_t *data_bytes, uint32_t data_size, const TurtleFileHash& hash, const RsPeerId& virtual_peer_id, bool accepts_fast_items) ;
|
||||||
|
#else
|
||||||
|
bool handleEncryptedData(const uint8_t *data_bytes, uint32_t data_size, const TurtleFileHash& hash, const RsPeerId& virtual_peer_id) ;
|
||||||
|
#endif
|
||||||
|
|
||||||
// local data
|
// local data
|
||||||
|
|
||||||
|
@ -230,11 +230,18 @@ isEmpty(RS_UPNP_LIB):RS_UPNP_LIB = upnp ixml threadutil
|
|||||||
#
|
#
|
||||||
# V07_NON_BACKWARD_COMPATIBLE_CHANGE_003:
|
# V07_NON_BACKWARD_COMPATIBLE_CHANGE_003:
|
||||||
#
|
#
|
||||||
# What: Do not hash PGP certificate twice when signing
|
# What: Do not hash PGP certificate twice when signing
|
||||||
#
|
#
|
||||||
# Why: hasing twice is not per se a security issue, but it makes it harder to change the settings for hashing.
|
# Why: hasing twice is not per se a security issue, but it makes it harder to change the settings for hashing.
|
||||||
#
|
#
|
||||||
# Backward compat: patched peers cannot connect to non patched peers older than Nov 2017.
|
# Backward compat: patched peers cannot connect to non patched peers older than Nov 2017.
|
||||||
|
#
|
||||||
|
# V07_NON_BACKWARD_COMPATIBLE_CHANGE_004:
|
||||||
|
#
|
||||||
|
# What: Do not probe that GXS tunnels accept fast items. Just assume they do.
|
||||||
|
# Why: Avoids sending probe packets
|
||||||
|
# BackwardCompat: old RS before Mai 2019 will not be able to distant chat.
|
||||||
|
#
|
||||||
###########################################################################################################################################################
|
###########################################################################################################################################################
|
||||||
|
|
||||||
#CONFIG += rs_v07_changes
|
#CONFIG += rs_v07_changes
|
||||||
@ -242,6 +249,7 @@ rs_v07_changes {
|
|||||||
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_001
|
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_001
|
||||||
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_002
|
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_002
|
||||||
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_003
|
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_003
|
||||||
|
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_004
|
||||||
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_UNNAMED
|
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_UNNAMED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user