diff options
| author | MHSanaei <ho3ein.sanaei@gmail.com> | 2024-02-04 01:21:31 +0300 |
|---|---|---|
| committer | MHSanaei <ho3ein.sanaei@gmail.com> | 2024-02-04 01:21:31 +0300 |
| commit | d17185025576a81bae641a0488b876ac143826df (patch) | |
| tree | 1cea673da99ae936d2843f780bac5f8354a066d4 | |
| parent | 12075014056d5288e845b11a46855d6cea1c578b (diff) | |
IPLimit - IPv4 Extraction Simplification
| -rw-r--r-- | web/job/check_client_ip_job.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/web/job/check_client_ip_job.go b/web/job/check_client_ip_job.go index 77cbe256..905a8cc7 100644 --- a/web/job/check_client_ip_job.go +++ b/web/job/check_client_ip_job.go @@ -115,13 +115,13 @@ func (j *CheckClientIpJob) processLogFile() { for scanner.Scan() { 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:.+`) - matchesIp := ipRegx.FindString(line) - if len(matchesIp) > 0 { - ip := string(matchesIp) - if ip == "127.0.0.1" || ip == "1.1.1.1" { + matches := ipRegx.FindStringSubmatch(line) + if len(matches) > 1 { + ip := matches[1] + if ip == "127.0.0.1" || ip == "[::1]" { continue } @@ -136,7 +136,6 @@ func (j *CheckClientIpJob) processLogFile() { continue } InboundClientIps[matchesEmail] = append(InboundClientIps[matchesEmail], ip) - } else { InboundClientIps[matchesEmail] = append(InboundClientIps[matchesEmail], ip) } |
