Files
M4andCursor 041cbb1250 Release 2.7.3.1: harden proxy recovery, updates and local API.
Restore orphaned system proxy after crash, require update SHA-256, add macOS /api auth token, fix UDP ping false positives, HTTPS-only subscriptions, and keep the UI responsive during connect.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 18:48:54 +03:00

40 lines
1.0 KiB
Go

package sysproxy
import (
"os"
"path/filepath"
"strings"
)
// SentinelPath is written while Navis owns the OS system proxy.
// Survives crash/kill so the next launch can clear a stuck proxy.
func SentinelPath(cfgPath string) string {
dir := filepath.Dir(strings.TrimSpace(cfgPath))
if dir == "" || dir == "." {
dir, _ = os.UserConfigDir()
if dir == "" {
dir = os.TempDir()
}
dir = filepath.Join(dir, "Navis")
}
return filepath.Join(dir, ".navis-proxy-on")
}
// WriteSentinel marks that system proxy was enabled by Navis.
func WriteSentinel(cfgPath, httpHostPort string) {
path := SentinelPath(cfgPath)
_ = os.MkdirAll(filepath.Dir(path), 0o755)
_ = os.WriteFile(path, []byte(strings.TrimSpace(httpHostPort)+"\n"), 0o600)
}
// ClearSentinel removes the ownership marker after a clean Disable.
func ClearSentinel(cfgPath string) {
_ = os.Remove(SentinelPath(cfgPath))
}
// HasSentinel reports whether a previous session left the proxy marked on.
func HasSentinel(cfgPath string) bool {
_, err := os.Stat(SentinelPath(cfgPath))
return err == nil
}