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:
@@ -454,7 +454,11 @@ func (c *Conf) validate() error {
|
||||
}
|
||||
|
||||
// HostPort returns UDP endpoint host and port for ping.
|
||||
// Prefers a light Endpoint=/URI extract; falls back to full Parse for JSON/vpn:// blobs.
|
||||
func HostPort(raw string) (host, port string, err error) {
|
||||
if h, p, ok := lightEndpoint(raw); ok {
|
||||
return h, p, nil
|
||||
}
|
||||
c, err := Parse(raw)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
@@ -466,6 +470,67 @@ func HostPort(raw string) (host, port string, err error) {
|
||||
return h, p, nil
|
||||
}
|
||||
|
||||
func lightEndpoint(raw string) (host, port string, ok bool) {
|
||||
raw = sanitizeShare(raw)
|
||||
if raw == "" {
|
||||
return "", "", false
|
||||
}
|
||||
lower := strings.ToLower(raw)
|
||||
switch {
|
||||
case strings.HasPrefix(lower, "awg://"), strings.HasPrefix(lower, "amneziawg://"),
|
||||
strings.HasPrefix(lower, "wireguard://"):
|
||||
// URI host:port only — no full config decode.
|
||||
rest := raw
|
||||
if i := strings.Index(rest, "://"); i >= 0 {
|
||||
rest = rest[i+3:]
|
||||
}
|
||||
if at := strings.Index(rest, "@"); at >= 0 {
|
||||
rest = rest[at+1:]
|
||||
}
|
||||
if i := strings.IndexAny(rest, "/?#"); i >= 0 {
|
||||
rest = rest[:i]
|
||||
}
|
||||
rest = strings.TrimSpace(rest)
|
||||
if rest == "" {
|
||||
return "", "", false
|
||||
}
|
||||
h, p, err := net.SplitHostPort(rest)
|
||||
if err != nil {
|
||||
return rest, "51820", true
|
||||
}
|
||||
return h, p, true
|
||||
}
|
||||
if strings.Contains(lower, "endpoint") {
|
||||
for _, line := range strings.Split(raw, "\n") {
|
||||
line = strings.TrimSpace(line)
|
||||
if line == "" || strings.HasPrefix(line, "#") || strings.HasPrefix(line, ";") {
|
||||
continue
|
||||
}
|
||||
low := strings.ToLower(line)
|
||||
if !strings.HasPrefix(low, "endpoint") {
|
||||
continue
|
||||
}
|
||||
_, val, cutOK := strings.Cut(line, "=")
|
||||
if !cutOK {
|
||||
_, val, cutOK = strings.Cut(line, ":")
|
||||
}
|
||||
if !cutOK {
|
||||
continue
|
||||
}
|
||||
val = strings.TrimSpace(val)
|
||||
if val == "" {
|
||||
continue
|
||||
}
|
||||
h, p, err := net.SplitHostPort(val)
|
||||
if err != nil {
|
||||
return val, "51820", true
|
||||
}
|
||||
return h, p, true
|
||||
}
|
||||
}
|
||||
return "", "", false
|
||||
}
|
||||
|
||||
// lookupIP is overridable in tests.
|
||||
var lookupIP = defaultLookupIP
|
||||
|
||||
|
||||
Reference in New Issue
Block a user