- added more debug info to p3LinkMgr

- added check for banned IP from DHT at connection time
- added regular removal of banned IPs from friend IP lists
- increased time of banned IP storage to 1 week (previously 6 hours)
- added save for banned IPs to keep them after restart (in bdfilter.cc) to file bdfilter.txt (can be manually updated)
- changed mFiltered into a std::map for increased search efficiency
- added secondary check of cert ID at connection time.-This line, and those below, will be ignored--

M    libretroshare/src/pqi/p3netmgr.cc
M    libretroshare/src/pqi/pqimonitor.h
M    libretroshare/src/pqi/p3peermgr.cc
M    libretroshare/src/pqi/p3linkmgr.h
M    libretroshare/src/pqi/pqissllistener.cc
M    libretroshare/src/pqi/p3peermgr.h
M    libretroshare/src/pqi/p3linkmgr.cc
M    libretroshare/src/pqi/pqiperson.cc
M    libretroshare/src/pqi/pqissl.cc
M    libretroshare/src/rsserver/rsinit.cc
M    libretroshare/src/dht/p3bitdht_relay.cc
M    libretroshare/src/dht/p3bitdht.cc
M    libretroshare/src/dht/p3bitdht.h
M    libretroshare/src/retroshare/rsdht.h
M    libbitdht/src/udp/udpbitdht.h
M    libbitdht/src/udp/udpbitdht.cc
M    libbitdht/src/bitdht/bdmanager.cc
M    libbitdht/src/bitdht/bdmanager.h
M    libbitdht/src/bitdht/bdnode.h
M    libbitdht/src/bitdht/bdfilter.h
M    libbitdht/src/bitdht/bdfilter.cc
M    libbitdht/src/bitdht/bdnode.cc
M    libbitdht/src/bitdht/bdstore.h


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8289 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-05-25 14:02:45 +00:00
parent e9b9dce9f5
commit 5b2ba1e81c
23 changed files with 442 additions and 200 deletions

View file

