fix: issue with capturing correct client ip
This commit is contained in:
@@ -118,7 +118,7 @@ func CreateComment(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
db.Create(&comment)
|
db.Create(&comment)
|
||||||
// Something was wrong with c.ClientIP() with trusted?? Weird.
|
// Something was wrong with c.ClientIP() with trusted?? Weird.
|
||||||
recentPosters[c.Request.Header.Get("X-Forwarded-For")]++
|
recentPosters[c.ClientIP()]++
|
||||||
// Pass the associated post to the template to add to the href
|
// Pass the associated post to the template to add to the href
|
||||||
c.HTML(http.StatusOK, "comment_post.tmpl", CommentDto{Url: comment.AssociatedPost})
|
c.HTML(http.StatusOK, "comment_post.tmpl", CommentDto{Url: comment.AssociatedPost})
|
||||||
}
|
}
|
||||||
|
|||||||
1
main.go
1
main.go
@@ -39,6 +39,7 @@ func main() {
|
|||||||
router.SetFuncMap(funcMap)
|
router.SetFuncMap(funcMap)
|
||||||
// This needs to change because of RCCTL in OpenBSD, not sure if you can use a ksh variable as path in Gin but i'll test
|
// This needs to change because of RCCTL in OpenBSD, not sure if you can use a ksh variable as path in Gin but i'll test
|
||||||
router.LoadHTMLGlob("templates/*.tmpl")
|
router.LoadHTMLGlob("templates/*.tmpl")
|
||||||
|
router.TrustedPlatform = "X-Real-Ip"
|
||||||
bootstrap.InitializeRoutes(router)
|
bootstrap.InitializeRoutes(router)
|
||||||
router.Run(":8080")
|
router.Run(":8080")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user