Added CF and Fastly IP in access list

Added CF and Fastly Client IP passthrough header for access control ip resolver
This commit is contained in:
Toby Chui 2024-12-31 20:30:36 +08:00
parent 30dfb9cb65
commit 84aec4387a

View File

@ -16,6 +16,15 @@ import (
func GetRequesterIP(r *http.Request) string {
ip := r.Header.Get("X-Real-Ip")
if ip == "" {
CF_Connecting_IP := r.Header.Get("CF-Connecting-IP")
Fastly_Client_IP := r.Header.Get("Fastly-Client-IP")
if CF_Connecting_IP != "" {
//Use CF Connecting IP
return CF_Connecting_IP
} else if Fastly_Client_IP != "" {
//Use Fastly Client IP
return Fastly_Client_IP
}
ip = r.Header.Get("X-Forwarded-For")
}
if ip == "" {