mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 16:09:37 -05:00
made init port random, depending on the SSL id
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4026 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e5385c533e
commit
081cfee461
@ -3306,7 +3306,16 @@ bool p3ConnectMgr::checkNetAddress()
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::checkNetAddress() Correcting Port to DEFAULT" << std::endl;
|
||||
#endif
|
||||
mOwnState.currentlocaladdr.sin_port = htons(PQI_DEFAULT_PORT);
|
||||
// Generate a default port from SSL id. The port will always be the
|
||||
// same, but appear random from peer to peer.
|
||||
// Random port avoids clashes, improves anonymity.
|
||||
//
|
||||
uint32_t default_port_seed = 0 ;
|
||||
for(uint i=0;i<mOwnState.id.size();++i)
|
||||
default_port_seed = (0x473a8b74u * (unsigned int)(mOwnState.id[i]) + default_port_seed)^0x11837bea ;
|
||||
|
||||
mOwnState.currentlocaladdr.sin_port = htons(PQI_MIN_PORT + (default_port_seed % (PQI_MAX_PORT - PQI_MIN_PORT)));
|
||||
|
||||
addrChanged = true;
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,7 @@ void RsInit::InitRsConfig()
|
||||
|
||||
RsInitConfig::load_trustedpeer = false;
|
||||
RsInitConfig::firsttime_run = false;
|
||||
RsInitConfig::port = (RSRandom::random_u32() & 0x1fff) + 7000 ; // random port between 7000 and 15191. Random port avoids clashes, improves anonymity.
|
||||
RsInitConfig::port = 0 ;
|
||||
RsInitConfig::forceLocalAddr = false;
|
||||
RsInitConfig::haveLogFile = false;
|
||||
RsInitConfig::outStderr = false;
|
||||
|
Loading…
Reference in New Issue
Block a user