summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-05-10 18:39:29 +0300
committerValery Piashchynski <[email protected]>2020-05-10 18:39:29 +0300
commitbd4601cf571a42ab18110d41f4977da6999ec12c (patch)
treefb84b4c1aee83c655c683b7ae45673c5cb0da73c /service
parent9272b8c8b4044f551b43ae4fc46a128ca4ec0b4e (diff)
Add comment and update according code review
Diffstat (limited to 'service')
-rw-r--r--service/http/handler.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/service/http/handler.go b/service/http/handler.go
index 457e7cb5..ab7c382b 100644
--- a/service/http/handler.go
+++ b/service/http/handler.go
@@ -175,8 +175,15 @@ func (h *Handler) resolveIP(r *Request) {
return
}
+ // The logic here is the following:
+ // In general case, we only expect X-Real-Ip header. If it exist, we get the IP addres from header and set request Remote address
+ // But, if there is no X-Real-Ip header, we also trying to check CloudFlare headers
+ // True-Client-IP is a general CF header in which copied information from X-Real-Ip in CF.
+ // CF-Connecting-IP is an Enterprise feature and we check it last in order.
+ // This operations are near O(1) because Headers struct are the map type -> type MIMEHeader map[string][]string
if r.Header.Get("X-Real-Ip") != "" {
r.RemoteAddr = fetchIP(r.Header.Get("X-Real-Ip"))
+ return
}
if r.Header.Get("True-Client-IP") != "" {