Documentation
¶
Index ¶
- Constants
- Variables
- func BlockInternal(_, address string, _ syscall.RawConn) error
- func CheckWebhookHost(host string) error
- func EventKey(event *livekit.WebhookEvent) string
- func IncDispatchDrop(reason string)
- func IncDispatchFailure()
- func IncDispatchSuccess()
- func InitWebhookStats(constLabels prometheus.Labels)
- func NewDialControl(blockPrivate bool, blocked, allowed []string) (func(network, address string, c syscall.RawConn) error, error)
- func Receive(r *http.Request, provider auth.KeyProvider) ([]byte, error)
- func ReceiveWebhookEvent(r *http.Request, provider auth.KeyProvider) (*livekit.WebhookEvent, error)
- func RecordQueueLength(queueLength int)
- func RedactSendError(text string) string
- type DefaultNotifier
- func (n *DefaultNotifier) QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error
- func (n *DefaultNotifier) RegisterProcessedHook(hook func(ctx context.Context, whi *livekit.WebhookInfo))
- func (n *DefaultNotifier) SetFilter(params FilterParams)
- func (n *DefaultNotifier) SetKeys(apiKey, apiSecret string)
- func (n *DefaultNotifier) Stop(force bool)
- type FilterParams
- type HTTPClientParams
- type NotifyOption
- type NotifyParams
- type QueuedNotifier
- type ResourceURLNotifier
- func (r *ResourceURLNotifier) IsAllowed(event string) bool
- func (r *ResourceURLNotifier) Process(ctx context.Context, queuedAt time.Time, event *livekit.WebhookEvent, ...)
- func (r *ResourceURLNotifier) QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error
- func (r *ResourceURLNotifier) RegisterProcessedHook(hook func(ctx context.Context, whi *livekit.WebhookInfo))
- func (r *ResourceURLNotifier) SetFilter(params FilterParams)
- func (r *ResourceURLNotifier) SetKeys(apiKey, apiSecret string)
- func (r *ResourceURLNotifier) Stop(force bool)
- type ResourceURLNotifierConfig
- type ResourceURLNotifierParams
- type URLNotifier
- func (n *URLNotifier) IsAllowed(event string) bool
- func (n *URLNotifier) QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error
- func (n *URLNotifier) RegisterProcessedHook(hook func(ctx context.Context, whi *livekit.WebhookInfo))
- func (n *URLNotifier) SetFilter(params FilterParams)
- func (n *URLNotifier) SetKeys(apiKey, apiSecret string)
- func (n *URLNotifier) Stop(force bool)
- type URLNotifierConfig
- type URLNotifierParams
- type WebHookConfig
Constants ¶
const ( // use a custom mime type to ensure signature is checked prior to parsing ContentType = "application/webhook+json" DefaultUserAgent = "LiveKit" )
const ( EventRoomStarted = "room_started" EventRoomFinished = "room_finished" EventParticipantJoined = "participant_joined" EventParticipantLeft = "participant_left" EventParticipantConnectionAborted = "participant_connection_aborted" EventTrackPublished = "track_published" EventTrackUnpublished = "track_unpublished" EventEgressStarted = "egress_started" EventEgressUpdated = "egress_updated" EventEgressEnded = "egress_ended" EventIngressStarted = "ingress_started" EventIngressEnded = "ingress_ended" EventAgentJobPending = "agent_job_pending" EventAgentJobStarted = "agent_job_started" EventAgentJobEnded = "agent_job_ended" )
Variables ¶
var ( ErrNoAuthHeader = errors.New("authorization header could not be found") ErrSecretNotFound = errors.New("API secret could not be found") ErrInvalidChecksum = errors.New("could not verify authenticity of message") )
var DefaultResourceURLNotifierConfig = ResourceURLNotifierConfig{ MaxAge: 30 * time.Second, MaxDepth: 200, }
var DefaultURLNotifierConfig = URLNotifierConfig{
NumWorkers: 10,
QueueSize: 100,
}
var DefaultWebHookConfig = WebHookConfig{ URLNotifier: DefaultURLNotifierConfig, ResourceURLNotifier: DefaultResourceURLNotifierConfig, FilterParams: FilterParams{}, }
var ErrBlockedAddress = errors.New("blocked destination address")
Marks a destination that the SSRF guard rejects. It threads through the transport's url.Error. Callers can then classify it as permanent.
Functions ¶
func BlockInternal ¶ added in v1.54.1
func CheckWebhookHost ¶ added in v1.54.1
CheckWebhookHost rejects a URL host that is localhost or a blocked IP literal, so the mistake surfaces when the webhook is saved. Hostnames are only resolved, and checked, when a delivery dials them.
func EventKey ¶ added in v1.42.1
func EventKey(event *livekit.WebhookEvent) string
func IncDispatchDrop ¶ added in v1.39.1
func IncDispatchDrop(reason string)
func IncDispatchFailure ¶ added in v1.39.1
func IncDispatchFailure()
func IncDispatchSuccess ¶ added in v1.39.1
func IncDispatchSuccess()
func InitWebhookStats ¶ added in v1.39.1
func InitWebhookStats(constLabels prometheus.Labels)
func NewDialControl ¶ added in v1.54.2
func NewDialControl(blockPrivate bool, blocked, allowed []string) (func(network, address string, c syscall.RawConn) error, error)
Refuses addresses in blocked, and private ones when blockPrivate is set, unless they are also in allowed.
func Receive ¶
Receive reads and verifies incoming webhook is signed with key/secret pair closes body after reading
func ReceiveWebhookEvent ¶ added in v0.13.0
func ReceiveWebhookEvent(r *http.Request, provider auth.KeyProvider) (*livekit.WebhookEvent, error)
ReceiveWebhookEvent reads and verifies incoming webhook, and returns a parsed WebhookEvent
func RecordQueueLength ¶ added in v1.39.1
func RecordQueueLength(queueLength int)
func RedactSendError ¶ added in v1.54.2
Rewrites a delivery's SendError for a host whose webhook owners are tenants. A refused or unresolvable destination always gives the same text. In any other error, each address in the private and reserved ranges that BlockInternal refuses becomes a placeholder. Ranges a caller configures are not consulted.
Types ¶
type DefaultNotifier ¶ added in v1.5.4
type DefaultNotifier struct {
// contains filtered or unexported fields
}
func (*DefaultNotifier) QueueNotify ¶ added in v1.5.4
func (n *DefaultNotifier) QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error
func (*DefaultNotifier) RegisterProcessedHook ¶ added in v1.34.0
func (n *DefaultNotifier) RegisterProcessedHook(hook func(ctx context.Context, whi *livekit.WebhookInfo))
func (*DefaultNotifier) SetFilter ¶ added in v1.35.0
func (n *DefaultNotifier) SetFilter(params FilterParams)
func (*DefaultNotifier) SetKeys ¶ added in v1.35.0
func (n *DefaultNotifier) SetKeys(apiKey, apiSecret string)
func (*DefaultNotifier) Stop ¶ added in v1.5.4
func (n *DefaultNotifier) Stop(force bool)
type FilterParams ¶ added in v1.35.0
type FilterParams struct {
IncludeEvents []string `yaml:"include_events,omitempty"`
ExcludeEvents []string `yaml:"exclude_events,omitempty"`
}
func (FilterParams) IsAllowed ¶ added in v1.51.0
func (p FilterParams) IsAllowed(event string) bool
IsAllowed reports whether event passes the include/exclude filter. IncludeEvents takes precedence over ExcludeEvents; if neither is set, the event is allowed.
type HTTPClientParams ¶ added in v1.19.2
type HTTPClientParams struct {
RetryWaitMin time.Duration
RetryWaitMax time.Duration
MaxRetries int
ClientTimeout time.Duration
ForceIPv4 bool
DialControl func(network, address string, c syscall.RawConn) error
// receivers pin WAF rules to this, so it must stay stable across releases
// defaults to DefaultUserAgent
UserAgent string
}
type NotifyOption ¶ added in v1.37.0
type NotifyOption func(*NotifyParams)
func WithExtraWebhooks ¶ added in v1.37.0
func WithExtraWebhooks(wh []*livekit.WebhookConfig) NotifyOption
func WithSecret ¶ added in v1.37.0
func WithSecret(secret string) NotifyOption
type NotifyParams ¶ added in v1.37.0
type NotifyParams struct {
ExtraWebhooks []*livekit.WebhookConfig
Secret string
}
type QueuedNotifier ¶ added in v1.5.4
type QueuedNotifier interface {
RegisterProcessedHook(f func(ctx context.Context, whi *livekit.WebhookInfo))
SetKeys(apiKey, apiSecret string)
SetFilter(params FilterParams)
QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error
Stop(force bool)
}
func NewDefaultNotifier ¶ added in v1.5.4
func NewDefaultNotifier(config WebHookConfig, kp auth.KeyProvider) (QueuedNotifier, error)
type ResourceURLNotifier ¶ added in v1.35.0
type ResourceURLNotifier struct {
// contains filtered or unexported fields
}
ResourceURLNotifier is a QueuedNotifier that sends a POST request to a Webhook URL. It queues up events per resource (could be egress, ingress, room, participant, track, etc.) to avoid blocking events of one resource blocking another resource's event(s). It will retry on failure, and will drop events if notification fall too far behind, either in age or queue depth.
func NewResourceURLNotifier ¶ added in v1.35.0
func NewResourceURLNotifier(params ResourceURLNotifierParams) *ResourceURLNotifier
func (*ResourceURLNotifier) IsAllowed ¶ added in v1.42.1
func (r *ResourceURLNotifier) IsAllowed(event string) bool
func (*ResourceURLNotifier) Process ¶ added in v1.35.0
func (r *ResourceURLNotifier) Process( ctx context.Context, queuedAt time.Time, event *livekit.WebhookEvent, params *ResourceURLNotifierParams, qLen int, )
poster interface
func (*ResourceURLNotifier) QueueNotify ¶ added in v1.35.0
func (r *ResourceURLNotifier) QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error
func (*ResourceURLNotifier) RegisterProcessedHook ¶ added in v1.35.0
func (r *ResourceURLNotifier) RegisterProcessedHook(hook func(ctx context.Context, whi *livekit.WebhookInfo))
func (*ResourceURLNotifier) SetFilter ¶ added in v1.35.0
func (r *ResourceURLNotifier) SetFilter(params FilterParams)
func (*ResourceURLNotifier) SetKeys ¶ added in v1.35.0
func (r *ResourceURLNotifier) SetKeys(apiKey, apiSecret string)
func (*ResourceURLNotifier) Stop ¶ added in v1.35.0
func (r *ResourceURLNotifier) Stop(force bool)
type ResourceURLNotifierConfig ¶ added in v1.35.0
type ResourceURLNotifierParams ¶ added in v1.35.0
type ResourceURLNotifierParams struct {
HTTPClientParams
Logger logger.Logger
Timeout time.Duration
Config ResourceURLNotifierConfig
URL string
APIKey string
APISecret string
FieldsHook func(whi *livekit.WebhookInfo)
EventKey func(event *livekit.WebhookEvent) string
FilterParams
}
type URLNotifier ¶ added in v1.5.4
type URLNotifier struct {
// contains filtered or unexported fields
}
URLNotifier is a QueuedNotifier that sends a POST request to a Webhook URL. It will retry on failure, and will drop events if notification fall too far behind
func NewURLNotifier ¶ added in v1.5.4
func NewURLNotifier(params URLNotifierParams) *URLNotifier
func (*URLNotifier) IsAllowed ¶ added in v1.42.1
func (n *URLNotifier) IsAllowed(event string) bool
func (*URLNotifier) QueueNotify ¶ added in v1.5.4
func (n *URLNotifier) QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error
func (*URLNotifier) RegisterProcessedHook ¶ added in v1.34.0
func (n *URLNotifier) RegisterProcessedHook(hook func(ctx context.Context, whi *livekit.WebhookInfo))
func (*URLNotifier) SetFilter ¶ added in v1.35.0
func (n *URLNotifier) SetFilter(params FilterParams)
func (*URLNotifier) SetKeys ¶ added in v1.5.4
func (n *URLNotifier) SetKeys(apiKey, apiSecret string)
func (*URLNotifier) Stop ¶ added in v1.5.4
func (n *URLNotifier) Stop(force bool)
type URLNotifierConfig ¶ added in v1.35.0
type URLNotifierParams ¶ added in v1.5.4
type URLNotifierParams struct {
HTTPClientParams
Logger logger.Logger
Config URLNotifierConfig
URL string
APIKey string
APISecret string
FieldsHook func(whi *livekit.WebhookInfo)
EventKey func(event *livekit.WebhookEvent) string
FilterParams
}
type WebHookConfig ¶ added in v1.35.0
type WebHookConfig struct {
URLs []string `yaml:"urls,omitempty"`
APIKey string `yaml:"api_key,omitempty"`
URLNotifier URLNotifierConfig `yaml:"url_notifier,omitempty"`
ResourceURLNotifier ResourceURLNotifierConfig `yaml:"resource_url_notifier,omitempty"`
FilterParams FilterParams `yaml:"filter_params,omitempty"`
BlockPrivateAddresses bool `yaml:"block_private_addresses,omitempty"`
BlockedCIDRs []string `yaml:"blocked_cidrs,omitempty"`
AllowedCIDRs []string `yaml:"allowed_cidrs,omitempty"`
}