diff --git a/.github/workflows/build-qv2ray-cmake.yml b/.github/workflows/build-qv2ray-cmake.yml index 36b5e94..9a934ef 100644 --- a/.github/workflows/build-qv2ray-cmake.yml +++ b/.github/workflows/build-qv2ray-cmake.yml @@ -170,7 +170,7 @@ jobs: cd deployment cp -r assets/* linux64 cp -r assets/* windows64 - rm -rf assets + rm -rf assets *.pdb mv linux64 nekoray zip -r $version_standalone-linux64.zip nekoray rm -rf nekoray diff --git a/core_commit.txt b/core_commit.txt index 55ceba3..59acbec 100644 --- a/core_commit.txt +++ b/core_commit.txt @@ -1 +1 @@ -edf4fcff77a0dfd40b20076faf45767a3394f5eb +98f91bf391bc16d6c5c825b406b5bdd82f06870e diff --git a/examples/vpn-run-root.sh b/examples/vpn-run-root.sh index 2fcf8b2..f5baf28 100755 --- a/examples/vpn-run-root.sh +++ b/examples/vpn-run-root.sh @@ -18,7 +18,7 @@ BASEDIR=$(dirname "$0") cd $BASEDIR start() { - # add tun (TODO the ip must be the same as matsuri) + # add tun ip tuntap add $TUN_NAME mode tun user $USER_ID || return ip link set dev nekoray-tun mtu $MTU || return ip link set dev $TUN_NAME up || return diff --git a/go/go.mod b/go/go.mod index 9d1ceec..3be69bb 100644 --- a/go/go.mod +++ b/go/go.mod @@ -7,9 +7,9 @@ require ( github.com/jsimonetti/rtnetlink v1.2.0 github.com/sirupsen/logrus v1.8.1 github.com/v2fly/v2ray-core/v5 v5.0.0 - golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a google.golang.org/grpc v1.48.0 google.golang.org/protobuf v1.28.1 + gvisor.dev/gvisor v0.0.0 kernel.org/pub/linux/libs/security/libcap/cap v1.2.64 libcore v1.0.0 ) @@ -23,11 +23,8 @@ require ( github.com/boljen/go-bitmap v0.0.0-20151001105940-23cd2fb0ce7d // indirect github.com/cheekybits/genny v1.0.0 // indirect github.com/dgryski/go-camellia v0.0.0-20191119043421-69a8a13fb23d // indirect - github.com/dgryski/go-idea v0.0.0-20170306091226-d2fb45a411fb // indirect github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect - github.com/dgryski/go-rc2 v0.0.0-20150621095337-8a9021637152 // indirect github.com/fsnotify/fsnotify v1.5.1 // indirect - github.com/geeksbaek/seed v0.0.0-20180909040025-2a7f5fb92e22 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/btree v1.0.1 // indirect @@ -35,7 +32,6 @@ require ( github.com/gorilla/websocket v1.5.0 // indirect github.com/jhump/protoreflect v1.12.0 // indirect github.com/josharian/native v1.0.0 // indirect - github.com/kierdavis/cfb8 v0.0.0-20180105024805-3a17c36ee2f8 // indirect github.com/klauspost/cpuid v1.2.3 // indirect github.com/klauspost/reedsolomon v1.9.3 // indirect github.com/lucas-clemente/quic-go v0.28.1 // indirect @@ -75,13 +71,13 @@ require ( golang.org/x/mod v0.5.1 // indirect golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect + golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect golang.org/x/tools v0.1.9 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect - gvisor.dev/gvisor v0.0.0 // indirect inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6 // indirect kernel.org/pub/linux/libs/security/libcap/psx v1.2.64 // indirect ) diff --git a/go/go.sum b/go/go.sum index 0232293..78cb4cc 100644 --- a/go/go.sum +++ b/go/go.sum @@ -80,18 +80,13 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-camellia v0.0.0-20191119043421-69a8a13fb23d h1:CPqTNIigGweVPT4CYb+OO2E6XyRKFOmvTHwWRLgCAlE= github.com/dgryski/go-camellia v0.0.0-20191119043421-69a8a13fb23d/go.mod h1:QX5ZVULjAfZJux/W62Y91HvCh9hyW6enAwcrrv/sLj0= -github.com/dgryski/go-idea v0.0.0-20170306091226-d2fb45a411fb h1:zXpN5126w/mhECTkqazBkrOJIMatbPP71aSIDR5UuW4= -github.com/dgryski/go-idea v0.0.0-20170306091226-d2fb45a411fb/go.mod h1:F7WkpqJj9t98ePxB/WJGQTIDeOVPuSJ3qdn6JUjg170= github.com/dgryski/go-metro v0.0.0-20180109044635-280f6062b5bc/go.mod h1:c9O8+fpSOX1DM8cPNSkX/qsBWdkD4yd2dpciOWQjpBw= github.com/dgryski/go-metro v0.0.0-20200812162917-85c65e2d0165/go.mod h1:c9O8+fpSOX1DM8cPNSkX/qsBWdkD4yd2dpciOWQjpBw= github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 h1:y7y0Oa6UawqTFPCDw9JG6pdKt4F9pAhHv0B7FMGaGD0= github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140/go.mod h1:c9O8+fpSOX1DM8cPNSkX/qsBWdkD4yd2dpciOWQjpBw= -github.com/dgryski/go-rc2 v0.0.0-20150621095337-8a9021637152 h1:ED31mPIxDJnrLt9W9dH5xgd/6KjzEACKHBVGQ33czc0= -github.com/dgryski/go-rc2 v0.0.0-20150621095337-8a9021637152/go.mod h1:I9fhc/EvSg88cDxmfQ47v35Ssz9rlFunL/KY0A1JAYI= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= -github.com/ebfe/rc2 v0.0.0-20131011165748-24b9757f5521 h1:fBHFH+Y/GPGFGo7LIrErQc3p2MeAhoIQNgaxPWYsSxk= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -108,8 +103,6 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= -github.com/geeksbaek/seed v0.0.0-20180909040025-2a7f5fb92e22 h1:CdVtqYWYGIEuYCbtyx6BVMKOcO0N6lKm99cR1DZubAs= -github.com/geeksbaek/seed v0.0.0-20180909040025-2a7f5fb92e22/go.mod h1:YS1s0XuwU13tHT0WeYeUXUwGk1m8WZvSbK9cx/kY1SE= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= @@ -225,8 +218,6 @@ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/kierdavis/cfb8 v0.0.0-20180105024805-3a17c36ee2f8 h1:QxgFSDEqLP8ZsmVm/Qke0HP6JLV7EB93vtWK7noU1Sw= -github.com/kierdavis/cfb8 v0.0.0-20180105024805-3a17c36ee2f8/go.mod h1:uL2TcUivilrs0kPsqUwIf8XHAcmkSjsfrzSgAJwS0TI= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/cpuid v1.2.3 h1:CCtW0xUnWGVINKvE/WWOYKdsPV6mawAtvQuSl8guwQs= diff --git a/go/grpc.go b/go/grpc.go index e343315..f2d7809 100644 --- a/go/grpc.go +++ b/go/grpc.go @@ -3,24 +3,17 @@ package main import ( "bufio" "context" - "encoding/json" "flag" "fmt" - "io" - "libcore" "log" "nekoray_core/gen" "net" - "net/http" "os" - "runtime" "strconv" "strings" "time" - _ "unsafe" grpc_auth "github.com/grpc-ecosystem/go-grpc-middleware/auth" - v2rayNet "github.com/v2fly/v2ray-core/v5/common/net" "google.golang.org/grpc" ) @@ -93,129 +86,3 @@ func NekorayCore() { log.Fatalf("failed to serve: %v", err) } } - -// PROXY - -func getProxyHttpClient(_instance *libcore.V2RayInstance) *http.Client { - dailContext := func(ctx context.Context, network, addr string) (net.Conn, error) { - dest, err := v2rayNet.ParseDestination(fmt.Sprintf("%s:%s", network, addr)) - if err != nil { - return nil, err - } - return _instance.DialContext(ctx, dest) - } - - transport := &http.Transport{ - TLSHandshakeTimeout: time.Second * 3, - ResponseHeaderTimeout: time.Second * 3, - } - if _instance != nil { - transport.DialContext = dailContext - } - - client := &http.Client{ - Transport: transport, - } - - return client -} - -// UPDATE - -var update_download_url string - -func (s *server) Update(ctx context.Context, in *gen.UpdateReq) (*gen.UpdateResp, error) { - ret := &gen.UpdateResp{} - - client := getProxyHttpClient(instance) - - if in.Action == gen.UpdateAction_Check { // Check update - ctx, cancel := context.WithTimeout(ctx, time.Second*10) - defer cancel() - - req, _ := http.NewRequestWithContext(ctx, "GET", "https://api.github.com/repos/MatsuriDayo/nekoray/releases", nil) - resp, err := client.Do(req) - if err != nil { - ret.Error = err.Error() - return ret, nil - } - defer resp.Body.Close() - - v := []struct { - HtmlUrl string `json:"html_url"` - Assets []struct { - Name string `json:"name"` - BrowserDownloadUrl string `json:"browser_download_url"` - } `json:"assets"` - Prerelease bool `json:"prerelease"` - Body string `json:"body"` - }{} - err = json.NewDecoder(resp.Body).Decode(&v) - if err != nil { - ret.Error = err.Error() - return ret, nil - } - - nowVer := strings.TrimLeft(version_standalone, "nekoray-") - - var search string - if runtime.GOOS == "windows" && runtime.GOARCH == "amd64" { - search = "windows64" - } else if runtime.GOOS == "linux" && runtime.GOARCH == "amd64" { - search = "linux64" - } else { - ret.Error = "Not official support platform" - return ret, nil - } - - for _, release := range v { - if len(release.Assets) > 0 { - for _, asset := range release.Assets { - if strings.Contains(asset.Name, nowVer) { - return ret, nil // No update - } - if strings.Contains(asset.Name, search) { - if release.Prerelease { - continue - } - update_download_url = asset.BrowserDownloadUrl - ret.AssetsName = asset.Name - ret.DownloadUrl = asset.BrowserDownloadUrl - ret.ReleaseUrl = release.HtmlUrl - ret.ReleaseNote = release.Body - return ret, nil // update - } - } - } - } - } else { // Download update - if update_download_url == "" { - ret.Error = "?" - return ret, nil - } - - req, _ := http.NewRequestWithContext(ctx, "GET", update_download_url, nil) - resp, err := client.Do(req) - if err != nil { - ret.Error = err.Error() - return ret, nil - } - defer resp.Body.Close() - - f, err := os.OpenFile("../nekoray.zip", os.O_TRUNC|os.O_CREATE|os.O_RDWR, 0644) - if err != nil { - ret.Error = err.Error() - return ret, nil - } - defer f.Close() - - _, err = io.Copy(f, resp.Body) - if err != nil { - ret.Error = err.Error() - return ret, nil - } - f.Sync() - } - - return ret, nil -} diff --git a/go/core_rpc.go b/go/grpc_core.go similarity index 94% rename from go/core_rpc.go rename to go/grpc_core.go index 1b95fb3..0cc45f9 100644 --- a/go/core_rpc.go +++ b/go/grpc_core.go @@ -137,6 +137,7 @@ func (s *server) Test(ctx context.Context, in *gen.TestReq) (out *gen.TestResp, if in.Config != nil { // Test instance i = libcore.NewV2rayInstance() + i.ForTest = true defer i.Close() err = i.LoadConfig(in.Config.CoreConfig) @@ -161,8 +162,19 @@ func (s *server) Test(ctx context.Context, in *gen.TestReq) (out *gen.TestResp, t, err = libcore.UrlTestV2ray(i, in.Inbound, in.Url, in.Timeout) out.Ms = t // sn: ms==0 是错误 } else if in.Mode == gen.TestMode_TcpPing { + host, port, err := net.SplitHostPort(in.Address) + if err != nil { + out.Error = err.Error() + return + } + ip, err := net.ResolveIPAddr("ip", host) + if err != nil { + out.Error = err.Error() + return + } + // startTime := time.Now() - _, err = net.DialTimeout("tcp", in.Address, time.Duration(in.Timeout)*time.Millisecond) + _, err = net.DialTimeout("tcp", net.JoinHostPort(ip.String(), port), time.Duration(in.Timeout)*time.Millisecond) endTime := time.Now() if err == nil { out.Ms = int32(endTime.Sub(startTime).Milliseconds()) @@ -174,6 +186,7 @@ func (s *server) Test(ctx context.Context, in *gen.TestReq) (out *gen.TestResp, // Test instance i := libcore.NewV2rayInstance() + i.ForTest = true defer i.Close() err = i.LoadConfig(in.Config.CoreConfig) diff --git a/go/grpc_update.go b/go/grpc_update.go new file mode 100644 index 0000000..f572dab --- /dev/null +++ b/go/grpc_update.go @@ -0,0 +1,144 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "io" + "libcore" + "nekoray_core/gen" + "net" + "net/http" + "os" + "runtime" + "strings" + "time" + + v2rayNet "github.com/v2fly/v2ray-core/v5/common/net" +) + +// PROXY + +func getProxyHttpClient(_instance *libcore.V2RayInstance) *http.Client { + dailContext := func(ctx context.Context, network, addr string) (net.Conn, error) { + dest, err := v2rayNet.ParseDestination(fmt.Sprintf("%s:%s", network, addr)) + if err != nil { + return nil, err + } + return _instance.DialContext(ctx, dest) + } + + transport := &http.Transport{ + TLSHandshakeTimeout: time.Second * 3, + ResponseHeaderTimeout: time.Second * 3, + } + if _instance != nil { + transport.DialContext = dailContext + } + + client := &http.Client{ + Transport: transport, + } + + return client +} + +// UPDATE + +var update_download_url string + +func (s *server) Update(ctx context.Context, in *gen.UpdateReq) (*gen.UpdateResp, error) { + ret := &gen.UpdateResp{} + + client := getProxyHttpClient(instance) + + if in.Action == gen.UpdateAction_Check { // Check update + ctx, cancel := context.WithTimeout(ctx, time.Second*10) + defer cancel() + + req, _ := http.NewRequestWithContext(ctx, "GET", "https://api.github.com/repos/MatsuriDayo/nekoray/releases", nil) + resp, err := client.Do(req) + if err != nil { + ret.Error = err.Error() + return ret, nil + } + defer resp.Body.Close() + + v := []struct { + HtmlUrl string `json:"html_url"` + Assets []struct { + Name string `json:"name"` + BrowserDownloadUrl string `json:"browser_download_url"` + } `json:"assets"` + Prerelease bool `json:"prerelease"` + Body string `json:"body"` + }{} + err = json.NewDecoder(resp.Body).Decode(&v) + if err != nil { + ret.Error = err.Error() + return ret, nil + } + + nowVer := strings.TrimLeft(version_standalone, "nekoray-") + + var search string + if runtime.GOOS == "windows" && runtime.GOARCH == "amd64" { + search = "windows64" + } else if runtime.GOOS == "linux" && runtime.GOARCH == "amd64" { + search = "linux64" + } else { + ret.Error = "Not official support platform" + return ret, nil + } + + for _, release := range v { + if len(release.Assets) > 0 { + for _, asset := range release.Assets { + if strings.Contains(asset.Name, nowVer) { + return ret, nil // No update + } + if strings.Contains(asset.Name, search) { + if release.Prerelease { + continue + } + update_download_url = asset.BrowserDownloadUrl + ret.AssetsName = asset.Name + ret.DownloadUrl = asset.BrowserDownloadUrl + ret.ReleaseUrl = release.HtmlUrl + ret.ReleaseNote = release.Body + return ret, nil // update + } + } + } + } + } else { // Download update + if update_download_url == "" { + ret.Error = "?" + return ret, nil + } + + req, _ := http.NewRequestWithContext(ctx, "GET", update_download_url, nil) + resp, err := client.Do(req) + if err != nil { + ret.Error = err.Error() + return ret, nil + } + defer resp.Body.Close() + + f, err := os.OpenFile("../nekoray.zip", os.O_TRUNC|os.O_CREATE|os.O_RDWR, 0644) + if err != nil { + ret.Error = err.Error() + return ret, nil + } + defer f.Close() + + _, err = io.Copy(f, resp.Body) + if err != nil { + ret.Error = err.Error() + return ret, nil + } + f.Sync() + } + + return ret, nil +} diff --git a/matsuri_commit.txt b/matsuri_commit.txt index d9e0d41..8c08cee 100644 --- a/matsuri_commit.txt +++ b/matsuri_commit.txt @@ -1 +1 @@ -4fdd5842f61b467f1de777aea4d0b1c23f5feb2a +b827a53549f0c79311bb8ac6e01bedff5a19a91e diff --git a/rpc/gRPC.cpp b/rpc/gRPC.cpp index 672d7de..c72fa02 100644 --- a/rpc/gRPC.cpp +++ b/rpc/gRPC.cpp @@ -23,6 +23,8 @@ namespace QtGrpc { const char *GrpcStatusMessage = "grpc-message"; const int GrpcMessageSizeHeaderSize = 5; + bool core_crashed = false; + class Http2GrpcChannelPrivate : public QObject { private: QString url_base; @@ -133,6 +135,8 @@ namespace QtGrpc { QNetworkReply::NetworkError Call(const QString &methodName, const google::protobuf::Message &req, google::protobuf::Message *rsp, int timeout_ms = 0) { + if (core_crashed) return QNetworkReply::NetworkError(-1919); + std::string reqStr; req.SerializeToString(&reqStr); auto requestArray = QByteArray::fromStdString(reqStr); diff --git a/sys/ExternalProcess.cpp b/sys/ExternalProcess.cpp index d6e74c8..3e9b269 100644 --- a/sys/ExternalProcess.cpp +++ b/sys/ExternalProcess.cpp @@ -45,7 +45,7 @@ namespace NekoRay::sys { } else if (!crashed) { crashed = true; Kill(); - showLog_ext(tag, "[Error] Crashed?"); + showLog_ext(tag, "[Error] Program exited accidentally"); dialog_message("ExternalProcess", "Crashed"); } } diff --git a/ui/edit/edit_custom.ui b/ui/edit/edit_custom.ui index 39aab2d..c03387c 100644 --- a/ui/edit/edit_custom.ui +++ b/ui/edit/edit_custom.ui @@ -83,6 +83,18 @@ Generator + + 0 + + + 0 + + + 0 + + + 0 + diff --git a/ui/edit/edit_shadowsocks.ui b/ui/edit/edit_shadowsocks.ui index faa8d5c..2efd0d8 100644 --- a/ui/edit/edit_shadowsocks.ui +++ b/ui/edit/edit_shadowsocks.ui @@ -90,12 +90,12 @@ - chacha20-poly1305 + chacha20-ietf-poly1305 - xchacha20-poly1305 + xchacha20-ieft-poly1305 diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index 8f34a3e..9d2aa61 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -16,12 +16,12 @@ #include "3rdparty/qrcodegen.hpp" #include "3rdparty/VT100Parser.hpp" +#include "qv2ray/v2/components/proxy/QvProxyConfigurator.hpp" #include "qv2ray/v2/ui/LogHighlighter.hpp" #ifndef NKR_NO_EXTERNAL #include "3rdparty/ZxingQtReader.hpp" -#include "qv2ray/v2/components/proxy/QvProxyConfigurator.hpp" #endif @@ -50,6 +50,10 @@ #include #include +namespace QtGrpc { + extern bool core_crashed; +} + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { mainwindow = this; @@ -358,7 +362,9 @@ MainWindow::MainWindow(QWidget *parent) #ifdef Q_OS_WIN if (!core_path.endsWith(".exe")) core_path += ".exe"; #endif - if (!QFile(core_path).exists()) { + if (NekoRay::dataStore->flag_use_appdata) { + core_path = QApplication::applicationDirPath() + "/nekoray_core"; + } else if (!QFile(core_path).exists()) { starting_info = "(not found)"; core_path = ""; } @@ -400,9 +406,11 @@ MainWindow::MainWindow(QWidget *parent) core_process->write((NekoRay::dataStore->core_token + "\n").toUtf8()); core_process->waitForFinished(-1); if (core_process_killed) return; - runOnUiThread([=] { neko_stop(true); }); - QThread::sleep(2); + // TODO Not retrying can avoid crash? core_process->deleteLater(); + QtGrpc::core_crashed = true; + showLog("[ERROR] nekoray_core crashed, please restart the program."); + return; } }); @@ -567,9 +575,7 @@ void MainWindow::neko_set_spmode(int mode, bool save) { // DISABLE if (title_spmode == NekoRay::SystemProxyMode::SYSTEM_PROXY) { -#ifndef NKR_NO_EXTERNAL ClearSystemProxy(); -#endif } else if (title_spmode == NekoRay::SystemProxyMode::VPN) { if (!StopVPNProcess()) { refresh_status(); @@ -580,7 +586,6 @@ void MainWindow::neko_set_spmode(int mode, bool save) { // ENABLE if (mode == NekoRay::SystemProxyMode::SYSTEM_PROXY) { -#ifndef NKR_NO_EXTERNAL #ifdef Q_OS_WIN if (mode == NekoRay::SystemProxyMode::SYSTEM_PROXY && !InRange(NekoRay::dataStore->inbound_http_port, 0, 65535)) { @@ -595,7 +600,6 @@ void MainWindow::neko_set_spmode(int mode, bool save) { SetSystemProxy("127.0.0.1", NekoRay::dataStore->inbound_http_port, NekoRay::dataStore->inbound_socks_port); -#endif } else if (mode == NekoRay::SystemProxyMode::VPN) { if (!StartVPNProcess()) { refresh_status();