mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-11 07:29:38 -05:00
fixed a few errors in TorManager event handling
This commit is contained in:
parent
1e8e489cd1
commit
281076d6b7
@ -107,7 +107,7 @@ enum class RsEventType : uint32_t
|
||||
FILE_HASHING_COMPLETED = 20,
|
||||
|
||||
/// @see rspeers.h
|
||||
TOR_MANAGER = 17,
|
||||
TOR_MANAGER = 21,
|
||||
|
||||
__MAX /// Used internally, keep last
|
||||
};
|
||||
|
@ -56,10 +56,11 @@ enum class RsTorConnectivityStatus: uint8_t {
|
||||
ERROR = 0x00,
|
||||
NOT_CONNECTED = 0x01,
|
||||
CONNECTING = 0x02,
|
||||
AUTHENTICATING = 0x03,
|
||||
AUTHENTICATED = 0x04,
|
||||
HIDDEN_SERVICE_READY = 0x05,
|
||||
UNKNOWN = 0x06
|
||||
SOCKET_CONNECTED = 0x03,
|
||||
AUTHENTICATING = 0x04,
|
||||
AUTHENTICATED = 0x05,
|
||||
HIDDEN_SERVICE_READY = 0x06,
|
||||
UNKNOWN = 0x07
|
||||
};
|
||||
|
||||
// Status of the Tor service with which RS is talking.
|
||||
|
@ -78,11 +78,14 @@ static RsTorConnectivityStatus torConnectivityStatus(Tor::TorControl::Status t)
|
||||
switch(t)
|
||||
{
|
||||
default:
|
||||
case TorControl::Error: return RsTorConnectivityStatus::ERROR;
|
||||
case TorControl::NotConnected: return RsTorConnectivityStatus::NOT_CONNECTED;
|
||||
case TorControl::Connecting: return RsTorConnectivityStatus::CONNECTING;
|
||||
case TorControl::Authenticating: return RsTorConnectivityStatus::AUTHENTICATING;
|
||||
case TorControl::Error: return RsTorConnectivityStatus::ERROR;
|
||||
case TorControl::NotConnected: return RsTorConnectivityStatus::NOT_CONNECTED;
|
||||
case TorControl::Connecting: return RsTorConnectivityStatus::CONNECTING;
|
||||
case TorControl::SocketConnected: return RsTorConnectivityStatus::SOCKET_CONNECTED;
|
||||
case TorControl::Authenticating: return RsTorConnectivityStatus::AUTHENTICATING;
|
||||
case TorControl::Authenticated: return RsTorConnectivityStatus::AUTHENTICATED;
|
||||
case TorControl::HiddenServiceReady: return RsTorConnectivityStatus::HIDDEN_SERVICE_READY;
|
||||
case TorControl::Unknown: return RsTorConnectivityStatus::UNKNOWN;
|
||||
}
|
||||
}
|
||||
static RsTorStatus torStatus(Tor::TorControl::TorStatus t)
|
||||
@ -107,6 +110,8 @@ void TorControl::setStatus(TorControl::Status n)
|
||||
if (old == TorControl::Error)
|
||||
mErrorMessage.clear();
|
||||
|
||||
std::cerr << "Setting status to s=" << mStatus << " val=" << (int)torConnectivityStatus(mStatus) << std::endl;
|
||||
|
||||
if(rsEvents)
|
||||
{
|
||||
auto ev = std::make_shared<RsTorManagerEvent>();
|
||||
@ -133,8 +138,9 @@ void TorControl::setTorStatus(TorControl::TorStatus n)
|
||||
auto ev = std::make_shared<RsTorManagerEvent>();
|
||||
|
||||
ev->mTorManagerEventType = RsTorManagerEventCode::TOR_STATUS_CHANGED;
|
||||
ev->mTorConnectivityStatus = torConnectivityStatus(mStatus);
|
||||
ev->mTorStatus = ::torStatus(mTorStatus);
|
||||
ev->mTorConnectivityStatus = torConnectivityStatus(mStatus);
|
||||
|
||||
rsEvents->sendEvent(ev);
|
||||
}
|
||||
}
|
||||
|
@ -51,13 +51,14 @@ class TorControl : public TorControlSocketClient
|
||||
public:
|
||||
enum Status
|
||||
{
|
||||
Error = -1,
|
||||
NotConnected = 0x00,
|
||||
Connecting = 0x01,
|
||||
SocketConnected = 0x02,
|
||||
Authenticating = 0x03,
|
||||
Authenticated = 0x04,
|
||||
HiddenServiceReady = 0x05
|
||||
Error = 0x00,
|
||||
NotConnected = 0x01,
|
||||
Connecting = 0x02,
|
||||
SocketConnected = 0x03,
|
||||
Authenticating = 0x04,
|
||||
Authenticated = 0x05,
|
||||
HiddenServiceReady = 0x06,
|
||||
Unknown = 0x07
|
||||
};
|
||||
|
||||
enum TorStatus
|
||||
|
@ -239,8 +239,6 @@ bool TorManager::setupHiddenService()
|
||||
|
||||
assert(d->hiddenService);
|
||||
|
||||
// connect(d->hiddenService, SIGNAL(statusChanged(int,int)), this, SLOT(hiddenServiceStatusChanged(int,int)));
|
||||
|
||||
// Generally, these are not used, and we bind to localhost and port 0
|
||||
// for an automatic (and portable) selection.
|
||||
|
||||
@ -258,6 +256,9 @@ bool TorManager::setupHiddenService()
|
||||
|
||||
std::cerr << ": OK - Adding hidden service to TorControl." << std::endl;
|
||||
|
||||
// Note: 9878 is quite arbitrary, but since each RS node generates its own hidden service, all of them
|
||||
// can use the same port without any conflict.
|
||||
|
||||
d->hiddenService->addTarget(9878, "127.0.0.1",hidden_service_port);
|
||||
control()->addHiddenService(d->hiddenService);
|
||||
|
||||
@ -483,6 +484,7 @@ void TorManager::threadTick()
|
||||
|
||||
switch(d->control->status())
|
||||
{
|
||||
case TorControl::Unknown:
|
||||
case TorControl::Connecting:
|
||||
break;
|
||||
|
||||
@ -618,12 +620,13 @@ void TorManagerPrivate::getConfFinished(TorControlCommand *sender)
|
||||
if(RsUtil::StringToInt(str,n) && n==1 && !configNeeded)
|
||||
{
|
||||
configNeeded = true;
|
||||
//emit q->configurationNeededChanged();
|
||||
|
||||
if(rsEvents)
|
||||
{
|
||||
auto ev = std::make_shared<RsTorManagerEvent>();
|
||||
ev->mTorManagerEventType = RsTorManagerEventCode::CONFIGURATION_NEEDED;
|
||||
ev->mTorConnectivityStatus = RsTorConnectivityStatus::UNKNOWN;
|
||||
ev->mTorStatus = RsTorStatus::UNKNOWN;
|
||||
rsEvents->sendEvent(ev);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,13 @@ void TorControlDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> ev
|
||||
if(!fe)
|
||||
return;
|
||||
|
||||
statusChanged(fe->mTorStatus,fe->mTorConnectivityStatus);
|
||||
switch(fe->mTorManagerEventType)
|
||||
{
|
||||
case RsTorManagerEventCode::TOR_STATUS_CHANGED:
|
||||
case RsTorManagerEventCode::TOR_CONNECTIVITY_CHANGED: statusChanged(fe->mTorStatus,fe->mTorConnectivityStatus);
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
|
||||
void TorControlDialog::onIncomingConnection()
|
||||
@ -73,12 +79,15 @@ void TorControlDialog::statusChanged(RsTorStatus torstatus, RsTorConnectivitySta
|
||||
switch(tor_control_status)
|
||||
{
|
||||
default:
|
||||
case RsTorConnectivityStatus::ERROR : tor_control_status_str = tr("Error") ; break ;
|
||||
case RsTorConnectivityStatus::ERROR: tor_control_status_str = tr("Error") ; break ;
|
||||
case RsTorConnectivityStatus::NOT_CONNECTED: tor_control_status_str = tr("Not connected") ; break ;
|
||||
case RsTorConnectivityStatus::CONNECTING: tor_control_status_str = tr("Connecting") ; break ;
|
||||
case RsTorConnectivityStatus::SOCKET_CONNECTED: tor_control_status_str = tr("Socket connected") ; break ;
|
||||
case RsTorConnectivityStatus::AUTHENTICATING: tor_control_status_str = tr("Authenticating") ; break ;
|
||||
case RsTorConnectivityStatus::AUTHENTICATED: tor_control_status_str = tr("Authenticated") ; break ;
|
||||
}
|
||||
case RsTorConnectivityStatus::HIDDEN_SERVICE_READY: tor_control_status_str = tr("Hidden service ready") ; break ;
|
||||
case RsTorConnectivityStatus::UNKNOWN: tor_control_status_str = tr("Unknown") ; break ;
|
||||
}
|
||||
|
||||
switch(torstatus)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user