diff --git a/libretroshare/src/pqi/p3netmgr.cc b/libretroshare/src/pqi/p3netmgr.cc index 01ec5551d..099ebe9c2 100644 --- a/libretroshare/src/pqi/p3netmgr.cc +++ b/libretroshare/src/pqi/p3netmgr.cc @@ -74,6 +74,10 @@ const uint32_t MIN_TIME_BETWEEN_NET_RESET = 5; * #define NETMGR_DEBUG_TICK 1 * #define NETMGR_DEBUG_STATEBOX 1 ***/ +// #define NETMGR_DEBUG 1 +// #define NETMGR_DEBUG_RESET 1 +// #define NETMGR_DEBUG_TICK 1 +// #define NETMGR_DEBUG_STATEBOX 1 pqiNetStatus::pqiNetStatus() :mLocalAddrOk(false), mExtAddrOk(false), mExtAddrStableOk(false), diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index 561d7c241..17b444b95 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -47,6 +47,7 @@ const int p3peermgrzone = 9531; #include "retroshare/rsiface.h" // Needed for rsicontrol (should remove this dependancy) #include "retroshare/rspeers.h" // Needed for Group Parameters. +#include "retroshare/rsdht.h" // Needed for banned IPs /* Network setup States */ @@ -274,7 +275,7 @@ bool p3PeerMgrIMPL::setOwnVisState(uint16_t vs_disc, uint16_t vs_dht) void p3PeerMgrIMPL::tick() { - static const time_t INTERVAL_BETWEEN_LOCATION_CLEANING = 600 ; // Remove unused locations and clean IPs every 10 minutes. + static const time_t INTERVAL_BETWEEN_LOCATION_CLEANING = 300 ; // Remove unused locations and clean IPs every 10 minutes. static time_t last_friends_check = time(NULL) ; // first cleaning after 1 hour. @@ -993,6 +994,12 @@ bool p3PeerMgrIMPL::UpdateOwnAddress(const struct sockaddr_storage &localAddr, std::cerr << ")" << std::endl; #endif + if(rsDht->isAddressBanned(localAddr)) + { + std::cerr << "(SS) Trying to set own IP to a banned IP " << sockaddr_storage_iptostring(localAddr) << ". Attack?" << std::endl; + return false ; + } + { RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ diff --git a/libretroshare/src/pqi/pqissl.cc b/libretroshare/src/pqi/pqissl.cc index b1b7c44e9..58a9251f6 100644 --- a/libretroshare/src/pqi/pqissl.cc +++ b/libretroshare/src/pqi/pqissl.cc @@ -39,6 +39,7 @@ #include "pqi/p3linkmgr.h" #include +#include const int pqisslzone = 37714; @@ -1309,6 +1310,12 @@ int pqissl::Authorise_SSL_Connection() bool res = AuthSSL::getAuthSSL()->CheckCertificate(PeerId(), peercert); bool certCorrect = true; /* WE know it okay already! */ + if(rsDht->isAddressBanned(remote_addr)) + { + std::cerr << "(SS) connection attempt from banned IP address. Refusing it. Attack??" << std::endl; + reset_locked(); + return 0 ; + } // check it's the right one. if (certCorrect) {