basics for TOR proxy status. Unfinished

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7567 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-09-28 09:54:20 +00:00
parent 65d2249bf4
commit 03fc766e55
5 changed files with 24 additions and 7 deletions

View File

@ -133,7 +133,9 @@ p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const RsPgpId& gpg_own_
sockaddr_storage_ipv4_aton(mProxyServerAddress, sockaddr_storage_ipv4_aton(mProxyServerAddress,
kConfigDefaultProxyServerIpAddr.c_str()); kConfigDefaultProxyServerIpAddr.c_str());
sockaddr_storage_ipv4_setport(mProxyServerAddress, sockaddr_storage_ipv4_setport(mProxyServerAddress,
kConfigDefaultProxyServerPort); kConfigDefaultProxyServerPort);
mProxyServerStatus = RS_NET_PROXY_STATUS_UNKNOWN ;
} }
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
@ -215,12 +217,12 @@ bool p3PeerMgrIMPL::setOwnNetworkMode(uint32_t netMode)
{ {
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
//#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::setOwnNetworkMode() :"; std::cerr << "p3PeerMgrIMPL::setOwnNetworkMode() :";
std::cerr << " Existing netMode: " << mOwnState.netMode; std::cerr << " Existing netMode: " << mOwnState.netMode;
std::cerr << " Input netMode: " << netMode; std::cerr << " Input netMode: " << netMode;
std::cerr << std::endl; std::cerr << std::endl;
//#endif #endif
if (mOwnState.netMode != (netMode & RS_NET_MODE_ACTUAL)) if (mOwnState.netMode != (netMode & RS_NET_MODE_ACTUAL))
{ {
@ -441,7 +443,13 @@ bool p3PeerMgrIMPL::setProxyServerAddress(const struct sockaddr_storage &proxy_a
return true; return true;
} }
bool p3PeerMgrIMPL::getProxyServerStatus(uint32_t& proxy_status)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
proxy_status = mProxyServerStatus;
return true;
}
bool p3PeerMgrIMPL::getProxyServerAddress(struct sockaddr_storage &proxy_addr) bool p3PeerMgrIMPL::getProxyServerAddress(struct sockaddr_storage &proxy_addr)
{ {
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/

View File

@ -184,6 +184,7 @@ virtual uint32_t getConnectionType(const RsPeerId &sslId) = 0;
virtual bool setProxyServerAddress(const struct sockaddr_storage &proxy_addr) = 0; virtual bool setProxyServerAddress(const struct sockaddr_storage &proxy_addr) = 0;
virtual bool getProxyServerAddress(struct sockaddr_storage &proxy_addr) = 0; virtual bool getProxyServerAddress(struct sockaddr_storage &proxy_addr) = 0;
virtual bool getProxyServerStatus(uint32_t& status) = 0;
virtual bool isHidden() = 0; virtual bool isHidden() = 0;
virtual bool isHiddenPeer(const RsPeerId &ssl_id) = 0; virtual bool isHiddenPeer(const RsPeerId &ssl_id) = 0;
virtual bool getProxyAddress(const RsPeerId &ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port) = 0; virtual bool getProxyAddress(const RsPeerId &ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port) = 0;
@ -284,6 +285,7 @@ virtual uint32_t getConnectionType(const RsPeerId& sslId);
virtual bool setProxyServerAddress(const struct sockaddr_storage &proxy_addr); virtual bool setProxyServerAddress(const struct sockaddr_storage &proxy_addr);
virtual bool getProxyServerAddress(struct sockaddr_storage &proxy_addr); virtual bool getProxyServerAddress(struct sockaddr_storage &proxy_addr);
virtual bool getProxyServerStatus(uint32_t &proxy_status);
virtual bool isHidden(); virtual bool isHidden();
virtual bool isHiddenPeer(const RsPeerId& ssl_id); virtual bool isHiddenPeer(const RsPeerId& ssl_id);
virtual bool getProxyAddress(const RsPeerId& ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port); virtual bool getProxyAddress(const RsPeerId& ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port);
@ -364,6 +366,7 @@ private:
std::map<RsPgpId, ServicePermissionFlags> mFriendsPermissionFlags ; // permission flags for each gpg key std::map<RsPgpId, ServicePermissionFlags> mFriendsPermissionFlags ; // permission flags for each gpg key
struct sockaddr_storage mProxyServerAddress; struct sockaddr_storage mProxyServerAddress;
uint32_t mProxyServerStatus ;
}; };
#endif // MRK_PQI_PEER_MANAGER_HEADER #endif // MRK_PQI_PEER_MANAGER_HEADER

View File

@ -159,6 +159,11 @@ const uint32_t RS_NET_CONN_TYPE_FRIEND = 0x02000000;
const uint32_t RS_NET_CONN_TYPE_SERVER = 0x04000000; const uint32_t RS_NET_CONN_TYPE_SERVER = 0x04000000;
const uint32_t RS_NET_CONN_TYPE_CLIENT = 0x08000000; const uint32_t RS_NET_CONN_TYPE_CLIENT = 0x08000000;
// working state of proxy
const uint32_t RS_NET_PROXY_STATUS_UNKNOWN = 0x0000 ;
const uint32_t RS_NET_PROXY_STATUS_OK = 0x0001 ;
// Potential certificate parsing errors. // Potential certificate parsing errors.
@ -340,7 +345,7 @@ class RsPeers
virtual bool setNetworkMode(const RsPeerId &ssl_id, uint32_t netMode) = 0; virtual bool setNetworkMode(const RsPeerId &ssl_id, uint32_t netMode) = 0;
virtual bool setVisState(const RsPeerId &ssl_id, uint16_t vs_disc, uint16_t vs_dht) = 0; virtual bool setVisState(const RsPeerId &ssl_id, uint16_t vs_disc, uint16_t vs_dht) = 0;
virtual bool getProxyServer(std::string &addr, uint16_t &port) = 0; virtual bool getProxyServer(std::string &addr, uint16_t &port,uint32_t& status_flags) = 0;
virtual bool setProxyServer(const std::string &addr, const uint16_t port) = 0; virtual bool setProxyServer(const std::string &addr, const uint16_t port) = 0;
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0; virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;

View File

@ -903,7 +903,7 @@ bool p3Peers::setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht)
return mPeerMgr->setVisState(id, vs_disc, vs_dht); return mPeerMgr->setVisState(id, vs_disc, vs_dht);
} }
bool p3Peers::getProxyServer(std::string &addr, uint16_t &port) bool p3Peers::getProxyServer(std::string &addr, uint16_t &port, uint32_t &status)
{ {
std::cerr << "p3Peers::getProxyServer()" << std::endl; std::cerr << "p3Peers::getProxyServer()" << std::endl;
@ -911,7 +911,8 @@ bool p3Peers::getProxyServer(std::string &addr, uint16_t &port)
mPeerMgr->getProxyServerAddress(proxy_addr); mPeerMgr->getProxyServerAddress(proxy_addr);
addr = sockaddr_storage_iptostring(proxy_addr); addr = sockaddr_storage_iptostring(proxy_addr);
port = sockaddr_storage_port(proxy_addr); port = sockaddr_storage_port(proxy_addr);
return true; mPeerMgr->getProxyServerStatus(status);
return true;
} }
bool p3Peers::setProxyServer(const std::string &addr_str, const uint16_t port) bool p3Peers::setProxyServer(const std::string &addr_str, const uint16_t port)

View File

@ -93,7 +93,7 @@ virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode); virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode);
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht); virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht);
virtual bool getProxyServer(std::string &addr, uint16_t &port); virtual bool getProxyServer(std::string &addr, uint16_t &port,uint32_t& status);
virtual bool setProxyServer(const std::string &addr, const uint16_t port); virtual bool setProxyServer(const std::string &addr, const uint16_t port);
virtual void getIPServersList(std::list<std::string>& ip_servers) ; virtual void getIPServersList(std::list<std::string>& ip_servers) ;