Cleaned the gui a little bit:

- added a checkbox to control the use of external servers for ip determination.
- put back Network on the left
- put channels out of RS_RELEASE_VERSION, as it's not working yet.
- NetworkDialog:
	- set the info in columns about trust to be more explicit
	- changed dark green into light green to comply with colors in the trust matrix (it's also more readable in light green)
	- corrected trust strings that appeared in the Last Contact column
- changed "generate certificate" in connect friends wizard into "export my certificate..." which is more appropriate



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1113 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2009-04-05 13:04:18 +00:00
parent afb51d5d31
commit 4bb497a905
16 changed files with 145 additions and 136 deletions

View file

@ -123,11 +123,23 @@ p3ConnectMgr::p3ConnectMgr(p3AuthMgr *am)
ownState.name = mAuthMgr->getName(ownState.id);
ownState.netMode = RS_NET_MODE_UDP;
}
mExtAddrFinder = NULL ;
use_extr_addr_finder = true ;
mExtAddrFinder = new ExtAddrFinder ;
return;
}
void p3ConnectMgr::getIPServersList(std::list<std::string>& ip_servers)
{
mExtAddrFinder->getIPServersList(ip_servers);
}
void p3ConnectMgr::setIPServersEnabled(bool b)
{
use_extr_addr_finder = b ;
std::cerr << "p3ConnectMgr: setIPServers to " << b << std::endl ;
}
void p3ConnectMgr::setOwnNetConfig(uint32_t netMode, uint32_t visState)
{
@ -406,9 +418,6 @@ void p3ConnectMgr::netTick()
uint32_t netStatus = mNetStatus;
if(mExtAddrFinder == NULL)
mExtAddrFinder = new ExtAddrFinder ;
connMtx.unlock(); /* UNLOCK MUTEX */
switch(netStatus)
@ -579,7 +588,7 @@ void p3ConnectMgr::netUdpCheck()
#endif
struct sockaddr_in tmpip ;
if (udpExtAddressCheck() || (mUpnpAddrValid) || mExtAddrFinder->hasValidIP(&tmpip))
if (udpExtAddressCheck() || (mUpnpAddrValid) || (use_extr_addr_finder && mExtAddrFinder->hasValidIP(&tmpip)))
{
bool extValid = false;
bool extAddrStable = false;
@ -605,7 +614,7 @@ void p3ConnectMgr::netUdpCheck()
extAddr = mStunExtAddr;
extAddrStable = mStunAddrStable;
}
else if(mExtAddrFinder->hasValidIP(&tmpip))
else if(use_extr_addr_finder && mExtAddrFinder->hasValidIP(&tmpip))
{
extValid = true;
extAddr = tmpip ;

View file

@ -186,6 +186,10 @@ bool getUPnPState();
bool getUPnPEnabled();
bool getDHTEnabled();
bool getIPServersEnabled() { return use_extr_addr_finder ;}
void setIPServersEnabled(bool b) ;
void getIPServersList(std::list<std::string>& ip_servers) ;
bool getNetStatusOk();
bool getNetStatusUpnpOk();
bool getNetStatusDhtOk();
@ -350,6 +354,7 @@ private:
std::list<pqiMonitor *> clients;
ExtAddrFinder *mExtAddrFinder ;
bool use_extr_addr_finder ;
/* external Address determination */
bool mUpnpAddrValid, mStunAddrValid;

View file

@ -144,6 +144,10 @@ virtual bool setExtAddress( std::string id, std::string addr, uint16_t port) =
virtual bool setNetworkMode(std::string id, uint32_t netMode) = 0;
virtual bool setVisState(std::string id, uint32_t vis) = 0;
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;
virtual void allowServerIPDetermination(bool) = 0;
virtual bool getAllowServerIPDetermination() = 0 ;
/* Auth Stuff */
virtual std::string GetRetroshareInvite() = 0;

View file

@ -459,6 +459,19 @@ bool p3Peers::connectAttempt(std::string id)
return mConnMgr->retryConnect(id);
}
void p3Peers::getIPServersList(std::list<std::string>& ip_servers)
{
mConnMgr->getIPServersList(ip_servers) ;
}
void p3Peers::allowServerIPDetermination(bool b)
{
mConnMgr->setIPServersEnabled(b) ;
}
bool p3Peers::getAllowServerIPDetermination()
{
return mConnMgr->getIPServersEnabled() ;
}
bool p3Peers::setLocalAddress(std::string id, std::string addr_str, uint16_t port)
{
#ifdef P3PEERS_DEBUG

View file

@ -67,6 +67,10 @@ virtual bool setExtAddress(std::string id, std::string addr, uint16_t port);
virtual bool setNetworkMode(std::string id, uint32_t netMode);
virtual bool setVisState(std::string id, uint32_t mode);
virtual void getIPServersList(std::list<std::string>& ip_servers) ;
virtual void allowServerIPDetermination(bool) ;
virtual bool getAllowServerIPDetermination() ;
/* Auth Stuff */
virtual std::string GetRetroshareInvite();

View file

@ -120,31 +120,24 @@ static void getPage(const std::string& server_name,std::string& page)
}
extern "C" void* doExtAddrSearch(void *p)
void* doExtAddrSearch(void *p)
{
static const int nb_ipservers = 4 ;
const std::string servers[nb_ipservers] = {
"checkip.dyndns.org",
"www.showmyip.com",
"showip.net",
"www.displaymyip.com"
};
std::vector<std::string> res ;
ExtAddrFinder *af = (ExtAddrFinder*)p ;
for(int i=0;i<nb_ipservers;++i)
for(std::list<std::string>::const_iterator it(af->_ip_servers.begin());it!=af->_ip_servers.end();++it)
{
std::string page ;
getPage(servers[i],page) ;
getPage(*it,page) ;
std::string ip = scan_ip(page) ;
if(ip != "")
res.push_back(ip) ;
#ifdef EXTADDRSEARCH_DEBUG
std::cout << "ip found through " << servers[i] << ": \"" << ip << "\"" << std::endl ;
std::cout << "ip found through " << *it << ": \"" << ip << "\"" << std::endl ;
#endif
}
if(res.empty())
@ -244,6 +237,11 @@ ExtAddrFinder::ExtAddrFinder()
_addr = (sockaddr_in*)malloc(sizeof(sockaddr_in)) ;
_ip_servers.push_back(std::string( "checkip.dyndns.org" )) ;
_ip_servers.push_back(std::string( "www.showmyip.com" )) ;
_ip_servers.push_back(std::string( "showip.net" )) ;
_ip_servers.push_back(std::string( "www.displaymyip.com")) ;
start_request() ;
}

View file

@ -1,5 +1,7 @@
#pragma once
#include <list>
#include <string>
#include "util/rsthreads.h"
struct sockaddr ;
@ -11,11 +13,16 @@ class ExtAddrFinder
~ExtAddrFinder() ;
bool hasValidIP(struct sockaddr_in *addr) ;
void getIPServersList(std::list<std::string>& ip_servers) { ip_servers = _ip_servers ; }
void start_request() ;
private:
friend void* doExtAddrSearch(void *p) ;
RsMutex _addrMtx ;
struct sockaddr_in *_addr ;
bool *_found ;
bool *_searching ;
std::list<std::string> _ip_servers ;
};