disallow double tunnels (encrypted+clear) in Accepted mode, since it is not needed

This commit is contained in:
mr-alice 2016-11-01 14:13:43 +01:00
parent ffdac640d8
commit 6a3610e6cb
2 changed files with 16 additions and 7 deletions

View File

@ -979,16 +979,20 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash
if(alreadyHaveFile(hash, info))
return false ;
// the strategy for requesting encryption is the following:
//
// if policy is STRICT
// - disable clear, enforce encryption
// else
// - if not specified, use clear
//
if(mDefaultEncryptionPolicy == RS_FILE_CTRL_ENCRYPTION_POLICY_STRICT)
{
flags |= RS_FILE_REQ_ENCRYPTED ;
flags &= ~RS_FILE_REQ_UNENCRYPTED ;
}
else
{
flags |= RS_FILE_REQ_ENCRYPTED ;
flags |= RS_FILE_REQ_UNENCRYPTED ;
}
else if(!(flags & ( RS_FILE_REQ_ENCRYPTED | RS_FILE_REQ_UNENCRYPTED )))
flags |= RS_FILE_REQ_UNENCRYPTED ;
if(size == 0) // we treat this special case because
{

View File

@ -269,7 +269,6 @@ bool ftServer::activateTunnels(const RsFileHash& hash,TransferRequestFlags flags
#ifdef SERVER_DEBUG
FTSERVER_DEBUG() << "Activating tunnels for hash " << hash << std::endl;
#endif
if(flags & RS_FILE_REQ_ENCRYPTED)
{
#ifdef SERVER_DEBUG
@ -277,7 +276,7 @@ bool ftServer::activateTunnels(const RsFileHash& hash,TransferRequestFlags flags
#endif
mTurtleRouter->monitorTunnels(hash_of_hash,this,true) ;
}
if(flags & RS_FILE_REQ_UNENCRYPTED)
if((flags & RS_FILE_REQ_UNENCRYPTED) && (mFtController->defaultEncryptionPolicy() != RS_FILE_CTRL_ENCRYPTION_POLICY_STRICT))
{
#ifdef SERVER_DEBUG
FTSERVER_DEBUG() << " flags require no end-to-end encryption. Requesting hash " << hash << std::endl;
@ -599,6 +598,12 @@ bool ftServer::handleTunnelRequest(const RsFileHash& hash,const RsPeerId& peer_i
}
}
if(mFtController->defaultEncryptionPolicy() == RS_FILE_CTRL_ENCRYPTION_POLICY_STRICT && hash == real_hash)
{
std::cerr << "(WW) rejecting file transfer for hash " << hash << " because the hash is not encrypted and encryption policy requires it." << std::endl;
return false ;
}
#ifdef SERVER_DEBUG
FTSERVER_DEBUG() << "ftServer: performing local hash search for hash " << hash << std::endl;