refactor(middlewares): remove xsync wrapper and replace strutils.SplitLine with bytes.Line

This commit is contained in:
yusing
2025-09-13 22:33:21 +08:00
parent fbe82c3082
commit a483e15a20
3 changed files with 16 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
package middleware
import (
"bytes"
"context"
"errors"
"fmt"
@@ -115,11 +116,12 @@ func fetchUpdateCFIPRange(endpoint string, cfCIDRs *[]*nettypes.CIDR) error {
return err
}
for _, line := range strutils.SplitLine(string(body)) {
if line == "" {
for line := range bytes.Lines(body) {
line = bytes.TrimSpace(line)
if len(line) == 0 {
continue
}
_, cidr, err := net.ParseCIDR(line)
_, cidr, err := net.ParseCIDR(string(line))
if err != nil {
return fmt.Errorf("cloudflare responeded an invalid CIDR: %s", line)
}