mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-03-31 19:18:28 -04:00
Fixed Bug in choosing port for Proxy UDP. Chooses a Random one between 30000-50000.
It was using the same port as the DHT, and switching to a Random one, on its own. * Added debugging for net reset. * Added further debugging for ssl (reset + killing existing connections) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4530 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
91b37be2e5
commit
8066862833
libretroshare/src
@ -30,13 +30,14 @@
|
|||||||
|
|
||||||
#include "util/rsnet.h"
|
#include "util/rsnet.h"
|
||||||
#include "util/rsrandom.h"
|
#include "util/rsrandom.h"
|
||||||
|
#include "util/rsdebug.h"
|
||||||
|
|
||||||
#include "util/extaddrfinder.h"
|
#include "util/extaddrfinder.h"
|
||||||
#include "util/dnsresolver.h"
|
#include "util/dnsresolver.h"
|
||||||
|
|
||||||
//#include "util/rsprint.h"
|
//#include "util/rsprint.h"
|
||||||
//#include "util/rsdebug.h"
|
//#include "util/rsdebug.h"
|
||||||
//const int p3connectzone = 3431;
|
const int p3netmgrzone = 7563;
|
||||||
|
|
||||||
#include "serialiser/rsconfigitems.h"
|
#include "serialiser/rsconfigitems.h"
|
||||||
#include "pqi/pqinotify.h"
|
#include "pqi/pqinotify.h"
|
||||||
@ -137,6 +138,11 @@ p3NetMgrIMPL::p3NetMgrIMPL()
|
|||||||
std::cerr << "p3NetMgr() Startup" << std::endl;
|
std::cerr << "p3NetMgr() Startup" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "p3NetMgr() Startup, resetting network";
|
||||||
|
rslog(RSL_WARNING, p3netmgrzone, out.str());
|
||||||
|
}
|
||||||
netReset();
|
netReset();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -229,6 +235,11 @@ void p3NetMgrIMPL::netReset()
|
|||||||
#ifdef NETMGR_DEBUG_RESET
|
#ifdef NETMGR_DEBUG_RESET
|
||||||
std::cerr << "p3NetMgrIMPL::netReset() Called" << std::endl;
|
std::cerr << "p3NetMgrIMPL::netReset() Called" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "p3NetMgr::netReset() Called";
|
||||||
|
rslog(RSL_ALERT, p3netmgrzone, out.str());
|
||||||
|
}
|
||||||
|
|
||||||
shutdown(); /* blocking shutdown call */
|
shutdown(); /* blocking shutdown call */
|
||||||
|
|
||||||
@ -471,6 +482,12 @@ void p3NetMgrIMPL::netTick()
|
|||||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||||
std::cerr << "p3NetMgrIMPL::netTick() STATUS: NEEDS_RESET" << std::endl;
|
std::cerr << "p3NetMgrIMPL::netTick() STATUS: NEEDS_RESET" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "p3NetMgr::netTick() RS_NET_NEEDS_RESET, resetting network";
|
||||||
|
rslog(RSL_WARNING, p3netmgrzone, out.str());
|
||||||
|
}
|
||||||
|
|
||||||
netReset();
|
netReset();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -870,6 +887,10 @@ void p3NetMgrIMPL::netExtCheck()
|
|||||||
|
|
||||||
/* update PeerMgr with correct info */
|
/* update PeerMgr with correct info */
|
||||||
mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr);
|
mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr);
|
||||||
|
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "p3NetMgr::netExtCheck() Network Setup Complete";
|
||||||
|
rslog(RSL_WARNING, p3netmgrzone, out.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -895,6 +916,11 @@ bool p3NetMgrIMPL::checkNetAddress()
|
|||||||
std::cerr << "p3NetMgrIMPL::checkNetAddress() no Valid Network Address, resetting network." << std::endl;
|
std::cerr << "p3NetMgrIMPL::checkNetAddress() no Valid Network Address, resetting network." << std::endl;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "p3NetMgr::checkNetAddress() No Valid Network Address, resetting network";
|
||||||
|
rslog(RSL_WARNING, p3netmgrzone, out.str());
|
||||||
|
}
|
||||||
netReset();
|
netReset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1005,6 +1031,11 @@ bool p3NetMgrIMPL::checkNetAddress()
|
|||||||
|
|
||||||
mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr);
|
mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr);
|
||||||
|
|
||||||
|
{
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "p3NetMgr::checkNetAddress() local address changed, resetting network";
|
||||||
|
rslog(RSL_WARNING, p3netmgrzone, out.str());
|
||||||
|
}
|
||||||
netReset();
|
netReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1044,6 +1075,11 @@ bool p3NetMgrIMPL::setLocalAddress(struct sockaddr_in addr)
|
|||||||
#ifdef NETMGR_DEBUG_RESET
|
#ifdef NETMGR_DEBUG_RESET
|
||||||
std::cerr << "p3NetMgrIMPL::setLocalAddress() Calling NetReset" << std::endl;
|
std::cerr << "p3NetMgrIMPL::setLocalAddress() Calling NetReset" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "p3NetMgr::setLocalAddress() local address changed, resetting network";
|
||||||
|
rslog(RSL_WARNING, p3netmgrzone, out.str());
|
||||||
|
}
|
||||||
netReset();
|
netReset();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1068,6 +1104,11 @@ bool p3NetMgrIMPL::setExtAddress(struct sockaddr_in addr)
|
|||||||
#ifdef NETMGR_DEBUG_RESET
|
#ifdef NETMGR_DEBUG_RESET
|
||||||
std::cerr << "p3NetMgrIMPL::setExtAddress() Calling NetReset" << std::endl;
|
std::cerr << "p3NetMgrIMPL::setExtAddress() Calling NetReset" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "p3NetMgr::setExtAddress() ext address changed, resetting network";
|
||||||
|
rslog(RSL_WARNING, p3netmgrzone, out.str());
|
||||||
|
}
|
||||||
netReset();
|
netReset();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1111,6 +1152,11 @@ bool p3NetMgrIMPL::setNetworkMode(uint32_t netMode)
|
|||||||
#ifdef NETMGR_DEBUG_RESET
|
#ifdef NETMGR_DEBUG_RESET
|
||||||
std::cerr << "p3NetMgrIMPL::setNetworkMode() Calling NetReset" << std::endl;
|
std::cerr << "p3NetMgrIMPL::setNetworkMode() Calling NetReset" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "p3NetMgr::setNetworkMode() Net Mode changed, resetting network";
|
||||||
|
rslog(RSL_WARNING, p3netmgrzone, out.str());
|
||||||
|
}
|
||||||
netReset();
|
netReset();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -255,7 +255,8 @@ int pqissl::reset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
out << "pqissl::reset() Complete!" << std::endl;
|
out << "pqissl::reset() Complete!" << std::endl;
|
||||||
rslog(RSL_DEBUG_BASIC, pqisslzone, out.str());
|
//rslog(RSL_DEBUG_BASIC, pqisslzone, out.str());
|
||||||
|
rslog(RSL_WARNING, pqisslzone, out.str());
|
||||||
|
|
||||||
// notify people of problem!
|
// notify people of problem!
|
||||||
// but only if we really shut something down.
|
// but only if we really shut something down.
|
||||||
@ -1294,14 +1295,14 @@ int pqissl::accept(SSL *ssl, int fd, struct sockaddr_in foreign_addr) // initiat
|
|||||||
/* shutdown existing - in all cases use the new one */
|
/* shutdown existing - in all cases use the new one */
|
||||||
if ((ssl_connection) && (ssl_connection != ssl))
|
if ((ssl_connection) && (ssl_connection != ssl))
|
||||||
{
|
{
|
||||||
rslog(RSL_DEBUG_BASIC, pqisslzone,
|
rslog(RSL_ALERT, pqisslzone,
|
||||||
"pqissl::accept() closing Previous/Existing ssl_connection");
|
"pqissl::accept() closing Previous/Existing ssl_connection");
|
||||||
SSL_shutdown(ssl_connection);
|
SSL_shutdown(ssl_connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sockfd > -1) && (sockfd != fd))
|
if ((sockfd > -1) && (sockfd != fd))
|
||||||
{
|
{
|
||||||
rslog(RSL_DEBUG_BASIC, pqisslzone,
|
rslog(RSL_ALERT, pqisslzone,
|
||||||
"pqissl::accept() closing Previous/Existing sockfd");
|
"pqissl::accept() closing Previous/Existing sockfd");
|
||||||
net_internal_close(sockfd);
|
net_internal_close(sockfd);
|
||||||
}
|
}
|
||||||
|
@ -1939,14 +1939,14 @@ int RsServer::StartupRetroShare()
|
|||||||
|
|
||||||
// NOW WE BUILD THE SECOND STACK.
|
// NOW WE BUILD THE SECOND STACK.
|
||||||
// Create the Second UdpStack... Port should be random (but openable!).
|
// Create the Second UdpStack... Port should be random (but openable!).
|
||||||
// XXX TODO
|
|
||||||
#define MIN_RANDOM_PORT 10000
|
#define MIN_RANDOM_PORT 30000
|
||||||
#define MAX_RANDOM_PORT 30000
|
#define MAX_RANDOM_PORT 50000
|
||||||
|
|
||||||
struct sockaddr_in sndladdr;
|
struct sockaddr_in sndladdr;
|
||||||
sockaddr_clear(&sndladdr);
|
sockaddr_clear(&sndladdr);
|
||||||
uint16_t rndport = MIN_RANDOM_PORT + RSRandom::random_u32() % (MAX_RANDOM_PORT - MIN_RANDOM_PORT);
|
uint16_t rndport = MIN_RANDOM_PORT + RSRandom::random_u32() % (MAX_RANDOM_PORT - MIN_RANDOM_PORT);
|
||||||
sndladdr.sin_port = htons(RsInitConfig::port);
|
sndladdr.sin_port = htons(rndport);
|
||||||
rsFixedUdpStack *mProxyStack = new rsFixedUdpStack(sndladdr);
|
rsFixedUdpStack *mProxyStack = new rsFixedUdpStack(sndladdr);
|
||||||
|
|
||||||
// FIRSTLY THE PROXY STUNNER.
|
// FIRSTLY THE PROXY STUNNER.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user