mirror of
https://github.com/minoplhy/chibisafe-netproxy.git
synced 2024-11-22 11:37:08 +00:00
add: comment on X-Real-IP
This commit is contained in:
parent
2650a8c31f
commit
53c6992ef6
2
main.go
2
main.go
@ -90,6 +90,7 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if client sent X-Real-IP Header
|
||||||
if r.Header.Get("X-Real-IP") != "" && handler.IsInternalIP(r.RemoteAddr) {
|
if r.Header.Get("X-Real-IP") != "" && handler.IsInternalIP(r.RemoteAddr) {
|
||||||
UploadHeaders["X-Real-IP"] = r.Header.Get("X-Real-IP")
|
UploadHeaders["X-Real-IP"] = r.Header.Get("X-Real-IP")
|
||||||
}
|
}
|
||||||
@ -134,6 +135,7 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if client sent X-Real-IP Header
|
||||||
if r.Header.Get("X-Real-IP") != "" && handler.IsInternalIP(r.RemoteAddr) {
|
if r.Header.Get("X-Real-IP") != "" && handler.IsInternalIP(r.RemoteAddr) {
|
||||||
ProcessHeaders["X-Real-IP"] = r.Header.Get("X-Real-IP")
|
ProcessHeaders["X-Real-IP"] = r.Header.Get("X-Real-IP")
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Check if request IP Address is in internal ranges
|
||||||
func IsInternalIP(ip string) bool {
|
func IsInternalIP(ip string) bool {
|
||||||
|
|
||||||
parts := strings.Split(ip, ":")
|
parts := strings.Split(ip, ":")
|
||||||
ip = parts[0]
|
ip = parts[0]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user