mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-17 13:30:36 -04:00
Added External Interface to control "Attached" Mode
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4483 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d0f52f1d5f
commit
f6002b3981
7 changed files with 32 additions and 2 deletions
|
@ -322,6 +322,8 @@ virtual void ConnectionAuth(bdId *srcId, bdId *proxyId, bdId *destId, uint32_t m
|
||||||
uint32_t bandwidth, uint32_t delay, uint32_t answer) = 0;
|
uint32_t bandwidth, uint32_t delay, uint32_t answer) = 0;
|
||||||
virtual void ConnectionOptions(uint32_t allowedModes, uint32_t flags) = 0;
|
virtual void ConnectionOptions(uint32_t allowedModes, uint32_t flags) = 0;
|
||||||
|
|
||||||
|
virtual bool setAttachMode(bool on) = 0;
|
||||||
|
|
||||||
|
|
||||||
/***** Add / Remove Callback Clients *****/
|
/***** Add / Remove Callback Clients *****/
|
||||||
virtual void addCallback(BitDhtCallback *cb) = 0;
|
virtual void addCallback(BitDhtCallback *cb) = 0;
|
||||||
|
|
|
@ -144,6 +144,21 @@ uint32_t bdNodeManager::statsBDVersionSize()
|
||||||
return mBdNetworkSize;
|
return mBdNetworkSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool bdNodeManager::setAttachMode(bool on)
|
||||||
|
{
|
||||||
|
if (on)
|
||||||
|
{
|
||||||
|
setNodeOptions(BITDHT_OPTIONS_MAINTAIN_UNSTABLE_PORT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setNodeOptions(0);
|
||||||
|
}
|
||||||
|
return on;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void bdNodeManager::addFindNode(bdNodeId *id, uint32_t qflags)
|
void bdNodeManager::addFindNode(bdNodeId *id, uint32_t qflags)
|
||||||
{
|
{
|
||||||
|
|
|
@ -126,6 +126,7 @@ virtual void ConnectionAuth(bdId *srcId, bdId *proxyId, bdId *destId,
|
||||||
uint32_t mode, uint32_t loc, uint32_t bandwidth, uint32_t delay, uint32_t answer);
|
uint32_t mode, uint32_t loc, uint32_t bandwidth, uint32_t delay, uint32_t answer);
|
||||||
virtual void ConnectionOptions(uint32_t allowedModes, uint32_t flags);
|
virtual void ConnectionOptions(uint32_t allowedModes, uint32_t flags);
|
||||||
|
|
||||||
|
virtual bool setAttachMode(bool on);
|
||||||
|
|
||||||
/* stats and Dht state */
|
/* stats and Dht state */
|
||||||
virtual int startDht();
|
virtual int startDht();
|
||||||
|
|
|
@ -92,11 +92,11 @@ void bdNode::setNodeOptions(uint32_t optFlags)
|
||||||
mNodeOptionFlags = optFlags;
|
mNodeOptionFlags = optFlags;
|
||||||
if (optFlags & BITDHT_OPTIONS_MAINTAIN_UNSTABLE_PORT)
|
if (optFlags & BITDHT_OPTIONS_MAINTAIN_UNSTABLE_PORT)
|
||||||
{
|
{
|
||||||
mNodeSpace.setAttachedFlag(BITDHT_PEER_STATUS_DHT_ENGINE, ATTACH_NUMBER);
|
mNodeSpace.setAttachedFlag(BITDHT_PEER_STATUS_DHT_ENGINE | BITDHT_PEER_STATUS_DHT_ENGINE_VERSION, ATTACH_NUMBER);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mNodeSpace.setAttachedFlag(BITDHT_PEER_STATUS_DHT_ENGINE, 0);
|
mNodeSpace.setAttachedFlag(BITDHT_PEER_STATUS_DHT_ENGINE | BITDHT_PEER_STATUS_DHT_ENGINE_VERSION, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -547,10 +547,14 @@ int bdSpace::updateAttachedPeers()
|
||||||
bool doAttached = (mAttachedCount > 0);
|
bool doAttached = (mAttachedCount > 0);
|
||||||
int attachedCount = 0;
|
int attachedCount = 0;
|
||||||
|
|
||||||
|
// Must scan through - otherwise we can never remove Attached state.
|
||||||
|
// It is only once every 10 minutes or so!
|
||||||
|
#if 0
|
||||||
if (!doAttached)
|
if (!doAttached)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::map<bdMetric, bdId> closest;
|
std::map<bdMetric, bdId> closest;
|
||||||
std::map<bdMetric, bdId>::iterator mit;
|
std::map<bdMetric, bdId>::iterator mit;
|
||||||
|
|
|
@ -150,6 +150,13 @@ void UdpBitDht::ConnectionOptions(uint32_t allowedModes, uint32_t flags)
|
||||||
mBitDhtManager->ConnectionOptions(allowedModes, flags);
|
mBitDhtManager->ConnectionOptions(allowedModes, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UdpBitDht::setAttachMode(bool on)
|
||||||
|
{
|
||||||
|
bdStackMutex stack(dhtMtx); /********** MUTEX LOCKED *************/
|
||||||
|
|
||||||
|
return mBitDhtManager->setAttachMode(on);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int UdpBitDht::getDhtPeerAddress(const bdNodeId *id, struct sockaddr_in &from)
|
int UdpBitDht::getDhtPeerAddress(const bdNodeId *id, struct sockaddr_in &from)
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,6 +72,7 @@ virtual bool ConnectionRequest(struct sockaddr_in *laddr, bdNodeId *target, uint
|
||||||
virtual void ConnectionAuth(bdId *srcId, bdId *proxyId, bdId *destId, uint32_t mode, uint32_t loc,
|
virtual void ConnectionAuth(bdId *srcId, bdId *proxyId, bdId *destId, uint32_t mode, uint32_t loc,
|
||||||
uint32_t bandwidth, uint32_t delay, uint32_t answer);
|
uint32_t bandwidth, uint32_t delay, uint32_t answer);
|
||||||
virtual void ConnectionOptions(uint32_t allowedModes, uint32_t flags);
|
virtual void ConnectionOptions(uint32_t allowedModes, uint32_t flags);
|
||||||
|
virtual bool setAttachMode(bool on);
|
||||||
|
|
||||||
/***** Get Results Details *****/
|
/***** Get Results Details *****/
|
||||||
virtual int getDhtPeerAddress(const bdNodeId *id, struct sockaddr_in &from);
|
virtual int getDhtPeerAddress(const bdNodeId *id, struct sockaddr_in &from);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue