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/otherthings/getip.go
Odyssey346 d1a0d01a5e ok its time to actually get their IP. it only works in reverse proxy.
Signed-off-by: Odyssey346 <odyssey346@disroot.org>
2022-07-28 11:21:25 +02:00

16 lines
276 B
Go

package otherthings
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
}