More ipv6_to_ipv4 conversions

This commit is contained in:
Gioacchino Mazzurco 2018-02-26 15:55:20 +01:00
parent ac8b56951c
commit f4a6090150
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
3 changed files with 20 additions and 23 deletions

View File

@ -331,8 +331,8 @@ const RsPeerId& p3PeerMgrIMPL::getOwnId()
bool p3PeerMgrIMPL::getOwnNetStatus(peerState &state)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
state = mOwnState;
RS_STACK_MUTEX(mPeerMtx);
state = mOwnState;
return true;
}
@ -817,15 +817,12 @@ int p3PeerMgrIMPL::getFriendCount(bool ssl, bool online)
bool p3PeerMgrIMPL::getFriendNetStatus(const RsPeerId &id, peerState &state)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
RS_STACK_MUTEX(mPeerMtx);
/* check for existing */
std::map<RsPeerId, peerState>::iterator it;
it = mFriendList.find(id);
if (it == mFriendList.end())
{
return false;
}
if (it == mFriendList.end()) return false;
state = it->second;
return true;
@ -834,27 +831,24 @@ bool p3PeerMgrIMPL::getFriendNetStatus(const RsPeerId &id, peerState &state)
bool p3PeerMgrIMPL::getOthersNetStatus(const RsPeerId &id, peerState &state)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
RS_STACK_MUTEX(mPeerMtx);
/* check for existing */
std::map<RsPeerId, peerState>::iterator it;
it = mOthersList.find(id);
if (it == mOthersList.end())
{
return false;
}
if (it == mOthersList.end()) return false;
state = it->second;
return true;
}
int p3PeerMgrIMPL::getConnectAddresses(const RsPeerId &id,
struct sockaddr_storage &lAddr, struct sockaddr_storage &eAddr,
pqiIpAddrSet &histAddrs, std::string &dyndns)
int p3PeerMgrIMPL::getConnectAddresses(
const RsPeerId &id, sockaddr_storage &lAddr, sockaddr_storage &eAddr,
pqiIpAddrSet &histAddrs, std::string &dyndns )
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
RS_STACK_MUTEX(mPeerMtx);
/* check for existing */
std::map<RsPeerId, peerState>::iterator it;
it = mFriendList.find(id);
@ -865,7 +859,7 @@ int p3PeerMgrIMPL::getConnectAddresses(const RsPeerId &id,
std::cerr << std::endl;
return 0;
}
lAddr = it->second.localaddr;
eAddr = it->second.serveraddr;
histAddrs = it->second.ipAddrs;

View File

@ -357,9 +357,9 @@ public:
bool setOwnNetworkMode(uint32_t netMode);
bool setOwnVisState(uint16_t vs_disc, uint16_t vs_dht);
int getConnectAddresses(const RsPeerId &id,
struct sockaddr_storage &lAddr, struct sockaddr_storage &eAddr,
pqiIpAddrSet &histAddrs, std::string &dyndns);
int getConnectAddresses( const RsPeerId &id, sockaddr_storage &lAddr,
sockaddr_storage &eAddr, pqiIpAddrSet &histAddrs,
std::string &dyndns );
protected:

View File

@ -333,8 +333,9 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
d.hiddenNodePort = 0;
d.hiddenType = RS_HIDDEN_TYPE_NONE;
if (sockaddr_storage_ipv6_to_ipv4(ps.localaddr))
if(!sockaddr_storage_isnull(ps.localaddr))
{
sockaddr_storage_ipv6_to_ipv4(ps.localaddr);
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
d.localPort = sockaddr_storage_port(ps.localaddr);
}
@ -344,8 +345,9 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
d.localPort = 0;
}
if (sockaddr_storage_ipv6_to_ipv4(ps.serveraddr))
if(!sockaddr_storage_isnull(ps.serveraddr))
{
sockaddr_storage_ipv6_to_ipv4(ps.serveraddr);
d.extAddr = sockaddr_storage_iptostring(ps.serveraddr);
d.extPort = sockaddr_storage_port(ps.serveraddr);
}
@ -417,6 +419,7 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
if (pcs.state & RS_PEER_S_CONNECTED)
{
sockaddr_storage_ipv6_to_ipv4(pcs.connectaddr);
d.connectAddr = sockaddr_storage_iptostring(pcs.connectaddr);
d.connectPort = sockaddr_storage_port(pcs.connectaddr);
}