Skip to content

Commit fed0320

Browse files
authored
Add files via upload
1 parent 239c254 commit fed0320

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

pkg/exec.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ type Configure struct {
4444
}
4545

4646
func ReadConfig() {
47-
data, err := ioutil.ReadFile("./config/config.json")
47+
data, _ := ioutil.ReadFile("./config/config.json")
48+
49+
// 解码 JSON 数据
50+
err := json.Unmarshal(data, &Config)
4851
if err != nil {
49-
fmt.Println("请配置config.json!")
52+
fmt.Println("config.json配置出错!")
5053
os.Exit(1)
5154
}
52-
53-
// 解码 JSON 数据
54-
json.Unmarshal(data, &Config)
5555
}
5656

5757
func ReadFile(filename string) {
@@ -66,21 +66,20 @@ func ReadFile(filename string) {
6666
line := strings.TrimSpace(scan.Text())
6767
wg.Add(1)
6868
go Match(line, &wg)
69-
wg.Wait()
7069
}
7170
wg.Wait()
7271
file.Close()
7372
}
7473

7574
func Match(url string, wg *sync.WaitGroup) {
7675
defer wg.Done()
77-
mu.Lock()
78-
defer mu.Unlock()
7976

8077
ipRegex := regexp.MustCompile(`\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(?:/\d{1,2}|)`)
8178
ip := ipRegex.FindString(url)
8279
if ip != "" {
80+
mu.Lock()
8381
Irs = append(Irs, ip)
82+
mu.Unlock()
8483
}
8584

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

0 commit comments

Comments
 (0)