mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-11 07:29:38 -05:00
using random port to link Tor to local node and check that the port is available
This commit is contained in:
parent
efe2ec03ff
commit
fb1e0bc81c
@ -232,21 +232,20 @@ bool TorManager::setupHiddenService()
|
||||
// for an automatic (and portable) selection.
|
||||
|
||||
std::string address = "127.0.0.1"; // we only listen from localhost
|
||||
unsigned short port = 7934;//(quint16)m_settings->read("localListenPort").toInt();
|
||||
unsigned short hidden_service_port = 7934;//(quint16)m_settings->read("localListenPort").toInt();
|
||||
|
||||
std::cerr << "Testing host address: " << address << ":" << port ;
|
||||
|
||||
if(!test_listening_port(address,port))
|
||||
do
|
||||
{
|
||||
// XXX error case
|
||||
std::cerr << " Failed to open incoming socket" << std::endl;
|
||||
return false;
|
||||
hidden_service_port = 1025 + (RsRandom::random_u32() >> 17);
|
||||
|
||||
std::cerr << "Testing listening address:port " << address << ":" << hidden_service_port ;
|
||||
std::cerr.flush();
|
||||
}
|
||||
while(!test_listening_port(address,hidden_service_port));
|
||||
|
||||
std::cerr << " OK - Adding hidden service to TorControl." << std::endl;
|
||||
std::cerr << ": OK - Adding hidden service to TorControl." << std::endl;
|
||||
|
||||
//d->hiddenService->addTarget(9878, mIncomingServer->serverAddress(), mIncomingServer->serverPort());
|
||||
d->hiddenService->addTarget(9878, "127.0.0.1",7934);
|
||||
d->hiddenService->addTarget(9878, "127.0.0.1",hidden_service_port);
|
||||
control()->addHiddenService(d->hiddenService);
|
||||
|
||||
return true ;
|
||||
|
@ -26,15 +26,6 @@ TorControlDialog::TorControlDialog(QWidget *)
|
||||
RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this );
|
||||
}, mEventHandlerId, RsEventType::TOR_MANAGER );
|
||||
|
||||
// QObject::connect(tm->control(),SIGNAL(statusChanged(int,int)),this,SLOT(statusChanged())) ;
|
||||
// QObject::connect(tm->control(),SIGNAL(connected()),this,SLOT(statusChanged()));
|
||||
// QObject::connect(tm->control(),SIGNAL(disconnected()),this,SLOT(statusChanged()));
|
||||
// QObject::connect(tm->control(),SIGNAL(bootstrapStatusChanged()),this,SLOT(statusChanged()));
|
||||
// QObject::connect(tm->control(),SIGNAL(connectivityChanged()),this,SLOT(statusChanged()));
|
||||
// QObject::connect(tm ,SIGNAL(errorChanged()),this,SLOT(statusChanged()));
|
||||
|
||||
//QTimer::singleShot(2000,this,SLOT(checkForHiddenService())) ;
|
||||
|
||||
mIncomingServer = new QTcpServer(this) ;
|
||||
|
||||
connect(mIncomingServer, SIGNAL(QTcpServer::newConnection()), this, SLOT(onIncomingConnection()));
|
||||
|
Loading…
Reference in New Issue
Block a user