hls: in logs, store both ip and port of incoming requests (#3013)

This commit is contained in:
Alessandro Ros 2024-02-12 22:44:44 +01:00 committed by GitHub
parent df3dfea132
commit 487f92ac55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 15 deletions

View file

@ -0,0 +1,15 @@
package httpserv
import (
"net"
"github.com/gin-gonic/gin"
)
// RemoteAddr returns the remote address of an HTTP client,
// with the IP replaced by the real IP passed by any proxy in between.
func RemoteAddr(ctx *gin.Context) string {
ip := ctx.ClientIP()
_, port, _ := net.SplitHostPort(ctx.Request.RemoteAddr)
return net.JoinHostPort(ip, port)
}