mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-20 02:53:24 -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
12 changed files with 254 additions and 74 deletions
|
|
@ -877,7 +877,10 @@ bool p3LinkMgrIMPL::connectResult(const std::string &id, bool success, uint32_t
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* 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
|
||||
{
|
||||
|
|
@ -896,6 +899,9 @@ bool p3LinkMgrIMPL::connectResult(const std::string &id, bool success, uint32_t
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* inform NetMgr that this peer is offline */
|
||||
mNetMgr->netAssistKnownPeer(id,remote_peer_address, NETASSIST_KNOWN_PEER_FRIEND | NETASSIST_KNOWN_PEER_OFFLINE);
|
||||
}
|
||||
|
||||
return success;
|
||||
|
|
|
|||
|
|
@ -888,7 +888,14 @@ void p3NetMgrIMPL::netExtCheck()
|
|||
updateNetStateBox_startup();
|
||||
|
||||
/* 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;
|
||||
out << "p3NetMgr::netExtCheck() Network Setup Complete";
|
||||
|
|
@ -1031,7 +1038,10 @@ bool p3NetMgrIMPL::checkNetAddress()
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr);
|
||||
if (mPeerMgr)
|
||||
{
|
||||
mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr);
|
||||
}
|
||||
|
||||
{
|
||||
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)
|
||||
{
|
||||
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_CLOSED 0x0003
|
||||
|
||||
|
||||
/**********
|
||||
* p3NetMgr Interface....
|
||||
* This allows a drop-in replacement for testing.
|
||||
|
|
@ -118,6 +119,7 @@ virtual bool setVisState(uint32_t visState) = 0;
|
|||
|
||||
// Switch DHT On/Off.
|
||||
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;
|
||||
|
||||
/* Get Network State */
|
||||
|
|
@ -172,6 +174,7 @@ virtual bool setVisState(uint32_t visState);
|
|||
|
||||
// Switch DHT On/Off.
|
||||
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);
|
||||
|
||||
/* Get Network State */
|
||||
|
|
|
|||
|
|
@ -716,7 +716,28 @@ bool p3PeerMgrIMPL::UpdateOwnAddress(const struct sockaddr_in &localAddr, const
|
|||
ipAddressTimed.mSeenTime = time(NULL);
|
||||
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! *****/
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -120,9 +130,11 @@ virtual bool findPeer(std::string id) = 0;
|
|||
virtual bool dropPeer(std::string id) = 0;
|
||||
|
||||
/* add non-active peers (can still toggle active/non-active via above) */
|
||||
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 int addKnownPeer(const std::string &pid, const struct sockaddr_in &addr, uint32_t flags) = 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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue