safety

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package safety persists owner policy and enforces it at Plex request boundaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRemote

func IsRemote(r *http.Request) bool

Types

type Policy

type Policy struct {
	StreamLimit      int      `json:"streamLimit"`
	MaxContentRating string   `json:"maxContentRating"`
	BlockedGenres    []string `json:"blockedGenres"`
	BlockedKeywords  []string `json:"blockedKeywords"`
	RemoteDisabled   bool     `json:"remoteDisabled"`
	MaxBitrateKbps   int      `json:"maxBitrateKbps"`
	// AllowedHours is empty for any time, otherwise hours 0..23 in Timezone.
	AllowedHours []int  `json:"allowedHours"`
	Timezone     string `json:"timezone"`
}

func KidsPreset

func KidsPreset(age string) Policy

func (Policy) Validate added in v0.2.4

func (p Policy) Validate() error

Validate reports why p cannot be stored, if it cannot.

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, db *sql.DB) (*Service, error)

func (*Service) Allowed

func (s *Service) Allowed(u *core.User, t *core.Title) bool

func (*Service) BitrateLimit

func (s *Service) BitrateLimit(u *core.User) int

func (*Service) CanPlay

func (s *Service) CanPlay(u *core.User, remote bool, now time.Time) bool

func (*Service) Close

func (s *Service) Close()

Close disconnects the cluster bus.

func (*Service) ForUser

func (s *Service) ForUser(u *core.User) Policy

ForUser is u's policy.

func (*Service) Get

func (s *Service) Get(id int64) Policy

func (*Service) Handler

func (s *Service) Handler() http.Handler

func (*Service) Put

func (s *Service) Put(ctx context.Context, id int64, p Policy) error

func (*Service) Restricted

func (s *Service) Restricted(u *core.User) bool

func (*Service) SetBus

func (s *Service) SetBus(bus clusterbus.Bus)

SetBus connects the cluster bus (nil disconnects): policy changes made on this node reach the others' caches and vice versa.

func (*Service) UserPolicy

func (s *Service) UserPolicy(u *core.User) *core.User

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL