fix check update

This commit is contained in:
arm64v8a
2022-08-08 11:25:40 +08:00
parent 8031c68038
commit 0b7abbe43e

View File

@@ -122,7 +122,7 @@ func getProxyHttpClient(_instance *libcore.V2RayInstance) *http.Client {
// UPDATE // UPDATE
var update_download_url, update_download_as string var update_download_url string
func (s *server) Update(ctx context.Context, in *gen.UpdateReq) (*gen.UpdateResp, error) { func (s *server) Update(ctx context.Context, in *gen.UpdateReq) (*gen.UpdateResp, error) {
ret := &gen.UpdateResp{} ret := &gen.UpdateResp{}
@@ -161,10 +161,8 @@ func (s *server) Update(ctx context.Context, in *gen.UpdateReq) (*gen.UpdateResp
var search string var search string
if runtime.GOOS == "windows" && runtime.GOARCH == "amd64" { if runtime.GOOS == "windows" && runtime.GOARCH == "amd64" {
search = "windows64" search = "windows64"
update_download_as = "nekoray.zip"
} else if runtime.GOOS == "linux" && runtime.GOARCH == "amd64" { } else if runtime.GOOS == "linux" && runtime.GOARCH == "amd64" {
search = "linux64" search = "linux64"
update_download_as = "nekoray.tar.gz"
} else { } else {
ret.Error = "Not official support platform" ret.Error = "Not official support platform"
return ret, nil return ret, nil
@@ -191,7 +189,7 @@ func (s *server) Update(ctx context.Context, in *gen.UpdateReq) (*gen.UpdateResp
} }
} }
} else { // Download update } else { // Download update
if update_download_url == "" || update_download_as == "" { if update_download_url == "" {
ret.Error = "?" ret.Error = "?"
return ret, nil return ret, nil
} }
@@ -204,7 +202,7 @@ func (s *server) Update(ctx context.Context, in *gen.UpdateReq) (*gen.UpdateResp
} }
defer resp.Body.Close() defer resp.Body.Close()
f, err := os.OpenFile("../"+update_download_as, os.O_TRUNC|os.O_CREATE|os.O_RDWR, 0644) f, err := os.OpenFile("../nekoray.zip", os.O_TRUNC|os.O_CREATE|os.O_RDWR, 0644)
if err != nil { if err != nil {
ret.Error = err.Error() ret.Error = err.Error()
return ret, nil return ret, nil