package updater import ( "context" "io" "net/http" "os" "time" mihomoHttp "github.com/metacubex/mihomo/component/http" ) const defaultHttpTimeout = time.Second * 90 func downloadForBytes(url string) ([]byte, error) { ctx, cancel := context.WithTimeout(context.Background(), defaultHttpTimeout) defer cancel() resp, err := mihomoHttp.HttpRequest(ctx, url, http.MethodGet, nil, nil) if err != nil { return nil, err } defer resp.Body.Close() return io.ReadAll(resp.Body) } func saveFile(bytes []byte, path string) error { return os.WriteFile(path, bytes, 0o644) }