mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 09:18:31 +02:00
refactor(middleware): replace Cloudflare IP range fetching with bytes.Lines
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -115,11 +116,11 @@ func fetchUpdateCFIPRange(endpoint string, cfCIDRs *[]*nettypes.CIDR) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, line := range strutils.SplitLine(string(body)) {
|
for line := range bytes.Lines(body) {
|
||||||
if line == "" {
|
if len(line) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
_, cidr, err := net.ParseCIDR(line)
|
_, cidr, err := net.ParseCIDR(string(line))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cloudflare responeded an invalid CIDR: %s", line)
|
return fmt.Errorf("cloudflare responeded an invalid CIDR: %s", line)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user