Skip to content

Commit

Permalink
Add request host to log output
Browse files Browse the repository at this point in the history
  • Loading branch information
jliebert committed Jun 21, 2024
1 parent cfde46a commit 221a5e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion blockuseragent.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (b *BlockUserAgent) ServeHTTP(rw http.ResponseWriter, req *http.Request) {

for i, re := range b.regexps {
if re.MatchString(userAgent) {
message := map[string]interface{}{ "regex": i, "user-agent": userAgent, "ip": req.RemoteAddr, "uri": req.RequestURI }
message := map[string]interface{}{ "regex": i, "user-agent": userAgent, "ip": req.RemoteAddr, "host": req.Host, "uri": req.RequestURI }
jsonMessage, _ := json.Marshal(message)
log.Printf("%s: %s", b.name, jsonMessage)
rw.WriteHeader(http.StatusForbidden)
Expand Down

0 comments on commit 221a5e4

Please sign in to comment.