From 03fc766e55cab9253a3ebb4bb209100469230a0e Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 28 Sep 2014 09:54:20 +0000 Subject: [PATCH] basics for TOR proxy status. Unfinished git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7567 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/p3peermgr.cc | 14 +++++++++++--- libretroshare/src/pqi/p3peermgr.h | 3 +++ libretroshare/src/retroshare/rspeers.h | 7 ++++++- libretroshare/src/rsserver/p3peers.cc | 5 +++-- libretroshare/src/rsserver/p3peers.h | 2 +- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index d3c18e76e..66b2b4a1e 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -133,7 +133,9 @@ p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const RsPgpId& gpg_own_ sockaddr_storage_ipv4_aton(mProxyServerAddress, kConfigDefaultProxyServerIpAddr.c_str()); sockaddr_storage_ipv4_setport(mProxyServerAddress, - kConfigDefaultProxyServerPort); + kConfigDefaultProxyServerPort); + + mProxyServerStatus = RS_NET_PROXY_STATUS_UNKNOWN ; } #ifdef PEER_DEBUG @@ -215,12 +217,12 @@ bool p3PeerMgrIMPL::setOwnNetworkMode(uint32_t netMode) { RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ -//#ifdef PEER_DEBUG +#ifdef PEER_DEBUG std::cerr << "p3PeerMgrIMPL::setOwnNetworkMode() :"; std::cerr << " Existing netMode: " << mOwnState.netMode; std::cerr << " Input netMode: " << netMode; std::cerr << std::endl; -//#endif +#endif if (mOwnState.netMode != (netMode & RS_NET_MODE_ACTUAL)) { @@ -441,7 +443,13 @@ bool p3PeerMgrIMPL::setProxyServerAddress(const struct sockaddr_storage &proxy_a 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) { RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ diff --git a/libretroshare/src/pqi/p3peermgr.h b/libretroshare/src/pqi/p3peermgr.h index 306c9c39a..69b1d9348 100644 --- a/libretroshare/src/pqi/p3peermgr.h +++ b/libretroshare/src/pqi/p3peermgr.h @@ -184,6 +184,7 @@ virtual uint32_t getConnectionType(const RsPeerId &sslId) = 0; virtual bool setProxyServerAddress(const 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 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; @@ -284,6 +285,7 @@ virtual uint32_t getConnectionType(const RsPeerId& sslId); virtual bool setProxyServerAddress(const 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 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); @@ -364,6 +366,7 @@ private: std::map mFriendsPermissionFlags ; // permission flags for each gpg key struct sockaddr_storage mProxyServerAddress; + uint32_t mProxyServerStatus ; }; #endif // MRK_PQI_PEER_MANAGER_HEADER diff --git a/libretroshare/src/retroshare/rspeers.h b/libretroshare/src/retroshare/rspeers.h index 35059e57d..29fd94f5c 100644 --- a/libretroshare/src/retroshare/rspeers.h +++ b/libretroshare/src/retroshare/rspeers.h @@ -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_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. @@ -340,7 +345,7 @@ class RsPeers 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 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 void getIPServersList(std::list& ip_servers) = 0; diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index 9bb9faf15..9b0f34761 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -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); } -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; @@ -911,7 +911,8 @@ bool p3Peers::getProxyServer(std::string &addr, uint16_t &port) mPeerMgr->getProxyServerAddress(proxy_addr); addr = sockaddr_storage_iptostring(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) diff --git a/libretroshare/src/rsserver/p3peers.h b/libretroshare/src/rsserver/p3peers.h index dd6a758b8..9f237088b 100644 --- a/libretroshare/src/rsserver/p3peers.h +++ b/libretroshare/src/rsserver/p3peers.h @@ -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 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 void getIPServersList(std::list& ip_servers) ;