Skip to content

Commit

Permalink
fix:limiter 改变时机判断错误 #21
Browse files Browse the repository at this point in the history
  • Loading branch information
XinRoom committed Jul 18, 2024
1 parent 9647f03 commit c19feb9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/port/syn/syn.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ func (ss *SynScanner) Scan(dstIp net.IP, dst uint16) (err error) {
}

// 与recv协同,当队列缓冲区到达80%时降半速,90%将为1/s
if len(ss.openPortChan)*10 >= cap(ss.openPortChan)*8 {
if len(ss.openPortChan)*10 >= cap(ss.openPortChan)*9 {
ss.limiter.SetLimit(1)
} else if len(ss.openPortChan)*10 >= cap(ss.openPortChan)*8 {
if ss.option.Rate/2 != 0 {
ss.limiter.SetLimit(limiter.Every(time.Second / time.Duration(ss.option.Rate/2)))
}
} else if len(ss.openPortChan)*10 >= cap(ss.openPortChan)*9 {
ss.limiter.SetLimit(1)
} else {
ss.limiter.SetLimit(limiter.Every(time.Second / time.Duration(ss.option.Rate)))
}
Expand Down

0 comments on commit c19feb9

Please sign in to comment.