aboutsummaryrefslogtreecommitdiff
path: root/clientapi
diff options
context:
space:
mode:
authorfcwoknhenuxdfiyv-nextcloud <84577563+fcwoknhenuxdfiyv@users.noreply.github.com>2022-04-19 10:46:54 +0200
committerGitHub <noreply@github.com>2022-04-19 09:46:54 +0100
commitabf71649b0a27ddc564105f94db270696698ecd5 (patch)
treeb1468349275ba131d4035aacab142af7a58f4c4f /clientapi
parent57e3622b85fd4d80d9826404135f09e91ed47973 (diff)
Make sure resp.Username is defined before hashing. Fixes #2356 (#2357)
Co-authored-by: Jason Quigley <jason@onecha.net>
Diffstat (limited to 'clientapi')
-rw-r--r--clientapi/routing/voip.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/clientapi/routing/voip.go b/clientapi/routing/voip.go
index 13dca7ac..c7ddaabc 100644
--- a/clientapi/routing/voip.go
+++ b/clientapi/routing/voip.go
@@ -52,6 +52,7 @@ func RequestTurnServer(req *http.Request, device *api.Device, cfg *config.Client
if turnConfig.SharedSecret != "" {
expiry := time.Now().Add(duration).Unix()
+ resp.Username = fmt.Sprintf("%d:%s", expiry, device.UserID)
mac := hmac.New(sha1.New, []byte(turnConfig.SharedSecret))
_, err := mac.Write([]byte(resp.Username))
@@ -60,7 +61,6 @@ func RequestTurnServer(req *http.Request, device *api.Device, cfg *config.Client
return jsonerror.InternalServerError()
}
- resp.Username = fmt.Sprintf("%d:%s", expiry, device.UserID)
resp.Password = base64.StdEncoding.EncodeToString(mac.Sum(nil))
} else if turnConfig.Username != "" && turnConfig.Password != "" {
resp.Username = turnConfig.Username