Files
mediamtx/internal/defs/path_access_request.go
T
5decbb4a3d Add user agent field to RTMP, RTSP, WebRTC, and HLS (#5753)
Surface user agent in the auth HTTP webhook payload as "userAgent"
and in the API structs for RTMP, RTSP, WebRTC and HLS connections.

---------

Co-authored-by: aler9 <46489434+aler9@users.noreply.github.com>
2026-06-02 20:29:07 +02:00

46 lines
1.1 KiB
Go

package defs
import (
"net"
"github.com/bluenviron/mediamtx/internal/auth"
"github.com/bluenviron/mediamtx/internal/conf"
"github.com/google/uuid"
)
// PathAccessRequest is a path access request.
type PathAccessRequest struct {
Name string
Query string
Publish bool
SkipAuth bool
UserAgent string
// only if skipAuth = false
Proto auth.Protocol
ID *uuid.UUID
Credentials *auth.Credentials
IP net.IP
CustomVerifyFunc func(expectedUser string, expectedPass string) bool
}
// ToAuthRequest converts a path access request into an authentication request.
func (r *PathAccessRequest) ToAuthRequest() *auth.Request {
return &auth.Request{
Action: func() conf.AuthAction {
if r.Publish {
return conf.AuthActionPublish
}
return conf.AuthActionRead
}(),
Path: r.Name,
Query: r.Query,
Protocol: r.Proto,
ID: r.ID,
UserAgent: r.UserAgent,
Credentials: r.Credentials,
IP: r.IP,
CustomVerifyFunc: r.CustomVerifyFunc,
}
}