IPLimit - IPv4 Extraction Simplification

This commit is contained in:
MHSanaei 2024-02-04 01:51:31 +03:30
parent 11268b9467
commit 17646fd6be

View file

@ -115,13 +115,13 @@ func (j *CheckClientIpJob) processLogFile() {
for scanner.Scan() { for scanner.Scan() {
line := scanner.Text() line := scanner.Text()
ipRegx, _ := regexp.Compile(`[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+`) ipRegx, _ := regexp.Compile(`(\d+\.\d+\.\d+\.\d+).* accepted`)
emailRegx, _ := regexp.Compile(`email:.+`) emailRegx, _ := regexp.Compile(`email:.+`)
matchesIp := ipRegx.FindString(line) matches := ipRegx.FindStringSubmatch(line)
if len(matchesIp) > 0 { if len(matches) > 1 {
ip := string(matchesIp) ip := matches[1]
if ip == "127.0.0.1" || ip == "1.1.1.1" { if ip == "127.0.0.1" || ip == "[::1]" {
continue continue
} }
@ -136,7 +136,6 @@ func (j *CheckClientIpJob) processLogFile() {
continue continue
} }
InboundClientIps[matchesEmail] = append(InboundClientIps[matchesEmail], ip) InboundClientIps[matchesEmail] = append(InboundClientIps[matchesEmail], ip)
} else { } else {
InboundClientIps[matchesEmail] = append(InboundClientIps[matchesEmail], ip) InboundClientIps[matchesEmail] = append(InboundClientIps[matchesEmail], ip)
} }