refactor(middleware): replace Cloudflare IP range fetching with bytes.Lines

This commit is contained in:
yusing
2025-08-30 11:26:10 +08:00
parent cc00859963
commit 2c6690b2d0

View File

@@ -1,6 +1,7 @@
package middleware
import (
"bytes"
"context"
"errors"
"fmt"
@@ -115,11 +116,11 @@ 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) {
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)
}