more bug fixing

This commit is contained in:
csoler 2021-12-17 22:17:26 +01:00
parent af4c948024
commit 3121a61910
6 changed files with 39 additions and 62 deletions

View File

@ -37,7 +37,7 @@
using namespace Tor;
ProtocolInfoCommand::ProtocolInfoCommand(TorControl *m)
: manager(m)
: manager(m),m_authMethods(0)
{
}

View File

@ -863,15 +863,14 @@ bool TorControl::torVersionAsNewAs(const std::string& match) const
int split_size = split.size();
int i=0;
const auto& b_split(split.begin());
auto b_split(split.begin());
auto b_matchsplit(matchSplit.begin());
for(const auto& b_matchsplit:matchSplit)
for(int i=0;;)
{
if (i >= split_size)
return false;
int currentVal,matchVal;
bool ok1 = RsUtil::StringToInt((*b_split).toString(),currentVal);
bool ok2 = RsUtil::StringToInt(b_matchsplit.toString(),matchVal);
bool ok2 = RsUtil::StringToInt((*b_matchsplit).toString(),matchVal);
if (!ok1 || !ok2)
return false;
@ -881,6 +880,12 @@ bool TorControl::torVersionAsNewAs(const std::string& match) const
return false;
++i;
if(i >= split_size)
return false;
++b_split;
++b_matchsplit;
}
// Versions are equal, up to the length of match

View File

@ -70,7 +70,7 @@ public:
SocketConnected = 0x02,
Authenticating = 0x03,
Authenticated = 0x04,
HiddenServiceReady = 0x05,
HiddenServiceReady = 0x05
};
enum TorStatus

View File

@ -481,6 +481,13 @@ void TorManager::threadTick()
case TorControl::SocketConnected:
RsDbg() << "Connection established." ;
if(d->hiddenService == nullptr)
{
RsDbg() << "Setting up hidden service" ;
setupHiddenService();
}
d->control->setAuthPassword(d->process->controlPassword());
d->control->authenticate();
break;
@ -489,15 +496,12 @@ void TorManager::threadTick()
RsDbg() << "Authenticating..." ;
break;
case TorControl::Authenticated:;
case TorControl::Authenticated:
RsDbg() << "Authenticated. Looking for hidden services.";
break;
for(auto service:d->control->hiddenServices())
if(service->status() == HiddenService::Online)
{
}
case TorControl::HiddenServiceReady:
break;
case TorControl::Error:

View File

@ -36,7 +36,6 @@ TorControlDialog::TorControlDialog(QWidget *)
//QTimer::singleShot(2000,this,SLOT(checkForHiddenService())) ;
mIncomingServer = new QTcpServer(this) ;
mHiddenServiceStatus = HIDDEN_SERVICE_STATUS_UNKNOWN;
connect(mIncomingServer, SIGNAL(QTcpServer::newConnection()), this, SLOT(onIncomingConnection()));
@ -192,63 +191,33 @@ TorControlDialog::HiddenServiceStatus TorControlDialog::checkForHiddenService()
{
std::cerr << "Checking for hidden services:" ;
switch(mHiddenServiceStatus)
std::string service_id;
RsTorHiddenServiceStatus service_status = RsTor::getHiddenServiceStatus(service_id);
if(service_id.empty())
{
default:
case HIDDEN_SERVICE_STATUS_FAIL: {
std::cerr << " Hidden service setup failed. Something's wrong." << std::endl;
return mHiddenServiceStatus;
std::cerr << "Not ready yet." << std::endl;
return HIDDEN_SERVICE_STATUS_REQUESTED ;
}
case HIDDEN_SERVICE_STATUS_UNKNOWN: {
else
{
if(mHiddenService.empty())
mHiddenService = service_id ;
std::cerr << " trying to setup. " ;
std::cerr << "New service acquired. Status is " << (int)service_status ;
if(!RsTor::setupHiddenService())
if(service_status == RsTorHiddenServiceStatus::ONLINE)
{
mHiddenServiceStatus = HIDDEN_SERVICE_STATUS_FAIL ;
std::cerr << "Failed." << std::endl;
return mHiddenServiceStatus ;
}
std::cerr << "Done." << std::endl;
mHiddenServiceStatus = HIDDEN_SERVICE_STATUS_REQUESTED ;
return mHiddenServiceStatus ;
}
std::cerr << ": published and running!" << std::endl;
case HIDDEN_SERVICE_STATUS_REQUESTED: {
std::string service_id;
RsTorHiddenServiceStatus service_status = RsTor::getHiddenServiceStatus(service_id);
if(service_id.empty())
{
std::cerr << "Not ready yet." << std::endl;
return mHiddenServiceStatus ;
return HIDDEN_SERVICE_STATUS_OK ;
}
else
{
if(mHiddenService.empty())
mHiddenService = service_id ;
std::cerr << "New service acquired. Status is " << (int)service_status ;
if(service_status == RsTorHiddenServiceStatus::ONLINE)
{
mHiddenServiceStatus = HIDDEN_SERVICE_STATUS_OK ;
std::cerr << ": published and running!" << std::endl;
return mHiddenServiceStatus ;
}
else
{
std::cerr << ": not ready yet." << std::endl;
return mHiddenServiceStatus ;
}
std::cerr << ": not ready yet." << std::endl;
return HIDDEN_SERVICE_STATUS_REQUESTED ;
}
}
case HIDDEN_SERVICE_STATUS_OK :
std::cerr << "New service acquired." << std::endl;
return mHiddenServiceStatus ;
}
}

View File

@ -42,7 +42,6 @@ protected slots:
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
private:
QString mErrorMsg ;
HiddenServiceStatus mHiddenServiceStatus ;
std::string mHiddenService;
QTcpServer *mIncomingServer ;