mirror of
https://github.com/livekit/livekit.git
synced 2026-03-31 08:55:39 +00:00
* move callbacks out of messageRouter * OCD * more OCD * fix forwarder test * even more OCD * maximum OCD * package name collision, copy lock by value
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package service
|
|
|
|
import (
|
|
"net/http"
|
|
"regexp"
|
|
|
|
"github.com/livekit/protocol/auth"
|
|
"github.com/livekit/protocol/livekit"
|
|
"github.com/livekit/protocol/logger"
|
|
)
|
|
|
|
func handleError(w http.ResponseWriter, status int, msg string) {
|
|
// GetLogger already with extra depth 1
|
|
logger.GetLogger().V(1).Info("error handling request", "error", msg, "status", status)
|
|
w.WriteHeader(status)
|
|
_, _ = w.Write([]byte(msg))
|
|
}
|
|
|
|
func boolValue(s string) bool {
|
|
return s == "1" || s == "true"
|
|
}
|
|
|
|
func IsValidDomain(domain string) bool {
|
|
domainRegexp := regexp.MustCompile(`^(?i)[a-z0-9-]+(\.[a-z0-9-]+)+\.?$`)
|
|
return domainRegexp.MatchString(domain)
|
|
}
|
|
|
|
func permissionFromGrant(claim *auth.VideoGrant) *livekit.ParticipantPermission {
|
|
p := &livekit.ParticipantPermission{
|
|
CanSubscribe: true,
|
|
CanPublish: true,
|
|
CanPublishData: true,
|
|
}
|
|
if claim.CanPublish != nil {
|
|
p.CanPublish = *claim.CanPublish
|
|
}
|
|
if claim.CanSubscribe != nil {
|
|
p.CanSubscribe = *claim.CanSubscribe
|
|
}
|
|
if claim.CanPublishData != nil {
|
|
p.CanPublishData = *claim.CanPublishData
|
|
}
|
|
return p
|
|
}
|