ok its time to actually get their IP. it only works in reverse proxy.

Signed-off-by: Odyssey346 <odyssey346@disroot.org>
This commit is contained in:
Odyssey346
2022-07-28 11:21:25 +02:00
parent 19c8432a40
commit d1a0d01a5e
2 changed files with 20 additions and 4 deletions

15
otherthings/getip.go Normal file
View File

@ -0,0 +1,15 @@
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
}