From df4cc066f2947026408104ade7fe4378fd8f9313 Mon Sep 17 00:00:00 2001 From: rawleyIfowler Date: Thu, 3 Mar 2022 13:16:01 -0600 Subject: [PATCH] fixed localip tracing bug with c.ClientIP() --- controllers/blog.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/blog.go b/controllers/blog.go index 002ec7e..258ae23 100644 --- a/controllers/blog.go +++ b/controllers/blog.go @@ -117,7 +117,8 @@ func CreateComment(c *gin.Context) { AssociatedPost: a[2], } db.Create(&comment) - recentPosters[c.ClientIP()]++ + // Something was wrong with c.ClientIP() with trusted?? Weird. + recentPosters[c.Request.Header.Get("X-Forwarded-For")]++ // Pass the associated post to the template to add to the href c.HTML(http.StatusOK, "comment_post.tmpl", CommentDto{Url: comment.AssociatedPost}) }