From dff7e3e53c3e6d3fcc4bc1f7c486c198d55ff8aa Mon Sep 17 00:00:00 2001 From: Kieran Moy Date: Fri, 3 May 2024 18:20:15 +0800 Subject: [PATCH 1/4] Fix issue #1139 --- ui/mainwindow_grpc.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/mainwindow_grpc.cpp b/ui/mainwindow_grpc.cpp index 55332bd..2cb4d10 100644 --- a/ui/mainwindow_grpc.cpp +++ b/ui/mainwindow_grpc.cpp @@ -6,6 +6,7 @@ #include "db/traffic/TrafficLooper.hpp" #include "rpc/gRPC.h" #include "ui/widget/MessageBoxTimer.h" +#include "sys/linux/LinuxCap.h" #include #include @@ -284,6 +285,9 @@ void MainWindow::neko_start(int _id) { if (NekoGui::dataStore->prepare_exit) return; auto ents = get_now_selected_list(); + if (IS_NEKO_BOX_INTERNAL_TUN) + auto ret = Linux_Pkexec_SetCapString(NekoGui::FindNekoBoxCoreRealPath(), "cap_net_admin-ep"); + auto ent = (_id < 0 && !ents.isEmpty()) ? ents.first() : NekoGui::profileManager->GetProfile(_id); if (ent == nullptr) return; From 09e9604006d1f540d997892875a2c786f879ccf5 Mon Sep 17 00:00:00 2001 From: Kieran Moy Date: Sat, 4 May 2024 00:42:23 +0800 Subject: [PATCH 2/4] Add missing os detection --- ui/mainwindow_grpc.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/mainwindow_grpc.cpp b/ui/mainwindow_grpc.cpp index 2cb4d10..ca70693 100644 --- a/ui/mainwindow_grpc.cpp +++ b/ui/mainwindow_grpc.cpp @@ -285,8 +285,11 @@ void MainWindow::neko_start(int _id) { if (NekoGui::dataStore->prepare_exit) return; auto ents = get_now_selected_list(); + +#ifdef Q_OS_LINUX if (IS_NEKO_BOX_INTERNAL_TUN) auto ret = Linux_Pkexec_SetCapString(NekoGui::FindNekoBoxCoreRealPath(), "cap_net_admin-ep"); +#endif auto ent = (_id < 0 && !ents.isEmpty()) ? ents.first() : NekoGui::profileManager->GetProfile(_id); if (ent == nullptr) return; From 0ceda1de0e0cdbf508e31dba825f7a9ba4ce012d Mon Sep 17 00:00:00 2001 From: Kieran Moy Date: Sat, 4 May 2024 00:45:23 +0800 Subject: [PATCH 3/4] Update ui/mainwindow_grpc.cpp --- ui/mainwindow_grpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/mainwindow_grpc.cpp b/ui/mainwindow_grpc.cpp index ca70693..18a60d3 100644 --- a/ui/mainwindow_grpc.cpp +++ b/ui/mainwindow_grpc.cpp @@ -288,7 +288,7 @@ void MainWindow::neko_start(int _id) { #ifdef Q_OS_LINUX if (IS_NEKO_BOX_INTERNAL_TUN) - auto ret = Linux_Pkexec_SetCapString(NekoGui::FindNekoBoxCoreRealPath(), "cap_net_admin-ep"); + Linux_Pkexec_SetCapString(NekoGui::FindNekoBoxCoreRealPath(), "cap_net_admin-ep"); #endif auto ent = (_id < 0 && !ents.isEmpty()) ? ents.first() : NekoGui::profileManager->GetProfile(_id); From 67032f3463512f7e65013bc9cf6ce9176c5070d8 Mon Sep 17 00:00:00 2001 From: Kieran Moy Date: Sun, 5 May 2024 17:45:31 +0800 Subject: [PATCH 4/4] Update mainwindow_grpc.cpp --- ui/mainwindow_grpc.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ui/mainwindow_grpc.cpp b/ui/mainwindow_grpc.cpp index 18a60d3..867a2b6 100644 --- a/ui/mainwindow_grpc.cpp +++ b/ui/mainwindow_grpc.cpp @@ -6,7 +6,6 @@ #include "db/traffic/TrafficLooper.hpp" #include "rpc/gRPC.h" #include "ui/widget/MessageBoxTimer.h" -#include "sys/linux/LinuxCap.h" #include #include @@ -286,10 +285,8 @@ void MainWindow::neko_start(int _id) { auto ents = get_now_selected_list(); -#ifdef Q_OS_LINUX if (IS_NEKO_BOX_INTERNAL_TUN) - Linux_Pkexec_SetCapString(NekoGui::FindNekoBoxCoreRealPath(), "cap_net_admin-ep"); -#endif + StopVPNProcess(); auto ent = (_id < 0 && !ents.isEmpty()) ? ents.first() : NekoGui::profileManager->GetProfile(_id); if (ent == nullptr) return;