From 3bb12e2a0a9716d8ca1158abe3ba1063556a4f12 Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Sun, 23 Jul 2023 18:23:15 +0200 Subject: [PATCH] webrtc: show both IP and port during session creation and in API (#2096) --- internal/core/webrtc_http_server.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/core/webrtc_http_server.go b/internal/core/webrtc_http_server.go index 1d2a728b..2feb2f20 100644 --- a/internal/core/webrtc_http_server.go +++ b/internal/core/webrtc_http_server.go @@ -291,6 +291,9 @@ func (s *webRTCHTTPServer) onRequest(ctx *gin.Context) { return } + ip := ctx.ClientIP() + _, port, _ := net.SplitHostPort(ctx.Request.RemoteAddr) + user, pass, hasCredentials := ctx.Request.BasicAuth() res := s.pathManager.getConfForPath(pathGetConfForPathReq{ @@ -298,7 +301,7 @@ func (s *webRTCHTTPServer) onRequest(ctx *gin.Context) { publish: publish, credentials: authCredentials{ query: ctx.Request.URL.RawQuery, - ip: net.ParseIP(ctx.ClientIP()), + ip: net.ParseIP(ip), user: user, pass: pass, proto: authProtocolWebRTC, @@ -353,7 +356,7 @@ func (s *webRTCHTTPServer) onRequest(ctx *gin.Context) { res := s.parent.sessionNew(webRTCSessionNewReq{ pathName: dir, - remoteAddr: ctx.ClientIP(), + remoteAddr: net.JoinHostPort(ip, port), offer: offer, publish: (fname == "whip"), })