.
This commit is contained in:
2
build.sh
2
build.sh
@@ -4,7 +4,7 @@
|
|||||||
UNAME=$(uname)
|
UNAME=$(uname)
|
||||||
|
|
||||||
if [ "$UNAME" == "Linux" ] ; then
|
if [ "$UNAME" == "Linux" ] ; then
|
||||||
JOBS=4
|
JOBS=2
|
||||||
elif [ "$UNAME" == "FreeBSD" ] ; then
|
elif [ "$UNAME" == "FreeBSD" ] ; then
|
||||||
JOBS=$(nproc)
|
JOBS=$(nproc)
|
||||||
elif [ "$UNAME" == "Darwin" ] ; then
|
elif [ "$UNAME" == "Darwin" ] ; then
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ ConnectionLoader::ConnectionLoader(MainWindow* main, Controller* rpc)
|
|||||||
connD->setupUi(d);
|
connD->setupUi(d);
|
||||||
|
|
||||||
auto theme = Settings::getInstance()->get_theme_name();
|
auto theme = Settings::getInstance()->get_theme_name();
|
||||||
qDebug() << theme << "theme has loaded";
|
qDebug() << theme << "theme " << theme << " has loaded";
|
||||||
auto size = QSize(512,512);
|
auto size = QSize(512,512);
|
||||||
|
|
||||||
if (theme == "Dark" || theme == "Midnight") {
|
if (theme == "Dark" || theme == "Midnight") {
|
||||||
@@ -146,8 +146,7 @@ void ConnectionLoader::doAutoConnect()
|
|||||||
main->logger->write(QObject::tr("Attempting to initialize library with ") + config->server);
|
main->logger->write(QObject::tr("Attempting to initialize library with ") + config->server);
|
||||||
|
|
||||||
// Check to see if there's an existing wallet
|
// 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."));
|
main->logger->write(QObject::tr("Using existing wallet."));
|
||||||
char* resp = litelib_initialize_existing(
|
char* resp = litelib_initialize_existing(
|
||||||
config->dangerous,
|
config->dangerous,
|
||||||
@@ -155,8 +154,7 @@ void ConnectionLoader::doAutoConnect()
|
|||||||
);
|
);
|
||||||
QString response = litelib_process_response(resp);
|
QString response = litelib_process_response(resp);
|
||||||
|
|
||||||
if (response.toUpper().trimmed() != "OK")
|
if (response.toUpper().trimmed() != "OK") {
|
||||||
{
|
|
||||||
showError(response);
|
showError(response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "camount.h"
|
#include "camount.h"
|
||||||
|
#include "../lib/silentdragonlitelib.h"
|
||||||
|
|
||||||
Settings* Settings::instance = nullptr;
|
Settings* Settings::instance = nullptr;
|
||||||
|
|
||||||
@@ -18,26 +19,41 @@ Settings* Settings::getInstance() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Config Settings::getSettings() {
|
Config Settings::getSettings() {
|
||||||
|
qDebug() << __func__;
|
||||||
// Load from the QT Settings.
|
// Load from the QT Settings.
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
|
||||||
// this domain is stolen and malicious!
|
// this domain is stolen and malicious!
|
||||||
auto malicious = "https://lite.myhush.org";
|
auto malicious = "https://lite.myhush.org";
|
||||||
auto server = s.value("connection/server").toString();
|
auto server = s.value("connection/server").toString();
|
||||||
|
bool torOnly = s.value("connectoin/torOnly").toBool();
|
||||||
|
|
||||||
|
// default behavior is no server listed in conf, and randomly choose from those listed in code
|
||||||
|
if (server.trimmed().isEmpty()) {
|
||||||
|
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 we see a valid connection, return this server
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Users that have old configs generated from old SDLs will have this hostname
|
||||||
if(server == malicious) {
|
if(server == malicious) {
|
||||||
server = "https://lite.hush.is";
|
|
||||||
qDebug() << "Replacing malicious SDL server with " << server;
|
qDebug() << "Replacing malicious SDL server with " << server;
|
||||||
s.setValue("connection/server", server);
|
s.setValue("connection/server", server);
|
||||||
s.sync();
|
|
||||||
// re-init to load correct settings
|
|
||||||
init();
|
|
||||||
}
|
}
|
||||||
|
s.sync();
|
||||||
|
// re-init to load correct settings
|
||||||
|
init();
|
||||||
|
|
||||||
if (server.trimmed().isEmpty()) {
|
return Config{server, torOnly};
|
||||||
server = Settings::getDefaultServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Config{server};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::saveSettings(const QString& server) {
|
void Settings::saveSettings(const QString& server) {
|
||||||
@@ -250,9 +266,7 @@ void Settings::set_theme_name(QString theme_name) {
|
|||||||
QSettings().setValue("options/theme_name", theme_name);
|
QSettings().setValue("options/theme_name", theme_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================
|
|
||||||
// Static Stuff
|
// Static Stuff
|
||||||
//=================================
|
|
||||||
void Settings::saveRestore(QDialog* d) {
|
void Settings::saveRestore(QDialog* d) {
|
||||||
d->restoreGeometry(QSettings().value(d->objectName() % "geometry").toByteArray());
|
d->restoreGeometry(QSettings().value(d->objectName() % "geometry").toByteArray());
|
||||||
|
|
||||||
@@ -271,6 +285,7 @@ void Settings::saveRestoreTableHeader(QTableView* table, QDialog* d, QString tab
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getRandomServer() {
|
QString Settings::getRandomServer() {
|
||||||
|
qDebug() << __func__;
|
||||||
// we don't need cryptographic random-ness, but we want
|
// we don't need cryptographic random-ness, but we want
|
||||||
// clients to never get "stuck" with the same server, which
|
// clients to never get "stuck" with the same server, which
|
||||||
// prevents various attacks
|
// prevents various attacks
|
||||||
@@ -278,12 +293,35 @@ QString Settings::getRandomServer() {
|
|||||||
//TODO: This should be a much larger list which we randomly choose from
|
//TODO: This should be a much larger list which we randomly choose from
|
||||||
servers[0] = "https://lite.hush.is";
|
servers[0] = "https://lite.hush.is";
|
||||||
servers[1] = "https://devo.crabdance.com";
|
servers[1] = "https://devo.crabdance.com";
|
||||||
//servers[2] = "https://hush.leto.net:5420";
|
servers[2] = "https://bies.xyz";
|
||||||
int x = rand() % 2;
|
servers[3] = "https://hush.leto.net";
|
||||||
return servers[x];
|
servers[4] = "https://milktoast.attackingzcash.com";
|
||||||
|
|
||||||
|
// start at a random place in the list
|
||||||
|
int x = rand() % servers.size();
|
||||||
|
auto server = servers[x];
|
||||||
|
int tries = 0;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
server = servers[++x % servers.size()];
|
||||||
|
|
||||||
|
tries++;
|
||||||
|
}
|
||||||
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getDefaultServer() {
|
QString Settings::getDefaultServer() {
|
||||||
|
qDebug() << __func__;
|
||||||
return "https://lite.hush.is";
|
return "https://lite.hush.is";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
|
// The randomly chosen server we are talking to OR user-specific server
|
||||||
QString server;
|
QString server;
|
||||||
|
bool torOnly {false};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ToFields;
|
struct ToFields;
|
||||||
|
|||||||
Reference in New Issue
Block a user