fix key generation and cleanup

This commit is contained in:
sehraf 2020-12-15 21:44:01 +01:00
parent 5418483934
commit 27fa8a35b0
No known key found for this signature in database
GPG Key ID: DF09F6EAE356B2C6

View File

@ -1452,8 +1452,6 @@ void ServerPage::getNewKey()
{ {
i2p::address *addr = new i2p::address(); i2p::address *addr = new i2p::address();
rsAutoProxyMonitor::taskAsync(autoProxyType::I2PSAM3, autoProxyTask::receiveKey, this, addr); rsAutoProxyMonitor::taskAsync(autoProxyType::I2PSAM3, autoProxyTask::receiveKey, this, addr);
updateStatus();
} }
void ServerPage::loadKey() void ServerPage::loadKey()
@ -1550,14 +1548,22 @@ void ServerPage::taskFinished(taskTicket *&ticket)
RS_WARN("auto proxy task finished but not for SMA, not exptected! Also not a serious problem."); RS_WARN("auto proxy task finished but not for SMA, not exptected! Also not a serious problem.");
else { else {
// update settings // update settings
mSamSettings.address = *addr; auto copy = *addr;
RsQThreadUtils::postToObject(
[this, copy]()
{
mSamSettings.address = copy;
rsAutoProxyMonitor::taskSync(autoProxyType::I2PSAM3, autoProxyTask::setSettings, &mSamSettings);
updateStatusSam();
});
} }
delete addr; delete addr;
addr = nullptr; addr = nullptr;
ticket->data = nullptr; ticket->data = nullptr;
updateStatusSam();
break; break;
} }
case autoProxyTask::establishConnection: case autoProxyTask::establishConnection:
@ -1568,13 +1574,19 @@ void ServerPage::taskFinished(taskTicket *&ticket)
if (ticket->types.front() != autoProxyType::I2PSAM3) if (ticket->types.front() != autoProxyType::I2PSAM3)
RS_WARN("auto proxy task finished but not for SMA, not exptected! Also not a serious problem."); RS_WARN("auto proxy task finished but not for SMA, not exptected! Also not a serious problem.");
else { else {
bool res = ticket->result == autoProxyStatus::ok && !!secw->connection->ses;
// update settings // update settings
if (secw->connection->ses) { if (res) {
updateInProxyIndicatorResult(true);
sam3CloseConnection(secw->connection); sam3CloseConnection(secw->connection);
secw->connection = nullptr; // freed by above call secw->connection = nullptr; // freed by above call
} else }
updateInProxyIndicatorResult(false);
RsQThreadUtils::postToObject(
[this, res]()
{
updateInProxyIndicatorResult(res);
});
} }
if (secw->connection) if (secw->connection)
@ -1764,105 +1776,7 @@ void ServerPage::updateStatusSam()
ui.iconlabel_i2p_bob->setToolTip(s); ui.iconlabel_i2p_bob->setToolTip(s);
bobSimpleText.append(s); bobSimpleText.append(s);
/*
// update BOB UI based on state
std::string errorString;
switch (bs.cs) {
case csDoConnect:
case csConnected:
case csDoDisconnect:
case csWaitForBob:
ui.iconlabel_i2p_bob->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_WORKING));
ui.iconlabel_i2p_bob->setToolTip(tr("BOB is processing a request"));
enableSamElements(false);
{
QString s;
switch (bs.ct) {
case ctRunCheck:
s = tr("connectivity check");
break;
case ctRunGetKeys:
s = tr("generating key");
break;
case ctRunSetUp:
s = tr("starting up");
break;
case ctRunShutDown:
s = tr("shuting down");
default:
break;
}
bobSimpleText.append(tr("BOB is processing a request: %1").arg(s));
}
ui.pbBobStart->setEnabled(false);
ui.pbBobRestart->setEnabled(false);
ui.pbBobStop->setEnabled(false);
break;
case csError:
// get error msg from bob
rsAutoProxyMonitor::taskSync(autoProxyType::I2PBOB, autoProxyTask::getErrorInfo, &errorString);
ui.iconlabel_i2p_bob->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_ERROR));
ui.iconlabel_i2p_bob->setToolTip(tr("BOB is broken\n") + QString::fromStdString(errorString));
enableSamElements(false);
bobSimpleText.append(tr("BOB encountered an error:\n"));
bobSimpleText.append(QString::fromStdString(errorString));
ui.pbBobStart->setEnabled(true);
ui.pbBobRestart->setEnabled(false);
ui.pbBobStop->setEnabled(true);
break;
case csDisconnected:
case csIdel:
switch (bs.ct) {
case ctRunSetUp:
ui.iconlabel_i2p_bob->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_OK));
ui.iconlabel_i2p_bob->setToolTip(tr("BOB tunnel is running"));
enableSamElements(false);
bobSimpleText.append(tr("BOB is working fine: tunnel established"));
ui.pbBobStart->setEnabled(false);
ui.pbBobRestart->setEnabled(true);
ui.pbBobStop->setEnabled(true);
break;
case ctRunCheck:
case ctRunGetKeys:
ui.iconlabel_i2p_bob->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_WORKING));
ui.iconlabel_i2p_bob->setToolTip(tr("BOB is processing a request"));
enableSamElements(false);
bobSimpleText.append(tr("BOB is processing a request"));
ui.pbBobStart->setEnabled(false);
ui.pbBobRestart->setEnabled(false);
ui.pbBobStop->setEnabled(false);
break;
case ctRunShutDown:
case ctIdle:
ui.iconlabel_i2p_bob->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_UNKNOWN));
ui.iconlabel_i2p_bob->setToolTip(tr("BOB tunnel is not running"));
enableSamElements(true);
bobSimpleText.append(tr("BOB is inactive: tunnel closed"));
ui.pbBobStart->setEnabled(true);
ui.pbBobRestart->setEnabled(false);
ui.pbBobStop->setEnabled(false);
break;
}
break;
}
*/
ui.pteBobSimple->setPlainText(bobSimpleText); ui.pteBobSimple->setPlainText(bobSimpleText);