mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-30 15:02:00 -08:00
hls: in logs, store both ip and port of incoming requests (#3013)
This commit is contained in:
parent
df3dfea132
commit
487f92ac55
4 changed files with 21 additions and 15 deletions
15
internal/protocols/httpserv/remote_addr.go
Normal file
15
internal/protocols/httpserv/remote_addr.go
Normal 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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue