mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 05:30:06 +08:00
commit
83df3706b8
@ -87,6 +87,7 @@ namespace Configs {
|
||||
int stats_tab = 0; // either connection or log
|
||||
int speed_test_mode = TestConfig::FULL;
|
||||
QString simple_dl_url = "http://cachefly.cachefly.net/1mb.test";
|
||||
bool allow_beta_update = false;
|
||||
|
||||
// Subscription
|
||||
QString user_agent = ""; // set at main.cpp
|
||||
|
||||
@ -66,7 +66,7 @@ public:
|
||||
|
||||
void profile_start(int _id = -1);
|
||||
|
||||
void profile_stop(bool crash = false, bool sem = false, bool manual = false);
|
||||
void profile_stop(bool crash = false, bool block = false, bool manual = false);
|
||||
|
||||
void set_spmode_system_proxy(bool enable, bool save = true);
|
||||
|
||||
@ -189,7 +189,6 @@ private:
|
||||
QMutex mu_starting;
|
||||
QMutex mu_stopping;
|
||||
QMutex mu_exit;
|
||||
QSemaphore sem_stopped;
|
||||
int exit_reason = 0;
|
||||
//
|
||||
QMutex mu_download_update;
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1000</width>
|
||||
<height>802</height>
|
||||
<height>885</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -121,99 +121,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="custom_box">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Custom Outbound Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QPushButton" name="custom_outbound_edit">
|
||||
<property name="text">
|
||||
<string notr="true">Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="custom_global_box">
|
||||
<property name="title">
|
||||
<string>Custom Config Settings</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="custom_config_edit">
|
||||
<property name="text">
|
||||
<string notr="true">Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QPushButton" name="apply_to_group">
|
||||
<property name="text">
|
||||
<string>Apply settings to this group</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="right_all_w" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="right_layout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="stream_box">
|
||||
<property name="sizePolicy">
|
||||
@ -419,6 +326,99 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="custom_box">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Custom Outbound Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QPushButton" name="custom_outbound_edit">
|
||||
<property name="text">
|
||||
<string notr="true">Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="custom_global_box">
|
||||
<property name="title">
|
||||
<string>Custom Config Settings</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="custom_config_edit">
|
||||
<property name="text">
|
||||
<string notr="true">Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QPushButton" name="apply_to_group">
|
||||
<property name="text">
|
||||
<string>Apply settings to this group</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="right_all_w" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="right_layout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="network_box">
|
||||
<property name="sizePolicy">
|
||||
|
||||
@ -208,6 +208,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="allow_beta">
|
||||
<property name="text">
|
||||
<string>Allow updating to beta versions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@ -310,6 +310,7 @@ namespace Configs {
|
||||
_add(new configItem("enable_tun_routing", &enable_tun_routing, itemType::boolean));
|
||||
_add(new configItem("speed_test_mode", &speed_test_mode, itemType::integer));
|
||||
_add(new configItem("use_mozilla_certs", &use_mozilla_certs, itemType::boolean));
|
||||
_add(new configItem("allow_beta_update", &allow_beta_update, itemType::boolean));
|
||||
}
|
||||
|
||||
void DataStore::UpdateStartedId(int id) {
|
||||
|
||||
@ -5,6 +5,8 @@
|
||||
#include <QDir>
|
||||
#include <QApplication>
|
||||
|
||||
#include "include/ui/mainwindow.h"
|
||||
|
||||
namespace Configs_sys {
|
||||
CoreProcess::~CoreProcess() {
|
||||
}
|
||||
@ -59,7 +61,8 @@ namespace Configs_sys {
|
||||
if (failed_to_start) return; // no retry
|
||||
if (restarting) return;
|
||||
|
||||
MW_dialog_message("ExternalProcess", "CoreCrashed");
|
||||
MW_show_log("[Fatal] " + QObject::tr("Core exited, cleaning up..."));
|
||||
GetMainWindow()->profile_stop(true, true);
|
||||
|
||||
// Retry rate limit
|
||||
if (coreRestartTimer.isValid()) {
|
||||
@ -74,7 +77,7 @@ namespace Configs_sys {
|
||||
|
||||
// Restart
|
||||
start_profile_when_core_is_up = Configs::dataStore->started_id;
|
||||
MW_show_log("[Fatal] " + QObject::tr("Core exited, restarting."));
|
||||
MW_show_log("[Warn] " + QObject::tr("Restarting the core ..."));
|
||||
setTimeout([=,this] { Restart(); }, this, 200);
|
||||
}
|
||||
});
|
||||
|
||||
@ -765,8 +765,6 @@ void MainWindow::dialog_message_impl(const QString &sender, const QString &info)
|
||||
} else if (sender == "ExternalProcess") {
|
||||
if (info == "Crashed") {
|
||||
profile_stop();
|
||||
} else if (info == "CoreCrashed") {
|
||||
profile_stop(true);
|
||||
} else if (info.startsWith("CoreStarted")) {
|
||||
Configs::IsAdmin(true);
|
||||
if (Configs::dataStore->remember_enable || Configs::dataStore->flag_restart_tun_on) {
|
||||
@ -879,7 +877,6 @@ void MainWindow::prepare_exit()
|
||||
//
|
||||
Configs::dataStore->save_control_no_save = true; // don't change datastore after this line
|
||||
profile_stop(false, true);
|
||||
sem_stopped.acquire();
|
||||
|
||||
QMutex coreKillMu;
|
||||
coreKillMu.lock();
|
||||
@ -2413,6 +2410,7 @@ void MainWindow::CheckUpdate() {
|
||||
QJsonArray array = QString2QJsonArray(resp.data);
|
||||
for (const QJsonValue value : array) {
|
||||
QJsonObject release = value.toObject();
|
||||
if (release["prerelease"].toBool() && !Configs::dataStore->allow_beta_update) continue;
|
||||
for (const QJsonValue asset : release["assets"].toArray()) {
|
||||
if (asset["name"].toString().contains(search) && asset["name"].toString().section('.', -1) == QString("zip")) {
|
||||
note_pre_release = release["prerelease"].toBool() ? " (Pre-release)" : "";
|
||||
|
||||
@ -524,8 +524,7 @@ void MainWindow::profile_start(int _id) {
|
||||
runOnNewThread([=, this] {
|
||||
// stop current running
|
||||
if (running != nullptr) {
|
||||
runOnUiThread([=,this] { profile_stop(false, true, true); });
|
||||
sem_stopped.acquire();
|
||||
profile_stop(false, true, true);
|
||||
}
|
||||
// do start
|
||||
MW_show_log(">>>>>>>> " + tr("Starting profile %1").arg(ent->bean->DisplayTypeAndName()));
|
||||
@ -564,12 +563,11 @@ void MainWindow::set_spmode_system_proxy(bool enable, bool save) {
|
||||
refresh_status();
|
||||
}
|
||||
|
||||
void MainWindow::profile_stop(bool crash, bool sem, bool manual) {
|
||||
auto id = Configs::dataStore->started_id;
|
||||
if (id < 0) {
|
||||
if (sem) sem_stopped.release();
|
||||
void MainWindow::profile_stop(bool crash, bool block, bool manual) {
|
||||
if (running == nullptr) {
|
||||
return;
|
||||
}
|
||||
auto id = running->id;
|
||||
|
||||
auto profile_stop_stage2 = [=,this] {
|
||||
if (!crash) {
|
||||
@ -586,9 +584,10 @@ void MainWindow::profile_stop(bool crash, bool sem, bool manual) {
|
||||
};
|
||||
|
||||
if (!mu_stopping.tryLock()) {
|
||||
if (sem) sem_stopped.release();
|
||||
return;
|
||||
}
|
||||
QMutex blocker;
|
||||
if (block) blocker.lock();
|
||||
|
||||
// timeout message
|
||||
auto restartMsgbox = new QMessageBox(QMessageBox::Question, software_name, tr("If there is no response for a long time, it is recommended to restart the software."),
|
||||
@ -612,7 +611,7 @@ void MainWindow::profile_stop(bool crash, bool sem, bool manual) {
|
||||
restartMsgboxTimer->deleteLater();
|
||||
restartMsgbox->deleteLater();
|
||||
|
||||
runOnNewThread([=, this] {
|
||||
runOnNewThread([=, this, &blocker] {
|
||||
// do stop
|
||||
MW_show_log(">>>>>>>> " + tr("Stopping profile %1").arg(running->bean->DisplayTypeAndName()));
|
||||
if (!profile_stop_stage2()) {
|
||||
@ -623,13 +622,19 @@ void MainWindow::profile_stop(bool crash, bool sem, bool manual) {
|
||||
Configs::dataStore->need_keep_vpn_off = false;
|
||||
running = nullptr;
|
||||
|
||||
if (sem) sem_stopped.release();
|
||||
if (block) blocker.unlock();
|
||||
|
||||
runOnUiThread([=, this] {
|
||||
runOnUiThread([=, this, &blocker] {
|
||||
refresh_status();
|
||||
refresh_proxy_list_impl_refresh_data(id, true);
|
||||
|
||||
mu_stopping.unlock();
|
||||
});
|
||||
});
|
||||
|
||||
if (block)
|
||||
{
|
||||
blocker.lock();
|
||||
blocker.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,6 +37,7 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
|
||||
D_LOAD_BOOL(disable_tray)
|
||||
ui->speedtest_mode->setCurrentIndex(Configs::dataStore->speed_test_mode);
|
||||
ui->simple_down_url->setText(Configs::dataStore->simple_dl_url);
|
||||
ui->allow_beta->setChecked(Configs::dataStore->allow_beta_update);
|
||||
|
||||
connect(ui->custom_inbound_edit, &QPushButton::clicked, this, [=,this] {
|
||||
C_EDIT_JSON_ALLOW_EMPTY(custom_inbound)
|
||||
@ -174,6 +175,7 @@ void DialogBasicSettings::accept() {
|
||||
Configs::dataStore->proxy_scheme = ui->proxy_scheme->currentText().toLower();
|
||||
Configs::dataStore->speed_test_mode = ui->speedtest_mode->currentIndex();
|
||||
Configs::dataStore->simple_dl_url = ui->simple_down_url->text();
|
||||
Configs::dataStore->allow_beta_update = ui->allow_beta->isChecked();
|
||||
|
||||
// Style
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user