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:
M4
2026-07-30 02:27:17 +03:00
co-authored by Cursor
parent bec6c8392d
commit 6b6c13c933
29 changed files with 559 additions and 100 deletions
+65
View File
@@ -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
+26
View File
@@ -236,3 +236,29 @@ func indexOf(s, sub string) int {
}
return -1
}
func TestHostPortLightINI(t *testing.T) {
raw := `[Interface]
PrivateKey = AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
Address = 10.8.0.2/32
[Peer]
PublicKey = AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEE=
Endpoint = 203.0.113.10:51820
AllowedIPs = 0.0.0.0/0
`
h, p, err := HostPort(raw)
if err != nil {
t.Fatal(err)
}
if h != "203.0.113.10" || p != "51820" {
t.Fatalf("got %s:%s", h, p)
}
h2, p2, err := HostPort("awg://AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=@9.9.9.9:41421")
if err != nil {
t.Fatal(err)
}
if h2 != "9.9.9.9" || p2 != "41421" {
t.Fatalf("uri got %s:%s", h2, p2)
}
}
+14 -7
View File
@@ -268,17 +268,24 @@ func handleHTTPProxy(client net.Conn, dial DialFunc) error {
func relay(a, b net.Conn) error {
errc := make(chan error, 2)
go func() {
_, err := io.Copy(a, b)
copyOne := func(dst, src net.Conn) {
bufp := copyBufPool.Get().(*[]byte)
defer copyBufPool.Put(bufp)
_, err := io.CopyBuffer(dst, src, *bufp)
errc <- err
}()
go func() {
_, err := io.Copy(b, a)
errc <- err
}()
}
go copyOne(a, b)
go copyOne(b, a)
err := <-errc
_ = a.Close()
_ = b.Close()
<-errc
return err
}
var copyBufPool = sync.Pool{
New: func() any {
b := make([]byte, 32*1024)
return &b
},
}