Skip to content

Commit f596d59

Browse files
committed
Fixed Index Out Of Range Problem
1 parent 98164f6 commit f596d59

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
-n 请求的SNI数量,默认为1
2828
如设置为0则检测全部可检测的域名
2929
-c 检测任务的并发数量,请根据系统资源自行调整,默认为50
30-
3130
```
3231

3332

fetch/manager.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,31 @@ func HandleRecords(rs []Record) {
1818
fetch.Con = len(domainList)
1919
}
2020
dIndex := 0
21-
for i:=0; i < fetch.Con; i++ {
21+
for i:= 0; i < fetch.Con; i++ {
2222
go processChallenge(domainList[dIndex], ch)
2323
dIndex++
2424
}
2525

2626
for {
27+
// When a check task finished
2728
<- ch
28-
if fetch.Num == 0 {
29-
if sniNum == len(domainList) {
30-
break
31-
}
32-
} else {
33-
if fetch.Num == len(vaildSNIs) {
29+
// All the SNI checks finished
30+
if sniNum == len(domainList) {
31+
break
32+
}
33+
if fetch.Num != 0 {
34+
if len(vaildSNIs) >= fetch.Num {
3435
break
3536
}
3637
}
37-
go processChallenge(domainList[dIndex], ch)
38-
dIndex++
38+
// Continue to create more tasks,
39+
// if not cover all the domains wanted to be checked
40+
if dIndex < len(domainList) {
41+
go processChallenge(domainList[dIndex], ch)
42+
dIndex++
43+
}
3944
}
45+
close(ch)
4046
output()
4147
}
4248

0 commit comments

Comments
 (0)