diff --git a/go.mod b/go.mod index 8b3cd89d4..0e20d22e6 100644 --- a/go.mod +++ b/go.mod @@ -72,6 +72,7 @@ require ( github.com/prometheus/common v0.26.0 // indirect github.com/prometheus/procfs v0.6.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/sebest/xff v0.0.0-20210106013422-671bd2870b3a // indirect go.uber.org/multierr v1.6.0 // indirect golang.org/x/crypto v0.0.0-20220208050332-20e1d8d225ab // indirect golang.org/x/mod v0.5.1 // indirect diff --git a/go.sum b/go.sum index 637283df2..2469c15e7 100644 --- a/go.sum +++ b/go.sum @@ -245,6 +245,8 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM= +github.com/sebest/xff v0.0.0-20210106013422-671bd2870b3a h1:iLcLb5Fwwz7g/DLK89F+uQBDeAhHhwdzB5fSlVdhGcM= +github.com/sebest/xff v0.0.0-20210106013422-671bd2870b3a/go.mod h1:wozgYq9WEBQBaIJe4YZ0qTSFAMxmcwBhQH0fO0R34Z0= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= diff --git a/pkg/service/rtcservice.go b/pkg/service/rtcservice.go index 3778635e8..e7eaa4fd0 100644 --- a/pkg/service/rtcservice.go +++ b/pkg/service/rtcservice.go @@ -8,6 +8,8 @@ import ( "strconv" "strings" + "github.com/sebest/xff" + "github.com/gorilla/websocket" "github.com/livekit/protocol/livekit" "github.com/livekit/protocol/logger" @@ -283,7 +285,8 @@ func (s *RTCService) ParseClientInfo(r *http.Request) *livekit.ClientInfo { ci.Browser = values.Get("browser") ci.BrowserVersion = values.Get("browser_version") ci.DeviceModel = values.Get("device_model") - ci.Address = r.RemoteAddr + // get real address (forwarded http header) + ci.Address = xff.GetRemoteAddr(r) // attempt to parse types for SDKs that support browser as a platform if ci.Sdk == livekit.ClientInfo_JS ||