I’m undecided, I want to identify the request of a client, and what better than using the IP, but looking at my options I don’t know which one is more reliable:
Native option with the net
package:
func PrintIP(l net.Listener) {
fmt.Println(fmt.Sprintf("<%s> %s", l.Addr().Network(), l.Addr().String()))
}
External option with github.com/tomasen/realip
package:
func PrintIP(r *http.Request) {
fmt.Println(realip.FromRequest(r))
}
Does net.Listener
keep the real IP of the client? Because if so I prefer to use that option but if not, then I guess it is best to use realip.FromRequest
or is there a better suggestion?.