Release 3.8.1.1: lighter idle UI poll, core cache, multicore ping.
Reduce idle CPU (cheap PollUI, binary cache, logbuf cap, DOM fingerprint), speed ping/AWG HostPort, CopyBuffer pool; ship arm64 build and update notes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"time"
|
||||
|
||||
"vpnclient/internal/config"
|
||||
"vpnclient/internal/corebin"
|
||||
"vpnclient/internal/linknorm"
|
||||
"vpnclient/internal/protocols/awg"
|
||||
"vpnclient/internal/protocols/hysteria2"
|
||||
@@ -277,6 +278,76 @@ func (m *Manager) Config() *config.Config {
|
||||
return m.cfg.Clone()
|
||||
}
|
||||
|
||||
// UIPoll is a cheap manager snapshot for GUI polling (no JSON deep-clone of all proxies).
|
||||
type UIPoll struct {
|
||||
Status Status
|
||||
Active string
|
||||
SystemProxy bool
|
||||
Subscription string
|
||||
ActiveProxy string
|
||||
ActiveProtocol config.Protocol
|
||||
Profiles []config.ProfileInfo
|
||||
Hy2 Hy2Options
|
||||
BinDir string
|
||||
}
|
||||
|
||||
// PollUI gathers status + profile list under one lock without Config().Clone().
|
||||
func (m *Manager) PollUI(includeSecrets bool) UIPoll {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
out := UIPoll{
|
||||
Status: Status{SystemProxy: m.sys.Enabled()},
|
||||
BinDir: m.binDir,
|
||||
SystemProxy: false,
|
||||
Subscription: "",
|
||||
Hy2: Hy2Options{Congestion: "bbr", BBRProfile: "standard"},
|
||||
}
|
||||
if m.cfg != nil {
|
||||
out.Active = m.cfg.Active
|
||||
out.SystemProxy = m.cfg.SystemProxy
|
||||
out.Subscription = m.cfg.SubscriptionURL
|
||||
if includeSecrets {
|
||||
out.Profiles = m.cfg.ListProfiles()
|
||||
} else {
|
||||
out.Profiles = m.cfg.ListProfilesForPoll()
|
||||
}
|
||||
if p, err := m.cfg.ActiveProfile(); err == nil {
|
||||
out.Active = p.Name
|
||||
out.ActiveProxy = p.Proxy
|
||||
out.ActiveProtocol = p.Protocol
|
||||
out.Hy2 = Hy2Options{
|
||||
Congestion: p.Hy2Congestion,
|
||||
BBRProfile: p.Hy2BBRProfile,
|
||||
BandwidthUp: p.Hy2BandwidthUp,
|
||||
BandwidthDown: p.Hy2BandwidthDown,
|
||||
Obfs: p.Hy2Obfs,
|
||||
ObfsPassword: p.Hy2ObfsPassword,
|
||||
SNI: p.Hy2SNI,
|
||||
Insecure: p.Hy2Insecure,
|
||||
PinSHA256: p.Hy2PinSHA256,
|
||||
FastOpen: p.Hy2FastOpen,
|
||||
Lazy: p.Hy2Lazy,
|
||||
HopInterval: p.Hy2HopInterval,
|
||||
}
|
||||
}
|
||||
}
|
||||
if m.engine != nil && m.engine.Running() {
|
||||
out.Status.Connected = true
|
||||
if m.profile != nil {
|
||||
out.Status.Profile = m.profile.Name
|
||||
out.Status.Protocol = m.profile.Protocol
|
||||
}
|
||||
if hp, ok := m.engine.LocalHTTPProxy(); ok {
|
||||
out.Status.HTTPProxy = hp
|
||||
}
|
||||
if sp, ok := m.engine.LocalSOCKSProxy(); ok {
|
||||
out.Status.SOCKSProxy = sp
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (m *Manager) SetSystemProxy(enabled bool) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
@@ -572,24 +643,37 @@ func (m *Manager) EnsureCore(proto config.Protocol) (string, error) {
|
||||
}
|
||||
m.mu.Unlock()
|
||||
|
||||
var (
|
||||
path string
|
||||
err error
|
||||
)
|
||||
switch proto {
|
||||
case config.ProtocolHysteria2:
|
||||
return hysteria2.EnsureBinary(binDir)
|
||||
path, err = hysteria2.EnsureBinary(binDir)
|
||||
case config.ProtocolAWG:
|
||||
return awg.EnsureBinary(binDir)
|
||||
path, err = awg.EnsureBinary(binDir)
|
||||
case config.ProtocolVLESS, config.ProtocolVMess, config.ProtocolTrojan:
|
||||
return xray.EnsureBinary(binDir)
|
||||
path, err = xray.EnsureBinary(binDir)
|
||||
default:
|
||||
return naive.EnsureBinary(binDir)
|
||||
path, err = naive.EnsureBinary(binDir)
|
||||
proto = config.ProtocolNaive
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
corebin.Set(corebin.CacheKey(binDir, corebin.ProtoKey(string(proto))), path)
|
||||
return path, nil
|
||||
}
|
||||
|
||||
// EnsureAllCores installs naive + hysteria2 + xray cores (AWG is embedded).
|
||||
// Downloads run in parallel (one goroutine per core) to use multiple CPU cores / network.
|
||||
func (m *Manager) EnsureAllCores() (map[string]string, error) {
|
||||
m.mu.Lock()
|
||||
binDir := m.binDir
|
||||
m.mu.Unlock()
|
||||
|
||||
corebin.Invalidate()
|
||||
|
||||
type item struct {
|
||||
key string
|
||||
path string
|
||||
@@ -623,6 +707,7 @@ func (m *Manager) EnsureAllCores() (map[string]string, error) {
|
||||
continue
|
||||
}
|
||||
out[it.key] = it.path
|
||||
corebin.Set(corebin.CacheKey(binDir, it.key), it.path)
|
||||
}
|
||||
return out, first
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user