mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 12:30:19 +08:00
Get real IP for verification log.
This commit is contained in:
@ -44,7 +44,7 @@ func GetIPInfo(clientIP string) string {
|
||||
return res
|
||||
}
|
||||
|
||||
func getIPFromRequest(req *http.Request) string {
|
||||
func GetIPFromRequest(req *http.Request) string {
|
||||
clientIP := req.Header.Get("x-forwarded-for")
|
||||
if clientIP == "" {
|
||||
ipPort := strings.Split(req.RemoteAddr, ":")
|
||||
@ -62,11 +62,11 @@ func getIPFromRequest(req *http.Request) string {
|
||||
}
|
||||
|
||||
func LogInfo(ctx *context.Context, f string, v ...interface{}) {
|
||||
ipString := fmt.Sprintf("(%s) ", getIPFromRequest(ctx.Request))
|
||||
ipString := fmt.Sprintf("(%s) ", GetIPFromRequest(ctx.Request))
|
||||
logs.Info(ipString+f, v...)
|
||||
}
|
||||
|
||||
func LogWarning(ctx *context.Context, f string, v ...interface{}) {
|
||||
ipString := fmt.Sprintf("(%s) ", getIPFromRequest(ctx.Request))
|
||||
ipString := fmt.Sprintf("(%s) ", GetIPFromRequest(ctx.Request))
|
||||
logs.Warning(ipString+f, v...)
|
||||
}
|
||||
|
Reference in New Issue
Block a user