Update deps and simplify parsing

Bump frontend and Go dependencies, then modernize a few hot paths with newer Go string/range helpers. Also widen the client form quota/limit fields to improve the layout.
This commit is contained in:
Sanaei
2026-09-08 14:12:13 +02:00
parent 2ec6c73613
commit 2d151d7648
12 changed files with 301 additions and 341 deletions
+1 -1
View File
@@ -113,7 +113,7 @@ func generateHValues() [4]string {
const lo = 5
bandSize := (awgHMax - lo + 1) / 4
var out [4]string
for i := 0; i < 4; i++ {
for i := range 4 {
bandLo := lo + i*bandSize
bandHi := bandLo + bandSize - 1
out[i] = fmt.Sprintf("%d", randInt(bandLo, bandHi))
+3 -3
View File
@@ -8,7 +8,7 @@ import (
)
func TestGenerateObfuscation31DefaultRanges(t *testing.T) {
for i := 0; i < 200; i++ {
for range 200 {
o := GenerateObfuscation31()
if o.Jc < 3 || o.Jc > 6 {
t.Fatalf("Jc = %d, want [3,6]", o.Jc)
@@ -96,7 +96,7 @@ func assertRangeWithin(t *testing.T, name, v string, min, max int64) (lo, hi int
}
func TestGenerateHValuesDistinct(t *testing.T) {
for i := 0; i < 50; i++ {
for range 50 {
h := generateHValues()
var prev int64
for i, v := range h {
@@ -117,7 +117,7 @@ func validObfuscation() Obfuscation31 {
}
func TestValidateObfuscationAcceptsGenerated(t *testing.T) {
for i := 0; i < 50; i++ {
for range 50 {
if err := ValidateObfuscation(validObfuscation()); err != nil {
t.Fatalf("generated obfuscation set rejected: %v", err)
}
+3 -3
View File
@@ -46,9 +46,9 @@ func parseForwardedPorts(input string) []portSpec {
}
func parsePortToken(tok string) (portSpec, bool) {
if idx := strings.IndexByte(tok, '-'); idx >= 0 {
start, ok1 := parsePortNumber(strings.TrimSpace(tok[:idx]))
end, ok2 := parsePortNumber(strings.TrimSpace(tok[idx+1:]))
if before, after, ok0 := strings.Cut(tok, "-"); ok0 {
start, ok1 := parsePortNumber(strings.TrimSpace(before))
end, ok2 := parsePortNumber(strings.TrimSpace(after))
if !ok1 || !ok2 || start > end {
return portSpec{}, false
}
+1 -1
View File
@@ -201,7 +201,7 @@ func peerFields(t *testing.T, conf string) []string {
t.Fatalf("config has no [Peer] block:\n%s", conf)
}
var got []string
for _, line := range strings.Split(conf[idx:], "\n") {
for line := range strings.SplitSeq(conf[idx:], "\n") {
key := strings.TrimSpace(strings.SplitN(line, "=", 2)[0])
if slices.Contains(peerFieldOrder, key) {
got = append(got, key)
@@ -18,7 +18,7 @@ func TestProbeRejectsOversizedStatusBody(t *testing.T) {
w.Header().Set("Content-Type", "application/json")
_, _ = w.Write([]byte(`{"success":true,"obj":{"cpuPct":1,"panelVersion":"`))
pad := strings.Repeat("x", 1<<20)
for i := 0; i < 3; i++ {
for range 3 {
_, _ = w.Write([]byte(pad))
}
_, _ = w.Write([]byte(`"}}`))
+3 -3
View File
@@ -2336,11 +2336,11 @@ func resolveGeofileTag(client *http.Client, latestURL string) (string, error) {
// redirect target.
func geofileTagFromLocation(location string) (string, error) {
const marker = "/releases/download/"
idx := strings.Index(location, marker)
if idx < 0 {
_, after, ok := strings.Cut(location, marker)
if !ok {
return "", common.NewErrorf("unexpected release redirect %q", location)
}
tag, _, found := strings.Cut(location[idx+len(marker):], "/")
tag, _, found := strings.Cut(after, "/")
if !found || tag == "" {
return "", common.NewErrorf("unexpected release redirect %q", location)
}
+1 -1
View File
@@ -85,7 +85,7 @@ func pageMessage(message string, limit int) []string {
}
pages := make([]string, 0)
for _, block := range strings.Split(message, "\r\n\r\n") {
for block := range strings.SplitSeq(message, "\r\n\r\n") {
for _, page := range splitMessageLines(block, limit) {
last := len(pages) - 1
if last >= 0 && len(pages[last])+len("\r\n\r\n")+len(page) <= limit {