Skip to content

Commit 3bcf21d

Browse files
committed
small fix
1 parent 63d0df9 commit 3bcf21d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pkg/protocols/common/honeypotdetector/honeypotdetector.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,17 @@ func (d *Detector) RecordMatch(host, templateID string) bool {
6060
state.mu.Lock()
6161
defer state.mu.Unlock()
6262

63-
// Even if already flagged, keep tracking distinct template IDs so internal state stays consistent.
63+
if state.flagged {
64+
return false
65+
}
6466
if _, ok := state.templateIDs[templateID]; ok {
6567
return false
6668
}
6769

6870
state.templateIDs[templateID] = struct{}{}
69-
if !state.flagged && len(state.templateIDs) >= d.threshold {
71+
if len(state.templateIDs) >= d.threshold {
7072
state.flagged = true
73+
state.templateIDs = nil
7174
return true
7275
}
7376
return false
@@ -129,9 +132,8 @@ func normalizeHostKey(input string) string {
129132
// Strip trailing slashes early.
130133
s = strings.TrimRight(s, "/")
131134

132-
// Strip http/https schemes if present.
133-
// If a scheme is present, parse to reliably extract host and optional port.
134-
if strings.HasPrefix(s, "http://") || strings.HasPrefix(s, "https://") {
135+
// If an absolute URL is present, parse it to reliably extract host and optional port.
136+
if strings.Contains(s, "://") {
135137
u, err := url.Parse(s)
136138
if err == nil && u != nil {
137139
host := u.Hostname()

0 commit comments

Comments
 (0)