@ -70,12 +70,14 @@
#define HISTORY_PERIOD 60
bdNode::bdNode(bdNodeId *ownId, std::string dhtVersion, std::string bootfile, bdDhtFunctions *fns)
:mNodeSpace(ownId, fns), mQueryMgr(NULL), mConnMgr(NULL),
mFilterPeers(NULL), mOwnId(*ownId), mDhtVersion(dhtVersion), mStore(bootfile, fns), mFns(fns),
mFriendList(ownId), mHistory(HISTORY_PERIOD)
bdNode::bdNode(bdNodeId *ownId, std::string dhtVersion, const std::string& bootfile, const std::string& filterfile, bdDhtFunctions *fns)
:mNodeSpace(ownId, fns),
mFilterPeers(filterfile,ownId, BITDHT_FILTER_REASON_OWNID, fns),
mQueryMgr(NULL),
mConnMgr(NULL),
mOwnId(*ownId), mDhtVersion(dhtVersion), mStore(bootfile, fns), mFns(fns),
mFriendList(ownId), mHistory(HISTORY_PERIOD)
{
init(); /* (uses this pointers) stuff it - do it here! */
}
@ -84,9 +86,6 @@ void bdNode::init()
mQueryMgr = new bdQueryManager(&mNodeSpace, mFns, this);
mConnMgr = new bdConnectManager(&mOwnId, &mNodeSpace, mQueryMgr, mFns, this);
std::list<bdFilteredPeer> emptyList;
mFilterPeers = new bdFilter(&mOwnId, emptyList, BITDHT_FILTER_REASON_OWNID, mFns);
//setNodeOptions(BITDHT_OPTIONS_MAINTAIN_UNSTABLE_PORT);
setNodeOptions(0);
@ -94,7 +93,15 @@ void bdNode::init()
setNodeDhtMode(BITDHT_MODE_TRAFFIC_DEFAULT);
}
//void bdNode::getFilteredPeers(std::list<bdFilteredPeer>& peers)
//{
// mFilterPeers.getFilteredPeers(peers) ;
//}
//
//void bdNode::loadFilteredPeers(const std::list<bdFilteredPeer>& peers)
//{
// mFilterPeers.loadFilteredPeers(peers) ;
//}
/* Unfortunately I've ended up with 2 calls down through the heirarchy...
* not ideal - must clean this up one day.
*/
@ -249,7 +256,12 @@ void bdNode::shutdownNode()
/* Crappy initial store... use bdspace as answer */
void bdNode::updateStore()
{
mStore.writeStore();
mStore.writeStore();
}
bool bdNode::addressBanned(const sockaddr_in& raddr)
{
return !mFilterPeers.addrOkay(const_cast<sockaddr_in*>(&raddr)) ;
}
void bdNode::printState()
@ -481,7 +493,7 @@ void bdNode::checkPotentialPeer(bdId *id, bdId *src)
/* Check BadPeer Filters for Potential Peers too */
/* first check the filters */
if (!mFilterPeers->addrOkay(&(id->addr)))
if (!mFilterPeers.addrOkay(&(id->addr)))
{
std::cerr << "bdNode::checkPotentialPeer(";
mFns->bdPrintId(std::cerr, id);
@ -509,10 +521,10 @@ void bdNode::checkPotentialPeer(bdId *id, bdId *src)
// Stores in queue for later callback and desemination around the network.
mBadPeerQueue.queuePeer(id, 0);
mFilterPeers->addPeerToFilter(id, 0);
mFilterPeers.addPeerToFilter(id->addr, 0);
std::list<struct sockaddr_in> filteredIPs;
mFilterPeers->filteredIPs(filteredIPs);
mFilterPeers.filteredIPs(filteredIPs);
mStore.filterIpList(filteredIPs);
return;
@ -542,8 +554,6 @@ void bdNode::addPotentialPeer(bdId *id, bdId * /*src*/)
mPotentialPeers.push_back(*id);
}
// virtual so manager can do callback.
// peer flags defined in bdiface.h
void bdNode::addPeer(const bdId *id, uint32_t peerflags)
@ -556,7 +566,7 @@ void bdNode::addPeer(const bdId *id, uint32_t peerflags)
#endif
/* first check the filters */
if (mFilterPeers->checkPeer(id, peerflags))
if (mFilterPeers.checkPeer(id, peerflags))
{
std::cerr << "bdNode::addPeer(";
mFns->bdPrintId(std::cerr, id);
@ -565,7 +575,7 @@ void bdNode::addPeer(const bdId *id, uint32_t peerflags)
std::cerr << std::endl;
std::list<struct sockaddr_in> filteredIPs;
mFilterPeers->filteredIPs(filteredIPs);
mFilterPeers.filteredIPs(filteredIPs);
mStore.filterIpList(filteredIPs);
mBadPeerQueue.queuePeer(id, peerflags);
@ -597,10 +607,10 @@ void bdNode::addPeer(const bdId *id, uint32_t peerflags)
// Stores in queue for later callback and desemination around the network.
mBadPeerQueue.queuePeer(id, peerflags);
mFilterPeers->addPeerToFilter(id, peerflags);
mFilterPeers.addPeerToFilter(id->addr, peerflags);
std::list<struct sockaddr_in> filteredIPs;
mFilterPeers->filteredIPs(filteredIPs);
mFilterPeers.filteredIPs(filteredIPs);
mStore.filterIpList(filteredIPs);
// DO WE EXPLICITLY NEED TO DO THIS, OR WILL THEY JUST BE DROPPED?
@ -826,7 +836,7 @@ int bdNode::outgoingMsg(struct sockaddr_in *addr, char *msg, int *len)
void bdNode::incomingMsg(struct sockaddr_in *addr, char *msg, int len)
{
/* check against the filter */
if (mFilterPeers->addrOkay(addr))
if (mFilterPeers.addrOkay(addr))
{
bdNodeNetMsg *bdmsg = new bdNodeNetMsg(msg, len, addr);
mIncomingMsgs.push_back(bdmsg);
@ -1133,7 +1143,7 @@ void bdNode::sendPkt(char *msg, int len, struct sockaddr_in addr)
// len, inet_ntoa(addr.sin_addr), htons(addr.sin_port));
/* filter outgoing packets */
if (mFilterPeers->addrOkay(&addr))
if (mFilterPeers.addrOkay(&addr))
{
bdNodeNetMsg *bdmsg = new bdNodeNetMsg(msg, len, &addr);
//bdmsg->print(std::cerr);