Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowabi authored Jul 21, 2023
1 parent 239c254 commit fed0320
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions pkg/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ type Configure struct {
}

func ReadConfig() {
data, err := ioutil.ReadFile("./config/config.json")
data, _ := ioutil.ReadFile("./config/config.json")

// 解码 JSON 数据
err := json.Unmarshal(data, &Config)
if err != nil {
fmt.Println("请配置config.json!")
fmt.Println("config.json配置出错!")
os.Exit(1)
}

// 解码 JSON 数据
json.Unmarshal(data, &Config)
}

func ReadFile(filename string) {
Expand All @@ -66,21 +66,20 @@ func ReadFile(filename string) {
line := strings.TrimSpace(scan.Text())
wg.Add(1)
go Match(line, &wg)
wg.Wait()
}
wg.Wait()
file.Close()
}

func Match(url string, wg *sync.WaitGroup) {
defer wg.Done()
mu.Lock()
defer mu.Unlock()

ipRegex := regexp.MustCompile(`\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(?:/\d{1,2}|)`)
ip := ipRegex.FindString(url)
if ip != "" {
mu.Lock()
Irs = append(Irs, ip)
mu.Unlock()
}

if strings.Contains(url, "http://") || strings.Contains(url, "https://") {
Expand All @@ -97,7 +96,9 @@ func Match(url string, wg *sync.WaitGroup) {
subDomainRegex := regexp.MustCompile(`([a-z0-9][a-z0-9\-]*?\.(?:\w{2,4})(?:\.(?:cn|hk))?)$`)
subDomain := subDomainRegex.FindString(domain)
if subDomain != "" && !Contains(Drs, subDomain) {
mu.Lock()
Drs = append(Drs, subDomain)
mu.Unlock()
}
}
}
Expand Down

0 comments on commit fed0320

Please sign in to comment.