mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-20 20:34:25 -04:00
Merging r4674 through r4699 from https://retroshare.svn.sourceforge.net/svnroot/retroshare/branches/v0.5-dhtmods into trunk.
Full Changes can be extracted from logs associated with the following checkins: r4674 r4678 r4679 r4680 r4681 r4684 r4686 r4687 r4697 r4698 r4699 Summary of changes: DHT Improvements: Added knowledge of Friends / FoFs and Relays to DHT. Added bdFriendList class to store this information. Added Checks against known Peer:IP information to detect bad peers. Bad Peer Checking is in Test Mode Only for the moment, New Interfaces to exchange above information with libretroshare Cleaned up various compiler warnings. libretroshare Improvements: Added p3BanList Service and DataTypes to exchange Bad Peer information. Added Plumbing to get info from network to DHT and back. Supply Friend List from p3LinkMgr Supply Friend of Friend List from p3Disc. Added p3Dsdv Service and DataTypes for NetworkWide Routing (Testing Mode). Various BugFixes. Patch Manual Forward mode to preserve user selected Port. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4700 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
commit
0d118c7033
46 changed files with 4373 additions and 96 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,39 @@ 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::netAssistBadPeer(const struct sockaddr_in &addr, uint32_t reason, uint32_t flags, uint32_t age)
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
||||
|
||||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgrIMPL::netAssistBadPeer(" << rs_inet_ntoa(addr.sin_addr) << ")";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
for(it = mDhts.begin(); it != mDhts.end(); it++)
|
||||
{
|
||||
(it->second)->addBadPeer(addr, reason, flags, age);
|
||||
}
|
||||
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,8 @@ 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 netAssistBadPeer(const struct sockaddr_in &addr, uint32_t reason, uint32_t flags, uint32_t age) = 0;
|
||||
virtual bool netAssistStatusUpdate(std::string id, int mode) = 0;
|
||||
|
||||
/* Get Network State */
|
||||
|
@ -172,6 +175,8 @@ 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 netAssistBadPeer(const struct sockaddr_in &addr, uint32_t reason, uint32_t flags, uint32_t age);
|
||||
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! *****/
|
||||
|
|
|
@ -79,6 +79,19 @@ virtual bool getExternalAddress(struct sockaddr_in &addr) = 0;
|
|||
};
|
||||
|
||||
|
||||
#define PNASS_TYPE_BADPEER 0x0001
|
||||
#define PNASS_REASON_UNKNOWN 0x0001
|
||||
|
||||
class pqiNetAssistPeerShare
|
||||
{
|
||||
public:
|
||||
|
||||
/* share Addresses for various reasons (bad peers, etc) */
|
||||
virtual void updatePeer(std::string id, struct sockaddr_in addr, int type, int reason, int age) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* this is for the Stunners
|
||||
*
|
||||
*
|
||||
|
@ -98,6 +111,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 +143,12 @@ 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 addBadPeer(const struct sockaddr_in &addr, uint32_t reason, uint32_t flags, uint32_t age) = 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