config

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config loads the TOML file that lists the cameras reostream serves. Unknown keys are a boot-time error rather than a warning: a typo in a camera's fields should fail loudly at startup, not silently drop the field and serve 404s at three in the morning.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeAddr

func NormalizeAddr(addr string) string

NormalizeAddr applies the same default-port rule baichuan.Dial does, so "192.0.2.50" and "192.0.2.50:9000" compare equal as the same camera.

Exported so a caller outside this package that also needs to recognise "is this the same camera as one already configured" -- the setup page's probe guard is the current one -- compares addresses the same way Validate does below, rather than keeping a second implementation that can quietly drift from this one.

Types

type Camera

type Camera struct {
	Name     string
	Address  string
	Username string
	Password string
	Streams  []string

	// RTSP names which of this camera's streams to serve over RTSP. Absent
	// means none, and every stream still reaches the HTTP output either way.
	RTSP []string
}

Camera names one Reolink camera and the streams to pull from it.

type Config

type Config struct {
	Listen  string
	RTSP    *RTSPConfig    `toml:"rtsp"`
	Control *ControlConfig `toml:"control"`
	Cameras []Camera       `toml:"camera"`
}

Config is the top level shape of the TOML file.

func Load

func Load(path string) (*Config, error)

Load reads and validates the config file at path. A password value that starts with "$" is resolved from the named environment variable rather than stored in the file; an unset variable is an error rather than an empty password, because a camera that silently never authenticates is much harder to notice than a process that refuses to start.

This resolves [control]'s password too, which is right for the one process that both dials cameras and listens on the control port.

func LoadRaw

func LoadRaw(path string) (*Config, error)

LoadRaw decodes the TOML file at path with the same unknown-key rejection Load applies, but performs no environment resolution: a camera's Password field comes back exactly as written, including an unresolved "$NAME" reference, and no environment variable needs to be set for this to succeed.

This exists for callers that read a config only to write it back, such as the control page's camera form. Editing the file's text should not require the file's secrets to pass through the process first, and resolving them here would mean writing a real password back to disk in place of the "$NAME" reference that was deliberately keeping it out of the file.

Never use the Config this returns to actually connect to a camera; its passwords may not be passwords at all.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the constraints Load cannot express through decoding alone: names and addresses present, streams recognised, and no two cameras or streams that would fight over the same connection. A camera permits exactly one connection per stream, so a duplicate here is not a harmless redundancy, it is two runners that will fight for one session and the loser blocks the winner until the camera times the session out.

type ControlConfig

type ControlConfig struct {
	Listen   string
	Password string

	// AllowNoPassword runs the page with no authentication at all. It is a
	// separate opt-in rather than the meaning of an empty password because
	// an empty password is much more often a mistake, and this page can
	// read and write camera credentials.
	AllowNoPassword bool `toml:"allow_no_password"`
}

ControlConfig configures the operator page's listener. Its absence turns the page off entirely, which is the default: a daemon that serves video should not start serving a credential store because it was upgraded.

type RTSPConfig

type RTSPConfig struct {
	Listen string
}

RTSPConfig configures the RTSP listener. Its absence turns RTSP off entirely, which is the default: HTTP MPEG-TS is what this daemon has always served, and RTSP is opt-in for consumers that cannot take it.

Jump to

Keyboard shortcuts

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