diff --git a/openclaw/installer/installer.exe b/openclaw/installer/installer.exe index 0d47fc7..a53ab2c 100644 Binary files a/openclaw/installer/installer.exe and b/openclaw/installer/installer.exe differ diff --git a/openclaw/installer/internal/sys/sys.go b/openclaw/installer/internal/sys/sys.go index 65a2845..66312ed 100644 --- a/openclaw/installer/internal/sys/sys.go +++ b/openclaw/installer/internal/sys/sys.go @@ -372,6 +372,26 @@ func getNpmPrefix() (string, error) { return cachedNpmPrefix, nil } +// checkIsCNLocation Checks if the current IP location is in China +func checkIsCNLocation() bool { + client := &http.Client{Timeout: 5 * time.Second} + resp, err := client.Get("https://www.cloudflare.com/cdn-cgi/trace") + if err != nil { + // If the request fails, assume CN to be safe and ensure accessibility + return true + } + defer resp.Body.Close() + + scanner := bufio.NewScanner(resp.Body) + for scanner.Scan() { + line := strings.TrimSpace(scanner.Text()) + if line == "loc=CN" { + return true + } + } + return false +} + func ResetPathCache() { cachedNpmPrefix = "" cachedNodePath = "" @@ -395,6 +415,10 @@ func ConfigureNpmMirror() error { } func ConfigureGitProxy() error { + if !checkIsCNLocation() { + return nil + } + var lastErr error for i := 0; i < 3; i++ { ResetPathCache() @@ -416,6 +440,21 @@ func ConfigureGitProxy() error { return lastErr } +// RemoveGitProxy 取消 Git 代理 +func RemoveGitProxy() error { + gitPath, err := GetGitPath() + if err != nil { + return nil + } + + proxy := gitProxy() + key := fmt.Sprintf("url.%shttps://github.com/.insteadOf", proxy) + + // Unset the proxy configuration + cmd := exec.Command(gitPath, "config", "--global", "--unset", key) + return cmd.Run() +} + // downloadFile 下载文件 func downloadFile(url, dest, expectedSHA256 string, onProgress ProgressCallback) error { if ok, err := verifyFileSHA256(dest, expectedSHA256); err == nil && ok { @@ -1140,6 +1179,8 @@ func UninstallOpenclaw() error { cmd.Run() } + RemoveGitProxy() + userHome, err := os.UserHomeDir() if err == nil { configDir := filepath.Join(userHome, ".openclaw")