Merge branch 'duke' into dev
This commit is contained in:
2
build.sh
2
build.sh
@@ -4,7 +4,7 @@
|
||||
UNAME=$(uname)
|
||||
|
||||
if [ "$UNAME" == "Linux" ] ; then
|
||||
JOBS=$(nproc)
|
||||
JOBS=2
|
||||
elif [ "$UNAME" == "FreeBSD" ] ; then
|
||||
JOBS=$(nproc)
|
||||
elif [ "$UNAME" == "Darwin" ] ; then
|
||||
|
||||
6
lib/Cargo.lock
generated
6
lib/Cargo.lock
generated
@@ -1192,7 +1192,7 @@ dependencies = [
|
||||
"blake3 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=8535a11e3774d79de2ebeaa5540567ccb4988f81)",
|
||||
"silentdragonlitelib 0.1.0 (git+https://git.hush.is/hush/silentdragonlite-cli?rev=8535a11e3774d79de2ebeaa5540567ccb4988f81)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1655,7 +1655,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "silentdragonlitelib"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/MyHush/silentdragonlite-cli?rev=8535a11e3774d79de2ebeaa5540567ccb4988f81#8535a11e3774d79de2ebeaa5540567ccb4988f81"
|
||||
source = "git+https://git.hush.is/hush/silentdragonlite-cli?rev=8535a11e3774d79de2ebeaa5540567ccb4988f81#8535a11e3774d79de2ebeaa5540567ccb4988f81"
|
||||
dependencies = [
|
||||
"base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bellman 0.1.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)",
|
||||
@@ -2672,7 +2672,7 @@ dependencies = [
|
||||
"checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35"
|
||||
"checksum sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0"
|
||||
"checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41"
|
||||
"checksum silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=8535a11e3774d79de2ebeaa5540567ccb4988f81)" = "<none>"
|
||||
"checksum silentdragonlitelib 0.1.0 (git+https://git.hush.is/hush/silentdragonlite-cli?rev=8535a11e3774d79de2ebeaa5540567ccb4988f81)" = "<none>"
|
||||
"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
||||
"checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6"
|
||||
"checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85"
|
||||
|
||||
@@ -550,7 +550,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="2038"/>
|
||||
<source>Import Privatkey</source>
|
||||
<source>Import Private Key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -748,7 +748,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="2038"/>
|
||||
<source>Import Privatkey</source>
|
||||
<source>Import Private Key</source>
|
||||
<translation>Імпартаваць Прыватныключ</translation>
|
||||
</message>
|
||||
<message>
|
||||
@@ -832,8 +832,8 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Ctrl+P</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Hush Discord</source>
|
||||
<translation type="vanished">&Hush Discord</translation>
|
||||
<source>&Hush Telegram</source>
|
||||
<translation type="vanished">&Hush Telegram</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="1962"/>
|
||||
|
||||
@@ -865,7 +865,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="2038"/>
|
||||
<source>Import Privatkey</source>
|
||||
<source>Import Private Key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -830,7 +830,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="2038"/>
|
||||
<source>Import Privatkey</source>
|
||||
<source>Import Private Key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -849,7 +849,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="2038"/>
|
||||
<source>Import Privatkey</source>
|
||||
<source>Import Private Key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -643,7 +643,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="2038"/>
|
||||
<source>Import Privatkey</source>
|
||||
<source>Import Private Key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -850,7 +850,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="2038"/>
|
||||
<source>Import Privatkey</source>
|
||||
<source>Import Private Key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -825,7 +825,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="2038"/>
|
||||
<source>Import Privatkey</source>
|
||||
<source>Import Private Key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -511,7 +511,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="2038"/>
|
||||
<source>Import Privatkey</source>
|
||||
<source>Import Private Key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -612,7 +612,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="2038"/>
|
||||
<source>Import Privatkey</source>
|
||||
<source>Import Private Key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -825,7 +825,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="2038"/>
|
||||
<source>Import Privatkey</source>
|
||||
<source>Import Private Key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -559,8 +559,8 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Повторное сканирование</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Hush Discord</source>
|
||||
<translation type="vanished">&Hush Discord</translation>
|
||||
<source>&Hush Telegram</source>
|
||||
<translation type="vanished">&Hush Telegram</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="51"/>
|
||||
@@ -665,7 +665,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="2038"/>
|
||||
<source>Import Privatkey</source>
|
||||
<source>Import Private Key</source>
|
||||
<translation>Импортировать Приватныйключ</translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -850,7 +850,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="2038"/>
|
||||
<source>Import Privatkey</source>
|
||||
<source>Import Private Key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -507,7 +507,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="2038"/>
|
||||
<source>Import Privatkey</source>
|
||||
<source>Import Private Key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -829,7 +829,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="2038"/>
|
||||
<source>Import Privatkey</source>
|
||||
<source>Import Private Key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -565,7 +565,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="2038"/>
|
||||
<source>Import Privatkey</source>
|
||||
<source>Import Private Key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -32,7 +32,7 @@ ConnectionLoader::ConnectionLoader(MainWindow* main, Controller* rpc)
|
||||
connD->setupUi(d);
|
||||
|
||||
auto theme = Settings::getInstance()->get_theme_name();
|
||||
qDebug() << theme << "theme has loaded";
|
||||
qDebug() << theme << "theme " << theme << " has loaded";
|
||||
auto size = QSize(512,512);
|
||||
|
||||
if (theme == "Dark" || theme == "Midnight") {
|
||||
@@ -114,7 +114,7 @@ void ConnectionLoader::ShowProgress()
|
||||
qint64 synced = reply["synced_blocks"].get<json::number_unsigned_t>();
|
||||
qint64 total = reply["total_blocks"].get<json::number_unsigned_t>();
|
||||
me->showInformation(
|
||||
"Synced " + QString::number(synced) + " / " + QString::number(total)
|
||||
"Syncing... " + QString::number(synced) + " / " + QString::number(total)
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -146,8 +146,7 @@ void ConnectionLoader::doAutoConnect()
|
||||
main->logger->write(QObject::tr("Attempting to initialize library with ") + config->server);
|
||||
|
||||
// Check to see if there's an existing wallet
|
||||
if (litelib_wallet_exists(Settings::getDefaultChainName().toStdString().c_str()))
|
||||
{
|
||||
if (litelib_wallet_exists(Settings::getDefaultChainName().toStdString().c_str())) {
|
||||
main->logger->write(QObject::tr("Using existing wallet."));
|
||||
char* resp = litelib_initialize_existing(
|
||||
config->dangerous,
|
||||
@@ -155,10 +154,24 @@ void ConnectionLoader::doAutoConnect()
|
||||
);
|
||||
QString response = litelib_process_response(resp);
|
||||
|
||||
if (response.toUpper().trimmed() != "OK")
|
||||
{
|
||||
showError(response);
|
||||
return;
|
||||
if (response.toUpper().trimmed() != "OK") {
|
||||
config->server = Settings::getRandomServer();
|
||||
|
||||
resp = litelib_initialize_existing(
|
||||
config->dangerous,
|
||||
config->server.toStdString().c_str()
|
||||
);
|
||||
response = litelib_process_response(resp);
|
||||
|
||||
if (response.toUpper().trimmed() != "OK") {
|
||||
QString resp = "Error when connecting to " + config->server + ": " + response;
|
||||
showError(resp);
|
||||
return;
|
||||
} else {
|
||||
qDebug() << __func__ << ": Successfully connected to random server: " << config->server << " !!!";
|
||||
}
|
||||
} else {
|
||||
qDebug() << __func__ << ": Successfully connected to " << config->server << " !!!";
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -208,7 +221,7 @@ void ConnectionLoader::doAutoConnect()
|
||||
qint64 synced = reply["synced_blocks"].get<json::number_unsigned_t>();
|
||||
qint64 total = reply["total_blocks"].get<json::number_unsigned_t>();
|
||||
me->showInformation(
|
||||
"Synced " + QString::number(synced) + " / " + QString::number(total)
|
||||
"Syncing... " + QString::number(synced) + " / " + QString::number(total)
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -298,14 +298,16 @@ void Controller::getInfoThenRefresh(bool force)
|
||||
static bool prevCallSucceeded = false;
|
||||
|
||||
zrpc->fetchInfo([=] (const json& reply) {
|
||||
prevCallSucceeded = true;
|
||||
int curBlock = reply["latest_block_height"].get<json::number_integer_t>();
|
||||
bool doUpdate = force || (model->getLatestBlock() != curBlock);
|
||||
int difficulty = reply["difficulty"].get<json::number_integer_t>();
|
||||
int blocks_until_halving= 340000 - curBlock;
|
||||
int halving_days = (blocks_until_halving * 150) / (60 * 60 * 24) ;
|
||||
int longestchain = reply["longestchain"].get<json::number_integer_t>();
|
||||
int notarized = reply["notarized"].get<json::number_integer_t>();
|
||||
prevCallSucceeded = true;
|
||||
int curBlock = reply["latest_block_height"].get<json::number_integer_t>();
|
||||
bool doUpdate = force || (model->getLatestBlock() != curBlock);
|
||||
int difficulty = reply["difficulty"].get<json::number_integer_t>();
|
||||
int num_halvings = 1; // number of halvings that have occured already
|
||||
int blocks_until_halving = (num_halvings*1680000 + 340000) - curBlock;
|
||||
int blocktime = 75;
|
||||
int halving_days = (blocks_until_halving * blocktime) / (60 * 60 * 24) ;
|
||||
int longestchain = reply["longestchain"].get<json::number_integer_t>();
|
||||
int notarized = reply["notarized"].get<json::number_integer_t>();
|
||||
|
||||
model->setLatestBlock(curBlock);
|
||||
if (
|
||||
@@ -330,9 +332,7 @@ void Controller::getInfoThenRefresh(bool force)
|
||||
(QLocale(QLocale::German).toString(blocks_until_halving)) +
|
||||
" Blocks or , " + (QLocale(QLocale::German).toString(halving_days) + " days" )
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ui->blockHeight->setText(
|
||||
"Block: " + QLocale(QLocale::English).toString(curBlock)
|
||||
);
|
||||
@@ -2040,7 +2040,7 @@ void Controller::shutdownhushd()
|
||||
connD.topIcon->setMovie(movie2);
|
||||
movie2->start();
|
||||
connD.status->setText(QObject::tr("Please wait for SilentDragonLite to exit"));
|
||||
connD.statusDetail->setText(QObject::tr("Waiting for hushd to exit"));
|
||||
connD.statusDetail->setText(QObject::tr("Please wait for SilentDragonLite to exit"));
|
||||
} else {
|
||||
QMovie *movie1 = new QMovie(":/img/res/silentdragonlite-animated-startup.gif");;
|
||||
movie1->setScaledSize(size);
|
||||
|
||||
@@ -40,7 +40,7 @@ void LiteInterface::importTPrivKey(QString addr,const std::function<void(json)>&
|
||||
if (conn == nullptr)
|
||||
return;
|
||||
|
||||
conn->doRPCWithDefaultErrorHandling("timport", addr, cb);
|
||||
conn->doRPCWithDefaultErrorHandling("timport", addr, cb);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
QObject::connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close);
|
||||
|
||||
// Set up Feedback action
|
||||
QObject::connect(ui->actionDonate, &QAction::triggered, this, &MainWindow::donate);
|
||||
//QObject::connect(ui->actionDonate, &QAction::triggered, this, &MainWindow::donate);
|
||||
|
||||
QObject::connect(ui->actionTelegram, &QAction::triggered, this, &MainWindow::telegram);
|
||||
|
||||
@@ -277,7 +277,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
dialog.exec();
|
||||
});
|
||||
|
||||
// Import Privkey
|
||||
// Import Privkey
|
||||
QObject::connect(ui->actionImport_Privatkey, &QAction::triggered, this, &MainWindow::importPrivKey);
|
||||
// Address Book
|
||||
QObject::connect(ui->action_Address_Book, &QAction::triggered, this, &MainWindow::addressBook);
|
||||
@@ -840,7 +840,7 @@ void MainWindow::setupSettingsModal() {
|
||||
|
||||
// List of default servers
|
||||
settings.cmbServer->addItem("https://lite.hush.is");
|
||||
settings.cmbServer->addItem("https://bies.xyz");
|
||||
settings.cmbServer->addItem("https://lite.hush.community");
|
||||
settings.cmbServer->addItem("https://devo.crabdance.com");
|
||||
//settings.cmbServer->addItem("https://hush.leto.net:5420");
|
||||
//TODO: seperate lists of https/Tor servers, only show user or attempt
|
||||
@@ -909,14 +909,11 @@ void MainWindow::website() {
|
||||
|
||||
|
||||
void MainWindow::donate() {
|
||||
// Set up a donation to me :)
|
||||
|
||||
ui->Address1->setText(Settings::getDonationAddr());
|
||||
ui->Address1->setCursorPosition(0);
|
||||
ui->Amount1->setText("0.00");
|
||||
ui->MemoTxt1->setText(tr("Some feedback about SilentDragonlite or Hush..."));
|
||||
|
||||
ui->statusBar->showMessage(tr("Send DenioD some private and shielded feedback about") % Settings::getTokenName() % tr(" or SilentDragonLite"));
|
||||
ui->statusBar->showMessage(tr("Send some private and shielded feedback about") % Settings::getTokenName() % tr(" or SilentDragonLite"));
|
||||
|
||||
// And switch to the send tab.
|
||||
ui->tabWidget->setCurrentIndex(1);
|
||||
@@ -930,30 +927,37 @@ void MainWindow::donate() {
|
||||
|
||||
if (keys->isEmpty()) {
|
||||
delete keys;
|
||||
ui->statusBar->showMessage(tr("Private key import rescan in progress. Your funds will be automaticly shield to a wallet seed zaddr. This will take some time"));
|
||||
ui->statusBar->showMessage(tr("Private key import rescan in progress. Your funds will be shielded into this wallet and backed up by your seed phrase. This will take some time"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Pop the first key
|
||||
|
||||
QString key = keys->first();
|
||||
QString key1 = key + QString(" ") + QString("0");
|
||||
keys->pop_front();
|
||||
bool rescan = keys->isEmpty();
|
||||
|
||||
|
||||
if (key.startsWith("SK") ||
|
||||
key.startsWith("secret")) {
|
||||
|
||||
if (key.startsWith("SK") || key.startsWith("secret")) {
|
||||
rpc->importZPrivKey(key, [=] (auto) { this->doImport(keys); });
|
||||
|
||||
} else if (key.startsWith("U")) {
|
||||
} else if (key.startsWith("U") || key.startsWith("5") || key.startsWith("L") || key.startsWith("K")) {
|
||||
// 5 = uncompressed, len=51
|
||||
// LK= compressed, len=52
|
||||
// TODO: verify exact length of (un)compressed
|
||||
if(key.length() > 52) {
|
||||
QMessageBox::critical(this, tr("Wrong Private key format"),
|
||||
tr("That private key is too long. It should be 51 or 52 characters.") + "\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(key.length() < 51) {
|
||||
QMessageBox::critical(this, tr("Wrong Private key format"),
|
||||
tr("That private key is too short. It should be 51 or 52 characters.") + "\n");
|
||||
return;
|
||||
}
|
||||
rpc->importTPrivKey(key, [=] (auto) { this->doImport(keys); });
|
||||
|
||||
}else{
|
||||
QMessageBox::critical(this, tr("Wrong Privatkey format"),
|
||||
tr("Privatkey should start with U (for taddr) or secret- (for zaddr)") + "\n");
|
||||
tr("Privatkey should start with 5, K, L or U (for taddr) or secret- (for zaddr)") + "\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1052,8 +1056,8 @@ void MainWindow::payhushURI(QString uri, QString myAddr) {
|
||||
pui.buttonBox->button(QDialogButtonBox::Save)->setVisible(true);
|
||||
pui.helpLbl->setText(QString() %
|
||||
tr("Please paste your private key(zs-Addr or R-addr) here, one per import") % ".\n" %
|
||||
tr("Caution: If this key is for Zs-addr it will be NOT inlcude in your Seed. Please send them direct to a Seed zs-addr") % ".\n" %
|
||||
tr("R-addr keys will be autoshield to a seed zs-addr")
|
||||
tr("Caution: If this key is for a zaddr it will be NOT included in your Seed. Please send them direct to a Seed zaddr") % ".\n" %
|
||||
tr("Transparent address (R.. or t1..) keys will be automatically sent to a zaddr in your Seed")
|
||||
);
|
||||
|
||||
if (d.exec() == QDialog::Accepted && !pui.privKeyTxt->toPlainText().trimmed().isEmpty()) {
|
||||
|
||||
@@ -2035,7 +2035,7 @@
|
||||
</action>
|
||||
<action name="actionImport_Privatkey">
|
||||
<property name="text">
|
||||
<string>Import Privatkey</string>
|
||||
<string>Import Private Key</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "mainwindow.h"
|
||||
#include "settings.h"
|
||||
#include "camount.h"
|
||||
#include "../lib/silentdragonlitelib.h"
|
||||
|
||||
Settings* Settings::instance = nullptr;
|
||||
|
||||
@@ -18,26 +19,49 @@ Settings* Settings::getInstance() {
|
||||
}
|
||||
|
||||
Config Settings::getSettings() {
|
||||
qDebug() << __func__;
|
||||
// Load from the QT Settings.
|
||||
QSettings s;
|
||||
|
||||
// this domain is stolen and malicious!
|
||||
auto malicious = "https://lite.myhush.org";
|
||||
// More info: https://git.hush.is/hush/fraud/#gilardh
|
||||
auto malicious = "lite.myhush.org";
|
||||
auto server = s.value("connection/server").toString();
|
||||
if(server == malicious) {
|
||||
server = "https://lite.hush.is";
|
||||
bool sticky = s.value("connection/stickyServer").toBool();
|
||||
bool torOnly = s.value("connection/torOnly").toBool();
|
||||
|
||||
// Users that have old configs generated from old SDLs will have this hostname
|
||||
if(server == malicious or server == (QString("https://") + malicious)) {
|
||||
qDebug() << "Replacing malicious SDL server with " << server;
|
||||
server = getRandomServer();
|
||||
s.setValue("connection/server", server);
|
||||
s.sync();
|
||||
// re-init to load correct settings
|
||||
init();
|
||||
}
|
||||
|
||||
// default behavior : no server listed in conf, randomly choose from server list, unless sticky
|
||||
if (server.trimmed().isEmpty()) {
|
||||
server = Settings::getDefaultServer();
|
||||
server = Settings::getRandomServer();
|
||||
|
||||
// make sure existing server in conf is alive, otherwise choose random one
|
||||
char* resp = litelib_initialize_existing(false, server.toStdString().c_str());
|
||||
QString response = litelib_process_response(resp);
|
||||
|
||||
if (response.toUpper().trimmed() != "OK") {
|
||||
qDebug() << "Lite server in conf " << server << " is down, getting a random one";
|
||||
server = Settings::getRandomServer();
|
||||
s.setValue("connection/server", server);
|
||||
}
|
||||
} else {
|
||||
if (sticky) {
|
||||
qDebug() << server << " is sticky";
|
||||
}
|
||||
// if it's down, oh well
|
||||
}
|
||||
|
||||
return Config{server};
|
||||
s.sync();
|
||||
// re-init to load correct settings
|
||||
init();
|
||||
|
||||
return Config{server, torOnly, sticky};
|
||||
}
|
||||
|
||||
void Settings::saveSettings(const QString& server) {
|
||||
@@ -250,9 +274,7 @@ void Settings::set_theme_name(QString theme_name) {
|
||||
QSettings().setValue("options/theme_name", theme_name);
|
||||
}
|
||||
|
||||
//=================================
|
||||
// Static Stuff
|
||||
//=================================
|
||||
void Settings::saveRestore(QDialog* d) {
|
||||
d->restoreGeometry(QSettings().value(d->objectName() % "geometry").toByteArray());
|
||||
|
||||
@@ -271,20 +293,43 @@ void Settings::saveRestoreTableHeader(QTableView* table, QDialog* d, QString tab
|
||||
}
|
||||
|
||||
QString Settings::getRandomServer() {
|
||||
qDebug() << __func__;
|
||||
// The more servers from different TLDs, the better
|
||||
QList<QString> servers = {
|
||||
"https://lite.hush.is",
|
||||
"https://devo.crabdance.com",
|
||||
//"https://thisisdown1.example.com",
|
||||
//"https://thisisdown2.example.com",
|
||||
//"https://thisisdown3.example.com",
|
||||
//"https://thisisdown4.example.com",
|
||||
//"https://thisisdown5.example.com",
|
||||
"https://lite.hush.community",
|
||||
};
|
||||
|
||||
// we don't need cryptographic random-ness, but we want
|
||||
// clients to never get "stuck" with the same server, which
|
||||
// prevents various attacks
|
||||
QList<QString> servers;
|
||||
//TODO: This should be a much larger list which we randomly choose from
|
||||
servers[0] = "https://lite.hush.is";
|
||||
servers[1] = "https://devo.crabdance.com";
|
||||
//servers[2] = "https://hush.leto.net:5420";
|
||||
int x = rand() % 2;
|
||||
return servers[x];
|
||||
}
|
||||
int x = rand() % servers.size();
|
||||
auto server = servers[x];
|
||||
int tries = 0;
|
||||
|
||||
QString Settings::getDefaultServer() {
|
||||
return "https://lite.hush.is";
|
||||
// We try every server,in order, starting from a random place in the list
|
||||
while (tries < servers.size() ) {
|
||||
qDebug() << "Checking if lite server " << server << " is a alive, try=" << tries;
|
||||
char* resp = litelib_initialize_existing(false, server.toStdString().c_str());
|
||||
QString response = litelib_process_response(resp);
|
||||
|
||||
// if we see a valid connection, return this server
|
||||
if (response.toUpper().trimmed() == "OK") {
|
||||
qDebug() << "Choosing lite server " << server;
|
||||
return server;
|
||||
}
|
||||
x++;
|
||||
x = x % servers.size();
|
||||
server = servers[x];
|
||||
tries++;
|
||||
}
|
||||
return server;
|
||||
}
|
||||
|
||||
void Settings::openAddressInExplorer(QString address) {
|
||||
|
||||
@@ -9,7 +9,12 @@
|
||||
using json = nlohmann::json;
|
||||
|
||||
struct Config {
|
||||
// The randomly chosen server we are talking to OR user-specific server
|
||||
QString server;
|
||||
// Shouuld we only speak Tor to this server?
|
||||
bool torOnly {false};
|
||||
// Should we randomly try other servers if specified server is down?
|
||||
bool stickyServer {false};
|
||||
};
|
||||
|
||||
struct ToFields;
|
||||
|
||||
Reference in New Issue
Block a user