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>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user