|
|
@@ -1,6 +1,7 @@ |
|
|
|
package models |
|
|
|
|
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"net/http" |
|
|
|
|
|
|
@@ -30,9 +31,12 @@ func SaveLoginInfoToDb(r *http.Request, u *User) { |
|
|
|
} |
|
|
|
|
|
|
|
func getIP(r *http.Request) string { |
|
|
|
headerjson, _ := json.Marshal(r.Header) |
|
|
|
log.Info("json=" + string(headerjson)) |
|
|
|
forwarded := r.Header.Get("X-FORWARDED-FOR") |
|
|
|
if forwarded != "" { |
|
|
|
return forwarded |
|
|
|
} |
|
|
|
|
|
|
|
return r.RemoteAddr |
|
|
|
} |