feat: require restart after profile change

This commit is contained in:
arm64v8a
2022-11-30 09:55:41 +09:00
parent a973c3f4ad
commit 163fe56947
6 changed files with 22 additions and 3 deletions

View File

@@ -381,6 +381,11 @@ namespace NekoRay {
tagOut = "proxy"; tagOut = "proxy";
} }
// ignoreConnTag
if (index != 0) {
status->result->ignoreConnTag << tagOut;
}
if (needGlobal) { if (needGlobal) {
if (status->globalProfiles.contains(ent->id)) { if (status->globalProfiles.contains(ent->id)) {
continue; continue;

View File

@@ -12,6 +12,7 @@ namespace NekoRay {
QList<QSharedPointer<traffic::TrafficData>> outboundStats; // all, but not including "bypass" "block" QList<QSharedPointer<traffic::TrafficData>> outboundStats; // all, but not including "bypass" "block"
QSharedPointer<traffic::TrafficData> outboundStat; // main QSharedPointer<traffic::TrafficData> outboundStat; // main
QStringList ignoreConnTag;
QList<sys::ExternalProcess *> ext; QList<sys::ExternalProcess *> ext;
}; };

View File

@@ -47,6 +47,7 @@ namespace NekoRay {
bool core_prepare_exit = false; bool core_prepare_exit = false;
int running_spmode = NekoRay::SystemProxyMode::DISABLE; int running_spmode = NekoRay::SystemProxyMode::DISABLE;
bool need_keep_vpn_off = false; bool need_keep_vpn_off = false;
QStringList ignoreConnTag = {};
Routing *routing = new Routing; Routing *routing = new Routing;
int imported_count = 0; int imported_count = 0;

View File

@@ -334,16 +334,20 @@ void DialogEditProfile::accept() {
*((QString *) custom_item->ptr) = CACHE.custom; *((QString *) custom_item->ptr) = CACHE.custom;
} }
// finish
QStringList msg = {"accept"};
if (newEnt) { if (newEnt) {
auto ok = NekoRay::profileManager->AddProfile(ent); auto ok = NekoRay::profileManager->AddProfile(ent);
if (!ok) { if (!ok) {
MessageBoxWarning("???", "id exists"); MessageBoxWarning("???", "id exists");
} }
} else { } else {
ent->Save(); auto changed = ent->Save();
if (changed && NekoRay::dataStore->started_id == ent->id) msg << "restart";
} }
MW_dialog_message(Dialog_DialogEditProfile, "accept"); MW_dialog_message(Dialog_DialogEditProfile, msg.join(","));
QDialog::accept(); QDialog::accept();
} }

View File

@@ -462,8 +462,14 @@ void MainWindow::dialog_message_impl(const QString &sender, const QString &info)
} }
// sender // sender
if (sender == Dialog_DialogEditProfile) { if (sender == Dialog_DialogEditProfile) {
if (info == "accept") { auto msg = info.split(",");
if (msg.contains("accept")) {
refresh_proxy_list(); refresh_proxy_list();
if (msg.contains("restart")) {
if (QMessageBox::question(GetMessageBoxParent(), tr("Confirmation"), tr("Settings changed, restart proxy?")) == QMessageBox::StandardButton::Yes) {
neko_start(NekoRay::dataStore->started_id);
}
}
} }
} else if (sender == Dialog_DialogManageGroups) { } else if (sender == Dialog_DialogManageGroups) {
if (info.startsWith("refresh")) { if (info.startsWith("refresh")) {
@@ -1342,6 +1348,7 @@ void MainWindow::refresh_connection_list(const QJsonArray &arr) {
int row = -1; int row = -1;
for (const auto &_item: arr) { for (const auto &_item: arr) {
auto item = _item.toObject(); auto item = _item.toObject();
if (NekoRay::dataStore->ignoreConnTag.contains(item["Tag"].toString())) continue;
row++; row++;
ui->tableWidget_conn->insertRow(row); ui->tableWidget_conn->insertRow(row);

View File

@@ -232,6 +232,7 @@ void MainWindow::neko_start(int _id) {
// //
NekoRay::traffic::trafficLooper->proxy = result->outboundStat.get(); NekoRay::traffic::trafficLooper->proxy = result->outboundStat.get();
NekoRay::traffic::trafficLooper->items = result->outboundStats; NekoRay::traffic::trafficLooper->items = result->outboundStats;
NekoRay::dataStore->ignoreConnTag = result->ignoreConnTag;
NekoRay::traffic::trafficLooper->loop_enabled = true; NekoRay::traffic::trafficLooper->loop_enabled = true;
#endif #endif