conf

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Log
	Log LogConfig `yaml:"log"`

	// Server
	Server ServerConfig `yaml:"server"`

	// Jwt
	Jwt JwtConfig `yaml:"jwt"`

	// Database
	Database DatabaseConfig `yaml:"database"`

	// Oauth2Plugins
	Oauth2Plugins Oauth2Plugins `yaml:"oauth2_plugins"`

	// RateLimit
	RateLimit RateLimitConfig `yaml:"rate_limit"`
}
var (
	Conf *Config
)

func DefaultConfig

func DefaultConfig() *Config

func (*Config) Save

func (c *Config) Save(file string) error

type DatabaseConfig added in v0.3.0

type DatabaseConfig struct {
	Type     DatabaseType `yaml:"type" lc:"default: sqlite3" hc:"support sqlite3, mysql, postgres" env:"DATABASE_TYPE"`
	Host     string       `yaml:"host" hc:"when type is not sqlite3, and port is 0, it will use unix socket file" env:"DATABASE_HOST"`
	Port     uint16       `yaml:"port" env:"DATABASE_PORT"`
	User     string       `yaml:"user" env:"DATABASE_USER"`
	Password string       `yaml:"password" env:"DATABASE_PASSWORD"`
	Name     string       `yaml:"name" lc:"default: synctv" hc:"when type is sqlite3, it will use sqlite db file or memory" env:"DATABASE_NAME"`
	SslMode  string       `` /* 146-byte string literal not displayed */

	CustomDSN string `yaml:"custom_dsn" hc:"when not empty, it will ignore other config" env:"DATABASE_CUSTOM_DSN"`

	MaxIdleConns    int    `yaml:"max_idle_conns" hc:"sqlite3 does not support setting connection parameters"  env:"DATABASE_MAX_IDLE_CONNS"`
	MaxOpenConns    int    `yaml:"max_open_conns" env:"DATABASE_MAX_OPEN_CONNS"`
	ConnMaxLifetime string `yaml:"conn_max_lifetime" env:"DATABASE_CONN_MAX_LIFETIME"`
	ConnMaxIdleTime string `yaml:"conn_max_idle_time" env:"DATABASE_CONN_MAX_IDLE_TIME"`
}

func DefaultDatabaseConfig added in v0.3.0

func DefaultDatabaseConfig() DatabaseConfig

type DatabaseType added in v0.3.0

type DatabaseType string
const (
	DatabaseTypeSqlite3  DatabaseType = "sqlite3"
	DatabaseTypeMysql    DatabaseType = "mysql"
	DatabaseTypePostgres DatabaseType = "postgres"
)

type HttpServerConfig added in v0.3.0

type HttpServerConfig struct {
	Listen string `yaml:"listen" env:"SERVER_LISTEN"`
	Port   uint16 `yaml:"port" env:"SERVER_PORT"`
	Quic   bool   `yaml:"quic" hc:"enable http3/quic need set cert and key file" env:"SERVER_QUIC"`

	CertPath string `yaml:"cert_path" env:"SERVER_CERT_PATH"`
	KeyPath  string `yaml:"key_path" env:"SERVER_KEY_PATH"`
}

type JwtConfig

type JwtConfig struct {
	Secret string `yaml:"secret" env:"JWT_SECRET"`
	Expire string `yaml:"expire" env:"JWT_EXPIRE"`
}

func DefaultJwtConfig

func DefaultJwtConfig() JwtConfig

type LogConfig

type LogConfig struct {
	Enable     bool   `yaml:"enable" env:"LOG_ENABLE"`
	LogFormat  string `yaml:"log_format" hc:"can be set: text | json" env:"LOG_FORMAT"`
	FilePath   string `yaml:"file_path" hc:"if it is a relative path, the data-dir directory will be used." env:"LOG_FILE_PATH"`
	MaxSize    int    `yaml:"max_size" cm:"mb" hc:"max size per log file" env:"LOG_MAX_SIZE"`
	MaxBackups int    `yaml:"max_backups" env:"LOG_MAX_BACKUPS"`
	MaxAge     int    `yaml:"max_age" env:"LOG_MAX_AGE"`
	Compress   bool   `yaml:"compress" env:"LOG_COMPRESS"`
}

func DefaultLogConfig

func DefaultLogConfig() LogConfig

type Oauth2Plugins added in v0.3.0

type Oauth2Plugins []struct {
	PluginFile string   `yaml:"plugin_file"`
	Args       []string `yaml:"args"`
}

func DefaultOauth2Plugins added in v0.3.0

func DefaultOauth2Plugins() Oauth2Plugins

type RateLimitConfig added in v0.3.0

type RateLimitConfig struct {
	Enable                bool   `yaml:"enable" lc:"default: false" env:"SERVER_RATE_LIMIT_ENABLE"`
	Period                string `yaml:"period" env:"SERVER_RATE_LIMIT_PERIOD"`
	Limit                 int64  `yaml:"limit" env:"SERVER_RATE_LIMIT_LIMIT"`
	TrustForwardHeader    bool   `` /* 325-byte string literal not displayed */
	TrustedClientIPHeader string `` /* 307-byte string literal not displayed */
}

func DefaultRateLimitConfig added in v0.3.0

func DefaultRateLimitConfig() RateLimitConfig

type RtmpServerConfig added in v0.3.0

type RtmpServerConfig struct {
	Enable bool   `yaml:"enable" env:"RTMP_ENABLE"`
	Listen string `yaml:"listen" lc:"default use http listen" env:"RTMP_LISTEN"`
	Port   uint16 `yaml:"port" lc:"default use server port" env:"RTMP_PORT"`
}

type ServerConfig

type ServerConfig struct {
	Http HttpServerConfig `yaml:"http"`
	Rtmp RtmpServerConfig `yaml:"rtmp"`
}

func DefaultServerConfig

func DefaultServerConfig() ServerConfig

Jump to

Keyboard shortcuts

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