-
-
Save M2shad0w/12e5028a0eceecee5e810a49ef1f4989 to your computer and use it in GitHub Desktop.
Revisions
-
johnsonz created this gist
May 20, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ func GetIPFromRequest(r *http.Request) string { ip, _, err := net.SplitHostPort(r.RemoteAddr) if err != nil { glog.Errorf("userip: %q is not IP:port", r.RemoteAddr) return "" } userIP := net.ParseIP(ip) if userIP == nil { glog.Errorf("userip: %q is not IP:port", r.RemoteAddr) return "" } return userIP.String() }