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
Odyssey346 c73b648451 initial announcements
Signed-off-by: Odyssey346 <odyssey346@disroot.org>
2022-08-03 21:37:12 +02:00

16 lines
252 B
Go

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
}