Add support X-Forwarded-For

This commit is contained in:
Alexey Khit
2023-03-25 11:59:55 +03:00
parent a42c3e21c9
commit 8bf5c85b79
5 changed files with 24 additions and 8 deletions

12
pkg/tcp/helpers.go Normal file
View File

@@ -0,0 +1,12 @@
package tcp
import (
"net/http"
)
func RemoteAddr(r *http.Request) string {
if remote := r.Header.Get("X-Forwarded-For"); remote != "" {
return remote + ", " + r.RemoteAddr
}
return r.RemoteAddr
}