mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fixed hidden nodes listening failure
In case of hidden node the listen address was not properly converted to ipv4 mapped format causing bind to fail Use sockaddr_storage_copy instead of = as sockaddr_storage is not guaranted to be copyable
This commit is contained in:
parent
73c6deebf4
commit
cc091cc2c8
@ -589,7 +589,10 @@ int pqissl::Initiate_Connection()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int err;
|
int err;
|
||||||
sockaddr_storage addr = remote_addr;
|
sockaddr_storage addr; sockaddr_storage_copy(remote_addr, addr);
|
||||||
|
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << " " << sockaddr_storage_tostring(addr)
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
|
|
||||||
if(waiting != WAITING_DELAY)
|
if(waiting != WAITING_DELAY)
|
||||||
@ -638,13 +641,6 @@ int pqissl::Initiate_Connection()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
std::string out;
|
|
||||||
rs_sprintf(out, "pqissl::Initiate_Connection() Connecting To: %s via: ", PeerId().toStdString().c_str());
|
|
||||||
out += sockaddr_storage_tostring(addr);
|
|
||||||
rslog(RSL_WARNING, pqisslzone, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sockaddr_storage_isnull(addr))
|
if (sockaddr_storage_isnull(addr))
|
||||||
{
|
{
|
||||||
rslog(RSL_WARNING, pqisslzone, "pqissl::Initiate_Connection() Invalid (0.0.0.0) Remote Address, Aborting Connect.");
|
rslog(RSL_WARNING, pqisslzone, "pqissl::Initiate_Connection() Invalid (0.0.0.0) Remote Address, Aborting Connect.");
|
||||||
@ -721,6 +717,11 @@ int pqissl::Initiate_Connection()
|
|||||||
//std::cerr << "Setting Connect Timeout " << mConnectTimeout << " Seconds into Future " << std::endl;
|
//std::cerr << "Setting Connect Timeout " << mConnectTimeout << " Seconds into Future " << std::endl;
|
||||||
|
|
||||||
sockaddr_storage_ipv4_to_ipv6(addr);
|
sockaddr_storage_ipv4_to_ipv6(addr);
|
||||||
|
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << " Connecting To: "
|
||||||
|
<< PeerId().toStdString() <<" via: "
|
||||||
|
<< sockaddr_storage_tostring(addr) << std::endl;
|
||||||
|
|
||||||
if (0 != (err = unix_connect(osock, addr)))
|
if (0 != (err = unix_connect(osock, addr)))
|
||||||
{
|
{
|
||||||
switch (errno)
|
switch (errno)
|
||||||
|
@ -60,8 +60,10 @@ static struct RsLog::logInfo pqissllistenzoneInfo = {RsLog::Default, "p3peermgr"
|
|||||||
|
|
||||||
|
|
||||||
pqissllistenbase::pqissllistenbase(const sockaddr_storage &addr, p3PeerMgr *pm)
|
pqissllistenbase::pqissllistenbase(const sockaddr_storage &addr, p3PeerMgr *pm)
|
||||||
: laddr(addr), mPeerMgr(pm), active(false)
|
: mPeerMgr(pm), active(false)
|
||||||
{
|
{
|
||||||
|
sockaddr_storage_copy(addr, laddr);
|
||||||
|
|
||||||
if (!(AuthSSL::getAuthSSL()-> active()))
|
if (!(AuthSSL::getAuthSSL()-> active()))
|
||||||
{
|
{
|
||||||
pqioutput(PQL_ALERT, pqissllistenzone,
|
pqioutput(PQL_ALERT, pqissllistenzone,
|
||||||
@ -208,26 +210,20 @@ int pqissllistenbase::setuplisten()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OPEN_UNIVERSAL_PORT
|
struct sockaddr_storage tmpaddr;
|
||||||
struct sockaddr_storage tmpaddr = laddr;
|
sockaddr_storage_copy(laddr, tmpaddr);
|
||||||
if (!mPeerMgr->isHidden())
|
sockaddr_storage_ipv4_to_ipv6(tmpaddr);
|
||||||
{
|
if (!mPeerMgr->isHidden()) sockaddr_storage_zeroip(tmpaddr);
|
||||||
tmpaddr.ss_family = PF_INET6;
|
|
||||||
sockaddr_storage_zeroip(tmpaddr);
|
|
||||||
}
|
|
||||||
if (0 != (err = rs_bind(lsock, tmpaddr)))
|
if (0 != (err = rs_bind(lsock, tmpaddr)))
|
||||||
#else
|
|
||||||
if (0 != (err = universal_bind(lsock, laddr)))
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
std::string out = "pqissllistenbase::setuplisten() Cannot Bind to Local Address!\n";
|
std::string out = "pqissllistenbase::setuplisten() Cannot Bind to Local Address!\n";
|
||||||
showSocketError(out);
|
showSocketError(out);
|
||||||
pqioutput(PQL_ALERT, pqissllistenzone, out);
|
pqioutput(PQL_ALERT, pqissllistenzone, out);
|
||||||
std::cerr << out << std::endl;
|
std::cerr << out << std::endl
|
||||||
std::cerr << "laddr: " << sockaddr_storage_tostring(laddr) << std::endl;
|
<< "tmpaddr: " << sockaddr_storage_tostring(tmpaddr)
|
||||||
#ifdef OPEN_UNIVERSAL_PORT
|
<< std::endl;
|
||||||
if (!mPeerMgr->isHidden()) std::cerr << "Zeroed tmpaddr: " << sockaddr_storage_tostring(tmpaddr) << std::endl;
|
print_stacktrace();
|
||||||
#endif
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user