This repository has been archived on 2022-10-30. You can view files and clone it, but cannot push or open issues or pull requests.
Segfautils/utils/getip.go

16 lines
252 B
Go
Raw Normal View History

package utils
import (
"net/http"
)
// Thanks random StackOverflow answerer
func GetUserIP(r *http.Request) string {
IPAddress := r.Header.Get("X-REAL-IP")
if IPAddress == "" {
IPAddress = r.Header.Get("X-FORWARDED-FOR")
}
return IPAddress
}