mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 22:25:04 -04:00
added new flag to allow peers auto-download recommended files from trusted neighbor nodes, which give the possibility to push data to other nodes
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7955 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d029dd0368
commit
d2c4c3bb09
15 changed files with 69 additions and 52 deletions
|
@ -292,7 +292,7 @@ void ftController::searchForDirectSources()
|
|||
|
||||
if(mSearch->search(it->first, RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY, info))
|
||||
for(std::list<TransferInfo>::const_iterator pit = info.peers.begin(); pit != info.peers.end(); ++pit)
|
||||
if(rsPeers->servicePermissionFlags(pit->peerId) & RS_SERVICE_PERM_DIRECT_DL)
|
||||
if(rsPeers->servicePermissionFlags(pit->peerId) & RS_NODE_PERM_DIRECT_DL)
|
||||
if(it->second->mTransfer->addFileSource(pit->peerId)) /* if the sources don't exist already - add in */
|
||||
setPeerState(it->second->mTransfer, pit->peerId, FT_CNTRL_STANDARD_RATE, mServiceCtrl->isPeerConnected(mFtServiceId, pit->peerId));
|
||||
}
|
||||
|
@ -1134,7 +1134,7 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash
|
|||
//
|
||||
if(!(flags & RS_FILE_REQ_CACHE))
|
||||
for(std::list<RsPeerId>::iterator it = srcIds.begin(); it != srcIds.end(); )
|
||||
if(!(rsPeers->servicePermissionFlags(*it) & RS_SERVICE_PERM_DIRECT_DL))
|
||||
if(!(rsPeers->servicePermissionFlags(*it) & RS_NODE_PERM_DIRECT_DL))
|
||||
{
|
||||
std::list<RsPeerId>::iterator tmp(it) ;
|
||||
++tmp ;
|
||||
|
@ -1190,7 +1190,7 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash
|
|||
*/
|
||||
|
||||
for(it = srcIds.begin(); it != srcIds.end(); ++it)
|
||||
if(rsPeers->servicePermissionFlags(*it) & RS_SERVICE_PERM_DIRECT_DL)
|
||||
if(rsPeers->servicePermissionFlags(*it) & RS_NODE_PERM_DIRECT_DL)
|
||||
{
|
||||
uint32_t i, j;
|
||||
if ((dit->second)->mTransfer->getPeerState(*it, i, j))
|
||||
|
@ -1245,7 +1245,7 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash
|
|||
#endif
|
||||
// Because this is auto-add, we only add sources that we allow to DL from using direct transfers.
|
||||
|
||||
if ((srcIds.end() == std::find( srcIds.begin(), srcIds.end(), pit->peerId)) && (RS_SERVICE_PERM_DIRECT_DL & rsPeers->servicePermissionFlags(pit->peerId)))
|
||||
if ((srcIds.end() == std::find( srcIds.begin(), srcIds.end(), pit->peerId)) && (RS_NODE_PERM_DIRECT_DL & rsPeers->servicePermissionFlags(pit->peerId)))
|
||||
{
|
||||
srcIds.push_back(pit->peerId);
|
||||
|
||||
|
|
|
@ -1700,7 +1700,7 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* ************* */
|
||||
addFriend(peer_id, peer_pgp_id, pitem->netMode, pitem->vs_disc, pitem->vs_dht, pitem->lastContact, RS_SERVICE_PERM_ALL);
|
||||
addFriend(peer_id, peer_pgp_id, pitem->netMode, pitem->vs_disc, pitem->vs_dht, pitem->lastContact, RS_NODE_PERM_DEFAULT);
|
||||
setLocation(pitem->peerId, pitem->location);
|
||||
}
|
||||
|
||||
|
@ -2135,7 +2135,7 @@ ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const RsPeerId& ssl
|
|||
std::map<RsPeerId, peerState>::const_iterator it = mFriendList.find(ssl_id);
|
||||
|
||||
if(it == mFriendList.end())
|
||||
return RS_SERVICE_PERM_ALL ;
|
||||
return RS_NODE_PERM_DEFAULT ;
|
||||
|
||||
gpg_id = it->second.gpg_id ;
|
||||
}
|
||||
|
@ -2152,7 +2152,7 @@ ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const RsPgpId& pgp_
|
|||
std::map<RsPgpId,ServicePermissionFlags>::const_iterator it = mFriendsPermissionFlags.find( pgp_id ) ;
|
||||
|
||||
if(it == mFriendsPermissionFlags.end())
|
||||
return RS_SERVICE_PERM_ALL ;
|
||||
return RS_NODE_PERM_DEFAULT ;
|
||||
else
|
||||
return it->second ;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ virtual ~p3PeerMgr() { return; }
|
|||
|
||||
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
|
||||
uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL,
|
||||
time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_SERVICE_PERM_ALL)) = 0;
|
||||
time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT)) = 0;
|
||||
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId) = 0;
|
||||
|
||||
virtual bool isFriend(const RsPeerId& ssl_id) = 0;
|
||||
|
@ -217,7 +217,7 @@ class p3PeerMgrIMPL: public p3PeerMgr, public p3Config
|
|||
|
||||
virtual bool addFriend(const RsPeerId&ssl_id, const RsPgpId&gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
|
||||
uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL,
|
||||
time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_SERVICE_PERM_ALL));
|
||||
time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT));
|
||||
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId);
|
||||
virtual bool removeFriend(const RsPgpId &pgp_id);
|
||||
|
||||
|
|
|
@ -75,9 +75,11 @@ const uint32_t RS_PEER_STATE_UNREACHABLE= 0x0008;
|
|||
|
||||
// Service option flags.
|
||||
//
|
||||
const ServicePermissionFlags RS_SERVICE_PERM_NONE ( 0x00000000 ) ;
|
||||
const ServicePermissionFlags RS_SERVICE_PERM_DIRECT_DL ( 0x00000008 ) ;
|
||||
const ServicePermissionFlags RS_SERVICE_PERM_ALL = RS_SERVICE_PERM_DIRECT_DL ;
|
||||
const ServicePermissionFlags RS_NODE_PERM_NONE ( 0x00000000 ) ;// 0x1, 0x2 and Ox4 are deprecated.
|
||||
const ServicePermissionFlags RS_NODE_PERM_DIRECT_DL ( 0x00000008 ) ;// Accept to directly DL from this peer (breaks anonymity)
|
||||
const ServicePermissionFlags RS_NODE_PERM_ALLOW_PUSH ( 0x00000010 ) ;// Auto-DL files recommended by this peer
|
||||
const ServicePermissionFlags RS_NODE_PERM_DEFAULT = RS_NODE_PERM_DIRECT_DL ;
|
||||
const ServicePermissionFlags RS_NODE_PERM_ALL = RS_NODE_PERM_DIRECT_DL | RS_NODE_PERM_ALLOW_PUSH;
|
||||
|
||||
// ...
|
||||
|
||||
|
@ -321,7 +323,7 @@ class RsPeers
|
|||
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) = 0;
|
||||
|
||||
/* Add/Remove Friends */
|
||||
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL) = 0;
|
||||
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT) = 0;
|
||||
virtual bool removeFriend(const RsPgpId& pgp_id) = 0;
|
||||
virtual bool removeFriendLocation(const RsPeerId& sslId) = 0;
|
||||
|
||||
|
|
|
@ -1087,7 +1087,7 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
|
|||
pd.location = cert.location_name_string();
|
||||
|
||||
pd.isOnlyGPGdetail = pd.id.isNull();
|
||||
pd.service_perm_flags = RS_SERVICE_PERM_ALL ;
|
||||
pd.service_perm_flags = RS_NODE_PERM_DEFAULT ;
|
||||
|
||||
if (!cert.hidden_node_string().empty())
|
||||
{
|
||||
|
|
|
@ -75,7 +75,7 @@ virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId> &ids
|
|||
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) ;
|
||||
|
||||
/* Add/Remove Friends */
|
||||
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL);
|
||||
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT);
|
||||
virtual bool removeFriend(const RsPgpId& gpgid);
|
||||
virtual bool removeFriendLocation(const RsPeerId& sslId);
|
||||
|
||||
|
|
|
@ -911,7 +911,7 @@ void p3discovery2::processContactInfo(const SSLID &fromId, const RsDiscContactIt
|
|||
#ifdef P3DISC_DEBUG
|
||||
std::cerr << "--> Adding to friends list " << item->sslId << " - " << item->pgpId << std::endl;
|
||||
#endif
|
||||
mPeerMgr->addFriend(item->sslId, item->pgpId, item->netMode, RS_VS_DISC_OFF, RS_VS_DHT_FULL,(time_t)0,RS_SERVICE_PERM_ALL);
|
||||
mPeerMgr->addFriend(item->sslId, item->pgpId, item->netMode, RS_VS_DISC_OFF, RS_VS_DHT_FULL,(time_t)0,RS_NODE_PERM_DEFAULT);
|
||||
updatePeerAddresses(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,6 +196,13 @@ void p3MsgService::processMsg(RsMsgItem *mi, bool incoming)
|
|||
mSrcIds.insert(std::pair<uint32_t, RsMsgSrcId*>(msi->msgId, msi));
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
}
|
||||
// If the peer is allowed to push files, then auto-download the recommended files.
|
||||
|
||||
if(rsPeers->servicePermissionFlags(mi->PeerId()) & RS_NODE_PERM_ALLOW_PUSH)
|
||||
for(std::list<RsTlvFileItem>::const_iterator it(mi->attachment.items.begin());it!=mi->attachment.items.end();++it)
|
||||
rsFiles->FileRequest((*it).name,(*it).hash,(*it).filesize,std::string(),RS_FILE_REQ_ANONYMOUS_ROUTING,std::list<RsPeerId>()) ;
|
||||
|
||||
|
||||
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue