mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-22 09:09:08 +01:00
refactor(middleware): replace Cloudflare IP range fetching with bytes.Lines
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user