Parse additional info parameters clients could send (#336)

This commit is contained in:
David Zhao
2022-01-13 08:40:29 -08:00
committed by GitHub
parent 017ed13338
commit 29eb8d9dbf
3 changed files with 14 additions and 7 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ require (
github.com/google/wire v0.5.0
github.com/gorilla/websocket v1.4.2
github.com/hashicorp/golang-lru v0.5.4
github.com/livekit/protocol v0.11.10
github.com/livekit/protocol v0.11.11-0.20220113073321-71562c1a1a33
github.com/magefile/mage v1.11.0
github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0
github.com/mitchellh/go-homedir v1.1.0
+2 -2
View File
@@ -132,8 +132,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lithammer/shortuuid/v3 v3.0.6 h1:pr15YQyvhiSX/qPxncFtqk+v4xLEpOZObbsY/mKrcvA=
github.com/lithammer/shortuuid/v3 v3.0.6/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts=
github.com/livekit/protocol v0.11.10 h1:njJ09Cqi7Y4QSDs7phcvHmWNcbSGwTvxeAPH4p3JajQ=
github.com/livekit/protocol v0.11.10/go.mod h1:YoHW9YbWbPnuVsgwBB4hAINKT+V68jmfh9zXBSSn6Wg=
github.com/livekit/protocol v0.11.11-0.20220113073321-71562c1a1a33 h1:XlV/QWVrwkCXXq/sS9ADNsIUGQWTJRaXSeCLznzc9OQ=
github.com/livekit/protocol v0.11.11-0.20220113073321-71562c1a1a33/go.mod h1:YoHW9YbWbPnuVsgwBB4hAINKT+V68jmfh9zXBSSn6Wg=
github.com/magefile/mage v1.11.0 h1:C/55Ywp9BpgVVclD3lRnSYCwXTYxmSppIgLeDYlNuls=
github.com/magefile/mage v1.11.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
+11 -4
View File
@@ -105,7 +105,7 @@ func (s *RTCService) validate(r *http.Request) (livekit.RoomName, routing.Partic
Metadata: claims.Metadata,
Hidden: claims.Video.Hidden,
Recorder: claims.Video.Recorder,
Client: s.parseClientInfo(r.Form),
Client: ParseClientInfo(r.Form),
}
if autoSubParam != "" {
@@ -231,7 +231,7 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}
func (s *RTCService) parseClientInfo(values url.Values) *livekit.ClientInfo {
func ParseClientInfo(values url.Values) *livekit.ClientInfo {
ci := &livekit.ClientInfo{}
if pv, err := strconv.Atoi(values.Get("protocol")); err == nil {
ci.Protocol = int32(pv)
@@ -240,15 +240,22 @@ func (s *RTCService) parseClientInfo(values url.Values) *livekit.ClientInfo {
switch sdkString {
case "js":
ci.Sdk = livekit.ClientInfo_JS
case "ios":
ci.Sdk = livekit.ClientInfo_IOS
case "ios", "swift":
ci.Sdk = livekit.ClientInfo_SWIFT
case "android":
ci.Sdk = livekit.ClientInfo_ANDROID
case "flutter":
ci.Sdk = livekit.ClientInfo_FLUTTER
case "go":
ci.Sdk = livekit.ClientInfo_GO
case "unity":
ci.Sdk = livekit.ClientInfo_UNITY
}
ci.Version = values.Get("version")
ci.Os = values.Get("os")
ci.OsVersion = values.Get("os_version")
ci.Browser = values.Get("browser")
ci.BrowserVersion = values.Get("browser_version")
ci.DeviceModel = values.Get("device_model")
return ci
}