fixed a few bugs

This commit is contained in:
csoler 2021-12-18 16:45:53 +01:00
parent bdbcadc43c
commit f352235ccd
5 changed files with 18 additions and 27 deletions

View File

@ -38,7 +38,7 @@
using namespace Tor; using namespace Tor;
AddOnionCommand::AddOnionCommand(HiddenService *service) AddOnionCommand::AddOnionCommand(HiddenService *service)
: m_service(service) : m_service(service), mSucceeded([](){}), mFailed([](int){})
{ {
assert(m_service); assert(m_service);
} }

View File

@ -487,7 +487,7 @@ void TorControl::getTorInfo()
void TorControl::getTorInfoReply(TorControlCommand *sender) void TorControl::getTorInfoReply(TorControlCommand *sender)
{ {
GetConfCommand *command = dynamic_cast<GetConfCommand*>(sender); GetConfCommand *command = dynamic_cast<GetConfCommand*>(sender);
if (!command || !isConnected()) if (!command)// || !isConnected())
return; return;
std::list<ByteArray> listenAddresses = splitQuotedStrings(command->get("net/listeners/socks").front(), ' '); std::list<ByteArray> listenAddresses = splitQuotedStrings(command->get("net/listeners/socks").front(), ' ');

View File

@ -97,7 +97,7 @@ public:
void setAuthPassword(const ByteArray& password); void setAuthPassword(const ByteArray& password);
/* Connection */ /* Connection */
bool isConnected() const { return status() == Authenticated; } bool isConnected() const { return status() >= Authenticated; }
void connect(const std::string &address, uint16_t port); void connect(const std::string &address, uint16_t port);
void authenticate(); void authenticate();

View File

@ -53,21 +53,13 @@ TorControlDialog::TorControlDialog(QWidget *)
void TorControlDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event) void TorControlDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
{ {
if(event->mType != RsEventType::TOR_MANAGER) return; if(event->mType != RsEventType::TOR_MANAGER) return;
const RsTorManagerEvent *fe = dynamic_cast<const RsTorManagerEvent*>(event.get()); const RsTorManagerEvent *fe = dynamic_cast<const RsTorManagerEvent*>(event.get());
if(!fe) if(!fe)
return; return;
switch (fe->mTorManagerEventType) statusChanged(fe->mTorStatus,fe->mTorConnectivityStatus);
{
case RsTorManagerEventCode::BOOTSTRAP_STATUS_CHANGED:
case RsTorManagerEventCode::TOR_CONNECTIVITY_CHANGED:
case RsTorManagerEventCode::TOR_STATUS_CHANGED: statusChanged(fe->mTorStatus,fe->mTorConnectivityStatus);
break;
default:
break;
}
} }
void TorControlDialog::onIncomingConnection() void TorControlDialog::onIncomingConnection()
@ -112,7 +104,6 @@ void TorControlDialog::statusChanged(RsTorStatus torstatus, RsTorConnectivitySta
std::cerr << "Tor control status: " << tor_control_status_str.toStdString() << std::endl; std::cerr << "Tor control status: " << tor_control_status_str.toStdString() << std::endl;
std::cerr << "Tor status: " << torstatus_str.toStdString() << std::endl; std::cerr << "Tor status: " << torstatus_str.toStdString() << std::endl;
std::cerr << "Bootstrap status map: " << std::endl; std::cerr << "Bootstrap status map: " << std::endl;
for(auto it(qvm.begin());it!=qvm.end();++it) for(auto it(qvm.begin());it!=qvm.end();++it)

View File

@ -100,12 +100,12 @@ void TorStatus::getTorStatus()
switch(tor_control_status) switch(tor_control_status)
{ {
default: default:
case RsTorConnectivityStatus::ERROR : tor_control_ok = false ; tor_control_status_str = "Error" ; break ; case RsTorConnectivityStatus::ERROR : tor_control_ok = false ; tor_control_status_str = "Error" ; break ;
case RsTorConnectivityStatus::NOT_CONNECTED: tor_control_ok = false ; tor_control_status_str = "Not connected" ; break ; case RsTorConnectivityStatus::NOT_CONNECTED: tor_control_ok = false ; tor_control_status_str = "Not connected" ; break ;
case RsTorConnectivityStatus::CONNECTING: tor_control_ok = false ; tor_control_status_str = "Connecting" ; break ; case RsTorConnectivityStatus::CONNECTING: tor_control_ok = false ; tor_control_status_str = "Connecting" ; break ;
case RsTorConnectivityStatus::AUTHENTICATING: tor_control_ok = false ; tor_control_status_str = "Authenticating" ; break ; case RsTorConnectivityStatus::AUTHENTICATING: tor_control_ok = false ; tor_control_status_str = "Authenticating" ; break ;
case RsTorConnectivityStatus::AUTHENTICATED: tor_control_ok = false ; tor_control_status_str = "Connected" ; break ; case RsTorConnectivityStatus::AUTHENTICATED: tor_control_ok = false ; tor_control_status_str = "Connected" ; break ;
case RsTorConnectivityStatus::HIDDEN_SERVICE_READY: tor_control_ok = true ; tor_control_status_str = "Hidden service ready" ; break ; case RsTorConnectivityStatus::HIDDEN_SERVICE_READY: tor_control_ok = true ; tor_control_status_str = "Hidden service ready" ; break ;
} }
switch(torstatus) switch(torstatus)
@ -141,12 +141,12 @@ void TorStatus::getTorStatus()
if(!_updated) if(!_updated)
{ {
RsPeerDetails pd; RsPeerDetails pd;
uint32_t hiddentype; uint32_t hiddentype = RS_HIDDEN_TYPE_UNKNOWN;
if (rsPeers->getPeerDetails(rsPeers->getOwnId(), pd)) {
if (rsPeers->getPeerDetails(rsPeers->getOwnId(), pd))
{
if(pd.netMode == RS_NETMODE_HIDDEN) if(pd.netMode == RS_NETMODE_HIDDEN)
{
hiddentype = pd.hiddenType; hiddentype = pd.hiddenType;
}
} }
std::string proxyaddr; std::string proxyaddr;
uint16_t proxyport; uint16_t proxyport;