mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 13:50:12 +08:00
improve exit
This commit is contained in:
parent
ca6924c467
commit
72c7d6c9ea
@ -5,8 +5,6 @@ option go_package = "grpc_server/gen";
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
service LibcoreService {
|
||||
rpc Exit(EmptyReq) returns (EmptyResp);
|
||||
//
|
||||
rpc Start(LoadConfigReq) returns (ErrorResp);
|
||||
rpc Stop(EmptyReq) returns (ErrorResp);
|
||||
rpc CheckConfig(LoadConfigReq) returns (ErrorResp);
|
||||
|
||||
@ -40,22 +40,6 @@ func To[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
|
||||
func (s *server) Exit(ctx context.Context, in *gen.EmptyReq) (out *gen.EmptyResp, _ error) {
|
||||
out = &gen.EmptyResp{}
|
||||
|
||||
if needUnsetDNS {
|
||||
needUnsetDNS = false
|
||||
err := sys.SetSystemDNS("Empty", boxInstance.Network().InterfaceMonitor())
|
||||
if err != nil {
|
||||
log.Println("Failed to unset system DNS:", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Connection closed
|
||||
defer os.Exit(0)
|
||||
return
|
||||
}
|
||||
|
||||
func (s *server) Start(ctx context.Context, in *gen.LoadConfigReq) (out *gen.ErrorResp, _ error) {
|
||||
var err error
|
||||
|
||||
|
||||
@ -16,8 +16,6 @@ namespace API {
|
||||
public:
|
||||
explicit Client(std::function<void(const QString &)> onError, const QString &target);
|
||||
|
||||
void Exit();
|
||||
|
||||
// QString returns is error string
|
||||
|
||||
QString Start(bool *rpcOK, const libcore::LoadConfigReq &request);
|
||||
|
||||
@ -188,13 +188,6 @@ namespace API {
|
||||
*rpcOK = false; \
|
||||
onError(QString("QNetworkReply::NetworkError code: %1\n").arg(status));
|
||||
|
||||
void Client::Exit() {
|
||||
libcore::EmptyReq request;
|
||||
libcore::EmptyResp reply;
|
||||
std::vector<uint8_t> rsp;
|
||||
default_grpc_channel->Call("Exit", spb::pb::serialize< std::string >( request ), rsp, 100);
|
||||
}
|
||||
|
||||
QString Client::Start(bool *rpcOK, const libcore::LoadConfigReq &request) {
|
||||
libcore::ErrorResp reply;
|
||||
std::vector<uint8_t> rsp;
|
||||
|
||||
@ -843,7 +843,7 @@ 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();
|
||||
API::defaultClient->Exit();
|
||||
core_process->Kill();
|
||||
mu_exit.unlock();
|
||||
qDebug() << "prepare exit done!";
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user