mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-31 11:54:22 -04:00
more cleanups + sanitize p3Peers::getPeerDetails avoid to look for port on null sockaddr_storage
This commit is contained in:
parent
ed7f958f95
commit
1303d855e6
3 changed files with 246 additions and 238 deletions
|
@ -243,21 +243,19 @@ bool p3Peers::isFriend(const RsPeerId &ssl_id)
|
|||
|
||||
bool p3Peers::haveSecretKey(const RsPgpId& id)
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->haveSecretKey(id) ;
|
||||
return AuthGPG::getAuthGPG()->haveSecretKey(id);
|
||||
}
|
||||
|
||||
/* There are too many dependancies of this function
|
||||
* to shift it immeidately
|
||||
*/
|
||||
|
||||
bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::getPeerDetails() called for id : " << id << std::endl;
|
||||
#endif
|
||||
|
||||
// NOW Only for SSL Details.
|
||||
|
||||
RsPeerId sOwnId = AuthSSL::getAuthSSL()->OwnId();
|
||||
peerState ps;
|
||||
|
||||
|
@ -271,27 +269,11 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
|||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::getPeerDetails() ERROR not an SSL Id: " << id << std::endl;
|
||||
#endif
|
||||
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 */
|
||||
/* 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);
|
||||
d.isOnlyGPGdetail = false;
|
||||
|
||||
|
@ -299,7 +281,7 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
|||
d.id = id;
|
||||
d.location = ps.location;
|
||||
|
||||
d.service_perm_flags = mPeerMgr->servicePermissionFlags(ps.gpg_id) ;
|
||||
d.service_perm_flags = mPeerMgr->servicePermissionFlags(ps.gpg_id);
|
||||
|
||||
/* generate */
|
||||
d.authcode = "AUTHCODE";
|
||||
|
@ -327,10 +309,28 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
|||
d.hiddenNodePort = 0;
|
||||
d.hiddenType = RS_HIDDEN_TYPE_NONE;
|
||||
|
||||
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
|
||||
d.localPort = sockaddr_storage_port(ps.localaddr);
|
||||
d.extAddr = sockaddr_storage_iptostring(ps.serveraddr);
|
||||
d.extPort = sockaddr_storage_port(ps.serveraddr);
|
||||
if (sockaddr_storage_isnull(ps.localaddr))
|
||||
{
|
||||
d.localAddr = "INVALID_IP";
|
||||
d.localPort = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
d.localAddr = sockaddr_storage_iptostring(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.extPort = sockaddr_storage_port(ps.serveraddr);
|
||||
}
|
||||
|
||||
d.dyndns = ps.dyndns;
|
||||
|
||||
std::list<pqiIpAddress>::iterator it;
|
||||
|
|
|
@ -35,118 +35,115 @@ struct sockaddr_storage;
|
|||
|
||||
class p3Peers: public RsPeers
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
p3Peers(p3LinkMgr *lm, p3PeerMgr *pm, p3NetMgr *nm);
|
||||
virtual ~p3Peers() { return; }
|
||||
p3Peers(p3LinkMgr *lm, p3PeerMgr *pm, p3NetMgr *nm);
|
||||
virtual ~p3Peers() {}
|
||||
|
||||
/* Updates ... */
|
||||
virtual bool FriendsChanged();
|
||||
virtual bool OthersChanged();
|
||||
virtual bool FriendsChanged();
|
||||
virtual bool OthersChanged();
|
||||
|
||||
/* Peer Details (Net & Auth) */
|
||||
virtual const RsPeerId& getOwnId();
|
||||
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 getFriendList(std::list<RsPeerId> &ids);
|
||||
virtual bool getPeerCount (unsigned int *friendCount, unsigned int *onlineCount, bool ssl);
|
||||
|
||||
virtual bool getOnlineList(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 isOnline(const RsPeerId &id);
|
||||
virtual bool isFriend(const RsPeerId &id);
|
||||
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend);
|
||||
virtual std::string getGPGName(const RsPgpId &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 isOnline(const RsPeerId &id);
|
||||
virtual bool isFriend(const RsPeerId &id);
|
||||
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend); //
|
||||
virtual std::string getGPGName(const RsPgpId &gpg_id);
|
||||
virtual std::string getPeerName(const RsPeerId& ssl_or_gpg_id);
|
||||
virtual bool getPeerDetails(const RsPeerId& ssl_or_gpg_id, RsPeerDetails &d);
|
||||
|
||||
/* Using PGP Ids */
|
||||
virtual const RsPgpId& getGPGOwnId();
|
||||
virtual RsPgpId getGPGId(const RsPeerId &ssl_id);
|
||||
virtual bool isKeySupported(const RsPgpId& ids);
|
||||
virtual bool getGPGAcceptedList(std::list<RsPgpId> &ids);
|
||||
virtual bool getGPGSignedList(std::list<RsPgpId> &ids);
|
||||
virtual bool getGPGValidList(std::list<RsPgpId> &ids);
|
||||
virtual bool getGPGAllList(std::list<RsPgpId> &ids);
|
||||
virtual bool getGPGDetails(const RsPgpId &id, RsPeerDetails &d);
|
||||
virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId> &ids);
|
||||
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) ;
|
||||
/* Using PGP Ids */
|
||||
virtual const RsPgpId& getGPGOwnId();
|
||||
virtual RsPgpId getGPGId(const RsPeerId &ssl_id);
|
||||
virtual bool isKeySupported(const RsPgpId& ids);
|
||||
virtual bool getGPGAcceptedList(std::list<RsPgpId> &ids);
|
||||
virtual bool getGPGSignedList(std::list<RsPgpId> &ids);
|
||||
virtual bool getGPGValidList(std::list<RsPgpId> &ids);
|
||||
virtual bool getGPGAllList(std::list<RsPgpId> &ids);
|
||||
virtual bool getGPGDetails(const RsPgpId &id, RsPeerDetails &d);
|
||||
virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId> &ids);
|
||||
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) ;
|
||||
|
||||
/* Add/Remove Friends */
|
||||
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT);
|
||||
virtual bool removeFriend(const RsPgpId& gpgid);
|
||||
virtual bool removeFriendLocation(const RsPeerId& sslId);
|
||||
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT);
|
||||
virtual bool removeFriend(const RsPgpId& gpgid);
|
||||
virtual bool removeFriendLocation(const RsPeerId& sslId);
|
||||
|
||||
/* keyring management */
|
||||
virtual bool removeKeysFromPGPKeyring(const std::set<RsPgpId> &pgp_ids,std::string& backup_file,uint32_t& error_code);
|
||||
/* keyring management */
|
||||
virtual bool removeKeysFromPGPKeyring(const std::set<RsPgpId> &pgp_ids,std::string& backup_file,uint32_t& error_code);
|
||||
|
||||
/* Network Stuff */
|
||||
virtual bool connectAttempt(const RsPeerId &id);
|
||||
virtual bool setLocation(const RsPeerId &ssl_id, const std::string &location);//location is shown in the gui to differentiate ssl certs
|
||||
virtual bool setHiddenNode(const RsPeerId &id, const std::string &hidden_node_address);
|
||||
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port);
|
||||
virtual bool connectAttempt(const RsPeerId &id);
|
||||
virtual bool setLocation(const RsPeerId &ssl_id, const std::string &location);//location is shown in the gui to differentiate ssl certs
|
||||
virtual bool setHiddenNode(const RsPeerId &id, const std::string &hidden_node_address);
|
||||
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port);
|
||||
|
||||
virtual bool setLocalAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
|
||||
virtual bool setExtAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
|
||||
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 setLocalAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
|
||||
virtual bool setExtAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
|
||||
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(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 isProxyAddress(const uint32_t type,const sockaddr_storage&);
|
||||
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 isProxyAddress(const uint32_t type, const sockaddr_storage &addr);
|
||||
|
||||
virtual void getIPServersList(std::list<std::string>& ip_servers) ;
|
||||
virtual void allowServerIPDetermination(bool) ;
|
||||
virtual bool getAllowServerIPDetermination() ;
|
||||
virtual bool resetOwnExternalAddressList() ;
|
||||
virtual void getIPServersList(std::list<std::string>& ip_servers);
|
||||
virtual void allowServerIPDetermination(bool);
|
||||
virtual bool getAllowServerIPDetermination();
|
||||
virtual bool resetOwnExternalAddressList();
|
||||
|
||||
/* Auth Stuff */
|
||||
// Get the invitation (GPG cert + local/ext address + SSL id for the given peer)
|
||||
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures);
|
||||
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) ;
|
||||
// Get the invitation (GPG cert + local/ext address + SSL id for the given peer)
|
||||
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures);
|
||||
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) ;
|
||||
|
||||
// same but for own id
|
||||
virtual std::string GetRetroshareInvite(bool include_signatures);
|
||||
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) ;
|
||||
// same but for own id
|
||||
virtual std::string GetRetroshareInvite(bool include_signatures);
|
||||
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum);
|
||||
|
||||
virtual bool hasExportMinimal() ;
|
||||
virtual bool hasExportMinimal();
|
||||
|
||||
virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,RsPgpId& pgp_id, std::string& error_string);
|
||||
virtual bool loadDetailsFromStringCert(const std::string &cert, RsPeerDetails &pd, uint32_t& error_code);
|
||||
virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,RsPgpId& pgp_id, std::string& error_string);
|
||||
virtual bool loadDetailsFromStringCert(const std::string &cert, RsPeerDetails &pd, uint32_t& error_code);
|
||||
|
||||
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code);
|
||||
virtual bool saveCertificateToFile(const RsPeerId &id, const std::string &fname);
|
||||
virtual std::string saveCertificateToString(const RsPeerId &id);
|
||||
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code);
|
||||
virtual bool saveCertificateToFile(const RsPeerId &id, const std::string &fname);
|
||||
virtual std::string saveCertificateToString(const RsPeerId &id);
|
||||
|
||||
virtual bool signGPGCertificate(const RsPgpId &id);
|
||||
virtual bool trustGPGCertificate(const RsPgpId &id, uint32_t trustlvl);
|
||||
virtual bool signGPGCertificate(const RsPgpId &id);
|
||||
virtual bool trustGPGCertificate(const RsPgpId &id, uint32_t trustlvl);
|
||||
|
||||
/* Group Stuff */
|
||||
virtual bool addGroup(RsGroupInfo &groupInfo);
|
||||
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo);
|
||||
virtual bool removeGroup(const std::string &groupId);
|
||||
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
|
||||
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
|
||||
virtual bool assignPeerToGroup(const std::string &groupId, const RsPgpId &peerId, bool assign);
|
||||
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId>& peerIds, bool assign);
|
||||
virtual bool addGroup(RsGroupInfo &groupInfo);
|
||||
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo);
|
||||
virtual bool removeGroup(const std::string &groupId);
|
||||
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
|
||||
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
|
||||
virtual bool assignPeerToGroup(const std::string &groupId, const RsPgpId &peerId, bool assign);
|
||||
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId>& peerIds, bool assign);
|
||||
|
||||
virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id,FileStorageFlags share_flags,const std::list<std::string>& parent_groups) ;
|
||||
virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id,FileStorageFlags share_flags,const std::list<std::string>& parent_groups);
|
||||
|
||||
// service permission stuff
|
||||
// service permission stuff
|
||||
|
||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) ;
|
||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId & ssl_id) ;
|
||||
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) ;
|
||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id);
|
||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId & ssl_id);
|
||||
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags);
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3PeerMgr *mPeerMgr;
|
||||
p3NetMgr *mNetMgr;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue