mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-25 17:21:27 -05:00
more cleanups + sanitize p3Peers::getPeerDetails avoid to look for port on null sockaddr_storage
This commit is contained in:
parent
ed7f958f95
commit
1303d855e6
@ -42,6 +42,10 @@
|
|||||||
class RsPeers;
|
class RsPeers;
|
||||||
extern RsPeers *rsPeers;
|
extern RsPeers *rsPeers;
|
||||||
|
|
||||||
|
/* TODO: 2015/12/31 As for type safetyness all those constant must be declared as enum!
|
||||||
|
* C++ now supports typed enum so there is no ambiguity in serialization size
|
||||||
|
*/
|
||||||
|
|
||||||
/* Trust Levels. Should be the same values than what is declared in PGPHandler.h */
|
/* Trust Levels. Should be the same values than what is declared in PGPHandler.h */
|
||||||
|
|
||||||
const uint32_t RS_TRUST_LVL_UNDEFINED = 0;
|
const uint32_t RS_TRUST_LVL_UNDEFINED = 0;
|
||||||
@ -216,7 +220,7 @@ class RsPeerDetails
|
|||||||
RsPgpId issuer;
|
RsPgpId issuer;
|
||||||
|
|
||||||
PGPFingerprintType fpr; /* pgp fingerprint */
|
PGPFingerprintType fpr; /* pgp fingerprint */
|
||||||
std::string authcode; // (cyril) what is this used for ?????
|
std::string authcode; // TODO: 2015/12/31 (cyril) what is this used for ?????
|
||||||
std::list<RsPgpId> gpgSigners;
|
std::list<RsPgpId> gpgSigners;
|
||||||
|
|
||||||
uint32_t trustLvl;
|
uint32_t trustLvl;
|
||||||
@ -234,6 +238,8 @@ class RsPeerDetails
|
|||||||
uint32_t state;
|
uint32_t state;
|
||||||
bool actAsServer;
|
bool actAsServer;
|
||||||
|
|
||||||
|
// TODO: 2015/12/31 to take advantage of multiple connection this must be
|
||||||
|
// replaced by a set of addresses
|
||||||
std::string connectAddr ; // current address if connected.
|
std::string connectAddr ; // current address if connected.
|
||||||
uint16_t connectPort ;
|
uint16_t connectPort ;
|
||||||
|
|
||||||
@ -274,7 +280,6 @@ class RsPeerDetails
|
|||||||
|
|
||||||
// This class is used to get info about crytographic algorithms used with a
|
// This class is used to get info about crytographic algorithms used with a
|
||||||
// particular peer.
|
// particular peer.
|
||||||
//
|
|
||||||
class RsPeerCryptoParams
|
class RsPeerCryptoParams
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -299,13 +304,17 @@ public:
|
|||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail);
|
std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail);
|
||||||
|
|
||||||
|
/* TODO: 2015/12/31 this class seems foundamental for RetroShare code
|
||||||
|
* understanding must document it as soon as possible
|
||||||
|
*/
|
||||||
class RsPeers
|
class RsPeers
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RsPeers() { return; }
|
RsPeers() {}
|
||||||
virtual ~RsPeers() { return; }
|
virtual ~RsPeers() {}
|
||||||
|
|
||||||
|
// TODO: 2015/12/31 is this dead code?
|
||||||
/* Updates ... */
|
/* Updates ... */
|
||||||
// not implemented
|
// not implemented
|
||||||
//virtual bool FriendsChanged() = 0;
|
//virtual bool FriendsChanged() = 0;
|
||||||
@ -322,7 +331,7 @@ class RsPeers
|
|||||||
|
|
||||||
virtual bool isOnline(const RsPeerId &ssl_id) = 0;
|
virtual bool isOnline(const RsPeerId &ssl_id) = 0;
|
||||||
virtual bool isFriend(const RsPeerId &ssl_id) = 0;
|
virtual bool isFriend(const RsPeerId &ssl_id) = 0;
|
||||||
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend) = 0; //
|
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend) = 0;
|
||||||
virtual std::string getPeerName(const RsPeerId &ssl_id) = 0;
|
virtual std::string getPeerName(const RsPeerId &ssl_id) = 0;
|
||||||
virtual std::string getGPGName(const RsPgpId& gpg_id) = 0;
|
virtual std::string getGPGName(const RsPgpId& gpg_id) = 0;
|
||||||
virtual bool getPeerDetails(const RsPeerId& ssl_id, RsPeerDetails &d) = 0;
|
virtual bool getPeerDetails(const RsPeerId& ssl_id, RsPeerDetails &d) = 0;
|
||||||
@ -410,7 +419,9 @@ class RsPeers
|
|||||||
// ... computes the sharing file permission hint flags set for this peer, that is a combination of
|
// ... computes the sharing file permission hint flags set for this peer, that is a combination of
|
||||||
// RS_FILE_HINTS_NETWORK_WIDE and RS_FILE_HINTS_BROWSABLE.
|
// RS_FILE_HINTS_NETWORK_WIDE and RS_FILE_HINTS_BROWSABLE.
|
||||||
//
|
//
|
||||||
virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id,FileStorageFlags file_sharing_flags,const std::list<std::string>& file_parent_groups) = 0;
|
virtual FileSearchFlags computePeerPermissionFlags(
|
||||||
|
const RsPeerId& peer_id, FileStorageFlags file_sharing_flags,
|
||||||
|
const std::list<std::string>& file_parent_groups) = 0;
|
||||||
|
|
||||||
/* Service permission flags */
|
/* Service permission flags */
|
||||||
|
|
||||||
|
@ -256,8 +256,6 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
|||||||
std::cerr << "p3Peers::getPeerDetails() called for id : " << id << std::endl;
|
std::cerr << "p3Peers::getPeerDetails() called for id : " << id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// NOW Only for SSL Details.
|
|
||||||
|
|
||||||
RsPeerId sOwnId = AuthSSL::getAuthSSL()->OwnId();
|
RsPeerId sOwnId = AuthSSL::getAuthSSL()->OwnId();
|
||||||
peerState ps;
|
peerState ps;
|
||||||
|
|
||||||
@ -274,24 +272,8 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool res = getGPGDetails(id, d);
|
|
||||||
//
|
|
||||||
// d.isOnlyGPGdetail = true;
|
|
||||||
//
|
|
||||||
// if(id.length() == 16)
|
|
||||||
// d.service_perm_flags = mPeerMgr->servicePermissionFlags(id) ;
|
|
||||||
// else if(id.length() == 32)
|
|
||||||
// d.service_perm_flags = mPeerMgr->servicePermissionFlags(id) ;
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// std::cerr << "p3Peers::getPeerDetails() ERROR not an correct Id: " << id << std::endl;
|
|
||||||
// d.service_perm_flags = RS_SERVICE_PERM_NONE ;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return res ;
|
|
||||||
|
|
||||||
/* get from gpg (first), to fill in the sign and trust details */
|
/* get from gpg (first), to fill in the sign and trust details */
|
||||||
/* don't retrun now, we've got fill in the ssl and connection info */
|
/* don't return now, we've got fill in the ssl and connection info */
|
||||||
getGPGDetails(ps.gpg_id, d);
|
getGPGDetails(ps.gpg_id, d);
|
||||||
d.isOnlyGPGdetail = false;
|
d.isOnlyGPGdetail = false;
|
||||||
|
|
||||||
@ -327,10 +309,28 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
|||||||
d.hiddenNodePort = 0;
|
d.hiddenNodePort = 0;
|
||||||
d.hiddenType = RS_HIDDEN_TYPE_NONE;
|
d.hiddenType = RS_HIDDEN_TYPE_NONE;
|
||||||
|
|
||||||
|
if (sockaddr_storage_isnull(ps.localaddr))
|
||||||
|
{
|
||||||
|
d.localAddr = "INVALID_IP";
|
||||||
|
d.localPort = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
|
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
|
||||||
d.localPort = sockaddr_storage_port(ps.localaddr);
|
d.localPort = sockaddr_storage_port(ps.localaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sockaddr_storage_isnull(ps.serveraddr))
|
||||||
|
{
|
||||||
|
d.extAddr = "INVALID_IP";
|
||||||
|
d.extPort = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
d.extAddr = sockaddr_storage_iptostring(ps.serveraddr);
|
d.extAddr = sockaddr_storage_iptostring(ps.serveraddr);
|
||||||
d.extPort = sockaddr_storage_port(ps.serveraddr);
|
d.extPort = sockaddr_storage_port(ps.serveraddr);
|
||||||
|
}
|
||||||
|
|
||||||
d.dyndns = ps.dyndns;
|
d.dyndns = ps.dyndns;
|
||||||
|
|
||||||
std::list<pqiIpAddress>::iterator it;
|
std::list<pqiIpAddress>::iterator it;
|
||||||
|
@ -38,7 +38,7 @@ class p3Peers: public RsPeers
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
p3Peers(p3LinkMgr *lm, p3PeerMgr *pm, p3NetMgr *nm);
|
p3Peers(p3LinkMgr *lm, p3PeerMgr *pm, p3NetMgr *nm);
|
||||||
virtual ~p3Peers() { return; }
|
virtual ~p3Peers() {}
|
||||||
|
|
||||||
/* Updates ... */
|
/* Updates ... */
|
||||||
virtual bool FriendsChanged();
|
virtual bool FriendsChanged();
|
||||||
@ -49,15 +49,13 @@ virtual const RsPeerId& getOwnId();
|
|||||||
|
|
||||||
virtual bool haveSecretKey(const RsPgpId& gpg_id) ;
|
virtual bool haveSecretKey(const RsPgpId& gpg_id) ;
|
||||||
|
|
||||||
|
|
||||||
virtual bool getOnlineList(std::list<RsPeerId> &ids);
|
virtual bool getOnlineList(std::list<RsPeerId> &ids);
|
||||||
virtual bool getFriendList(std::list<RsPeerId> &ids);
|
virtual bool getFriendList(std::list<RsPeerId> &ids);
|
||||||
//virtual bool getOthersList(std::list<std::string> &ids);
|
|
||||||
virtual bool getPeerCount (unsigned int *friendCount, unsigned int *onlineCount, bool ssl);
|
virtual bool getPeerCount (unsigned int *friendCount, unsigned int *onlineCount, bool ssl);
|
||||||
|
|
||||||
virtual bool isOnline(const RsPeerId &id);
|
virtual bool isOnline(const RsPeerId &id);
|
||||||
virtual bool isFriend(const RsPeerId &id);
|
virtual bool isFriend(const RsPeerId &id);
|
||||||
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend); //
|
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend);
|
||||||
virtual std::string getGPGName(const RsPgpId &gpg_id);
|
virtual std::string getGPGName(const RsPgpId &gpg_id);
|
||||||
virtual std::string getPeerName(const RsPeerId& ssl_or_gpg_id);
|
virtual std::string getPeerName(const RsPeerId& ssl_or_gpg_id);
|
||||||
virtual bool getPeerDetails(const RsPeerId& ssl_or_gpg_id, RsPeerDetails &d);
|
virtual bool getPeerDetails(const RsPeerId& ssl_or_gpg_id, RsPeerDetails &d);
|
||||||
@ -96,7 +94,7 @@ virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht);
|
|||||||
|
|
||||||
virtual bool getProxyServer(const uint32_t type, std::string &addr, uint16_t &port,uint32_t& status);
|
virtual bool getProxyServer(const uint32_t type, std::string &addr, uint16_t &port,uint32_t& status);
|
||||||
virtual bool setProxyServer(const uint32_t type, const std::string &addr, const uint16_t port);
|
virtual bool setProxyServer(const uint32_t type, const std::string &addr, const uint16_t port);
|
||||||
virtual bool isProxyAddress(const uint32_t type,const sockaddr_storage&);
|
virtual bool isProxyAddress(const uint32_t type, const sockaddr_storage &addr);
|
||||||
|
|
||||||
virtual void getIPServersList(std::list<std::string>& ip_servers);
|
virtual void getIPServersList(std::list<std::string>& ip_servers);
|
||||||
virtual void allowServerIPDetermination(bool);
|
virtual void allowServerIPDetermination(bool);
|
||||||
@ -146,7 +144,6 @@ virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id,FileS
|
|||||||
p3LinkMgr *mLinkMgr;
|
p3LinkMgr *mLinkMgr;
|
||||||
p3PeerMgr *mPeerMgr;
|
p3PeerMgr *mPeerMgr;
|
||||||
p3NetMgr *mNetMgr;
|
p3NetMgr *mNetMgr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user