mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 06:06:10 -04:00
Ported branch commits 2980/1: cleaned the code in IP address lists management. Removed some bugs. Changed the strategy a bit: only keep the most recent port for identical ips. Changed the interface of extAddrFinder to make it mroe secure.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2983 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
591a141a18
commit
757aa7a95d
6 changed files with 346 additions and 313 deletions
|
@ -161,7 +161,7 @@ void* doExtAddrSearch(void *p)
|
|||
sort(res.begin(),res.end()) ; // eliminates outliers.
|
||||
|
||||
|
||||
if(!inet_aton(res[res.size()/2].c_str(),&(af->_addr->sin_addr)))
|
||||
if(!inet_aton(res[res.size()/2].c_str(),af->_addr))
|
||||
{
|
||||
std::cerr << "ExtAddrFinder: Could not convert " << res[res.size()/2] << " into an address." << std::endl ;
|
||||
{
|
||||
|
@ -194,7 +194,7 @@ void ExtAddrFinder::start_request()
|
|||
pthread_detach(tid); /* so memory is reclaimed in linux */
|
||||
}
|
||||
|
||||
bool ExtAddrFinder::hasValidIP(struct sockaddr_in *addr)
|
||||
bool ExtAddrFinder::hasValidIP(struct in_addr *addr)
|
||||
{
|
||||
#ifdef EXTADDRSEARCH_DEBUG
|
||||
std::cerr << "ExtAddrFinder: Getting ip." << std::endl ;
|
||||
|
@ -284,10 +284,10 @@ ExtAddrFinder::ExtAddrFinder()
|
|||
_searching = new bool ;
|
||||
*_searching = false ;
|
||||
|
||||
mFoundTS = new time_t;
|
||||
*mFoundTS = time(NULL) - MAX_IP_STORE;
|
||||
mFoundTS = new time_t;
|
||||
*mFoundTS = time(NULL) - MAX_IP_STORE;
|
||||
|
||||
_addr = (sockaddr_in*)malloc(sizeof(sockaddr_in)) ;
|
||||
_addr = (in_addr*)malloc(sizeof(in_addr)) ;
|
||||
|
||||
_ip_servers.push_back(std::string( "checkip.dyndns.org" )) ;
|
||||
_ip_servers.push_back(std::string( "www.showmyip.com" )) ;
|
||||
|
|
|
@ -12,7 +12,7 @@ class ExtAddrFinder
|
|||
ExtAddrFinder() ;
|
||||
~ExtAddrFinder() ;
|
||||
|
||||
bool hasValidIP(struct sockaddr_in *addr) ;
|
||||
bool hasValidIP(struct in_addr *addr) ;
|
||||
void getIPServersList(std::list<std::string>& ip_servers) { ip_servers = _ip_servers ; }
|
||||
|
||||
void start_request() ;
|
||||
|
@ -24,7 +24,7 @@ class ExtAddrFinder
|
|||
|
||||
time_t *mFoundTS;
|
||||
RsMutex _addrMtx ;
|
||||
struct sockaddr_in *_addr ;
|
||||
struct in_addr *_addr ;
|
||||
bool *_found ;
|
||||
bool *_searching ;
|
||||
std::list<std::string> _ip_servers ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue