client

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 69 Imported by: 0

Documentation

Overview

Package client provides the low level assembly of the Notifiarr client application. This package orchestrates reading in of configuration, parsing cli flags, actioning those cli flags, setting up logging, and finally the starting of internal service routines for the webserver, plex sessions, snapshots, service checks and others. This package sets everything up for the client application.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupport = errors.New("this feature is not supported on this platform")
	ErrNilAPIKey = errors.New("API key may not be empty: set a key in config file, OR with environment variable")
)

Errors returned by this package.

View Source
var ErrConfigVersionMismatch = errors.New("config version mismatch")
View Source
var (
	ErrInvalidHeader = errors.New("invalid header provided; must contain a colon")
)

Errors.

Functions

func Fortune added in v0.3.2

func Fortune() string

Fortune returns a fortune.

func Start

func Start() error

Start runs the app.

Types

type BrowseDir added in v0.9.0

type BrowseDir struct {
	Sep   string   `json:"sep"`   // Filepath separator.
	Path  string   `json:"path"`  // Current directory path.
	Mom   string   `json:"mom"`   // Parent directory path.
	Dirs  []string `json:"dirs"`  // Directories in the current directory.
	Files []string `json:"files"` // Files in the current directory.
	Error string   `json:"error"` // Error message.
}

type Client

type Client struct {
	Flags  *configfile.Flags
	Config *configfile.Config

	Services *services.Services

	// this locks anything that may be updated while running.
	// at least "UIPassword" and "reloading" as of its creation.
	sync.RWMutex
	// contains filtered or unexported fields
}

Client stores all the running data.

func (*Client) Exit

func (c *Client) Exit(ctx context.Context, reload func()) error

Exit stops the web server and logs our exit messages. Start() calls this.

func (*Client) PlexHandler added in v0.3.2

func (c *Client) PlexHandler(w http.ResponseWriter, r *http.Request)

PlexHandler handles an incoming webhook from Plex.

@Summary		Accept Plex Media Server Webhook
@Description	Accepts a Plex webhook; when conditions are satisfied sends a notification to the website,
@Description	and may include snapshot data and/or fetched session data. Does not require X-API-Key header.
@Tags			Plex
@Accept			json
@Produce		text/plain
@Param			token	query		string					true	"Plex Token or Client API Key"
@Param			POST	body		plex.IncomingWebhook	true	"webhook payload"
@Success		202		{string}	string					"accepted"
@Success		208		{string}	string					"ignored"
@Failure		400		{string}	string					"bad input"
@Failure		404		{string}	string					"bad token or api key"
@Router			/plex [post]

func (*Client) PrintStartupInfo

func (c *Client) PrintStartupInfo(ctx context.Context, clientInfo *clientinfo.ClientInfo)

PrintStartupInfo prints info about our startup config. This runs once on startup, and again during reloads.

func (*Client) RunWebServer added in v0.9.0

func (c *Client) RunWebServer()

RunWebServer starts the http or https listener.

func (*Client) SetupWebServer added in v0.9.0

func (c *Client) SetupWebServer()

SetupWebServer starts the web server.

func (*Client) StopWebServer

func (c *Client) StopWebServer(ctx context.Context) error

StopWebServer stops the web servers. Panics if that causes an error or timeout.

type Integrations added in v0.9.0

type Integrations struct {
	Snapshot         *snapshot.Snapshot `json:"snapshot"`
	SnapshotAge      time.Time          `json:"snapshotAge"`
	Plex             *plex.PMSInfo      `json:"plex"`
	PlexAge          time.Time          `json:"plexAge"`
	Sessions         *plex.Sessions     `json:"sessions"`
	SessionsAge      time.Time          `json:"sessionsAge"`
	Dashboard        *dashboard.States  `json:"dashboard"`
	DashboardAge     time.Time          `json:"dashboardAge"`
	TautulliUsers    *tautulli.Users    `json:"tautulliUsers"`
	TautulliUsersAge time.Time          `json:"tautulliUsersAge"`
	Tautulli         *tautulli.Info     `json:"tautulli"`
	TautulliAge      time.Time          `json:"tautulliAge"`
	Lidarr           struct {
		Status    []*lidarr.SystemStatus `json:"status"`
		StatusAge []time.Time            `json:"statusAge"`
		Queue     []*lidarr.Queue        `json:"queue"`
		QueueAge  []time.Time            `json:"queueAge"`
	} `json:"lidarr"`
	Radarr struct {
		Status    []*radarr.SystemStatus `json:"status"`
		StatusAge []time.Time            `json:"statusAge"`
		Queue     []*radarr.Queue        `json:"queue"`
		QueueAge  []time.Time            `json:"queueAge"`
	} `json:"radarr"`
	Readarr struct {
		Status    []*readarr.SystemStatus `json:"status"`
		StatusAge []time.Time             `json:"statusAge"`
		Queue     []*readarr.Queue        `json:"queue"`
		QueueAge  []time.Time             `json:"queueAge"`
	} `json:"readarr"`
	Sonarr struct {
		Status    []*sonarr.SystemStatus `json:"status"`
		StatusAge []time.Time            `json:"statusAge"`
		Queue     []*sonarr.Queue        `json:"queue"`
		QueueAge  []time.Time            `json:"queueAge"`
	} `json:"sonarr"`
	Prowlarr struct {
		Status    []*prowlarr.SystemStatus `json:"status"`
		StatusAge []time.Time              `json:"statusAge"`
	} `json:"prowlarr"`
}

Integrations is the data returned by the UI integrations endpoint.

type Profile added in v0.9.0

type Profile struct {
	Username        string                 `json:"username"`
	Config          configfile.Config      `json:"config"`
	ClientInfo      *clientinfo.ClientInfo `json:"clientInfo"`
	IsWindows       bool                   `json:"isWindows"`
	IsLinux         bool                   `json:"isLinux"`
	IsDarwin        bool                   `json:"isDarwin"`
	IsDocker        bool                   `json:"isDocker"`
	IsUnstable      bool                   `json:"isUnstable"`
	IsFreeBSD       bool                   `json:"isFreeBsd"`
	IsSynology      bool                   `json:"isSynology"`
	Headers         http.Header            `json:"headers"`
	Fortune         string                 `json:"fortune"`
	UpstreamIP      string                 `json:"upstreamIp"`
	UpstreamAllowed bool                   `json:"upstreamAllowed"`
	UpstreamHeader  string                 `json:"upstreamHeader"`
	UpstreamType    configfile.AuthType    `json:"upstreamType"`
	Languages       frontend.Languages     `json:"languages"`
	Triggers        []common.TriggerInfo   `json:"triggers"`
	Timers          []common.TriggerInfo   `json:"timers"`
	Schedules       []common.TriggerInfo   `json:"schedules"`
	SiteCrons       []*crontimer.Timer     `json:"siteCrons"`
	PlexInfo        *plex.PMSInfo          `json:"plexInfo"`
	PlexAge         time.Time              `json:"plexAge"`
	// LoggedIn is only used by the front end. Backend does not set or use it.
	LoggedIn        bool                           `json:"loggedIn"`
	Updated         time.Time                      `json:"updated"`
	Flags           *configfile.Flags              `json:"flags"`
	Dynamic         bool                           `json:"dynamic"`
	Webauth         bool                           `json:"webauth"`
	Msg             string                         `json:"msg,omitempty"`
	LogFiles        *logs.LogFileInfos             `json:"logFileInfo"`
	ConfigFiles     *logs.LogFileInfos             `json:"configFileInfo"`
	Expvar          mnd.AllData                    `json:"expvar"`
	HostInfo        *host.InfoStat                 `json:"hostInfo"`
	Disks           map[string]*snapshot.Partition `json:"disks"`
	ProxyAllow      bool                           `json:"proxyAllow"`
	PoolStats       map[string]*mulery.PoolSize    `json:"poolStats"`
	Started         time.Time                      `json:"started"`
	CmdList         []*cmdconfig.Config            `json:"cmdList"`
	CheckResults    []*services.CheckResult        `json:"checkResults"`
	CheckRunning    bool                           `json:"checkRunning"`
	CheckDisabled   bool                           `json:"checkDisabled"`
	Program         string                         `json:"program"`
	Version         string                         `json:"version"`
	Revision        string                         `json:"revision"`
	Branch          string                         `json:"branch"`
	BuildUser       string                         `json:"buildUser"`
	BuildDate       string                         `json:"buildDate"`
	GoVersion       string                         `json:"goVersion"`
	OS              string                         `json:"os"`
	Arch            string                         `json:"arch"`
	Binary          string                         `json:"binary"`
	Environment     map[string]string              `json:"environment"`
	Docker          bool                           `json:"docker"`
	UID             int                            `json:"uid"`
	GID             int                            `json:"gid"`
	IP              string                         `json:"ip"`
	Gateway         string                         `json:"gateway"`
	IfName          string                         `json:"ifName"`
	Netmask         string                         `json:"netmask"`
	MD5             string                         `json:"md5"`
	ActiveTunnel    string                         `json:"activeTunnel"`
	TunnelPoolStats map[string]*mulery.PoolSize    `json:"tunnelPoolStats"`
}

Profile is the data returned by the profile GET endpoint. Basically everything.

type ProfilePost added in v0.9.0

type ProfilePost struct {
	Username  string              `json:"username"`
	Password  string              `json:"password"`
	AuthType  configfile.AuthType `json:"authType"`
	Header    string              `json:"header"`
	NewPass   string              `json:"newPass"`
	Upstreams string              `json:"upstreams"`
}

ProfilePost is the data sent to the profile POST endpoint when updating the trust profile.

Jump to

Keyboard shortcuts

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