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:
15
otherthings/getip.go
Normal file
15
otherthings/getip.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user