diff --git a/libretroshare/src/retroshare/rspeers.h b/libretroshare/src/retroshare/rspeers.h index 29fd94f5c..3315f6087 100644 --- a/libretroshare/src/retroshare/rspeers.h +++ b/libretroshare/src/retroshare/rspeers.h @@ -91,6 +91,7 @@ const uint32_t RS_PEER_CONNECTSTATE_TRYING_TCP = 2; const uint32_t RS_PEER_CONNECTSTATE_TRYING_UDP = 3; const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_TCP = 4; const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_UDP = 5; +const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_TOR = 6; const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN = 7; diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index 78e224510..3ffa6c59e 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -432,20 +432,22 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d) } } else if (pcs.state & RS_PEER_S_CONNECTED) - { - if (pcs.connecttype == RS_NET_CONN_TCP_ALL) - { - d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TCP; - } - else if (pcs.connecttype == RS_NET_CONN_UDP_ALL) - { - d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UDP; - } - else - { - d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN; - } - } + { + if(isProxyAddress(pcs.connectaddr)) + d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TOR; + else if (pcs.connecttype == RS_NET_CONN_TCP_ALL) + { + d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TCP; + } + else if (pcs.connecttype == RS_NET_CONN_UDP_ALL) + { + d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UDP; + } + else + { + d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN; + } + } d.wasDeniedConnection = pcs.wasDeniedConnection; d.deniedTS = pcs.deniedTS; @@ -453,6 +455,18 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d) return true; } +bool p3Peers::isProxyAddress(const sockaddr_storage& addr) +{ + uint16_t port ; + std::string string_addr; + uint32_t status ; + + if(!getProxyServer(string_addr, port, status)) + return false ; + + return sockaddr_storage_iptostring(addr)==string_addr && sockaddr_storage_port(addr)==port ; +} + bool p3Peers::isKeySupported(const RsPgpId& id) { return AuthGPG::getAuthGPG()->isKeySupported(id); diff --git a/libretroshare/src/rsserver/p3peers.h b/libretroshare/src/rsserver/p3peers.h index 9f237088b..9f8443f9e 100644 --- a/libretroshare/src/rsserver/p3peers.h +++ b/libretroshare/src/rsserver/p3peers.h @@ -30,6 +30,7 @@ class p3LinkMgr; class p3PeerMgr; class p3NetMgr; +struct sockaddr_storage; class p3Peers: public RsPeers @@ -95,6 +96,7 @@ virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht); 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 isProxyAddress(const sockaddr_storage&); virtual void getIPServersList(std::list& ip_servers) ; virtual void allowServerIPDetermination(bool) ; diff --git a/retroshare-gui/src/gui/common/StatusDefs.cpp b/retroshare-gui/src/gui/common/StatusDefs.cpp index 6cc4f771f..6945605c5 100644 --- a/retroshare-gui/src/gui/common/StatusDefs.cpp +++ b/retroshare-gui/src/gui/common/StatusDefs.cpp @@ -156,6 +156,9 @@ QString StatusDefs::connectStateString(RsPeerDetails &details) case RS_PEER_CONNECTSTATE_CONNECTED_UDP: stateString = qApp->translate("StatusDefs", "Connected: UDP"); break; + case RS_PEER_CONNECTSTATE_CONNECTED_TOR: + stateString = qApp->translate("StatusDefs", "Connected: TOR"); + break; case RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN: stateString = qApp->translate("StatusDefs", "Connected: Unknown"); break;