Skip to content

Commit

Permalink
Update loadAllCDN Function
Browse files Browse the repository at this point in the history
  • Loading branch information
ImAyrix committed May 17, 2023
1 parent 93c27f3 commit 786cc55
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const (

var wg sync.WaitGroup

const VERSION = "1.0.19"
const VERSION = "1.0.20"

func main() {
var allRange []*net.IPNet
Expand Down Expand Up @@ -155,19 +155,24 @@ var CDNS = []CDN{

func loadAllCDN() []*net.IPNet {

var wg sync.WaitGroup
var allRanges []*net.IPNet
cidrChan := make(chan []*net.IPNet, len(CDNS)+1)
wg.Add(len(CDNS))

for _, cdn := range CDNS {
cdn := cdn
func() {
go func() {
defer wg.Done()
cidr := cdn.sender(cdn.url)
cidrChan <- cidr
}()

}

func() {
wg.Add(1)
go func() {
defer wg.Done()
incapsulaIPUrl := "https://my.incapsula.com/api/integration/v1/ips"
client := &http.Client{
Timeout: 30 * time.Second,
Expand All @@ -181,6 +186,7 @@ func loadAllCDN() []*net.IPNet {
}
}()

wg.Wait()
close(cidrChan)

for cidr := range cidrChan {
Expand Down

0 comments on commit 786cc55

Please sign in to comment.