mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-04 17:15:31 -05:00
Incremental DHT improvement - support in libretroshare.
- Added missing Mutex protection in p3BitDht. - Added p3BitDht::addKnownPeer() to communicate with libbitdht. - Disabled placeholder versions (addFriend/AddFriendOfFriend) - Added netAssistKnownPeer() libretroshare interface. - Added calls to netAssistKnownPeer() from p3disc and p3NetMgr. - Check for NULL ptr in p3NetMgr before calling p3PeerMgr. - Added FIX to maintain MANUAL FORWARD port (untested!) - Removed some compiler warnings. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-dhtmods@4681 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
4cd7523947
commit
7b0a33c318
@ -177,9 +177,10 @@ virtual bool getNetworkStats(uint32_t &netsize, uint32_t &localnetsize);
|
|||||||
virtual bool findPeer(std::string id);
|
virtual bool findPeer(std::string id);
|
||||||
virtual bool dropPeer(std::string id);
|
virtual bool dropPeer(std::string id);
|
||||||
|
|
||||||
virtual int addFriend(const std::string pid);
|
virtual int addKnownPeer(const std::string &pid, const struct sockaddr_in &addr, uint32_t flags);
|
||||||
virtual int addFriendOfFriend(const std::string pid);
|
//virtual int addFriend(const std::string pid);
|
||||||
virtual int addOther(const std::string pid);
|
//virtual int addFriendOfFriend(const std::string pid);
|
||||||
|
//virtual int addOther(const std::string pid);
|
||||||
|
|
||||||
/* feedback on success failure of Connections */
|
/* feedback on success failure of Connections */
|
||||||
virtual void ConnectionFeedback(std::string pid, int state);
|
virtual void ConnectionFeedback(std::string pid, int state);
|
||||||
|
@ -60,67 +60,73 @@ bool p3BitDht::findPeer(std::string pid)
|
|||||||
std::cerr << "p3BitDht::findPeer(" << pid << ")";
|
std::cerr << "p3BitDht::findPeer(" << pid << ")";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
bdNodeId nid;
|
||||||
|
|
||||||
DhtPeerDetails *dpd = findInternalRsPeer_locked(pid);
|
|
||||||
if (!dpd)
|
|
||||||
{
|
{
|
||||||
dpd = addInternalPeer_locked(pid, RSDHT_PEERTYPE_FRIEND);
|
RsStackMutex stack(dhtMtx); /********* LOCKED *********/
|
||||||
|
|
||||||
|
DhtPeerDetails *dpd = findInternalRsPeer_locked(pid);
|
||||||
if (!dpd)
|
if (!dpd)
|
||||||
{
|
{
|
||||||
/* ERROR */
|
dpd = addInternalPeer_locked(pid, RSDHT_PEERTYPE_FRIEND);
|
||||||
|
if (!dpd)
|
||||||
|
{
|
||||||
|
/* ERROR */
|
||||||
#ifdef DEBUG_BITDHT
|
#ifdef DEBUG_BITDHT
|
||||||
std::cerr << "p3BitDht::findPeer() ERROR installing InternalPeer";
|
std::cerr << "p3BitDht::findPeer() ERROR installing InternalPeer";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* new entry... what do we need to set? */
|
/* new entry... what do we need to set? */
|
||||||
dpd->mDhtState = RSDHT_PEERDHT_SEARCHING;
|
dpd->mDhtState = RSDHT_PEERDHT_SEARCHING;
|
||||||
|
|
||||||
#ifdef DEBUG_BITDHT
|
#ifdef DEBUG_BITDHT
|
||||||
std::cerr << "p3BitDht::findPeer() Installed new DhtPeer with pid => NodeId: ";
|
std::cerr << "p3BitDht::findPeer() Installed new DhtPeer with pid => NodeId: ";
|
||||||
bdStdPrintNodeId(std::cerr, &(dpd->mDhtId.id));
|
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* old entry */
|
|
||||||
#ifdef DEBUG_BITDHT
|
|
||||||
std::cerr << "p3BitDht::findPeer() Reactivating DhtPeer with pid => NodeId: ";
|
|
||||||
bdStdPrintNodeId(std::cerr, &(dpd->mDhtId.id));
|
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (dpd->mDhtState != RSDHT_PEERDHT_NOT_ACTIVE)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_BITDHT
|
|
||||||
std::cerr << "p3BitDht::findPeer() WARNING DhtState is Already Active!";
|
|
||||||
bdStdPrintNodeId(std::cerr, &(dpd->mDhtId.id));
|
bdStdPrintNodeId(std::cerr, &(dpd->mDhtId.id));
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* flag as searching */
|
/* old entry */
|
||||||
dpd->mDhtState = RSDHT_PEERDHT_SEARCHING;
|
|
||||||
#ifdef DEBUG_BITDHT
|
#ifdef DEBUG_BITDHT
|
||||||
std::cerr << "p3BitDht::findPeer() Marking Old Peer as SEARCHING";
|
std::cerr << "p3BitDht::findPeer() Reactivating DhtPeer with pid => NodeId: ";
|
||||||
|
bdStdPrintNodeId(std::cerr, &(dpd->mDhtId.id));
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (dpd->mDhtState != RSDHT_PEERDHT_NOT_ACTIVE)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_BITDHT
|
||||||
|
std::cerr << "p3BitDht::findPeer() WARNING DhtState is Already Active!";
|
||||||
|
bdStdPrintNodeId(std::cerr, &(dpd->mDhtId.id));
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* flag as searching */
|
||||||
|
dpd->mDhtState = RSDHT_PEERDHT_SEARCHING;
|
||||||
|
#ifdef DEBUG_BITDHT
|
||||||
|
std::cerr << "p3BitDht::findPeer() Marking Old Peer as SEARCHING";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
nid = dpd->mDhtId.id;
|
||||||
|
|
||||||
bdNodeId nid = dpd->mDhtId.id;
|
|
||||||
|
|
||||||
#ifdef DEBUG_BITDHT
|
#ifdef DEBUG_BITDHT
|
||||||
std::cerr << "p3BitDht::findPeer() calling AddFindNode() with pid => NodeId: ";
|
std::cerr << "p3BitDht::findPeer() calling AddFindNode() with pid => NodeId: ";
|
||||||
bdStdPrintNodeId(std::cerr, &nid);
|
bdStdPrintNodeId(std::cerr, &nid);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* add in peer */
|
/* add in peer */
|
||||||
mUdpBitDht->addFindNode(&nid, BITDHT_QFLAGS_DO_IDLE | BITDHT_QFLAGS_UPDATES);
|
mUdpBitDht->addFindNode(&nid, BITDHT_QFLAGS_DO_IDLE | BITDHT_QFLAGS_UPDATES);
|
||||||
|
|
||||||
@ -134,29 +140,36 @@ bool p3BitDht::dropPeer(std::string pid)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bdNodeId nid;
|
||||||
|
|
||||||
DhtPeerDetails *dpd = findInternalRsPeer_locked(pid);
|
|
||||||
if (!dpd)
|
|
||||||
{
|
{
|
||||||
/* ERROR */
|
RsStackMutex stack(dhtMtx); /********* LOCKED *********/
|
||||||
std::cerr << "p3BitDht::dropPeer(" << pid << ") HACK TO INCLUDE FRIEND AS NON-ACTIVE PEER";
|
|
||||||
std::cerr << std::endl;
|
DhtPeerDetails *dpd = findInternalRsPeer_locked(pid);
|
||||||
|
if (!dpd)
|
||||||
addFriend(pid);
|
{
|
||||||
return false;
|
/* ERROR */
|
||||||
}
|
std::cerr << "p3BitDht::dropPeer(" << pid << ") HACK TO INCLUDE FRIEND AS NON-ACTIVE PEER";
|
||||||
|
std::cerr << std::endl;
|
||||||
/* flag as searching */
|
|
||||||
dpd->mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
|
//addFriend(pid);
|
||||||
|
dpd = addInternalPeer_locked(pid, RSDHT_PEERTYPE_FOF);
|
||||||
bdNodeId nid = dpd->mDhtId.id;
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* flag as searching */
|
||||||
|
dpd->mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
|
||||||
|
|
||||||
|
nid = dpd->mDhtId.id;
|
||||||
|
|
||||||
#ifdef DEBUG_BITDHT
|
#ifdef DEBUG_BITDHT
|
||||||
std::cerr << "p3BitDht::dropPeer() calling removeFindNode() with pid => NodeId: ";
|
std::cerr << "p3BitDht::dropPeer() calling removeFindNode() with pid => NodeId: ";
|
||||||
bdStdPrintNodeId(std::cerr, &nid);
|
bdStdPrintNodeId(std::cerr, &nid);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* remove in peer */
|
/* remove in peer */
|
||||||
mUdpBitDht->removeFindNode(&nid);
|
mUdpBitDht->removeFindNode(&nid);
|
||||||
|
|
||||||
@ -170,6 +183,84 @@ bool p3BitDht::dropPeer(std::string pid)
|
|||||||
********************************* Basic Peer Details *************************************
|
********************************* Basic Peer Details *************************************
|
||||||
******************************************************************************************/
|
******************************************************************************************/
|
||||||
|
|
||||||
|
int p3BitDht::addKnownPeer(const std::string &pid, const struct sockaddr_in &addr, uint32_t flags)
|
||||||
|
{
|
||||||
|
|
||||||
|
int p3type = 0;
|
||||||
|
int bdflags = 0;
|
||||||
|
bdId id;
|
||||||
|
bool isOwnId = false;
|
||||||
|
|
||||||
|
switch(flags & NETASSIST_KNOWN_PEER_TYPE_MASK)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case NETASSIST_KNOWN_PEER_WHITELIST:
|
||||||
|
p3type = RSDHT_PEERTYPE_OTHER;
|
||||||
|
bdflags = BITDHT_PEER_STATUS_DHT_WHITELIST;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case NETASSIST_KNOWN_PEER_FOF:
|
||||||
|
p3type = RSDHT_PEERTYPE_FOF;
|
||||||
|
bdflags = BITDHT_PEER_STATUS_DHT_FOF;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case NETASSIST_KNOWN_PEER_FRIEND:
|
||||||
|
p3type = RSDHT_PEERTYPE_FRIEND;
|
||||||
|
bdflags = BITDHT_PEER_STATUS_DHT_FRIEND;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case NETASSIST_KNOWN_PEER_RELAY:
|
||||||
|
p3type = RSDHT_PEERTYPE_OTHER;
|
||||||
|
bdflags = BITDHT_PEER_STATUS_DHT_RELAY_SERVER;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case NETASSIST_KNOWN_PEER_SELF:
|
||||||
|
p3type = RSDHT_PEERTYPE_OTHER;
|
||||||
|
bdflags = BITDHT_PEER_STATUS_DHT_SELF;
|
||||||
|
isOwnId = true;
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & NETASSIST_KNOWN_PEER_ONLINE)
|
||||||
|
{
|
||||||
|
bdflags |= BD_FRIEND_ENTRY_ONLINE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isOwnId)
|
||||||
|
{
|
||||||
|
RsStackMutex stack(dhtMtx); /********* LOCKED *********/
|
||||||
|
DhtPeerDetails *dpd = addInternalPeer_locked(pid, p3type);
|
||||||
|
|
||||||
|
|
||||||
|
if (bdflags & BD_FRIEND_ENTRY_ONLINE)
|
||||||
|
{
|
||||||
|
/* can we update the address? */
|
||||||
|
//dpd->mDhtId.addr = addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
id.id = dpd->mDhtId.id;
|
||||||
|
id.addr = addr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// shouldn't use own id without mutex - but it is static!
|
||||||
|
id.id = mOwnDhtId;
|
||||||
|
id.addr = addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
mUdpBitDht->updateKnownPeer(&id, 0, bdflags);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
int p3BitDht::addFriend(const std::string pid)
|
int p3BitDht::addFriend(const std::string pid)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(dhtMtx); /********* LOCKED *********/
|
RsStackMutex stack(dhtMtx); /********* LOCKED *********/
|
||||||
@ -192,6 +283,7 @@ int p3BitDht::addOther(const std::string pid)
|
|||||||
|
|
||||||
return (NULL != addInternalPeer_locked(pid, RSDHT_PEERTYPE_OTHER));
|
return (NULL != addInternalPeer_locked(pid, RSDHT_PEERTYPE_OTHER));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int p3BitDht::removePeer(const std::string pid)
|
int p3BitDht::removePeer(const std::string pid)
|
||||||
|
@ -877,7 +877,10 @@ bool p3LinkMgrIMPL::connectResult(const std::string &id, bool success, uint32_t
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
/* always switch it off now */
|
/* always switch it off now */
|
||||||
mNetMgr->netAssistFriend(id,false) ;
|
mNetMgr->netAssistFriend(id,false);
|
||||||
|
|
||||||
|
/* inform NetMgr that we know this peers address */
|
||||||
|
mNetMgr->netAssistKnownPeer(id,remote_peer_address, NETASSIST_KNOWN_PEER_FRIEND | NETASSIST_KNOWN_PEER_ONLINE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -896,6 +899,9 @@ bool p3LinkMgrIMPL::connectResult(const std::string &id, bool success, uint32_t
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* inform NetMgr that this peer is offline */
|
||||||
|
mNetMgr->netAssistKnownPeer(id,remote_peer_address, NETASSIST_KNOWN_PEER_FRIEND | NETASSIST_KNOWN_PEER_OFFLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
@ -888,7 +888,14 @@ void p3NetMgrIMPL::netExtCheck()
|
|||||||
updateNetStateBox_startup();
|
updateNetStateBox_startup();
|
||||||
|
|
||||||
/* update PeerMgr with correct info */
|
/* update PeerMgr with correct info */
|
||||||
mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr);
|
if (mPeerMgr)
|
||||||
|
{
|
||||||
|
mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* inform DHT about our external address */
|
||||||
|
std::string fakeId;
|
||||||
|
netAssistKnownPeer(fakeId, mExtAddr, NETASSIST_KNOWN_PEER_SELF | NETASSIST_KNOWN_PEER_ONLINE);
|
||||||
|
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << "p3NetMgr::netExtCheck() Network Setup Complete";
|
out << "p3NetMgr::netExtCheck() Network Setup Complete";
|
||||||
@ -1031,7 +1038,10 @@ bool p3NetMgrIMPL::checkNetAddress()
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr);
|
if (mPeerMgr)
|
||||||
|
{
|
||||||
|
mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
@ -1397,6 +1407,23 @@ bool p3NetMgrIMPL::netAssistFriend(std::string id, bool on)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool p3NetMgrIMPL::netAssistKnownPeer(std::string id, const struct sockaddr_in &addr, uint32_t flags)
|
||||||
|
{
|
||||||
|
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
||||||
|
|
||||||
|
#ifdef NETMGR_DEBUG
|
||||||
|
std::cerr << "p3NetMgrIMPL::netAssistKnownPeer(" << id << ")";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for(it = mDhts.begin(); it != mDhts.end(); it++)
|
||||||
|
{
|
||||||
|
(it->second)->addKnownPeer(id, addr, flags);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool p3NetMgrIMPL::netAssistAttach(bool on)
|
bool p3NetMgrIMPL::netAssistAttach(bool on)
|
||||||
{
|
{
|
||||||
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
||||||
|
@ -97,6 +97,7 @@ class UdpRelayReceiver;
|
|||||||
#define NETMGR_DHT_FEEDBACK_CONN_FAILED 0x0002
|
#define NETMGR_DHT_FEEDBACK_CONN_FAILED 0x0002
|
||||||
#define NETMGR_DHT_FEEDBACK_CONN_CLOSED 0x0003
|
#define NETMGR_DHT_FEEDBACK_CONN_CLOSED 0x0003
|
||||||
|
|
||||||
|
|
||||||
/**********
|
/**********
|
||||||
* p3NetMgr Interface....
|
* p3NetMgr Interface....
|
||||||
* This allows a drop-in replacement for testing.
|
* This allows a drop-in replacement for testing.
|
||||||
@ -118,6 +119,7 @@ virtual bool setVisState(uint32_t visState) = 0;
|
|||||||
|
|
||||||
// Switch DHT On/Off.
|
// Switch DHT On/Off.
|
||||||
virtual bool netAssistFriend(std::string id, bool on) = 0;
|
virtual bool netAssistFriend(std::string id, bool on) = 0;
|
||||||
|
virtual bool netAssistKnownPeer(std::string id, const struct sockaddr_in &addr, uint32_t flags) = 0;
|
||||||
virtual bool netAssistStatusUpdate(std::string id, int mode) = 0;
|
virtual bool netAssistStatusUpdate(std::string id, int mode) = 0;
|
||||||
|
|
||||||
/* Get Network State */
|
/* Get Network State */
|
||||||
@ -172,6 +174,7 @@ virtual bool setVisState(uint32_t visState);
|
|||||||
|
|
||||||
// Switch DHT On/Off.
|
// Switch DHT On/Off.
|
||||||
virtual bool netAssistFriend(std::string id, bool on);
|
virtual bool netAssistFriend(std::string id, bool on);
|
||||||
|
virtual bool netAssistKnownPeer(std::string id, const struct sockaddr_in &addr, uint32_t flags);
|
||||||
virtual bool netAssistStatusUpdate(std::string id, int mode);
|
virtual bool netAssistStatusUpdate(std::string id, int mode);
|
||||||
|
|
||||||
/* Get Network State */
|
/* Get Network State */
|
||||||
|
@ -716,7 +716,28 @@ bool p3PeerMgrIMPL::UpdateOwnAddress(const struct sockaddr_in &localAddr, const
|
|||||||
ipAddressTimed.mSeenTime = time(NULL);
|
ipAddressTimed.mSeenTime = time(NULL);
|
||||||
mOwnState.ipAddrs.updateExtAddrs(ipAddressTimed);
|
mOwnState.ipAddrs.updateExtAddrs(ipAddressTimed);
|
||||||
|
|
||||||
mOwnState.serveraddr = extAddr;
|
/* Attempted Fix to MANUAL FORWARD Mode....
|
||||||
|
* don't update the server address - if we are in this mode
|
||||||
|
*
|
||||||
|
* It is okay - if they get it wrong, as we put the address in the address list anyway.
|
||||||
|
* This should keep people happy, and allow for misconfiguration!
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (mOwnState.netMode & RS_NET_MODE_TRY_EXT)
|
||||||
|
{
|
||||||
|
mOwnState.serveraddr.sin_addr.s_addr = extAddr.sin_addr.s_addr;
|
||||||
|
std::cerr << "p3PeerMgrIMPL::UpdateOwnAddress() Disabling Update of Server Port ";
|
||||||
|
std::cerr << " as MANUAL FORWARD Mode";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "Address is Now: ";
|
||||||
|
std::cerr << rs_inet_ntoa(mOwnState.serveraddr.sin_addr);
|
||||||
|
std::cerr << ":" << htons(mOwnState.serveraddr.sin_port);
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mOwnState.serveraddr = extAddr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||||
|
@ -98,6 +98,16 @@ virtual int tick() = 0; /* for internal accounting */
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#define NETASSIST_KNOWN_PEER_OFFLINE 0x0001
|
||||||
|
#define NETASSIST_KNOWN_PEER_ONLINE 0x0002
|
||||||
|
|
||||||
|
#define NETASSIST_KNOWN_PEER_WHITELIST 0x0100
|
||||||
|
#define NETASSIST_KNOWN_PEER_FRIEND 0x0200
|
||||||
|
#define NETASSIST_KNOWN_PEER_FOF 0x0400
|
||||||
|
#define NETASSIST_KNOWN_PEER_RELAY 0x0800
|
||||||
|
#define NETASSIST_KNOWN_PEER_SELF 0x1000
|
||||||
|
|
||||||
|
#define NETASSIST_KNOWN_PEER_TYPE_MASK 0xff00
|
||||||
|
|
||||||
class pqiNetAssistConnect: public pqiNetAssist
|
class pqiNetAssistConnect: public pqiNetAssist
|
||||||
{
|
{
|
||||||
@ -120,9 +130,11 @@ virtual bool findPeer(std::string id) = 0;
|
|||||||
virtual bool dropPeer(std::string id) = 0;
|
virtual bool dropPeer(std::string id) = 0;
|
||||||
|
|
||||||
/* add non-active peers (can still toggle active/non-active via above) */
|
/* add non-active peers (can still toggle active/non-active via above) */
|
||||||
virtual int addFriend(const std::string pid) = 0;
|
virtual int addKnownPeer(const std::string &pid, const struct sockaddr_in &addr, uint32_t flags) = 0;
|
||||||
virtual int addFriendOfFriend(const std::string pid) = 0;
|
|
||||||
virtual int addOther(const std::string pid) = 0;
|
//virtual int addFriend(const std::string pid) = 0;
|
||||||
|
//virtual int addFriendOfFriend(const std::string pid) = 0;
|
||||||
|
//virtual int addOther(const std::string pid) = 0;
|
||||||
|
|
||||||
|
|
||||||
virtual void ConnectionFeedback(std::string pid, int mode) = 0;
|
virtual void ConnectionFeedback(std::string pid, int mode) = 0;
|
||||||
|
@ -83,7 +83,7 @@ class RsPlugin
|
|||||||
virtual MainPage *qt_page() const { return NULL ; }
|
virtual MainPage *qt_page() const { return NULL ; }
|
||||||
virtual QWidget *qt_config_panel() const { return NULL ; }
|
virtual QWidget *qt_config_panel() const { return NULL ; }
|
||||||
virtual QIcon *qt_icon() const { return NULL ; }
|
virtual QIcon *qt_icon() const { return NULL ; }
|
||||||
virtual QTranslator *qt_translator(QApplication *app, const QString& languageCode) const { return NULL ; }
|
virtual QTranslator *qt_translator(QApplication * /* app */, const QString& /* languageCode */ ) const { return NULL ; }
|
||||||
|
|
||||||
virtual std::string configurationFileName() const { return std::string() ; }
|
virtual std::string configurationFileName() const { return std::string() ; }
|
||||||
virtual std::string getShortPluginDescription() const = 0 ;
|
virtual std::string getShortPluginDescription() const = 0 ;
|
||||||
|
@ -2059,7 +2059,7 @@ int RsServer::StartupRetroShare()
|
|||||||
mPluginsManager->setInterfaces(interfaces);
|
mPluginsManager->setInterfaces(interfaces);
|
||||||
|
|
||||||
/* create Services */
|
/* create Services */
|
||||||
ad = new p3disc(mPeerMgr, mLinkMgr, pqih);
|
ad = new p3disc(mPeerMgr, mLinkMgr, mNetMgr, pqih);
|
||||||
#ifndef MINIMAL_LIBRS
|
#ifndef MINIMAL_LIBRS
|
||||||
msgSrv = new p3MsgService(mLinkMgr);
|
msgSrv = new p3MsgService(mLinkMgr);
|
||||||
chatSrv = new p3ChatService(mLinkMgr, mHistoryMgr);
|
chatSrv = new p3ChatService(mLinkMgr, mHistoryMgr);
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "pqi/p3peermgr.h"
|
#include "pqi/p3peermgr.h"
|
||||||
#include "pqi/p3linkmgr.h"
|
#include "pqi/p3linkmgr.h"
|
||||||
|
#include "pqi/p3netmgr.h"
|
||||||
|
|
||||||
#include "pqi/authssl.h"
|
#include "pqi/authssl.h"
|
||||||
#include "pqi/authgpg.h"
|
#include "pqi/authgpg.h"
|
||||||
@ -78,10 +79,10 @@ const uint32_t P3DISC_FLAGS_ASK_VERSION = 0x0080;
|
|||||||
******************************************************************************************
|
******************************************************************************************
|
||||||
*****************************************************************************************/
|
*****************************************************************************************/
|
||||||
|
|
||||||
p3disc::p3disc(p3PeerMgr *pm, p3LinkMgr *lm, pqipersongrp *pqih)
|
p3disc::p3disc(p3PeerMgr *pm, p3LinkMgr *lm, p3NetMgr *nm, pqipersongrp *pqih)
|
||||||
:p3Service(RS_SERVICE_TYPE_DISC),
|
:p3Service(RS_SERVICE_TYPE_DISC),
|
||||||
p3Config(CONFIG_TYPE_P3DISC),
|
p3Config(CONFIG_TYPE_P3DISC),
|
||||||
mPeerMgr(pm), mLinkMgr(lm),
|
mPeerMgr(pm), mLinkMgr(lm), mNetMgr(nm),
|
||||||
mPqiPersonGrp(pqih), mDiscMtx("p3disc")
|
mPqiPersonGrp(pqih), mDiscMtx("p3disc")
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||||
@ -711,6 +712,17 @@ void p3disc::recvPeerDetails(RsDiscReply *item, const std::string &certGpgId)
|
|||||||
/* skip if not one of our peers */
|
/* skip if not one of our peers */
|
||||||
if (!mPeerMgr->isFriend(pit->pid))
|
if (!mPeerMgr->isFriend(pit->pid))
|
||||||
{
|
{
|
||||||
|
/* THESE ARE OUR FRIEND OF FRIENDS ... pass this information along to NetMgr & DHT...
|
||||||
|
* as we can track FOF and use them as potential Proxies / Relays
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* add into NetMgr and non-search, so we can detect connect attempts */
|
||||||
|
mNetMgr->netAssistFriend(pit->pid,false);
|
||||||
|
|
||||||
|
/* inform NetMgr that we know this peer */
|
||||||
|
mNetMgr->netAssistKnownPeer(pit->pid, pit->currentremoteaddr,
|
||||||
|
NETASSIST_KNOWN_PEER_FOF | NETASSIST_KNOWN_PEER_OFFLINE);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@ class autoneighbour: public autoserver
|
|||||||
|
|
||||||
class p3PeerMgr;
|
class p3PeerMgr;
|
||||||
class p3LinkMgr;
|
class p3LinkMgr;
|
||||||
|
class p3NetMgr;
|
||||||
|
|
||||||
|
|
||||||
class p3disc: public p3Service, public pqiMonitor, public p3Config, public AuthGPGService
|
class p3disc: public p3Service, public pqiMonitor, public p3Config, public AuthGPGService
|
||||||
@ -81,7 +82,7 @@ class p3disc: public p3Service, public pqiMonitor, public p3Config, public AuthG
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
p3disc(p3PeerMgr *pm, p3LinkMgr *lm, pqipersongrp *persGrp);
|
p3disc(p3PeerMgr *pm, p3LinkMgr *lm, p3NetMgr *nm, pqipersongrp *persGrp);
|
||||||
|
|
||||||
/************* from pqiMonitor *******************/
|
/************* from pqiMonitor *******************/
|
||||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||||
@ -145,6 +146,7 @@ int idServers();
|
|||||||
|
|
||||||
p3PeerMgr *mPeerMgr;
|
p3PeerMgr *mPeerMgr;
|
||||||
p3LinkMgr *mLinkMgr;
|
p3LinkMgr *mLinkMgr;
|
||||||
|
p3NetMgr *mNetMgr;
|
||||||
|
|
||||||
pqipersongrp *mPqiPersonGrp;
|
pqipersongrp *mPqiPersonGrp;
|
||||||
|
|
||||||
|
@ -187,6 +187,7 @@ int p3Dsdv::generateRoutingTables(bool incremental)
|
|||||||
|
|
||||||
/* now clear significant flag */
|
/* now clear significant flag */
|
||||||
clearSignificantChangesFlags();
|
clearSignificantChangesFlags();
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -240,6 +241,7 @@ int p3Dsdv::generateRoutingTable(const std::string &peerId, bool incremental)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendItem(dsdv);
|
sendItem(dsdv);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -334,6 +336,7 @@ int p3Dsdv::handleDSDV(RsDsdvRouteItem *dsdv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -447,6 +450,7 @@ int p3Dsdv::printDsdvTable(std::ostream &out)
|
|||||||
}
|
}
|
||||||
out << std::endl;
|
out << std::endl;
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user